Thanks for the vid link Santiago. It definitely clear things up a bit.
I am still trying to figure out if there is 1 to 1 mapping between AST node
-> bytecode -> JSOpcode
For example, there are a lot of bytecode node such as StackCheck, which I
think is for stack overflow check.
Then in TurboFan bytecode graph I see FrameState/StateValue, and those are
probably for accessing properties in closure?
I dont think a StackCheck bytecode maps to an AST node, and is inserted
when BytecodeGenerator walks a FunctionStatement AST node, because v8 needs
to check for stackoverflow for every function execution.
Is there a design doc that says FunctionStatement AST node -> StackCheck
bytecode, {other bytecodes in the function body statements...}?
Thanks in advance,
Yoshi
On Wednesday, February 12, 2020 at 2:22:06 AM UTC-8, Santiago Aboy Solanes
wrote:
>
> Hi Yoshi,
>
> With Dominik we presented "Life of a <script>"
> <https://www.youtube.com/watch?v=3bVcTFOKRyo&feature=youtu.be> which is a
> high level overview of V8's pipeline. It should shed some light on how V8
> works.
>
> As a super quick drawing, the V8's phases are:
> Loading -> Parsing (generate the AST) -> Interpreting (Ignition) ->
> Execution -> Optimization (TurboFan, if necessary)
>
> ^ |
>
> \______________________________/
>
> deoptimization (if necessary)
>
> Also, we have a flag you can use if you want to take a look at the
> generated bytecode, --print-bytecode.
>
> Both --print-bytecode and --trace-turbo can be used with an extra flag
> that acts as a filter (i.e --print-bytecode--filter=function_name ,
> --trace-turbo-filter=function_name).
> It is useful to use the filters so you just get the information for the
> functions that you want to analyse.
>
> Cheers,
> Santiago
>
> On Wed, Feb 12, 2020 at 5:56 AM yoshi chen <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> I am trying to understand how AST is translated into TurboFan bytecode
>> graph, then update the graph for JIT optimization.
>>
>> So far from googling, online blogs, and stepping through the v8 code, I
>> have gathered that:
>> Compiler -> AST -> GnerateUnoptimizedCode -> unoptimied BytecodeGraph ->
>> turbofan optimization stages when code is hot
>>
>> Most of the info are from this doc:
>>
>> https://docs.google.com/document/d/11T2CRex9hXxoJwbYqVQ32yIPMh0uouUZLdyrtmMoL44/edit?ts=56f27d9d#
>>
>> But I can't find any documentation at a high level, how an AST node maps
>> to a JSOpcode.
>> The test cases gives some insights, but an overall documentation would be
>> great.
>> I have also been playing with d8 with --trace-turbo flag.
>>
>> For example, just doing
>> console.log('stuff')
>>
>> will create the following opcodes:
>> JSLoadGlobal (for 'console')
>> JSLoadNamed (for 'log')
>> -> JSLoadNamed creates FrameState, and PeeHole constant in case the
>> 'log' property doesnt exist
>>
>> HeapConstant (for 'stuff')
>>
>> The process of stepping through code, looking at tests, playing with d8
>> has been illuminating but very slow and tedious.
>> Does anybody know if there are any docs around this area of v8?
>> I am assuming anybody that want to become a new v8 contributor would need
>> to go through this process and might have built some docs already.
>>
>> Thanks in advance,
>> Yoshi
>>
>> --
>> --
>> v8-dev mailing list
>> [email protected] <javascript:>
>> http://groups.google.com/group/v8-dev
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/v8-dev/91385b8f-a198-4dd1-8c51-585309c26e3f%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/v8-dev/91385b8f-a198-4dd1-8c51-585309c26e3f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/v8-dev/fe63e255-ee49-4b6c-8811-28b4eb774c55%40googlegroups.com.