diff --git a/mmtk/Cargo.lock b/mmtk/Cargo.lock index c8d073e8..be0729cf 100644 --- a/mmtk/Cargo.lock +++ b/mmtk/Cargo.lock @@ -449,7 +449,7 @@ dependencies = [ [[package]] name = "mmtk" version = "0.22.1" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=ef2bd6d043d8675badaa415db89be7b52439725f#ef2bd6d043d8675badaa415db89be7b52439725f" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=7cafe560139211c0e3a74815d2e288278506099d#7cafe560139211c0e3a74815d2e288278506099d" dependencies = [ "atomic 0.6.0", "atomic-traits", @@ -500,7 +500,7 @@ dependencies = [ [[package]] name = "mmtk-macros" version = "0.22.1" -source = "git+https://github.com/mmtk/mmtk-core.git?rev=ef2bd6d043d8675badaa415db89be7b52439725f#ef2bd6d043d8675badaa415db89be7b52439725f" +source = "git+https://github.com/mmtk/mmtk-core.git?rev=7cafe560139211c0e3a74815d2e288278506099d#7cafe560139211c0e3a74815d2e288278506099d" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/mmtk/Cargo.toml b/mmtk/Cargo.toml index 9c1d1287..fe5fac16 100644 --- a/mmtk/Cargo.toml +++ b/mmtk/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [package.metadata.julia] # Our CI matches the following line and extract mmtk/julia. If this line is updated, please check ci yaml files and make sure it works. julia_repo = "https://github.com/mmtk/julia.git" -julia_version = "5c406d9bb20d76e2298a6101f171cfac491f651c" +julia_version = "22524a81f9920a8ecc70f195d53b145761de2fa0" [lib] crate-type = ["cdylib"] @@ -31,7 +31,7 @@ lazy_static = "1.1" # - 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="ef2bd6d043d8675badaa415db89be7b52439725f" } +mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev="7cafe560139211c0e3a74815d2e288278506099d" } # Uncomment the following to build locally # mmtk = { path = "../repos/mmtk-core" } log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"] } diff --git a/mmtk/api/mmtk.h b/mmtk/api/mmtk.h index e3d10c4a..9ddd411b 100644 --- a/mmtk/api/mmtk.h +++ b/mmtk/api/mmtk.h @@ -95,8 +95,6 @@ extern bool mmtk_process(char* name, char* value); extern void mmtk_scan_region(void); extern void mmtk_handle_user_collection_request(void *tls, uint8_t collection); extern void mmtk_initialize_collection(void* tls); -extern void mmtk_enable_collection(void); -extern void mmtk_disable_collection(void); extern void mmtk_start_control_collector(void *tls); extern void mmtk_start_worker(void *tls, void* worker, void* mmtk); extern void mmtk_process_julia_obj(void* addr); diff --git a/mmtk/src/api.rs b/mmtk/src/api.rs index 0e647ed2..a8eaa11a 100644 --- a/mmtk/src/api.rs +++ b/mmtk/src/api.rs @@ -3,7 +3,6 @@ use crate::JuliaVM; use crate::Julia_Upcalls; -use crate::BLOCK_FOR_GC; use crate::JULIA_HEADER_SIZE; use crate::SINGLETON; use crate::UPCALLS; @@ -240,30 +239,6 @@ pub extern "C" fn mmtk_initialize_collection(tls: VMThread) { memory_manager::initialize_collection(&SINGLETON, tls); } -#[no_mangle] -pub extern "C" fn mmtk_enable_collection() { - if AtomicBool::load(&DISABLED_GC, Ordering::SeqCst) { - memory_manager::enable_collection(&SINGLETON); - AtomicBool::store(&DISABLED_GC, false, Ordering::SeqCst); - } -} - -#[no_mangle] -pub extern "C" fn mmtk_disable_collection() { - if AtomicBool::load(&DISABLED_GC, Ordering::SeqCst) == false { - AtomicBool::store(&DISABLED_GC, true, Ordering::SeqCst); - memory_manager::disable_collection(&SINGLETON); - } - - // if user has triggered GC, wait until GC is finished - while AtomicIsize::load(&USER_TRIGGERED_GC, Ordering::SeqCst) != 0 - || AtomicBool::load(&BLOCK_FOR_GC, Ordering::SeqCst) - { - info!("Waiting for a triggered gc to finish..."); - unsafe { ((*UPCALLS).wait_in_a_safepoint)() }; - } -} - #[no_mangle] pub extern "C" fn mmtk_used_bytes() -> usize { memory_manager::used_bytes(&SINGLETON) diff --git a/mmtk/src/collection.rs b/mmtk/src/collection.rs index a2c30c14..230f74cb 100644 --- a/mmtk/src/collection.rs +++ b/mmtk/src/collection.rs @@ -5,12 +5,16 @@ use mmtk::util::alloc::AllocationError; use mmtk::util::opaque_pointer::*; use mmtk::vm::{Collection, GCThreadContext}; use mmtk::Mutator; -use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU32, AtomicU64, Ordering}; use crate::{BLOCK_FOR_GC, STW_COND, WORLD_HAS_STOPPED}; static GC_START: AtomicU64 = AtomicU64::new(0); +extern "C" { + pub static jl_gc_disable_counter: AtomicU32; +} + pub struct VMCollection {} impl Collection for VMCollection { @@ -100,6 +104,10 @@ impl Collection for VMCollection { fn vm_live_bytes() -> usize { crate::api::JULIA_MALLOC_BYTES.load(Ordering::SeqCst) } + + fn is_collection_enabled() -> bool { + unsafe { AtomicU32::load(&jl_gc_disable_counter, Ordering::SeqCst) <= 0 } + } } pub fn is_current_gc_nursery() -> bool {