Commit cc5740e4 authored by qinsoon's avatar qinsoon

passed tests from test_heap

parent 8dee81ec
Pipeline #258 failed with stage
in 29 minutes and 56 seconds
......@@ -47,7 +47,8 @@ lazy_static! {
UINT16_TYPE.clone(),
UINT32_TYPE.clone(),
UINT64_TYPE.clone(),
DOUBLE_TYPE.clone()
DOUBLE_TYPE.clone(),
VOID_TYPE.clone()
];
}
......
......@@ -13,9 +13,24 @@ use compiler::backend::BackendTypeInfo;
use runtime::ValueLocation;
use runtime::thread::MuThread;
fn allocate(size: ByteSize, align: ByteSize, encode: u64, hybrid_len: Option<u64>) -> ObjectReference {
let allocator = (&mut MuThread::current_mut().allocator) as *mut Mutator;
fn check_allocator(size: ByteSize, align: ByteSize, encode: u64, hybrid_len: Option<u64>) -> ObjectReference {
if MuThread::has_current() {
// we have an allocator
let allocator = (&mut MuThread::current_mut().allocator) as *mut Mutator;
allocate(allocator, size, align, encode, hybrid_len)
} else {
let mut allocator = new_mutator();
let ret = allocate(&mut allocator as *mut Mutator, size, align, encode, hybrid_len);
drop_mutator(&mut allocator as *mut Mutator);
ret
}
}
#[inline(always)]
fn allocate(allocator: *mut Mutator, size: ByteSize, align: ByteSize, encode: u64, hybrid_len: Option<u64>) -> ObjectReference {
let ret = if size > LARGE_OBJECT_THRESHOLD {
muentry_alloc_large(allocator, size, align)
} else {
......@@ -39,7 +54,7 @@ pub fn allocate_fixed(ty: P<MuType>, backendtype: Box<BackendTypeInfo>) -> Addre
trace!("API: gc ty : {:?}", gctype);
trace!("API: encode : {:b}", encode);
allocate(gctype.size(), gctype.alignment, encode, None).to_address()
check_allocator(gctype.size(), gctype.alignment, encode, None).to_address()
}
pub fn allocate_hybrid(ty: P<MuType>, len: u64, backendtype: Box<BackendTypeInfo>) -> Address {
......@@ -50,7 +65,7 @@ pub fn allocate_hybrid(ty: P<MuType>, len: u64, backendtype: Box<BackendTypeInfo
trace!("API: gc ty : {:?}", gctype);
trace!("API: encode : {:b}", encode);
allocate(gctype.size_hybrid(len as u32), gctype.alignment, encode, Some(len)).to_address()
check_allocator(gctype.size_hybrid(len as u32), gctype.alignment, encode, Some(len)).to_address()
}
pub fn allocate_global(iref_global: P<Value>, backendtype: Box<BackendTypeInfo>) -> ValueLocation {
......
......@@ -14,6 +14,7 @@ use utils::Word;
use utils::mem::memmap;
use utils::mem::memsec;
use std::ptr;
use std::mem;
use std::thread;
use std::thread::JoinHandle;
......@@ -256,6 +257,11 @@ impl MuThread {
exception_obj: unsafe {Address::zero()}
}
}
#[inline(always)]
pub fn has_current() -> bool {
! unsafe {muentry_get_thread_local()}.is_zero()
}
#[inline(always)]
pub fn current() -> &'static MuThread {
......@@ -350,6 +356,9 @@ impl MuThread {
let mu_thread : Box<MuThread> = Box::from_raw(mu_thread);
// set thread local to zero
set_thread_local(ptr::null_mut())
// drop mu_thread here
}
}
......
......@@ -969,7 +969,12 @@ impl <'a> VM {
pub fn handle_get_iref(&self, handle_ref: APIHandleArg) -> APIHandleResult {
let (ty, addr) = handle_ref.v.as_ref();
/// FIXME: iref/ref share the same address - this actually depends on GC
// iref has the same address as ref
trace!("API: get iref from {:?}", handle_ref);
trace!("API: result {} {:?}", ty, addr);
self.new_handle(APIHandle {
id: self.next_id(),
v : APIHandleValue::IRef(ty, addr)
......@@ -1145,7 +1150,10 @@ impl <'a> VM {
unimplemented!()
}
Value_::Constant(Constant::NullRef) => {
unimplemented!()
APIHandle {
id: handle_id,
v : APIHandleValue::Ref(types::VOID_TYPE.clone(), unsafe {Address::zero()})
}
}
_ => unimplemented!()
};
......
......@@ -21,8 +21,8 @@ AOT Compiler:
--aot-emit-dir=<dir> the emit directory for ahead-of-time compiling [default: emit]
Garbage Collection:
--gc-immixspace-size=<kb> immix space size (default 65536kb = 64mb) [default: 65536]
--gc-lospace-size=<kb> large object space size (default 65536kb = 64mb) [default: 65536]
--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]
";
......
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