Find out the bytecode associated with given JIT code?

40 views
Skip to first unread message

Thomson Tan

unread,
Jun 14, 2018, 4:33:10 PM6/14/18
to v8-users
I saw some JIT instructions under debugger which seems for the templated interpreter code. How could I find out which bytecode the binaries instructions are associated with under debugger? There seems a table with mapping for each bytecode to JIT code address in isolate. What's the easy way for doing this?

Caitlin Potter

unread,
Jun 14, 2018, 5:13:07 PM6/14/18
to v8-u...@googlegroups.com
If I understand the question... You're stepping through machine instructions, and you want to figure out which bytecode handler the code is associated with?

A way to find this in lldb: `e _v8_internal_Print_Code((void*)$pc)/`, which will dump information about the code (ever since v8 5.1.146 / https://codereview.chromium.org/1806883002) --- something similar should work in gdb or msvc's debugger.

> On Jun 14, 2018, at 4:33 PM, Thomson Tan <lil...@gmail.com> wrote:
>
> I saw some JIT instructions under debugger which seems for the templated interpreter code. How could I find out which bytecode the binaries instructions are associated with under debugger? There seems a table with mapping for each bytecode to JIT code address in isolate. What's the easy way for doing this?
>
> --
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Thomson Tan

unread,
Jun 18, 2018, 5:04:47 PM6/18/18
to v8-users
Thanks. This works perfectly for bytecode handlers. Is there any similar function for optimized JIT code, like print out the function name with some extra information?

Caitlin Potter

unread,
Jun 18, 2018, 6:49:01 PM6/18/18
to v8-u...@googlegroups.com
Print_Code will output information for any Code object (builtins, bytecode handlers, JIT-ed code, even IC stubs AFAIU) — so it should already do that for you.

The main limitation WRT optimized code is, if some part of the fn is inlined, it won’t tell you anything about the code that was inlined/where it came from (I think)


On Jun 18, 2018, at 5:04 PM, Thomson Tan <lil...@gmail.com> wrote:

Thanks. This works perfectly for bytecode handlers. Is there any similar function for optimized JIT code, like print out the function name with some extra information?

--

Jakob Gruber

unread,
Jun 19, 2018, 1:54:46 AM6/19/18
to v8-u...@googlegroups.com
Take a look at v8's gdbinit file for more convenience macros: https://cs.chromium.org/chromium/src/v8/tools/gdbinit

Thomson Tan

unread,
Jun 19, 2018, 2:57:53 AM6/19/18
to v8-users
Thanks for pointing to the GDB plug-in.

I think is still Windows is still a major target of Chromium/V8? Wondering how to do such debugging (get JIT code meta-data, stackwalk, etc.) in V8 running on Windows, like any dedicate script or plug-in for WinDbg? Is it also possible to do such debugging for release build?

Jakob Kummerow

unread,
Jun 19, 2018, 1:13:58 PM6/19/18
to v8-users
Yes, Windows is a major target. But most developers use Linux, so debugging support is best on that platform. Feel free to contribute WinDbg helper scripts!

As the names try to imply, release builds are for releasing and debug builds are for debugging. While you can run a release build in a debugger, you typically won't have much fun with it because compiler optimizations are getting in the way (e.g. you can't see the value of variables that got compiled out; line-by-line stepping is no longer possible after code reordering).

On Mon, Jun 18, 2018 at 11:57 PM Thomson Tan <lil...@gmail.com> wrote:
Thanks for pointing to the GDB plug-in.

I think is still Windows is still a major target of Chromium/V8? Wondering how to do such debugging (get JIT code meta-data, stackwalk, etc.) in V8 running on Windows, like any dedicate script or plug-in for WinDbg? Is it also possible to do such debugging for release build?

--
Reply all
Reply to author
Forward
0 new messages