Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cross to compile mmtk-v8 #71

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/scripts/args-debug.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ v8_enable_fast_mksnapshot = true
v8_enable_verify_csa = true
v8_enable_slow_dchecks = false
v8_optimized_debug = false
# If we enable external code space, this error shows up.
# ERROR at //BUILD.gn:560:1: Assertion failed.
# assert(!v8_enable_external_code_space || v8_enable_pointer_compression,
# ^-----
# External code space feature requires pointer compression
v8_enable_external_code_space = false

v8_enable_third_party_heap = true
v8_third_party_heap_files = [
Expand All @@ -23,4 +29,4 @@ v8_third_party_heap_files = [
"$the_root/v8/third_party/heap/mmtk/mmtkUpcalls.h",
"$the_root/v8/third_party/heap/mmtk/mmtkUpcalls.cc"
]
v8_third_party_heap_libs = [ "$the_root/mmtk/target/debug/libmmtk_v8.so" ]
v8_third_party_heap_libs = [ "$the_root/mmtk/target/x86_64-unknown-linux-gnu/debug/libmmtk_v8.so" ]
8 changes: 7 additions & 1 deletion .github/scripts/args-optdebug.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ v8_enable_backtrace = true
v8_enable_fast_mksnapshot = true
v8_enable_verify_heap = true
v8_optimized_debug = true
# If we enable external code space, this error shows up.
# ERROR at //BUILD.gn:560:1: Assertion failed.
# assert(!v8_enable_external_code_space || v8_enable_pointer_compression,
# ^-----
# External code space feature requires pointer compression
v8_enable_external_code_space = false

v8_enable_third_party_heap = true
v8_third_party_heap_files = [
Expand All @@ -22,4 +28,4 @@ v8_third_party_heap_files = [
"$the_root/v8/third_party/heap/mmtk/mmtkUpcalls.h",
"$the_root/v8/third_party/heap/mmtk/mmtkUpcalls.cc"
]
v8_third_party_heap_libs = [ "$the_root/mmtk/target/debug/libmmtk_v8.so" ]
v8_third_party_heap_libs = [ "$the_root/mmtk/target/x86_64-unknown-linux-gnu/debug/libmmtk_v8.so" ]
11 changes: 10 additions & 1 deletion .github/scripts/build-mmtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ set -xe

. $(dirname "$0")/common.sh

export PATH=~/.cargo/bin:$PATH
# Check if we have cross available
if ! [ -x "$(command -v cross)" ]; then
echo 'Cross is not available. Will install cross.' >&2
# lock to version 0.2.4. This version uses libc 2.31 for x86_64.
# This matches the version in the sysroot used by V8 (debian bullseye)
cargo install cross --tag v0.2.4 --git https://github.com/cross-rs/cross
fi

# simply build mmtk-v8 with nogc
cd $THE_ROOT/mmtk
rustup run $RUSTUP_TOOLCHAIN cargo build --features nogc
cross build --target x86_64-unknown-linux-gnu --features nogc
4 changes: 2 additions & 2 deletions .github/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export THE_ROOT=`realpath $(dirname "$0")/../..`
export V8_ROOT=$THE_ROOT/deps

# Test with a specific revision.
export V8_VERSION=`cargo read-manifest --manifest-path=$THE_ROOT/mmtk/Cargo.toml | python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["v8"]["v8_version"])'`
export V8_VERSION=`cargo read-manifest --manifest-path=$THE_ROOT/mmtk/Cargo.toml | python3 -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["v8"]["v8_version"])'`
# The commit after this requires python 3.7. This is the only reason we fix to this revision.
export DEPOT_TOOLS_VERSION=`cargo read-manifest --manifest-path=$THE_ROOT/mmtk/Cargo.toml | python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["v8"]["depot_tools_version"])'`
export DEPOT_TOOLS_VERSION=`cargo read-manifest --manifest-path=$THE_ROOT/mmtk/Cargo.toml | python3 -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["v8"]["depot_tools_version"])'`

export RUSTUP_TOOLCHAIN=`cat $THE_ROOT/mmtk/rust-toolchain`
2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]
lto = true

[package.metadata.v8]
v8_version = "191b637f28c0e2c6ca5f2d6ac89377039a754337"
v8_version = "bc0e7c8722b81d92fe3c2e35da5457c25574e07e"
depot_tools_version = "b674278ce71b2ee683b8b0c98c9a64152988ecdb"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion mmtk/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use mmtk::vm::EdgeVisitor;
use mmtk::vm::RootsWorkFactory;
use mmtk::vm::Scanning;
use mmtk::Mutator;
use V8;
use V8Edge;
use V8;

pub struct VMScanning {}

Expand Down
22 changes: 17 additions & 5 deletions v8/third_party/heap/mmtk/mmtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ AllocationResult Heap::Allocate(size_t size_in_bytes, AllocationType type, Alloc
CheckMutator(this);
TPHData* tph_data_ = get_tph_data(this);
bool large_object = size_in_bytes > kMaxRegularHeapObjectSize;
size_t align_bytes = (type == AllocationType::kCode) ? kCodeAlignment : (align == kWordAligned) ? kSystemPointerSize : (align == kDoubleAligned) ? kDoubleSize : kSystemPointerSize;
size_t align_bytes = (type == AllocationType::kCode) ? kCodeAlignment : (align == kTaggedAligned) ? kTaggedSize : (align == kDoubleAligned) ? kDoubleSize : kSystemPointerSize;
// Get MMTk space that the object should be allocated to.
Address result =
reinterpret_cast<Address>(alloc(tph_mutator_, size_in_bytes, align_bytes, 0, 0));
Expand All @@ -136,7 +136,7 @@ AllocationResult Heap::Allocate(size_t size_in_bytes, AllocationType type, Alloc
}
tph_archive_insert(tph_data_->archive(), reinterpret_cast<void*>(result), tph_data_->isolate(), uint8_t(allocation_space));
HeapObject rtn = HeapObject::FromAddress(result);
return rtn;
return AllocationResult::FromObject(rtn);
}

Address Heap::GetObjectFromInnerPointer(Address inner_pointer) {
Expand All @@ -155,7 +155,7 @@ bool Heap::CollectGarbage() {
}

// Uninitialized space tag
constexpr AllocationSpace kNoSpace = AllocationSpace(255);
constexpr AllocationSpace kNoSpace = AllocationSpace(7);

// Checks whether the address is *logically* in the allocation_space.
// This does not related the real MMTk space that contains the address,
Expand All @@ -176,9 +176,21 @@ bool Heap::InOldSpace(Address address) {
return InSpace(address, OLD_SPACE);
}

bool Heap::IsValidCodeObject(HeapObject object) {
return InSpace(object.address(), CODE_SPACE);
}

bool Heap::IsImmovable(HeapObject object) {
// FIXME: we need to check with MMTK
return true;
}

bool Heap::InCodeSpace(Address address) {
return InSpace(address, CODE_SPACE);
// Check if the given object was recently allocated and its fields may appear
// as uninitialized to background threads.
bool Heap::IsPendingAllocation(HeapObject object) {
// Initializing fields should be the responsibility of the runtime.
// MMTk won't know that?
return false;
}

bool Heap::InReadOnlySpace(Address address) {
Expand Down