Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions mmtk/Cargo.lock

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

9 changes: 9 additions & 0 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ 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"
<<<<<<< HEAD
julia_version = "2fe85be017c11392f7268fba52699d642944bd3b"
=======
julia_version = "22524a81f9920a8ecc70f195d53b145761de2fa0"
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))

[lib]
crate-type = ["staticlib", "rlib", "dylib"]
Expand All @@ -28,8 +32,13 @@ lazy_static = "1.1"
# These changes are safe:
# - change branch
# - change repo name
<<<<<<< HEAD
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "b2968e3903a5730f2ce33654d75dd2e53b26d8b2" }
=======
# But other changes including adding/removing whitespaces in commented lines may break the CI
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev="7cafe560139211c0e3a74815d2e288278506099d" }
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))
# 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
14 changes: 14 additions & 0 deletions mmtk/api/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct {
/**
* Misc
*/
<<<<<<< HEAD
extern void gc_init(long long min_heap_size, long long max_heap_size, Julia_Upcalls *calls, long header_size);
extern bool will_never_move(void* object);
extern bool process(char* name, char* value);
Expand All @@ -128,6 +129,19 @@ extern void start_worker(void *tls, void* worker, void* mmtk);
extern void process_julia_obj(void* addr);
extern void register_finalizer(void* obj, void* function, bool is_ptr);
extern void run_finalizers_for_obj(void* obj);
=======
extern void mmtk_gc_init(uintptr_t min_heap_size, uintptr_t max_heap_size, uintptr_t n_gcthreads, Julia_Upcalls *calls, uintptr_t header_size, uintptr_t tag);
extern bool mmtk_will_never_move(void* object);
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_start_control_collector(void *tls);
extern void mmtk_start_worker(void *tls, void* worker, void* mmtk);
extern void mmtk_process_julia_obj(void* addr);
extern void mmtk_register_finalizer(void* obj, void* function, bool is_ptr);
extern void mmtk_run_finalizers_for_obj(void* obj);
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))
extern void mmtk_run_finalizers(bool at_exit);
extern void mmtk_gc_poll(void *tls);

Expand Down
8 changes: 8 additions & 0 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
use crate::reference_glue::JuliaFinalizableObject;
use crate::JuliaVM;
use crate::Julia_Upcalls;
<<<<<<< HEAD
use crate::BLOCK_FOR_GC;
use crate::FINALIZER_ROOTS;
=======
use crate::JULIA_HEADER_SIZE;
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))
use crate::SINGLETON;
use crate::UPCALLS;
use crate::{
Expand Down Expand Up @@ -197,6 +201,7 @@ pub extern "C" fn initialize_collection(tls: VMThread) {
}

#[no_mangle]
<<<<<<< HEAD
pub extern "C" fn enable_collection() {
if AtomicBool::load(&DISABLED_GC, Ordering::SeqCst) {
memory_manager::enable_collection(&SINGLETON);
Expand All @@ -222,6 +227,9 @@ pub extern "C" fn disable_collection() {

#[no_mangle]
pub extern "C" fn used_bytes() -> usize {
=======
pub extern "C" fn mmtk_used_bytes() -> usize {
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))
memory_manager::used_bytes(&SINGLETON)
}

Expand Down
24 changes: 24 additions & 0 deletions mmtk/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ use mmtk::util::opaque_pointer::*;
use mmtk::util::Address;
use mmtk::vm::{Collection, GCThreadContext};
use mmtk::Mutator;
<<<<<<< HEAD
use mmtk::MutatorContext;
use std::sync::atomic::{AtomicBool, Ordering};
=======
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU32, AtomicU64, Ordering};
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))

use crate::{BLOCK_FOR_GC, FINALIZERS_RUNNING, STW_COND, WORLD_HAS_STOPPED};

const GC_THREAD_KIND_CONTROLLER: libc::c_int = 0;
const GC_THREAD_KIND_WORKER: libc::c_int = 1;

extern "C" {
pub static jl_gc_disable_counter: AtomicU32;
}

pub struct VMCollection {}

impl Collection<JuliaVM> for VMCollection {
Expand Down Expand Up @@ -132,11 +140,27 @@ impl Collection<JuliaVM> for VMCollection {
unsafe { ((*UPCALLS).jl_throw_out_of_memory_error)() };
}

<<<<<<< HEAD
fn prepare_mutator<T: MutatorContext<JuliaVM>>(
_tls_w: VMWorkerThread,
_tls_m: VMMutatorThread,
_mutator: &T,
) {
=======
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 {
match crate::SINGLETON.get_plan().generational() {
Some(gen) => gen.is_current_gc_nursery(),
None => false,
>>>>>>> eac7e88 (Ask from binding if GC is disabled (#126))
}
}

Expand Down