On Mon, Nov 12, 2018 at 10:28 PM TLim <heuichan....@gmail.com> wrote:
> I'm sorry to keep asking questions, but I'm wondering how can I get
> void Code::Disassemble(const char* name, std::ostream& os, Address 
> current_pc) {   ...
> }
> to get executed instead of
> void BytecodeArray::Disassemble(std::ostream& os) { ...}

V8 consists of an interpreter and a JIT compiler. The interpreter
operates on bytecode, the compiler emits code objects. The compiler is
only used for interpreted functions that are considered hot (called
frequently and with stable types.)

In the example you posted, if you call foo() in a loop, it eventually
gets compiled to native code because it's a good candidate.* You can
also start d8 with --allow_natives_syntax and optionally
--predictable, and call %OptimizeFunctionOnNextCall(foo) to force it
to be compiled. The percentage sign is not a typo, by the way.

* In fact, I would expect TurboFan to compile the top-level script,
inline foo() into the caller and optimize it down to just `.result =
3`, where .result is a pseudo-variable containing the result of the
evaluated script.

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

Reply via email to