← 返回命令列表

Linux command

d8 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start an interactive

d8

Run a JavaScript file

d8 [script.js]

Evaluate code

d8 -e "[console.log(1+2)]"

Pass arguments

d8 [script.js] -- [arg1] [arg2]

Enable staged harmony

d8 --harmony [script.js]

Print generated bytecode

d8 --print-bytecode [script.js]

Enable V8 natives

d8 --allow-natives-syntax [script.js]

Generate a V8 profile

d8 --prof [script.js]

说明

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.

参数

-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.

FAQ

What is the d8 command used for?

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.

How do I run a basic d8 example?

Run `d8` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -e _code_ do in d8?

Execute the supplied JavaScript source string.