Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 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 @@ -9,8 +9,8 @@ edition = "2018"
# Metadata for the Julia repository
[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_repo = "https://github.com/udesou/julia.git"
julia_version = "99aa5dd6289ac5445f9f019c4d8c4284fe5da0ba"

[lib]
crate-type = ["cdylib"]
Expand All @@ -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/udesou/mmtk-core.git", rev="e9660c7ffca6a0d7fb5efb159482d89053f5d203" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }
log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"] }
Expand Down
2 changes: 0 additions & 2 deletions mmtk/api/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 0 additions & 25 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion mmtk/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<JuliaVM> for VMCollection {
Expand Down Expand Up @@ -100,6 +104,17 @@ impl Collection<JuliaVM> for VMCollection {
fn vm_live_bytes() -> usize {
crate::api::JULIA_MALLOC_BYTES.load(Ordering::SeqCst)
}

fn is_collection_enabled() -> bool {
unsafe {
AtomicU32::load(
::std::mem::transmute::<*const AtomicU32, &AtomicU32>(::std::ptr::addr_of!(
jl_gc_disable_counter
)),
Ordering::SeqCst,
) <= 0
}
}
}

pub fn is_current_gc_nursery() -> bool {
Expand Down