Skip to content

mmtk/mmtk-v8

Repository files navigation

MMTk-V8

This repository provides the V8 binding for MMTk.

Contents

Requirements

We maintain an up to date list of the prerequisite for building MMTk and its bindings in the mmtk-dev-env repository. Please make sure your dev machine satisfies those prerequisites.

MMTk/V8 currently only supports linux-x86_64.

Before you continue

The minimal supported Rust version for MMTk-V8 binding is 1.57.0. Make sure your Rust version is higher than this. We test MMTk-V8 binding with Rust 1.59.0 (as specified in rust-toolchain).

Getting Sources (for MMTk and VM)

First, set environment variables to refer to the root directories for MMTk and V8 respectively (change these to match your preferred locations):

$ export MMTK_V8_ROOT=$HOME/mmtk_v8_root

MMTk

$ cd $MMTK_V8_ROOT
$ git clone [email protected]:mmtk/mmtk-v8.git

V8

The following is based on the V8 documentation. Please refer to the original documentation if you run into difficulties getting V8.

First, fetch and then update depot_tools, which contains the key build dependencies for V8.

$ cd $MMTK_V8_ROOT
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:$PATH
$ gclient

You will need depot_tools in your path when you build V8, so you may wish to update your shell profile (e.g. .bash_profile) accordingly.

You should now be able to fetch the V8 sources:

$ fetch v8

The fetch command will get the V8 sources and create a build directory for you. It intentionally puts your V8 repo in a detached head state.

Tip: if you decide to maintain your own fork of V8, be mindful that the fetch command is a necessary step in setting up a new repo; it is not sufficient to simply clone the source.

To update your V8 sources, use:

$ fetch v8

Occasionally V8 won't build after a fetch because dependencies have changed. This is fixed by synching:

$ gclient sync

Build

First build MMTk, then V8

Building MMTk

$ cd $MMTK_V8_ROOT/mmtk-v8/mmtk
$ cargo build --features nogc

Building V8

We provide instructions here for building V8 with its gm workflow.

First you may wish to create an alias to the gm script, which lives in the tools/dev directory of the V8 source tree.

$ alias gm=$MMTK_V8_ROOT/v8/tools/dev/gm.py

You may wish to add the above alias to your shell profile.

Now you can build V8.

First Ensure you can Build Release V8

Before trying to build V8 with MMTk, ensure you can build V8 without MMTk:

$ cd $MMTK_V8_ROOT/v8
$ gm x64.release

The above builds a standard release build of v8.

Next Ensure you can Build a Debug V8

You need to create a config file, which we'll call x64.debug.

Use gn, which will open an editor:

$ gn args out/x64.debug

Enter the following values:

is_component_build = true
is_debug = true
symbol_level = 2
target_cpu = "x64"
use_goma = false
v8_enable_backtrace = true
v8_enable_fast_mksnapshot = true
v8_enable_verify_csa = true
v8_enable_slow_dchecks = false
v8_optimized_debug = false

Then Build with MMTk

Create a gn config for building v8 with mmtk, which we'll call x64.debug-mmtk.

Use gn, which will open an editor:

$ cd $MMTK_V8_ROOT/v8
$ gn args out/x64.debug-mmtk

Enter the following values:

is_component_build = true
is_debug = true
symbol_level = 2
target_cpu = "x64"
use_goma = false
v8_enable_backtrace = true
v8_enable_fast_mksnapshot = true
v8_enable_verify_csa = true
v8_enable_slow_dchecks = false
v8_optimized_debug = false
v8_disable_write_barriers = true
v8_enable_single_generation = true
v8_enable_shared_ro_heap = false
v8_enable_pointer_compression = false
v8_enable_third_party_heap = true
v8_third_party_heap_files = [ "../mmtk-v8/v8/third_party/heap/mmtk/mmtk.cc",
"../mmtk-v8/v8/third_party/heap/mmtk/mmtk.h",
"../mmtk-v8/v8/third_party/heap/mmtk/mmtkUpcalls.h",
"../mmtk-v8/v8/third_party/heap/mmtk/mmtkUpcalls.cc"]
v8_third_party_heap_libs = [ "../mmtk-v8/mmtk/target/debug/libmmtk_v8.so" ]

Then build:

$ gm x64.debug-mmtk

Test

The V8 document on testing discusses various options for running V8 tests.

For instance, benchmarks tests can be run on "V8 with MMTk" as:

$ gm x64.debug-mmtk benchmarks/*
# autoninja -C out/x64.debug-mmtk d8
ninja: Entering directory `out/x64.debug-mmtk'
ninja: no work to do.
# "/usr/bin/python2" tools/run-tests.py --outdir=out/x64.debug-mmtk benchmarks/*
Build found: /home/javad/sources/v8/v8/v8/out/x64.debug-mmtk
>>> Autodetected:
verify_csa
>>> Running tests for x64.debug
>>> Running with test processors
[02:20|%  96|+  53|-   0]: Done
>>> 55 base tests produced 53 (96%) non-filtered tests
>>> 53 tests ran
Done! - V8 compilation finished successfully.

Limitations

There are a few reasons why MMTk-V8 can not pass all V8 tests, including regression and unit tests:

  • MMTk-V8 does not support garbage collection yet.
  • MMTk does not support multiple heap instances yet.
  • Many of the V8 tests are unit tests targeting specific V8 features, and are not applicable to MMTk.