LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

d8

V8 JavaScript engine developer shell

TLDR

Start an interactive JavaScript REPL
$ d8
copy
Run a JavaScript file
$ d8 [script.js]
copy
Evaluate code from the command line
$ d8 -e "[console.log(1+2)]"
copy
Pass arguments to the script (available via `arguments`)
$ d8 [script.js] -- [arg1] [arg2]
copy
Enable staged harmony (near-stable) features
$ d8 --harmony [script.js]
copy
Print generated bytecode for analysis
$ d8 --print-bytecode [script.js]
copy
Enable V8 natives like `%OptimizeFunctionOnNextCall`
$ d8 --allow-natives-syntax [script.js]
copy
Generate a V8 profile for the tick processor
$ d8 --prof [script.js]
copy

SYNOPSIS

d8 [V8-options] [script.js] [--] [arguments]

DESCRIPTION

d8 is V8's own developer shell, shipped alongside the V8 JavaScript engine source tree. It provides a minimal JavaScript execution environment used for testing the engine, benchmarking, and exploring how V8 compiles and optimizes code.Unlike Node.js or a browser, d8 exposes almost no host APIs. In return it exposes V8-specific hooks such as Ignition bytecode dumping, TurboFan optimization tracing, heap statistics, and runtime intrinsics. The shell offers a few convenience globals for file I/O (`read`, `load`, `readline`) and output (`print`, `console.log`).For a full list of flags, run `d8 --help`; the set is large and changes between V8 releases.

PARAMETERS

script.js

JavaScript file to execute. If omitted, `d8` starts an interactive shell.
-e code
Execute the supplied JavaScript source string.
--harmony
Enable staged Harmony (ECMAScript proposal) features.
--print-bytecode
Print Ignition bytecode generated for each function.
--trace-opt, --trace-deopt
Log TurboFan optimization and deoptimization decisions.
--prof
Write `v8.log` profiling output for use with `tools/tick-processor`.
--allow-natives-syntax
Allow `%`-prefixed V8 runtime functions such as `%OptimizeFunctionOnNextCall`.
--help
List all supported V8 flags with short descriptions.
--
Separator: everything after is passed to the script via the `arguments` array.

CAVEATS

d8 is a developer tool, not a runtime: it has no `setTimeout`, `fetch`, module resolver, or filesystem API beyond the few built-ins above. Behavior and flag names frequently change between V8 versions, and binaries are usually obtained by building V8 from source or via `jsvu`/`esvu`. The `--allow-natives-syntax` runtime functions are unstable and intended only for V8 development.

HISTORY

d8 is the debugging shell for V8, the JavaScript engine open-sourced by Google in 2008 with the launch of Chrome. The name is a shortened form of the engine name. It has remained the primary playground for V8 engineers and a popular tool for JavaScript performance researchers studying how code is optimized.

SEE ALSO

node(1), deno(1)

Copied to clipboard
Kai