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 mark sweep space as the nonmoving space #163

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
# Run the tests
- name: Dacapo Tests
run: ./.github/scripts/ci-test-normal.sh
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

# Run these checks after build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ public abstract class MMTkMutatorContext extends MutatorContext {
@Entrypoint
Address immixAllocator0Context;
@Entrypoint
Address immixAllocator0Hot;
byte immixAllocator0Hot;
@Entrypoint
Address immixAllocator0Copy;
byte immixAllocator0Copy;
byte immixAllocator0Pad0;
byte immixAllocator0Pad1;
@Entrypoint
Address immixAllocator0LargeCursor;
@Entrypoint
Expand Down Expand Up @@ -253,7 +255,7 @@ public abstract class MMTkMutatorContext extends MutatorContext {
// Malloc allocator size. We do not need offsets for each field, as we don't need to implement fastpath for large object allocator.
static final int MALLOC_ALLOCATOR_SIZE = 3 * BYTES_IN_WORD;
// Immix allocator size
static final int IMMIX_ALLOCATOR_SIZE = 12 * BYTES_IN_WORD;
static final int IMMIX_ALLOCATOR_SIZE = 11 * BYTES_IN_WORD;
// Free list allocator size
static final int FREE_LIST_ALLOCATOR_SIZE = 7 * BYTES_IN_WORD;
// Mark compact allocator size (the same as bump allocator)
Expand Down Expand Up @@ -420,4 +422,9 @@ public void deinitMutator() {
Address handle = Magic.objectAsAddress(this).plus(MUTATOR_BASE_OFFSET);
sysCall.sysDestroyMutator(handle);
}

@Entrypoint
public static final int getInlinedMutatorSize() {
return MUTATOR_SIZE;
}
}
10 changes: 4 additions & 6 deletions jikesrvm/rvm/src/org/jikesrvm/mm/mminterface/MSContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
@Uninterruptible
public class MSContext extends MMTkMutatorContext {
// DEFAULT: FreeListAllocator #0 (MarkSweepSpace)
// NonMomving: FreeListAllocator #1 (MarkSweepSpace)
// CODE: BumpAllocator #0 (ImmortalSpace)
// LARGECODE: BumpAllocator #1 (ImmortalSpace)
// Immortal: BumpAllocator #2 (ImmortalSpace)
// NonMomving: BumpAllocator #3 (ImmortalSpace)
// LOS: LargeObjectAllocator #0 (LargeObjectSpace)

@Inline
protected final int getAllocatorTag(int allocator) {
if (allocator == MMTkAllocator.DEFAULT)
if (allocator == MMTkAllocator.DEFAULT || allocator == MMTkAllocator.NONMOVING)
return MMTkMutatorContext.TAG_FREE_LIST;
else if (allocator == MMTkAllocator.LOS)
return MMTkMutatorContext.TAG_LARGE_OBJECT;
Expand All @@ -37,20 +37,18 @@ else if (allocator == MMTkAllocator.LOS)
protected final int getAllocatorIndex(int allocator) {
if (allocator == MMTkAllocator.DEFAULT || allocator == MMTkAllocator.CODE || allocator == MMTkAllocator.LOS) {
return 0;
} else if (allocator == MMTkAllocator.LARGE_CODE) {
} else if (allocator == MMTkAllocator.LARGE_CODE || allocator == MMTkAllocator.NONMOVING) {
return 1;
} else if (allocator == MMTkAllocator.IMMORTAL) {
return 2;
} else if (allocator == MMTkAllocator.NONMOVING) {
return 3;
} else {
VM.sysFail("Unexpected allocator", allocator);
return 0;
}
}
@Inline
protected final int getSpaceTag(int allocator) {
if (allocator == MMTkAllocator.DEFAULT)
if (allocator == MMTkAllocator.DEFAULT || allocator == MMTkAllocator.NONMOVING)
return MMTkMutatorContext.MARK_SWEEP_SPACE;
else if (allocator == MMTkAllocator.LOS)
return MMTkMutatorContext.LARGE_OBJECT_SPACE;
Expand Down
8 changes: 6 additions & 2 deletions jikesrvm/rvm/src/org/jikesrvm/mm/mminterface/SSContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public class SSContext extends MMTkMutatorContext {
// CODE: BumpAllocator #1 (ImmortalSpace)
// LARGE_CODE: BumpAllocator #2 (ImmortalSpace)
// Immortal: BumpAllocator #3 (ImmortalSpace)
// NonMoving: BumpAllocator #4 (ImmortalSpace)
// LOS: LargeObjectAllocator #0 (LargeObjectSpace)
// NonMoving: FreeListAllocator #0 (MarkSweepSpace)

@Inline
protected final int getAllocatorTag(int allocator) {
if (allocator == MMTkAllocator.LOS) {
return MMTkMutatorContext.TAG_LARGE_OBJECT;
} else if (allocator == MMTkAllocator.NONMOVING) {
return MMTkMutatorContext.TAG_FREE_LIST;
} else {
return MMTkMutatorContext.TAG_BUMP_POINTER;
}
Expand All @@ -44,7 +46,7 @@ protected final int getAllocatorIndex(int allocator) {
} else if (allocator == MMTkAllocator.IMMORTAL) {
return 3;
} else if (allocator == MMTkAllocator.NONMOVING) {
return 4;
return 0;
} else {
VM.sysFail("Unexpected allocator", allocator);
return 0;
Expand All @@ -56,6 +58,8 @@ protected final int getSpaceTag(int allocator) {
return COPY_SPACE;
} else if (allocator == MMTkAllocator.LOS) {
return LARGE_OBJECT_SPACE;
} else if (allocator == MMTkAllocator.NONMOVING) {
return MARK_SWEEP_SPACE;
} else {
return IMMORTAL_SPACE;
}
Expand Down
3 changes: 3 additions & 0 deletions jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public class Entrypoints {
public static final NormalMethod enqueueReferenceMethod =
getMethod(org.jikesrvm.mm.mminterface.MemoryManager.class, "enqueueReference", "(Lorg/vmmagic/unboxed/Address;)V");

public static final NormalMethod getInlinedMutatorSizeMethod =
getMethod(org.jikesrvm.mm.mminterface.MMTkMutatorContext.class, "getInlinedMutatorSize", "()I");

public static final RVMField numThreadsField =
getField(org.jikesrvm.scheduler.RVMThread.class, "numThreads", int.class);
public static final RVMField isCollectorField =
Expand Down
8 changes: 4 additions & 4 deletions mmtk/Cargo.lock

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

6 changes: 3 additions & 3 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ lto = true
# Metadata for the JikesRVM repository
[package.metadata.jikesrvm]
# Our CI matches the following line and extract mmtk/jikesrvm. If this line is updated, please check ci yaml files and make sure it works.
jikesrvm_repo = "https://github.com/mmtk/jikesrvm.git"
jikesrvm_version = "a43efe4f33a6a69aabeb03e5c5e2e8880f96f047"
jikesrvm_repo = "https://github.com/qinsoon/jikesrvm.git"
jikesrvm_version = "9d04231d8a241e6309d99feea3850d936cc4ec68"

[dependencies]
libc = "0.2"
Expand All @@ -28,7 +28,7 @@ log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"]
# - change branch/rev
# - 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 = "e79e94e744660c486d5471f252ff05c4248bcea9" }
mmtk = { git = "https://github.com/qinsoon/mmtk-core.git", rev = "b4424295ebfd146cf45c5b1568524a5c64440093" }
# Uncomment the following to build locally - if you change the path locally, do not commit the change in a PR
# mmtk = { path = "../repos/mmtk-core" }

Expand Down
10 changes: 9 additions & 1 deletion mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub extern "C" fn jikesrvm_gc_init(jtoc: *mut c_void, heap_size: usize) {
builder
.options
.vm_space_start
.set(unsafe { Address::from_usize(0x6000_0000) });
.set(unsafe { Address::from_usize(0x7000_0000) });
builder.options.vm_space_size.set(0x800_0000);
}

Expand Down Expand Up @@ -133,6 +133,14 @@ pub extern "C" fn start_worker(tls: VMWorkerThread, worker: *mut GCWorker<JikesR

#[no_mangle]
pub extern "C" fn enable_collection(tls: VMThread) {
{
use crate::entrypoint::*;
use std::arch::asm;
let java_inlined_mutator_size = unsafe { jtoc_call!(GET_INLINED_MUTATOR_SIZE_METHOD_OFFSET, tls) };
let rust_inlined_mutator_size = std::mem::size_of::<mmtk::Mutator<JikesRVM>>();
assert_eq!(java_inlined_mutator_size, rust_inlined_mutator_size);
}

// MMTk core renamed enable_collection() to initialize_collection(). The JikesRVM binding
// never uses the new enable_collection() API so we just expose this as enable_collection().
// Also this is used by JikesRVM for third party heaps in places where it uses JavaMMTK's enableCollection().
Expand Down
Loading