Search code examples
v8

Where are d8 options implemented?


I search for --print-bytecode or --print-ast which are optional arguments of d8 on code search, I cannot find it. I would like to check all options, but they are not written in the source code. Is my checking method incorrect?


Solution

  • V8 flags are defined in src/flags/flag-definition.h¹.

    When searching for a flag, you should ignore the initial -- and replace the remaining dashes (-) by underscores (_). For instance, if you want to find where --print-bytecode is used, search for print_bytecode. Additionally, flags are accessed through v8_flags, so to be more precise you could search for v8_flags.print_bytecode.

    Both print_bytecode and print_ast seem to be only used in src/interpreter/interpreter.cc; cf this search for print_bytecode, and this one for print_ast.

    Tip 1: when passing flags to d8, you can always use underscores instead of dashes. For instance, d8 --print_bytecode and d8 --print-bytecode are equivalent.

    Tip 2: you can run d8 --help to see a list of all available flags.


    ¹ As pointed out by @jmrk, there are a few d8-specific flags, which are defined in src/d8/d8.cc. These are processed by Shell::SetOptions, and are usually used only in d8.cc.