Hi Dmitry, We've thought about this in the past, but unfortunately it's not that easy. The biggest problem is that parsing isn't just lexing tokens or building an AST - a significant cost is in things like scope resolution and similar complex language features, which we'd still have to either calculate or at least confirm (for security or just correctness), so you lose most of the benefit.
Additionally, we assume things about the generated bytecode, e.g. that loops only have one backwards jump, or that we have a stackcheck bytecode at the beginning of functions, so we'd have to check that these invariants are maintained - not to mention that the bytecode isn't properly specified or versioned, and changes with every release, so we'd have to handle that. Finally, JavaScript source is a reasonably compact encoding of JavaScript semantics, more so than bytecode - we measure around a 6x increase in size from gzipped, minified source to bytecode. We're hoping that code caching and improvements to the parser will give you most of the benefits you'd want, without the above disadvantages. Cheers, Leszek On Mon, 13 Mar 2017, 08:33 Dmitriy -, <[email protected]> wrote: Yeah, thx Yang, code cache is like what I want. But are there some instruments in browser and compilers for producing Ingition bytecodes? (I don't want to use code caching) This is some example of pipeline: write script.js compile script.js into Ignition bytecode -> script-bytecode.bjs in HTML <script src="path/to/script-bytecode.bjs"> Browser loads script-bytecode.bjs and doesn't parse it, just loads bytecodes into Ignition and later in Turbofan. On Monday, March 13, 2017 at 3:19:01 PM UTC+7, Yang Guo wrote: Javac produces bytecode. The equivalent to that would be to pre-generate bytecode. This can be done with V8 already with the code cache. Cheers, Yang On Mon, Mar 13, 2017 at 8:19 AM Dmitriy - <[email protected]> wrote: Hi all, Today we have the Ignition interpreter and bytecode for JS. I think that we can reduce size of JavaScript code via using some compiler like javac in the Java language. In such case we didn't need to parse raw JS source. WDYT about it? -- -- 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]. For more options, visit https://groups.google.com/d/optout. -- * • * *Yang Guo** • **Google Germany GmbH* * • *Erika-Mann-Str. 33 * • *80636 Munich • [email protected] Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank. This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks. -- -- 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]. For more options, visit https://groups.google.com/d/optout. -- -- 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]. For more options, visit https://groups.google.com/d/optout.
