Skip to content

Commit

Permalink
Add option to put forwarding bits on the side (#277)
Browse files Browse the repository at this point in the history
Added a feature to force using on-the-side forwarding bits. This is for
testing mmtk-core. The CI script for minimal test is also extended to
run several plans involving CopySpace and ImmixSpace on OpenJDK with
side forwarding bits.

Related PR: mmtk/mmtk-core#1138 The feature
introduced in this PR can be used to check the correctness of that PR.

---------

Co-authored-by: mmtkgc-bot <[email protected]>
  • Loading branch information
wks and mmtkgc-bot authored Jun 3, 2024
1 parent 9360c18 commit 928ce42
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 27 deletions.
21 changes: 21 additions & 0 deletions .github/scripts/ci-test-forwarding-on-side.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set -xe

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

unset JAVA_TOOL_OPTIONS

run_subset() {
heap_multiplier=$1

runbms_dacapo2006_with_heap_multiplier antlr $heap_multiplier
runbms_dacapo2006_with_heap_multiplier fop $heap_multiplier
runbms_dacapo2006_with_heap_multiplier luindex $heap_multiplier
runbms_dacapo2006_with_heap_multiplier lusearch $heap_multiplier
}

# Run plans that involve CopySpace and ImmixSpace which use forwarding bits.
MMTK_PLAN=SemiSpace run_subset 4
MMTK_PLAN=Immix run_subset 4
MMTK_PLAN=GenCopy run_subset 4
MMTK_PLAN=GenImmix run_subset 4
MMTK_PLAN=StickyImmix run_subset 4
9 changes: 9 additions & 0 deletions .github/scripts/ci-test-minimal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ MMTK_PLAN=GenImmix runbms_dacapo2006_with_heap_multiplier fop 4 -XX:-UseCompress
MMTK_VO_BIT=1 $cur/ci-build.sh
# Test
MMTK_PLAN=GenImmix runbms_dacapo2006_with_heap_multiplier fop 4

# Build with on-the-side forwarding bits
MMTK_FORWARDING_ON_SIDE=1 $cur/ci-build.sh
# Test
MMTK_PLAN=SemiSpace runbms_dacapo2006_with_heap_multiplier lusearch 4
MMTK_PLAN=Immix runbms_dacapo2006_with_heap_multiplier lusearch 4
MMTK_PLAN=GenCopy runbms_dacapo2006_with_heap_multiplier lusearch 4
MMTK_PLAN=GenImmix runbms_dacapo2006_with_heap_multiplier lusearch 4
MMTK_PLAN=StickyImmix runbms_dacapo2006_with_heap_multiplier lusearch 4
9 changes: 8 additions & 1 deletion .github/workflows/run-dacapo-2006.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ jobs:
strategy:
fail-fast: false
matrix:
test-script: ["ci-test-vo-bit", "ci-test-assertions", "ci-test-malloc-mark-sweep", "ci-test-mark-in-header"]
test-script:
- ci-test-vo-bit
- ci-test-assertions
- ci-test-malloc-mark-sweep
- ci-test-mark-in-header
- ci-test-forwarding-on-side
include:
- test-script: ci-test-vo-bit
build-suffix: MMTK_VO_BIT=1
Expand All @@ -99,6 +104,8 @@ jobs:
build-suffix: MMTK_MALLOC_MARK_SWEEP=1_MMTK_EXTREME_ASSERTIONS=1
- test-script: ci-test-mark-in-header
build-suffix: MMTK_MALLOC_MARK_SWEEP=1_MMTK_MARK_IN_HEADER=1
- test-script: ci-test-forwarding-on-side
build-suffix: MMTK_FORWARDING_ON_SIDE=1
steps:
- name: Checkout MMTk OpenJDK binding
uses: actions/checkout@v4
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ jobs:
build-env-var: MMTK_MALLOC_MARK_SWEEP=1 MMTK_MARK_IN_HEADER=1
debug-level: fastdebug

build-forwarding-on-side:
uses: ./.github/workflows/build.yml
with:
build-env-var: MMTK_FORWARDING_ON_SIDE=1
debug-level: fastdebug

run-dacapo-2006:
needs:
- build-normal-fastdebug
- build-vo-bit
- build-extreme-assertions
- build-malloc-mark-sweep
- build-mark-in-header
- build-forwarding-on-side
uses: ./.github/workflows/run-dacapo-2006.yml

run-dacapo-chopin:
Expand Down
23 changes: 12 additions & 11 deletions mmtk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ lazy_static = "1.1"
once_cell = "1.10.0"
atomic = "0.6.0"
memoffset = "0.9.0"
cfg-if = "1.0"

# Be very careful to commit any changes to the following mmtk dependency, as our CI scripts (including mmtk-core CI)
# rely on matching these lines to modify them: e.g. comment out the git dependency and use the local path.
# These changes are safe:
# - change branch
# - change repo name
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "56b2521d2b99848ee0613a0a5288fe6d81b754ba" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "a9b619a4ee18a4f83209f930f8c48a3b63ee478c" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }

