On Mon, Dec 7, 2015 at 11:36 PM,  <a.skol...@samsung.com> wrote:
> Dear all,
>
> Hi!  My name is Abe.  I work in a part of Samsung the mission of which is to
> make Open Source compilers better.  It`s a wonderful job.
>
> What I would like to do with V8 -- and have not yet been able to figure out
> how -- is to have it parse and compile the JS code it receives, not execute
> that code, and profile the compilation time.  In other words, to pretend
> that V8 is a “normal” compiler like GCC`s C compiler, and to profile V8 as
> such.
>
> If I understand correctly, recent V8 releases have 3 compilers:
>   * full-codegen
>   * Crankshaft
>   * TurboFan
>
> Have I understood correctly, or is the preceding the result of mentally
> merging documentation from different V8 releases in a way that doesn`t
> correspond to the real world?
>
> Ideally, I would like to be able to invoke V8 ‘c•f’ times, where ‘c’ is the
> # of compilers V8 has inside and ‘f’ is the # of JS source files I am
> processing [my first choice is to use the Octane benchmark suite].  For each
> invocation, I want the compiler to compile all the functions in the code,
> without actually executing any of it, and to profile the invocation,
> preferably with somewhat-fine-grained statistics, e.g. with time to parse
> reported separately from time to compile.
>
> I realize that at least some of the above is already provided by the
> profiling-related and tracing-related options to “d8” and friends, but it
> seems to me that what`s already there [at least in version 4.9.167, which
> was released on Dec. 7 2015] is not enough to get it all done.
>
> As a temporary work-around, I would call it major progress if I could do all
> of the above with the exception of the “without executing the code” part.  I
> realize that this is a challenge for an implementation of a very dynamic
> language, especially one in which function definition is not necessarily
> done statically.
>
> Can any of the above be done at all without writing a new C++ program that
> uses V8 as a library?  If so, then how, please?
>
> Regards,
>
> Abe

d8 currently doesn't have functionality to parse but not execute
source code, although that should be trivial to add: just return
before the call to script->Run() in Shell::ExecuteString() in
src/d8.cc.

That said, there are a number of gotchas to keep in mind when you
start profiling:

1. V8 is a tiered JIT compiler.  Native code is initially generated by
the baseline (full-codegen) compiler, Crankshaft and TurboFan don't
come into play until the run-time profiler decides that a function is
"hot" (a heuristic for call count and the stability of types inside
the function.)

You can force the issue to some extent with the --always_opt flag but
the optimizing compilers aren't very effective when they haven't had
time to collect run-time information.  You may end up profiling the
wrong thing this way.

2. Functions are normally compiled lazily.  The baseline compiler
doesn't emit native code until the first time a function is called but
you can force it to with the --nolazy flag.

3. The V8 team considers Crankshaft deprecated(ish), soon to be
replaced with TurboFan.  You would probably do best to focus your
efforts on the latter.

Hope that helps.  Don't hesitate to ask more questions.

-- 
-- 
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