Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions .github/scripts/Make.user
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FORCE_ASSERTIONS=1
LLVM_ASSERTIONS=1
USE_BINARYBUILDER_MMTK_JULIA=0
WITH_THIRD_PARTY_GC=mmtk
4 changes: 3 additions & 1 deletion mmtk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ fn main() {
.clang_arg("c++")
.clang_arg("-std=c++14")
// using MMTK types
.clang_arg("-DMMTK_GC")
.clang_arg("-DWITH_THIRD_PARTY_HEAP=1")
// using sticky, but it should not matter for the FFI bindings
.clang_arg("-DMMTK_PLAN_STICKYIMMIX")
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
Expand Down
36 changes: 6 additions & 30 deletions mmtk/src/julia_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ pub unsafe fn scan_julia_object<SV: SlotVisitor<JuliaVMSlot>>(obj: Address, clos
}
process_slot(closure, Address::from_ptr(usings_backeges_slot));

let scanned_methods_slot = ::std::ptr::addr_of!((*m).scanned_methods);
if PRINT_OBJ_TYPE {
println!(" - scan parent: {:?}\n", scanned_methods_slot);
}
process_slot(closure, Address::from_ptr(scanned_methods_slot));

// m.usings.items may be inlined in the module when the array list size <= AL_N_INLINE (cf. arraylist_new)
// In that case it may be an mmtk object and not a malloced address.
// If it is an mmtk object, (*m).usings.items will then be an internal pointer to the module
Expand Down Expand Up @@ -317,15 +323,6 @@ pub unsafe fn scan_julia_object<SV: SlotVisitor<JuliaVMSlot>>(obj: Address, clos
let layout = (*vt).layout;
let npointers = (*layout).npointers;
if npointers != 0 {
if vt == jl_binding_partition_type {
let bpart_ptr = obj.to_mut_ptr::<jl_binding_partition_t>();
let restriction = (*bpart_ptr).restriction._M_i;
let offset = mmtk_decode_restriction_value(restriction);
let slot = Address::from_ptr(::std::ptr::addr_of!((*bpart_ptr).restriction));
if restriction - offset != 0 {
process_offset_slot(closure, slot, offset);
}
}
debug_assert!(
(*layout).nfields > 0 && (*layout).fielddesc_type_custom() != 3,
"opaque types should have been handled specially"
Expand Down Expand Up @@ -526,27 +523,6 @@ pub fn process_slot<EV: SlotVisitor<JuliaVMSlot>>(closure: &mut EV, slot: Addres
closure.visit_slot(JuliaVMSlot::Simple(simple_slot));
}

// This is based on the function decode_restriction_value from julia_internal.h.
// However, since MMTk uses the slot to load the object, we get the offset from pku using
// that offset to pass to process_offset_edge and get the right address.
#[inline(always)]
pub fn mmtk_decode_restriction_value(pku: usize) -> usize {
#[cfg(target_pointer_width = "64")]
{
// need to apply (pku & ~0x7) to get the object to be traced
// so we use (pku & 0x7) to get the offset from the object
// and pass it to process_offset_slot
pku & 0x7
}

#[cfg(not(target_pointer_width = "64"))]
{
// when not #ifdef _P64 we simply return pku.val
// i.e., the offset is 0, since val is the first field
0
}
}

#[inline(always)]
pub fn process_offset_slot<EV: SlotVisitor<JuliaVMSlot>>(
closure: &mut EV,
Expand Down
72 changes: 39 additions & 33 deletions mmtk/src/julia_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ const _: () = {
pub type sigjmp_buf = [__jmp_buf_tag; 1usize];
pub type jl_taggedvalue_t = _jl_taggedvalue_t;
pub type jl_ptls_t = *mut _jl_tls_states_t;
pub type jl_genericmemory_t = _jl_genericmemory_t;
pub type sig_atomic_t = __sig_atomic_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _jl_value_t {
_unused: [u8; 0],
}
pub type sig_atomic_t = __sig_atomic_t;
pub type jl_value_t = _jl_value_t;
#[repr(C)]
#[repr(align(8))]
Expand Down Expand Up @@ -930,18 +931,18 @@ const _: () = {
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct jl_genericmemory_t {
pub struct _jl_genericmemory_t {
pub length: usize,
pub ptr: *mut ::std::os::raw::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of jl_genericmemory_t"][::std::mem::size_of::<jl_genericmemory_t>() - 16usize];
["Alignment of jl_genericmemory_t"][::std::mem::align_of::<jl_genericmemory_t>() - 8usize];
["Offset of field: jl_genericmemory_t::length"]
[::std::mem::offset_of!(jl_genericmemory_t, length) - 0usize];
["Offset of field: jl_genericmemory_t::ptr"]
[::std::mem::offset_of!(jl_genericmemory_t, ptr) - 8usize];
["Size of _jl_genericmemory_t"][::std::mem::size_of::<_jl_genericmemory_t>() - 16usize];
["Alignment of _jl_genericmemory_t"][::std::mem::align_of::<_jl_genericmemory_t>() - 8usize];
["Offset of field: _jl_genericmemory_t::length"]
[::std::mem::offset_of!(_jl_genericmemory_t, length) - 0usize];
["Offset of field: _jl_genericmemory_t::ptr"]
[::std::mem::offset_of!(_jl_genericmemory_t, ptr) - 8usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -1936,15 +1937,14 @@ const _: () = {
[::std::mem::offset_of!(_jl_weakref_t, value) - 0usize];
};
pub type jl_weakref_t = _jl_weakref_t;
pub type jl_ptr_kind_union_t = usize;
#[repr(C)]
#[derive(Debug)]
pub struct _jl_binding_partition_t {
pub restriction: std_atomic<jl_ptr_kind_union_t>,
pub restriction: *mut jl_value_t,
pub min_world: usize,
pub max_world: std_atomic<usize>,
pub next: u64,
pub reserved: usize,
pub kind: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
Expand All @@ -1959,8 +1959,8 @@ const _: () = {
[::std::mem::offset_of!(_jl_binding_partition_t, max_world) - 16usize];
["Offset of field: _jl_binding_partition_t::next"]
[::std::mem::offset_of!(_jl_binding_partition_t, next) - 24usize];
["Offset of field: _jl_binding_partition_t::reserved"]
[::std::mem::offset_of!(_jl_binding_partition_t, reserved) - 32usize];
["Offset of field: _jl_binding_partition_t::kind"]
[::std::mem::offset_of!(_jl_binding_partition_t, kind) - 32usize];
};
pub type jl_binding_partition_t = _jl_binding_partition_t;
#[repr(C)]
Expand All @@ -1986,6 +1986,7 @@ pub struct _jl_module_t {
pub file: *mut jl_sym_t,
pub line: i32,
pub usings_backedges: *mut jl_value_t,
pub scanned_methods: *mut jl_value_t,
pub usings: arraylist_t,
pub build_id: jl_uuid_t,
pub uuid: jl_uuid_t,
Expand All @@ -1996,12 +1997,13 @@ pub struct _jl_module_t {
pub infer: i8,
pub istopmod: u8,
pub max_methods: i8,
pub export_set_changed_since_require_world: std_atomic<i8>,
pub lock: jl_mutex_t,
pub hash: isize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of _jl_module_t"][::std::mem::size_of::<_jl_module_t>() - 384usize];
["Size of _jl_module_t"][::std::mem::size_of::<_jl_module_t>() - 392usize];
["Alignment of _jl_module_t"][::std::mem::align_of::<_jl_module_t>() - 8usize];
["Offset of field: _jl_module_t::name"][::std::mem::offset_of!(_jl_module_t, name) - 0usize];
["Offset of field: _jl_module_t::parent"]
Expand All @@ -2014,27 +2016,31 @@ const _: () = {
["Offset of field: _jl_module_t::line"][::std::mem::offset_of!(_jl_module_t, line) - 40usize];
["Offset of field: _jl_module_t::usings_backedges"]
[::std::mem::offset_of!(_jl_module_t, usings_backedges) - 48usize];
["Offset of field: _jl_module_t::scanned_methods"]
[::std::mem::offset_of!(_jl_module_t, scanned_methods) - 56usize];
["Offset of field: _jl_module_t::usings"]
[::std::mem::offset_of!(_jl_module_t, usings) - 56usize];
[::std::mem::offset_of!(_jl_module_t, usings) - 64usize];
["Offset of field: _jl_module_t::build_id"]
[::std::mem::offset_of!(_jl_module_t, build_id) - 312usize];
["Offset of field: _jl_module_t::uuid"][::std::mem::offset_of!(_jl_module_t, uuid) - 328usize];
[::std::mem::offset_of!(_jl_module_t, build_id) - 320usize];
["Offset of field: _jl_module_t::uuid"][::std::mem::offset_of!(_jl_module_t, uuid) - 336usize];
["Offset of field: _jl_module_t::counter"]
[::std::mem::offset_of!(_jl_module_t, counter) - 344usize];
[::std::mem::offset_of!(_jl_module_t, counter) - 352usize];
["Offset of field: _jl_module_t::nospecialize"]
[::std::mem::offset_of!(_jl_module_t, nospecialize) - 348usize];
[::std::mem::offset_of!(_jl_module_t, nospecialize) - 356usize];
["Offset of field: _jl_module_t::optlevel"]
[::std::mem::offset_of!(_jl_module_t, optlevel) - 352usize];
[::std::mem::offset_of!(_jl_module_t, optlevel) - 360usize];
["Offset of field: _jl_module_t::compile"]
[::std::mem::offset_of!(_jl_module_t, compile) - 353usize];
[::std::mem::offset_of!(_jl_module_t, compile) - 361usize];
["Offset of field: _jl_module_t::infer"]
[::std::mem::offset_of!(_jl_module_t, infer) - 354usize];
[::std::mem::offset_of!(_jl_module_t, infer) - 362usize];
["Offset of field: _jl_module_t::istopmod"]
[::std::mem::offset_of!(_jl_module_t, istopmod) - 355usize];
[::std::mem::offset_of!(_jl_module_t, istopmod) - 363usize];
["Offset of field: _jl_module_t::max_methods"]
[::std::mem::offset_of!(_jl_module_t, max_methods) - 356usize];
["Offset of field: _jl_module_t::lock"][::std::mem::offset_of!(_jl_module_t, lock) - 360usize];
["Offset of field: _jl_module_t::hash"][::std::mem::offset_of!(_jl_module_t, hash) - 376usize];
[::std::mem::offset_of!(_jl_module_t, max_methods) - 364usize];
["Offset of field: _jl_module_t::export_set_changed_since_require_world"]
[::std::mem::offset_of!(_jl_module_t, export_set_changed_since_require_world) - 365usize];
["Offset of field: _jl_module_t::lock"][::std::mem::offset_of!(_jl_module_t, lock) - 368usize];
["Offset of field: _jl_module_t::hash"][::std::mem::offset_of!(_jl_module_t, hash) - 384usize];
};
pub type jl_module_t = _jl_module_t;
#[repr(C)]
Expand Down Expand Up @@ -2340,13 +2346,6 @@ const _: () = {
[::std::mem::align_of::<std_atomic<i16>>() - 2usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of template specialization: std_atomic_open0_jl_ptr_kind_union_t_close0"]
[::std::mem::size_of::<std_atomic<jl_ptr_kind_union_t>>() - 8usize];
["Align of template specialization: std_atomic_open0_jl_ptr_kind_union_t_close0"]
[::std::mem::align_of::<std_atomic<jl_ptr_kind_union_t>>() - 8usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of template specialization: std_atomic_open0_size_t_close0"]
[::std::mem::size_of::<std_atomic<usize>>() - 8usize];
Expand All @@ -2361,6 +2360,13 @@ const _: () = {
[::std::mem::align_of::<std_atomic<u32>>() - 4usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of template specialization: std_atomic_open0_int8_t_close0"]
[::std::mem::size_of::<std_atomic<i8>>() - 1usize];
["Align of template specialization: std_atomic_open0_int8_t_close0"]
[::std::mem::align_of::<std_atomic<i8>>() - 1usize];
};
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of template specialization: std_atomic_open0_intptr_t_close0"]
[::std::mem::size_of::<std_atomic<isize>>() - 8usize];
Expand Down
Loading