Commit c6fd384b authored by qinsoon's avatar qinsoon

by default, disable gc (for easy debugging)

parent 11e47785
......@@ -11,7 +11,7 @@ use MY_GC;
use utils::{Address, ObjectReference};
use utils::POINTER_SIZE;
use std::sync::atomic::{AtomicIsize, Ordering};
use std::sync::atomic::{AtomicIsize, AtomicBool, Ordering};
use std::sync::{Arc, Mutex, Condvar, RwLock};
use crossbeam::sync::chase_lev::*;
......@@ -29,6 +29,8 @@ lazy_static! {
static ref ROOTS : RwLock<Vec<ObjectReference>> = RwLock::new(vec![]);
}
pub static ENABLE_GC : AtomicBool = atomic::ATOMIC_BOOL_INIT;
static CONTROLLER : AtomicIsize = atomic::ATOMIC_ISIZE_INIT;
const NO_CONTROLLER : isize = -1;
......@@ -216,6 +218,10 @@ fn block_current_thread(mutator: &mut ImmixMutatorLocal) {
pub static GC_COUNT : atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT;
fn gc() {
if ! ENABLE_GC.load(Ordering::SeqCst) {
panic!("Triggering GC when GC is disabled");
}
GC_COUNT.store(GC_COUNT.load(atomic::Ordering::SeqCst) + 1, atomic::Ordering::SeqCst);
trace!("GC starts");
......
......@@ -103,7 +103,7 @@ pub extern fn get_gc_type_encode(id: u32) -> u64 {
}
#[no_mangle]
pub extern fn gc_init(immix_size: usize, lo_size: usize, n_gcthreads: usize) {
pub extern fn gc_init(immix_size: usize, lo_size: usize, n_gcthreads: usize, enable_gc: bool) {
// set this line to turn on certain level of debugging info
// simple_logger::init_with_level(log::LogLevel::Trace).ok();
......@@ -131,8 +131,17 @@ pub extern fn gc_init(immix_size: usize, lo_size: usize, n_gcthreads: usize) {
roots : LinkedHashSet::new()
});
if enable_gc {
heap::gc::ENABLE_GC.store(true, Ordering::Relaxed);
} else {
heap::gc::ENABLE_GC.store(false, Ordering::Relaxed);
}
info!("heap is {} bytes (immix: {} bytes, lo: {} bytes) . ", immix_size + lo_size, immix_size, lo_size);
info!("{} gc threads", n_gcthreads);
if !enable_gc {
warn!("GC disabled (panic when a collection is triggered)");
}
}
#[no_mangle]
......
......@@ -52,7 +52,7 @@ const FIXSIZE_REFx1_ENCODE : u64 = 0xb000000000000001u64;
#[test]
fn test_exhaust_alloc() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
println!("Trying to allocate {} objects of (size {}, align {}). ", WORK_LOAD, OBJECT_SIZE, OBJECT_ALIGN);
......@@ -75,7 +75,7 @@ const LARGE_OBJECT_SIZE : usize = 256;
#[test]
#[allow(unused_variables)]
fn test_exhaust_alloc_large() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
start_logging();
......@@ -96,7 +96,7 @@ fn test_alloc_large_lo_trigger_gc() {
const KEEP_N_ROOTS : usize = 1;
let mut roots : usize = 0;
gc::gc_init(SMALL_SPACE_SIZE, 4096 * 10, 8);
gc::gc_init(SMALL_SPACE_SIZE, 4096 * 10, 8, true);
let mut mutator = gc::new_mutator();
start_logging();
......@@ -119,7 +119,7 @@ fn test_alloc_large_lo_trigger_gc() {
#[test]
#[allow(unused_variables)]
fn test_alloc_large_both_trigger_gc() {
gc::gc_init(SMALL_SPACE_SIZE, 4096 * 10, 8);
gc::gc_init(SMALL_SPACE_SIZE, 4096 * 10, 8, true);
let mut mutator = gc::new_mutator();
start_logging();
......@@ -150,7 +150,7 @@ fn test_alloc_large_both_trigger_gc() {
#[test]
#[cfg(feature = "use-sidemap")]
fn test_alloc_mark() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
println!("Trying to allocate 1 object of (size {}, align {}). ", OBJECT_SIZE, OBJECT_ALIGN);
......@@ -194,7 +194,7 @@ fn test_alloc_mark() {
#[test]
#[cfg(not(feature = "use-sidemap"))]
fn test_alloc_mark() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
println!("Trying to allocate 1 object of (size {}, align {}). ", OBJECT_SIZE, OBJECT_ALIGN);
......@@ -246,7 +246,7 @@ struct Node<'a> {
#[test]
fn test_alloc_trace() {
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 8, false);
let mut mutator = gc::new_mutator();
let (shared_space, lo_space) = gc::get_spaces();
......
......@@ -149,7 +149,7 @@ fn create_linked_list() {
start_logging();
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1, true);
gc::gc_stats();
let mut mutator = gc::new_mutator();
......@@ -177,7 +177,7 @@ fn linked_list_heap_dump() {
start_logging();
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1, true);
gc::gc_stats();
let mut mutator = gc::new_mutator();
......@@ -214,7 +214,7 @@ fn linked_list_survive_gc() {
start_logging();
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1, true);
gc::gc_stats();
let mut mutator = gc::new_mutator();
......
......@@ -153,7 +153,7 @@ fn start() {
start_logging();
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1);
gc::gc_init(IMMIX_SPACE_SIZE, LO_SPACE_SIZE, 1, true);
gc::gc_stats();
let mut mutator = gc::new_mutator();
......
......@@ -469,7 +469,7 @@ impl <'a> VM {
// init gc
{
let ref options = self.vm_options;
gc::gc_init(options.flag_gc_immixspace_size, options.flag_gc_lospace_size, options.flag_gc_nthreads);
gc::gc_init(options.flag_gc_immixspace_size, options.flag_gc_lospace_size, options.flag_gc_nthreads, !options.flag_gc_disable_collection);
}
}
......
......@@ -25,6 +25,7 @@ AOT Compiler:
--bootimage-external-libpath=<path> ... path for the libraries during bootimage generation [default: ]
Garbage Collection:
--gc-disable-collection disable collection
--gc-immixspace-size=<kb> immix space size (default 65536kb = 64mb) [default: 67108864]
--gc-lospace-size=<kb> large object space size (default 65536kb = 64mb) [default: 67108864]
--gc-nthreads=<n> number of threads for parallel gc [default: 8]
......@@ -40,6 +41,7 @@ pub struct VMOptions {
pub flag_bootimage_external_lib: Vec<String>,
pub flag_bootimage_external_libpath: Vec<String>,
pub flag_gc_disable_collection: bool,
pub flag_gc_immixspace_size: usize,
pub flag_gc_lospace_size: usize,
pub flag_gc_nthreads: usize
......@@ -66,6 +68,11 @@ impl VMOptions {
impl Default for VMOptions {
fn default() -> VMOptions {
VMOptions::init("")
let mut options = VMOptions::init("");
// by default, disable colleciton for easier debugging
options.flag_gc_disable_collection = true;
options
}
}
from util import fncptr_from_py_script, may_spawn_proc
from rpython.rlib import rmu_fast as rmu # NOTE: depends on RPython
from rpython.rlib.rmu import zebu as rmu
@may_spawn_proc
def test_load_int_from_gcell():
......
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib import rmu_fast as rmu
from rpython.rlib.rmu import zebu as rmu
from util import fncptr_from_rpy_func, fncptr_from_py_script, may_spawn_proc
import ctypes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment