Are code objects relocatable? (possible outdated comment in the codebase)

27 views
Skip to first unread message

m...@mmarchini.me

unread,
Sep 11, 2019, 8:24:57 PM9/11/19
to v8-dev
I just found this comment on the codebase:

    // We may receive a CodeMove event if a BytecodeArray object moves. Otherwise
   
// code relocation is not supported.

I thought (optimized) code objects were allowed relocation (enabled by default with --compact-code-space). Is this comment outdated, or is my understanding incorrect?

Jakob Kummerow

unread,
Sep 12, 2019, 5:03:08 AM9/12/19
to v8-...@googlegroups.com
Code relocation is not supported by (external) profiling tools, because mapping a pc to a function when processing the log file is hard when that function has been moving around over time. Without profiling, Code objects are relocatable.

The CHECK right below the comment you found guarantees that it is not outdated: CHECK(from.IsBytecodeArray()); would cause a crash if the function was called with a Code object.

And src/flags/flag-definitions.h is where the magic happens: DEFINE_NEG_IMPLICATION(perf_prof, compact_code_space) turns off code space compaction when profiling.


--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/cb765436-928c-4f29-b334-cf60581ae89f%40googlegroups.com.

Matheus Marchini

unread,
Sep 12, 2019, 9:44:49 AM9/12/19
to v8-...@googlegroups.com
Oh, ok, that makes sense. I thought I saw code relocations in production which were messing with our profiling, but we are using the CodeEventHandler API, so code moves are not disabled.

It's possible to make Linux perf understand code relocations though: --perf-prof writes a jitdump file, which has support for code relocations through timestamps.

I'm already writing a pull request to report code moves through the CodeEventHandler API. Would you be interested in a pull request to make --perf-prof work with code relocations as well?

You received this message because you are subscribed to a topic in the Google Groups "v8-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-dev/7cGYttemOFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAKSzg3QuW2X9a53ZpgmdfhVXefM%2BNecNabdkN3ikRrzQtpWcbg%40mail.gmail.com.

Peter Marshall

unread,
Sep 13, 2019, 8:34:09 AM9/13/19
to v8-dev
Hi Matheus, I think --perf-prof isn't used that frequently by us (others might use it more than I do) but I can review patches there (peterm...@chromium.org).

Cheers


On Thursday, September 12, 2019 at 3:44:49 PM UTC+2, Matheus Marchini wrote:
Oh, ok, that makes sense. I thought I saw code relocations in production which were messing with our profiling, but we are using the CodeEventHandler API, so code moves are not disabled.

It's possible to make Linux perf understand code relocations though: --perf-prof writes a jitdump file, which has support for code relocations through timestamps.

I'm already writing a pull request to report code moves through the CodeEventHandler API. Would you be interested in a pull request to make --perf-prof work with code relocations as well?

On Thu, Sep 12, 2019, 2:03 AM Jakob Kummerow <jkum...@chromium.org> wrote:
Code relocation is not supported by (external) profiling tools, because mapping a pc to a function when processing the log file is hard when that function has been moving around over time. Without profiling, Code objects are relocatable.

The CHECK right below the comment you found guarantees that it is not outdated: CHECK(from.IsBytecodeArray()); would cause a crash if the function was called with a Code object.

And src/flags/flag-definitions.h is where the magic happens: DEFINE_NEG_IMPLICATION(perf_prof, compact_code_space) turns off code space compaction when profiling.


On Thu, Sep 12, 2019 at 2:25 AM <m...@mmarchini.me> wrote:
I just found this comment on the codebase:

    // We may receive a CodeMove event if a BytecodeArray object moves. Otherwise
   
// code relocation is not supported.

I thought (optimized) code objects were allowed relocation (enabled by default with --compact-code-space). Is this comment outdated, or is my understanding incorrect?

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-...@googlegroups.com.

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to a topic in the Google Groups "v8-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/v8-dev/7cGYttemOFQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to v8-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages