Skip to content

Commit

Permalink
Upgrade maximum heap size, then passed the ms test
Browse files Browse the repository at this point in the history
changes:
  - Refactor to use state machine style scanning
  - Remove unnecessary debugging code
  • Loading branch information
fepicture committed Oct 1, 2023
1 parent bbcda6c commit fe6e302
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 94 deletions.
43 changes: 22 additions & 21 deletions .github/scripts/ci-test-weak-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@ cd $JIKESRVM_PATH
# Run all possible dacapo benchmarks

export MMTK_THREADS=16
export RUST_BACKTRACE=1
RVM_OPTIONS=-X:gc:no_reference_types=false

# RFastAdaptiveSemiSpace
./bin/buildit localhost RFastAdaptiveSemiSpace -j $JAVA_HOME --answer-yes --use-third-party-heap=$BINDING_PATH/ --use-third-party-build-configs=$BINDING_PATH/jikesrvm/build/configs --use-external-source=$BINDING_PATH/jikesrvm/rvm/src --m32
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar antlr
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar bloat
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms200M -Xmx200M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar jython
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar luindex
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar lusearch
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx75M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar pmd
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms100M -Xmx100M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar xalan
# ./bin/buildit localhost RFastAdaptiveSemiSpace -j $JAVA_HOME --answer-yes --use-third-party-heap=$BINDING_PATH/ --use-third-party-build-configs=$BINDING_PATH/jikesrvm/build/configs --use-external-source=$BINDING_PATH/jikesrvm/rvm/src --m32
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar antlr
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar bloat
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms200M -Xmx200M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar luindex
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar jython
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar lusearch
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms75M -Xmx750M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar pmd
# ./dist/RFastAdaptiveSemiSpace_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms100M -Xmx1000M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar xalan

