I'm studying hardware performance of JS programs. I tried with --print-
code switch with shell sample but the problem is I only got assembly
code. What I would like to have is something like objdump result of C/C
++ program. Is there a way of doing this?
On Wed, Jul 6, 2011 at 7:09 PM, Albert <wingle...@gmail.com> wrote: > Hi,
> I'm studying hardware performance of JS programs. I tried with --print- > code switch with shell sample but the problem is I only got assembly > code. What I would like to have is something like objdump result of C/C > ++ program. Is there a way of doing this?
In these two lines, the callees are not shown, I suppose CEntry and StackCheck are both built-in functions of v8.
Basically, my goal is to catch runtime instructions trace (this is the easy part) and relate it back to javascript source code. Will --gdbjit-dump help? Is this option only available in debug build?
--- Raw source --- // A benchmark has a name (string) and a function that will be run to // do the performance measurement. The optional setup and tearDown // arguments are functions that will be invoked before and after // running the benchmark, but the running time of these functions will // not be accounted for in the benchmark score. function Benchmark(name, run, setup, tearDown) { this.name = name; this.run = run; this.Setup = setup ? setup : function() { }; this.TearDown = tearDown ? tearDown : function() { };
> What kind of information in your opinion is missing from the > --print-code output?
> You can use --code-comments to make assembly more human readable.
> Strictly speaking there is not such thing as a translated JS program as > whole.
> V8 compiles different functions separately as application runs. It > might compile the same function several times with different > compilers.
> -- > Vyacheslav Egorov
> On Wed, Jul 6, 2011 at 7:09 PM, Albert <wingle...@gmail.com> wrote: > > Hi,
> > I'm studying hardware performance of JS programs. I tried with --print- > > code switch with shell sample but the problem is I only got assembly > > code. What I would like to have is something like objdump result of C/C > > ++ program. Is there a way of doing this?
On Wed, Jul 6, 2011 at 7:15 PM, Vyacheslav Egorov <vego...@chromium.org>wrote:
> V8 compiles different functions separately as application runs. It > might compile the same function several times with different > compilers.
Just out of curiosity: can you give us (or point us to) an overview of the different modes and why one mode might be chosen over another in a different context? i'd be particularly interested in knowing why the same function might get compiled in different ways. (Again, just of curiosity, not because i want to optimize at that level.)
> In this line, the object at 0x7fe8125aa911 is not shown. I assume it is placed in "data section".
Well. There is not data section. The object itself lives in the heap. If you look at relocation information you can see that object 0x7fe8125aa911 is a two element FixedArray.
You can extend Code::Disassemble to print all referenced objects recursively but that would produce quite a large output with cycles.
Alternatively you can just put a breakpoint into CodeGenerator::PrintCode, wait until V8 compiles and prints interesting function and then expect heap state, print objects that are interesting to you etc.
> In these two lines, the callees are not shown, I suppose CEntry and StackCheck are both built-in functions of v8.
They will be printed if you pass --print-code-stubs to V8 (your shell should be compiled with snapshot=off).
> Basically, my goal is to catch runtime instructions trace (this is the easy part) and relate it back to javascript > source code.
--code-comment will help you to do that.
> Will --gdbjit-dump help? Is this option only available in debug build?
GDBJIT interface produces object that contain debugging information (like pc to line mapping) but no code. So I don't think --gdbjit-dump will help you.
> In these two lines, the callees are not shown, I suppose CEntry and > StackCheck are both built-in functions of v8.
> Basically, my goal is to catch runtime instructions trace (this is the easy > part) and relate it back to javascript source code. Will --gdbjit-dump help? > Is this option only available in debug build?
> --- Raw source --- > // A benchmark has a name (string) and a function that will be run to > // do the performance measurement. The optional setup and tearDown > // arguments are functions that will be invoked before and after > // running the benchmark, but the running time of these functions will > // not be accounted for in the benchmark score. > function Benchmark(name, run, setup, tearDown) { > this.name = name; > this.run = run; > this.Setup = setup ? setup : function() { }; > this.TearDown = tearDown ? tearDown : function() { }; > }
> On Wed, Jul 6, 2011 at 1:15 PM, Vyacheslav Egorov <vego...@chromium.org> > wrote:
>> Hi Albert,
>> Can you clarify?
>> What kind of information in your opinion is missing from the >> --print-code output?
>> You can use --code-comments to make assembly more human readable.
>> Strictly speaking there is not such thing as a translated JS program as >> whole.
>> V8 compiles different functions separately as application runs. It >> might compile the same function several times with different >> compilers.
>> -- >> Vyacheslav Egorov
>> On Wed, Jul 6, 2011 at 7:09 PM, Albert <wingle...@gmail.com> wrote: >> > Hi,
>> > I'm studying hardware performance of JS programs. I tried with --print- >> > code switch with shell sample but the problem is I only got assembly >> > code. What I would like to have is something like objdump result of C/C >> > ++ program. Is there a way of doing this?
There are two compilers: non-optimizing (aka full) and optimizing.
Every function starts non-optimized. V8 profiles the application as it runs and tries to optimize hot functions making assumptions based on type feedback it gathered during execution of non-optimized code.
On Wed, Jul 6, 2011 at 8:04 PM, Stephan Beal <sgb...@googlemail.com> wrote: > On Wed, Jul 6, 2011 at 7:15 PM, Vyacheslav Egorov <vego...@chromium.org> > wrote:
>> V8 compiles different functions separately as application runs. It >> might compile the same function several times with different >> compilers.
> Just out of curiosity: can you give us (or point us to) an overview of the > different modes and why one mode might be chosen over another in a different > context? i'd be particularly interested in knowing why the same function > might get compiled in different ways. (Again, just of curiosity, not because > i want to optimize at that level.) > -- > ----- stephan beal > http://wanderinghorse.net/home/stephan/
> > In this line, the object at 0x7fe8125aa911 is not shown. I assume it is > placed in "data section".
> Well. There is not data section. The object itself lives in the heap. > If you look at relocation information you can see that object > 0x7fe8125aa911 is a two element FixedArray.
> You can extend Code::Disassemble to print all referenced objects > recursively but that would produce quite a large output with cycles.
> Alternatively you can just put a breakpoint into > CodeGenerator::PrintCode, wait until V8 compiles and prints > interesting function and then expect heap state, print objects that > are interesting to you etc.
> > In these two lines, the callees are not shown, I suppose CEntry and > StackCheck are both built-in functions of v8.
> They will be printed if you pass --print-code-stubs to V8 (your shell > should be compiled with snapshot=off).
> > Basically, my goal is to catch runtime instructions trace (this is the > easy part) and relate it back to javascript > > source code.
> --code-comment will help you to do that.
> > Will --gdbjit-dump help? Is this option only available in debug build?
> GDBJIT interface produces object that contain debugging information > (like pc to line mapping) but no code. So I don't think --gdbjit-dump > will help you.
> -- > Vyacheslav Egorov
> On Wed, Jul 6, 2011 at 8:03 PM, Zhaoshi Zheng <wingle...@gmail.com> wrote: > > Vyacheslav,
> > Thanks for your reply. Take this function for example, Benchmark in > base.js > > of V8 benchmark suite:
> > In these two lines, the callees are not shown, I suppose CEntry and > > StackCheck are both built-in functions of v8.
> > Basically, my goal is to catch runtime instructions trace (this is the > easy > > part) and relate it back to javascript source code. Will --gdbjit-dump > help? > > Is this option only available in debug build?
> > --- Raw source --- > > // A benchmark has a name (string) and a function that will be run to > > // do the performance measurement. The optional setup and tearDown > > // arguments are functions that will be invoked before and after > > // running the benchmark, but the running time of these functions will > > // not be accounted for in the benchmark score. > > function Benchmark(name, run, setup, tearDown) { > > this.name = name; > > this.run = run; > > this.Setup = setup ? setup : function() { }; > > this.TearDown = tearDown ? tearDown : function() { }; > > }
> > On Wed, Jul 6, 2011 at 1:15 PM, Vyacheslav Egorov <vego...@chromium.org> > > wrote:
> >> Hi Albert,
> >> Can you clarify?
> >> What kind of information in your opinion is missing from the > >> --print-code output?
> >> You can use --code-comments to make assembly more human readable.
> >> Strictly speaking there is not such thing as a translated JS program as > >> whole.
> >> V8 compiles different functions separately as application runs. It > >> might compile the same function several times with different > >> compilers.
> >> -- > >> Vyacheslav Egorov
> >> On Wed, Jul 6, 2011 at 7:09 PM, Albert <wingle...@gmail.com> wrote: > >> > Hi,
> >> > I'm studying hardware performance of JS programs. I tried with > --print- > >> > code switch with shell sample but the problem is I only got assembly > >> > code. What I would like to have is something like objdump result of > C/C > >> > ++ program. Is there a way of doing this?