Skip to content

Commit ac90d4b

Browse files
committed
Allow running MockVM with side metadata
1 parent e568453 commit ac90d4b

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

.github/scripts/ci-test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ find ./src ./tests -type f -name "mock_test_*" | while read -r file; do
3434

3535
# Run the test with each plan it needs.
3636
for MMTK_PLAN in $PLANS; do
37-
env MMTK_PLAN=$MMTK_PLAN cargo test --features mock_test,"$FEATURES" -- $t;
37+
env MMTK_PLAN=$MMTK_PLAN cargo test --features mock_test,mock_test_side_metadata,"$FEATURES" -- $t;
38+
# We should alro run the tests with mock_test_header_metadata feature -- be careful that some plans like compressor requires side mark bits which will fail if we use header metadata (including mark bits).
39+
# env MMTK_PLAN=$MMTK_PLAN cargo test --features mock_test,mock_test_header_metadata,"$FEATURES" -- $t;
3840
done
3941
done
4042

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ perf_counter = ["dep:pfm"]
116116
# This feature is only used for tests with MockVM.
117117
# CI scripts run those tests with this feature.
118118
mock_test = ["test_private"]
119+
mock_test_header_metadata = []
120+
mock_test_side_metadata = []
119121

120122
# This feature will expose some private functions for testings or benchmarking.
121123
test_private = []

src/util/test_util/mock_vm.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,39 @@ impl crate::vm::Collection<MockVM> for MockVM {
462462
}
463463
}
464464

465-
impl crate::vm::ObjectModel<MockVM> for MockVM {
466-
const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::in_header(0);
467-
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec =
465+
#[cfg(feature = "mock_test_header_metadata")]
466+
mod mockvm_metadata {
467+
use super::*;
468+
pub const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::in_header(0);
469+
pub const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec =
468470
VMLocalForwardingPointerSpec::in_header(0);
469-
const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec =
471+
pub const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec =
470472
VMLocalForwardingBitsSpec::in_header(0);
471-
const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec = VMLocalMarkBitSpec::in_header(0);
472-
const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec =
473+
pub const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec = VMLocalMarkBitSpec::in_header(0);
474+
pub const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec =
473475
VMLocalLOSMarkNurserySpec::in_header(0);
476+
}
477+
478+
#[cfg(feature = "mock_test_side_metadata")]
479+
mod mockvm_metadata {
480+
use super::*;
481+
pub const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::side_first();
482+
// Forarding pointer has to be in the header, as we cannot fit it in the side metadata (1 word metadata for 1 word data)
483+
pub const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec =
484+
VMLocalForwardingPointerSpec::in_header(0);
485+
pub const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec =
486+
VMLocalForwardingBitsSpec::side_first();
487+
pub const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec = VMLocalMarkBitSpec::side_after(LOCAL_FORWARDING_BITS_SPEC.as_spec());
488+
pub const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec =
489+
VMLocalLOSMarkNurserySpec::side_after(LOCAL_MARK_BIT_SPEC.as_spec());
490+
}
491+
492+
impl crate::vm::ObjectModel<MockVM> for MockVM {
493+
const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = mockvm_metadata::GLOBAL_LOG_BIT_SPEC;
494+
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec = mockvm_metadata::LOCAL_FORWARDING_POINTER_SPEC;
495+
const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec = mockvm_metadata::LOCAL_FORWARDING_BITS_SPEC;
496+
const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec = mockvm_metadata::LOCAL_MARK_BIT_SPEC;
497+
const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec = mockvm_metadata::LOCAL_LOS_MARK_NURSERY_SPEC;
474498

475499
#[cfg(feature = "object_pinning")]
476500
const LOCAL_PINNING_BIT_SPEC: VMLocalPinningBitSpec = VMLocalPinningBitSpec::in_header(0);

0 commit comments

Comments
 (0)