# RFastAdaptiveMarkSweep
./bin/buildit localhost RFastAdaptiveMarkSweep -j $JAVA_HOME --answer-yes --use-third-party-heap=$BINDING_PATH/ --use-third-party-build-configs=$BINDING_PATH/jikesrvm/build/configs --use-external-source=$BINDING_PATH/jikesrvm/rvm/src --m32
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar antlr
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar bloat
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar antlr
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar bloat
# Failing instruction offset: 0x000000c3 in method ___ with descriptor ___ Couldn't find a method for given instruction offset
#./dist/RFastAdaptiveMarkSweep_x86_64-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms300M -Xmx300M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar jython
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar luindex
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar lusearch
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar pmd
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar xalan
# ./dist/RFastAdaptiveMarkSweep_x86_64-linux/rvm $RVM_OPTIONS -Xms150M -Xmx150M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
# ./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms300M -Xmx4000M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar jython
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar luindex
# ./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar lusearch
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar pmd
./dist/RFastAdaptiveMarkSweep_x86_64_m32-linux/rvm $RVM_OPTIONS -Xms150M -Xmx1500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar xalan
9 changes: 5 additions & 4 deletions jikesrvm/rvm/src/org/jikesrvm/runtime/Entrypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public class Entrypoints {
getMethod(org.jikesrvm.mm.mminterface.RustScanning.class, "scanBootImage", "(Lorg/vmmagic/unboxed/Address;)V");
public static final NormalMethod scheduleFinalizerMethod =
getMethod(org.jikesrvm.scheduler.FinalizerThread.class, "schedule", "()V");
public static final NormalMethod swiftMethod = getMethod(org.jikesrvm.mm.mminterface.MemoryManager.class, "swift",
"()V");
public static final NormalMethod doFinalizableProcessorScanMethod = getMethod(
org.jikesrvm.mm.mminterface.MemoryManager.class, "doFinalizableProcessorScan", "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Z)V");
public static final NormalMethod doReferenceProcessorDelegatorScanMethod = getMethod(
org.jikesrvm.mm.mminterface.MemoryManager.class, "doReferenceProcessorDelegatorScan", "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;ZZ)Z");
public static final NormalMethod doReferenceProcessorDelegatorForwardMethod = getMethod(
org.jikesrvm.mm.mminterface.MemoryManager.class, "doReferenceProcessorDelegatorForward", "(Lorg/vmmagic/unboxed/Address;Lorg/vmmagic/unboxed/Address;Z)V");


// The usual causes for getField/Method() to fail are:
// 1. you misspelled the class name, member name, or member signature
Expand Down
5 changes: 0 additions & 5 deletions mmtk/api/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,14 @@ extern void* last_heap_address();
/**
* Reference Processing
*/
extern void hell_world();
extern void* get_forwarded_object(void * object_reference);
extern bool is_reachable(void * object_reference);
extern void add_weak_candidate(void* ref, void* referent);
extern void add_soft_candidate(void* ref, void* referent);
extern void add_phantom_candidate(void* ref, void* referent);

extern bool get_boolean_option(char* option);

/**
* Finalization
*/
extern void add_finalizer(void* obj);
extern void* get_finalized_object();

extern void harness_begin(void *tls);
Expand Down
29 changes: 0 additions & 29 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,6 @@ pub extern "C" fn is_reachable(object: ObjectReference) -> i32 {
}


#[no_mangle]
pub extern "C" fn hell_world() {
println!("[rust] hell world from mmtk/src/api.rs:hell_world")
}

#[no_mangle]
pub extern "C" fn add_weak_candidate(reff: ObjectReference, referent: ObjectReference) {
<JikesRVM as VMBinding>::VMReferenceGlue::set_referent(reff, referent);
memory_manager::add_weak_candidate(&SINGLETON, reff)
}

#[no_mangle]
pub extern "C" fn add_soft_candidate(reff: ObjectReference, referent: ObjectReference) {
<JikesRVM as VMBinding>::VMReferenceGlue::set_referent(reff, referent);
memory_manager::add_soft_candidate(&SINGLETON, reff)
}

#[no_mangle]
pub extern "C" fn add_phantom_candidate(reff: ObjectReference, referent: ObjectReference) {
<JikesRVM as VMBinding>::VMReferenceGlue::set_referent(reff, referent);
memory_manager::add_phantom_candidate(&SINGLETON, reff)
}

#[no_mangle]
// We trust the name/value pointer is valid.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
Expand Down Expand Up @@ -293,12 +270,6 @@ pub extern "C" fn last_heap_address() -> Address {
memory_manager::last_heap_address()
}

// finalization
#[no_mangle]
pub extern "C" fn add_finalizer(object: ObjectReference) {
memory_manager::add_finalizer(&SINGLETON, object);
}

#[no_mangle]
pub extern "C" fn get_finalized_object() -> ObjectReference {
match memory_manager::get_finalized_object(&SINGLETON) {
Expand Down
22 changes: 3 additions & 19 deletions mmtk/src/reference_glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,22 @@ use mmtk::util::opaque_pointer::*;
use mmtk::util::ObjectReference;
use mmtk::vm::ReferenceGlue;

use entrypoint::*;
use JikesRVM;

use std::arch::asm;

pub struct VMReferenceGlue {}

impl ReferenceGlue<JikesRVM> for VMReferenceGlue {
type FinalizableType = ObjectReference;

fn set_referent(reff: ObjectReference, referent: ObjectReference) {
unsafe {
(reff.to_raw_address() + REFERENCE_REFERENT_FIELD_OFFSET).store(referent);
}
unimplemented!()
}

fn get_referent(object: ObjectReference) -> ObjectReference {
debug_assert!(!object.is_null());
unsafe {
(object.to_raw_address() + REFERENCE_REFERENT_FIELD_OFFSET).load::<ObjectReference>()
}
unimplemented!()
}

fn enqueue_references(references: &[ObjectReference], tls: VMWorkerThread) {
for reff in references {
unsafe {
jtoc_call!(
ENQUEUE_REFERENCE_METHOD_OFFSET,
tls,
std::mem::transmute::<_, usize>(*reff)
);
}
}
unimplemented!()
}
}
71 changes: 55 additions & 16 deletions mmtk/src/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,69 @@ impl Scanning<JikesRVM> for VMScanning {
}

fn process_weak_refs(
_worker: &mut GCWorker<JikesRVM>,
_tracer_context: impl ObjectTracerContext<JikesRVM>,
worker: &mut GCWorker<JikesRVM>,
tracer_context: impl ObjectTracerContext<JikesRVM>,
) -> bool {
process_weak_refs_inner(_worker, _tracer_context)
process_weak_refs_inner(worker, tracer_context)
}

fn forward_weak_refs(
worker: &mut GCWorker<JikesRVM>,
tracer_context: impl ObjectTracerContext<JikesRVM>,
) {
forward_weak_refs_inner(worker, tracer_context)
}
}

fn process_weak_refs_inner<C>(_worker: &mut GCWorker<JikesRVM>, _tracer_context: C) -> bool
fn forward_weak_refs_inner<C>(worker: &mut GCWorker<JikesRVM>, tracer_context: C)
where
C: ObjectTracerContext<JikesRVM>,
{
let tls = _worker.tls;
_tracer_context.with_tracer(_worker, |tracer| {
unsafe {
jtoc_call!(
DO_FINALIZABLE_PROCESSOR_SCAN_METHOD_OFFSET,
tls,
trace_object_callback_for_jikesrvm::<C::TracerType>,
tracer as *mut _ as *mut libc::c_void,
0
);
}
let tls = worker.tls;

let is_nursery = SINGLETON
.get_plan()
.generational()
.map_or(false, |plan| plan.is_current_gc_nursery());

tracer_context.with_tracer(worker, |tracer| unsafe {
jtoc_call!(
DO_REFERENCE_PROCESSOR_DELEGATOR_FORWARD_METHOD_OFFSET,
tls,
trace_object_callback_for_jikesrvm::<C::TracerType>,
tracer as *mut _ as *mut libc::c_void,
is_nursery as i32
);
});
false
}

fn process_weak_refs_inner<C>(worker: &mut GCWorker<JikesRVM>, tracer_context: C) -> bool
where
C: ObjectTracerContext<JikesRVM>,
{
let tls = worker.tls;

let is_nursery = SINGLETON
.get_plan()
.generational()
.map_or(false, |plan| plan.is_current_gc_nursery());

let need_retain = SINGLETON.get_plan().is_emergency_collection();

let mut scan_result = 0;

tracer_context.with_tracer(worker, |tracer| unsafe {
scan_result = jtoc_call!(
DO_REFERENCE_PROCESSOR_DELEGATOR_SCAN_METHOD_OFFSET,
tls,
trace_object_callback_for_jikesrvm::<C::TracerType>,
tracer as *mut _ as *mut libc::c_void,
is_nursery as i32,
need_retain as i32
);
});

scan_result == 0
}

impl VMScanning {
Expand Down

0 comments on commit fe6e302

Please sign in to comment.