On Sun, Jul 31, 2016 at 8:41 PM, D T <[email protected]> wrote: > Hi there! > > This mailing list helped me so many times, so I will give it another try :) > I am executing a javascript file containing a simple addition program as > follows: > user@debugbox: v8/out/ia32.release/d8 --print_opt_code test.js > > The addition in the program is called a few thousand times in a for loop > to trigger the optimization. > When looking at the produced assembler code I wondered about its > generation: > Sometimes, when executing different JS programs, similar ASM code is > generated, which means, that different JS code is optimized into the same > ASM (or similar ASM code). > So far so good. But is there something like a template, which specifies > which JS code is translated into which ASM code? > I mean something like "If there is a JS assignment, use 'mov register, > variable' in ASM". >
That's the basic idea. The details are complicated enough to fill many books titled "compiler construction" and similar ;-) . It's a very interesting area of research! In particular, optimizing compilers usually use several processing steps operating on various intermediate representations. For example, V8's "Crankshaft" optimizing compiler goes from the AST (abstract syntax tree) to high-level IR to low-level IR and then finally to machine code. The reason is that different operations are most easily done at specific steps of this workflow, e.g. variable scopes are resolved on the AST, dead code is eliminated in high-level IR, registers are allocated in low-level IR. Sorry, if the question is dumb. I just want to understand what's going on :) > > Thanks! > > -- > -- > v8-users mailing list > [email protected] > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
