Skip to content

Commit eac7e88

Browse files
udesoummtkgc-bot
andauthored
Ask from binding if GC is disabled (#126)
Upstream PR: mmtk/mmtk-core#1075 Julia PR: mmtk/julia#35 --------- Co-authored-by: mmtkgc-bot <[email protected]>
1 parent 6f38359 commit eac7e88

File tree

5 files changed

+13
-32
lines changed

5 files changed

+13
-32
lines changed

mmtk/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mmtk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
[package.metadata.julia]
1111
# 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.
1212
julia_repo = "https://github.com/mmtk/julia.git"
13-
julia_version = "5c406d9bb20d76e2298a6101f171cfac491f651c"
13+
julia_version = "22524a81f9920a8ecc70f195d53b145761de2fa0"
1414

1515
[lib]
1616
crate-type = ["cdylib"]
@@ -31,7 +31,7 @@ lazy_static = "1.1"
3131
# - change branch
3232
# - change repo name
3333
# But other changes including adding/removing whitespaces in commented lines may break the CI
34-
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev="ef2bd6d043d8675badaa415db89be7b52439725f" }
34+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev="7cafe560139211c0e3a74815d2e288278506099d" }
3535
# Uncomment the following to build locally
3636
# mmtk = { path = "../repos/mmtk-core" }
3737
log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"] }

mmtk/api/mmtk.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ extern bool mmtk_process(char* name, char* value);
9595
extern void mmtk_scan_region(void);
9696
extern void mmtk_handle_user_collection_request(void *tls, uint8_t collection);
9797
extern void mmtk_initialize_collection(void* tls);
98-
extern void mmtk_enable_collection(void);
99-
extern void mmtk_disable_collection(void);
10098
extern void mmtk_start_control_collector(void *tls);
10199
extern void mmtk_start_worker(void *tls, void* worker, void* mmtk);
102100
extern void mmtk_process_julia_obj(void* addr);

mmtk/src/api.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use crate::JuliaVM;
55
use crate::Julia_Upcalls;
6-
use crate::BLOCK_FOR_GC;
76
use crate::JULIA_HEADER_SIZE;
87
use crate::SINGLETON;
98
use crate::UPCALLS;
@@ -240,30 +239,6 @@ pub extern "C" fn mmtk_initialize_collection(tls: VMThread) {
240239
memory_manager::initialize_collection(&SINGLETON, tls);
241240
}
242241

243-
#[no_mangle]
244-
pub extern "C" fn mmtk_enable_collection() {
245-
if AtomicBool::load(&DISABLED_GC, Ordering::SeqCst) {
246-
memory_manager::enable_collection(&SINGLETON);
247-
AtomicBool::store(&DISABLED_GC, false, Ordering::SeqCst);
248-
}
249-
}
250-
251-
#[no_mangle]
252-
pub extern "C" fn mmtk_disable_collection() {
253-
if AtomicBool::load(&DISABLED_GC, Ordering::SeqCst) == false {
254-
AtomicBool::store(&DISABLED_GC, true, Ordering::SeqCst);
255-
memory_manager::disable_collection(&SINGLETON);
256-
}
257-
258-
// if user has triggered GC, wait until GC is finished
259-
while AtomicIsize::load(&USER_TRIGGERED_GC, Ordering::SeqCst) != 0
260-
|| AtomicBool::load(&BLOCK_FOR_GC, Ordering::SeqCst)
261-
{
262-
info!("Waiting for a triggered gc to finish...");
263-
unsafe { ((*UPCALLS).wait_in_a_safepoint)() };
264-
}
265-
}
266-
267242
#[no_mangle]
268243
pub extern "C" fn mmtk_used_bytes() -> usize {
269244
memory_manager::used_bytes(&SINGLETON)

mmtk/src/collection.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ use mmtk::util::alloc::AllocationError;
55
use mmtk::util::opaque_pointer::*;
66
use mmtk::vm::{Collection, GCThreadContext};
77
use mmtk::Mutator;
8-
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU64, Ordering};
8+
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU32, AtomicU64, Ordering};
99

1010
use crate::{BLOCK_FOR_GC, STW_COND, WORLD_HAS_STOPPED};
1111

1212
static GC_START: AtomicU64 = AtomicU64::new(0);
1313

14+
extern "C" {
15+
pub static jl_gc_disable_counter: AtomicU32;
16+
}
17+
1418
pub struct VMCollection {}
1519

1620
impl Collection<JuliaVM> for VMCollection {
@@ -100,6 +104,10 @@ impl Collection<JuliaVM> for VMCollection {
100104
fn vm_live_bytes() -> usize {
101105
crate::api::JULIA_MALLOC_BYTES.load(Ordering::SeqCst)
102106
}
107+
108+
fn is_collection_enabled() -> bool {
109+
unsafe { AtomicU32::load(&jl_gc_disable_counter, Ordering::SeqCst) <= 0 }
110+
}
103111
}
104112

105113
pub fn is_current_gc_nursery() -> bool {

0 commit comments

Comments
 (0)