Commit 9bea1c6c authored by qinsoon's avatar qinsoon

use offset_of! macro from field_offset

parent 60a4f0c2
......@@ -21,6 +21,7 @@ ast = {path = "src/ast"}
utils = {path = "src/utils"}
gc = {path = "src/gc"}
field-offset = "0.1.1"
libloading = "0.3"
lazy_static = "0.1.15"
log = "0.3.5"
......
......@@ -23,4 +23,5 @@ log = "0.3.5"
simple_logger = "0.4.0"
aligned_alloc = "0.1.2"
crossbeam = "0.2.8"
rustc-serialize = "*"
\ No newline at end of file
rustc-serialize = "*"
field-offset = "0.1.1"
\ No newline at end of file
......@@ -26,7 +26,6 @@ lazy_static! {
const TRACE_ALLOC_FASTPATH : bool = true;
#[repr(C)]
// do not change the layout (unless change the offset of fields correspondingly)
pub struct ImmixMutatorLocal {
id : usize,
......@@ -53,12 +52,8 @@ pub struct ImmixMutatorLocal {
}
lazy_static! {
pub static ref CURSOR_OFFSET : usize = mem::size_of::<usize>()
+ mem::size_of::<*mut u8>() * 2
+ mem::size_of::<Address>();
pub static ref LIMIT_OFFSET : usize = *CURSOR_OFFSET
+ mem::size_of::<Address>();
pub static ref CURSOR_OFFSET : usize = offset_of!(ImmixMutatorLocal=>cursor).get_byte_offset();
pub static ref LIMIT_OFFSET : usize = offset_of!(ImmixMutatorLocal=>limit).get_byte_offset();
}
pub struct ImmixMutatorGlobal {
......
......@@ -7,6 +7,8 @@ extern crate simple_logger;
extern crate aligned_alloc;
extern crate crossbeam;
extern crate rustc_serialize;
#[macro_use]
extern crate field_offset;
use std::sync::atomic::Ordering;
......
......@@ -6,6 +6,8 @@ extern crate rustc_serialize;
extern crate stderrlog;
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate field_offset;
#[macro_use]
pub extern crate ast;
......
......@@ -197,8 +197,6 @@ pub enum MuStackState {
}
#[repr(C)]
#[allow(improper_ctypes)]
// do not change the layout (unless change the offset of fields correspondingly)
pub struct MuThread {
pub hdr: MuEntityHeader,
pub allocator: mm::Mutator,
......@@ -213,15 +211,10 @@ pub struct MuThread {
// this depends on the layout of MuThread
lazy_static! {
pub static ref ALLOCATOR_OFFSET : usize = mem::size_of::<MuEntityHeader>();
pub static ref NATIVE_SP_LOC_OFFSET : usize = *ALLOCATOR_OFFSET
+ mem::size_of::<mm::Mutator>()
+ mem::size_of::<Option<Box<MuStack>>>();
pub static ref USER_TLS_OFFSET : usize = *NATIVE_SP_LOC_OFFSET + mem::size_of::<Address>();
pub static ref EXCEPTION_OBJ_OFFSET : usize = *USER_TLS_OFFSET + mem::size_of::<Address>();
pub static ref ALLOCATOR_OFFSET : usize = offset_of!(MuThread=>allocator).get_byte_offset();
pub static ref NATIVE_SP_LOC_OFFSET : usize = offset_of!(MuThread=>native_sp_loc).get_byte_offset();
pub static ref USER_TLS_OFFSET : usize = offset_of!(MuThread=>user_tls).get_byte_offset();
pub static ref EXCEPTION_OBJ_OFFSET : usize = offset_of!(MuThread=>exception_obj).get_byte_offset();
}
impl fmt::Display for MuThread {
......
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