Expand All @@ -48,9 +50,12 @@ nogc_no_zeroing = ["mmtk/nogc_no_zeroing"]
# See README.
vo_bit = ["mmtk/vo_bit"]

# This compile time constant places the mark bit in the header of the object instead of on the side.
# Place the mark bit in the header of objects instead of on the side.
mark_bit_in_header = []

# Place the forwarding bits on the side instead of in the header of objects.
forwarding_bits_on_side = []

# Use malloc mark sweep - we should only run marksweep with this feature turned on.
malloc_mark_sweep = ["mmtk/malloc_mark_sweep"]

Expand Down
47 changes: 34 additions & 13 deletions mmtk/src/vm_metadata/constants.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use mmtk::vm::*;
use mmtk::{util::metadata::MetadataSpec, vm::*};

#[cfg(target_pointer_width = "64")]
#[allow(unused)]
pub(crate) const FORWARDING_BITS_OFFSET: isize = 56;
#[cfg(target_pointer_width = "32")]
#[allow(unused)]
pub(crate) const FORWARDING_BITS_OFFSET: isize = unimplemented!();

pub(crate) const FORWARDING_POINTER_OFFSET: isize = 0;
Expand All @@ -22,20 +24,39 @@ pub(crate) const LOGGING_SIDE_METADATA_SPEC: VMGlobalLogBitSpec = VMGlobalLogBit
pub(crate) const FORWARDING_POINTER_METADATA_SPEC: VMLocalForwardingPointerSpec =
VMLocalForwardingPointerSpec::in_header(FORWARDING_POINTER_OFFSET);

/// PolicySpecific object forwarding status metadata spec
/// 2 bits per object
pub(crate) const FORWARDING_BITS_METADATA_SPEC: VMLocalForwardingBitsSpec =
VMLocalForwardingBitsSpec::in_header(FORWARDING_BITS_OFFSET);
cfg_if::cfg_if! {
if #[cfg(feature = "mark_bit_in_header")] {
/// PolicySpecific mark bit metadata spec
/// 1 bit per object
pub(crate) const MARKING_METADATA_SPEC: VMLocalMarkBitSpec =
VMLocalMarkBitSpec::in_header(FORWARDING_BITS_OFFSET);

/// PolicySpecific mark bit metadata spec
/// 1 bit per object
#[cfg(feature = "mark_bit_in_header")]
pub(crate) const MARKING_METADATA_SPEC: VMLocalMarkBitSpec =
VMLocalMarkBitSpec::in_header(FORWARDING_BITS_OFFSET);
#[allow(unused)]
const LAST_SIDE_SPEC_BEFORE_MARK: &MetadataSpec = LOS_METADATA_SPEC.as_spec();
} else {
/// PolicySpecific mark bit metadata spec
/// 1 bit per object
pub(crate) const MARKING_METADATA_SPEC: VMLocalMarkBitSpec =
VMLocalMarkBitSpec::side_after(LOS_METADATA_SPEC.as_spec());

#[allow(unused)]
const LAST_SIDE_SPEC_BEFORE_MARK: &MetadataSpec = MARKING_METADATA_SPEC.as_spec();
}
}

#[cfg(not(feature = "mark_bit_in_header"))]
pub(crate) const MARKING_METADATA_SPEC: VMLocalMarkBitSpec =
VMLocalMarkBitSpec::side_after(LOS_METADATA_SPEC.as_spec());
cfg_if::cfg_if! {
if #[cfg(feature = "forwarding_bits_on_side")] {
/// PolicySpecific object forwarding status metadata spec
/// 2 bits per object
pub(crate) const FORWARDING_BITS_METADATA_SPEC: VMLocalForwardingBitsSpec =
VMLocalForwardingBitsSpec::side_after(LAST_SIDE_SPEC_BEFORE_MARK);
} else {
/// PolicySpecific object forwarding status metadata spec
/// 2 bits per object
pub(crate) const FORWARDING_BITS_METADATA_SPEC: VMLocalForwardingBitsSpec =
VMLocalForwardingBitsSpec::in_header(FORWARDING_BITS_OFFSET);
}
}

/// PolicySpecific mark-and-nursery bits metadata spec
/// 2-bits per object
Expand Down
8 changes: 8 additions & 0 deletions openjdk/CompileThirdPartyHeap.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ ifeq ($(MMTK_MARK_IN_HEADER), 1)
endif
endif

ifeq ($(MMTK_FORWARDING_ON_SIDE), 1)
ifndef GC_FEATURES
GC_FEATURES=--features forwarding_bits_on_side
else
GC_FEATURES:=$(strip $(GC_FEATURES))",forwarding_bits_on_side"
endif
endif

ifeq ($(MMTK_EXTREME_ASSERTIONS), 1)
ifndef GC_FEATURES
GC_FEATURES=--features mmtk_extreme_assertions
Expand Down

0 comments on commit 928ce42

Please sign in to comment.