diff --git a/.github/scripts/args-debug.gn b/.github/scripts/args-debug.gn index f0acb13..8a3d837 100644 --- a/.github/scripts/args-debug.gn +++ b/.github/scripts/args-debug.gn @@ -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 = [ @@ -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" ] diff --git a/.github/scripts/args-optdebug.gn b/.github/scripts/args-optdebug.gn index ec9bd6a..3958309 100644 --- a/.github/scripts/args-optdebug.gn +++ b/.github/scripts/args-optdebug.gn @@ -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 = [ @@ -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" ] diff --git a/.github/scripts/build-mmtk.sh b/.github/scripts/build-mmtk.sh index 6471fa5..4425e15 100755 --- a/.github/scripts/build-mmtk.sh +++ b/.github/scripts/build-mmtk.sh @@ -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 diff --git a/.github/scripts/common.sh b/.github/scripts/common.sh index cf58cc2..3cb12ce 100644 --- a/.github/scripts/common.sh +++ b/.github/scripts/common.sh @@ -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` diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 4dbc472..0848d47 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib"] lto = true [package.metadata.v8] -v8_version = "191b637f28c0e2c6ca5f2d6ac89377039a754337" +v8_version = "bc0e7c8722b81d92fe3c2e35da5457c25574e07e" depot_tools_version = "b674278ce71b2ee683b8b0c98c9a64152988ecdb" [dependencies] diff --git a/mmtk/src/scanning.rs b/mmtk/src/scanning.rs index 257fcf1..ab11d2d 100644 --- a/mmtk/src/scanning.rs +++ b/mmtk/src/scanning.rs @@ -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 {} diff --git a/v8/third_party/heap/mmtk/mmtk.cc b/v8/third_party/heap/mmtk/mmtk.cc index bfa7c98..7db4dea 100644 --- a/v8/third_party/heap/mmtk/mmtk.cc +++ b/v8/third_party/heap/mmtk/mmtk.cc @@ -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
(alloc(tph_mutator_, size_in_bytes, align_bytes, 0, 0)); @@ -136,7 +136,7 @@ AllocationResult Heap::Allocate(size_t size_in_bytes, AllocationType type, Alloc } tph_archive_insert(tph_data_->archive(), reinterpret_cast(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) { @@ -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, @@ -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) {