View assembly code for built in functions

53 views
Skip to first unread message

Marija

unread,
Sep 18, 2017, 5:23:09 AM9/18/17
to v8-users
Hi,

Is it possible to see generated assembly code for built-in functions? If I use just print_code with a simple program, like [].push(1), nothing is generated.
Is --print_builtin_code flag the right thing to use? For array push the output looks like:

kind = BUILTIN
name = ArrayPush
compiler = unknown
Instructions (size = 10)
0x246f7340     0  bb20c45908     mov ebx,0x859c420           ;; external reference (Builtin_ArrayPush)
0x246f7345     5  e9f682feff     jmp 0x246df640  (AdaptorWithBuiltinExitFrame)    ;; code: BUILTIN


RelocInfo (size = 3)
0x246f7341  external reference (Builtin_ArrayPush)  (0x859c420)
0x246f7346  code target (BUILTIN)  (0x246df640)

There is another code for FastArrayPush. 

Can you also help me to understand the output if the flag --print_builtin_code is the right thing to use?

Thanks!

Rong Jie

unread,
Sep 18, 2017, 8:40:41 AM9/18/17
to v8-users
You need to build V8 with v8_enable_disassembler enabled (disabled by default in release build). See https://cs.chromium.org/chromium/src/v8/BUILD.gn?type=cs&q=v8_enable_disassembler

Jakob Kummerow

unread,
Sep 18, 2017, 6:02:40 PM9/18/17
to v8-users
ArrayPush is implemented in C++, see src/builtins/builtins-array.cc. The code object you've disassembled is a small wrapper/trampoline stub, the first step in the C++ entry sequence.

In general, there is no single way to inspect "built-in functions", because there are several ways to implement them (a few are still in handwritten assembly; many are in C++ [exposed as "runtime functions" or "builtins"] and CodeStubAssembler; some are in JavaScript), and that implies different ways to dump their code. Many functions also have several implementations, e.g. a fast path in a generated stub (FastArrayPush is an example), with a C++ fallback for non-fast cases.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages