Skip to content

Commit dce04bf

Browse files
committed
Do not process the linked list in the jl_handler_t object
1 parent df72168 commit dce04bf

File tree

3 files changed

+30
-45
lines changed

3 files changed

+30
-45
lines changed

mmtk/src/julia_scanning.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ pub unsafe fn capture_potential_task(addr: Address, extra_root_tasks: &mut Vec<O
649649
let vtag_usize = mmtk_jl_typetagof(obj).as_usize();
650650

651651
if vtag_usize == ((jl_small_typeof_tags_jl_task_tag as usize) << 4) {
652-
log::info!("Task {} occurs in shadow stack!", objref);
653652
extra_root_tasks.push(objref);
654653
}
655654
}

mmtk/src/julia_types.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* automatically generated by rust-bindgen 0.71.1 */
1+
/* automatically generated by rust-bindgen 0.72.0 */
22

33
#[repr(C)]
44
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
@@ -36,7 +36,9 @@ where
3636
pub unsafe fn raw_get_bit(this: *const Self, index: usize) -> bool {
3737
debug_assert!(index / 8 < core::mem::size_of::<Storage>());
3838
let byte_index = index / 8;
39-
let byte = *(core::ptr::addr_of!((*this).storage) as *const u8).offset(byte_index as isize);
39+
let byte = unsafe {
40+
*(core::ptr::addr_of!((*this).storage) as *const u8).offset(byte_index as isize)
41+
};
4042
Self::extract_bit(byte, index)
4143
}
4244
#[inline]
@@ -64,9 +66,10 @@ where
6466
pub unsafe fn raw_set_bit(this: *mut Self, index: usize, val: bool) {
6567
debug_assert!(index / 8 < core::mem::size_of::<Storage>());
6668
let byte_index = index / 8;
67-
let byte =
68-
(core::ptr::addr_of_mut!((*this).storage) as *mut u8).offset(byte_index as isize);
69-
*byte = Self::change_bit(*byte, index, val);
69+
let byte = unsafe {
70+
(core::ptr::addr_of_mut!((*this).storage) as *mut u8).offset(byte_index as isize)
71+
};
72+
unsafe { *byte = Self::change_bit(*byte, index, val) };
7073
}
7174
#[inline]
7275
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
@@ -93,7 +96,7 @@ where
9396
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= core::mem::size_of::<Storage>());
9497
let mut val = 0;
9598
for i in 0..(bit_width as usize) {
96-
if Self::raw_get_bit(this, i + bit_offset) {
99+
if unsafe { Self::raw_get_bit(this, i + bit_offset) } {
97100
let index = if cfg!(target_endian = "big") {
98101
bit_width as usize - 1 - i
99102
} else {
@@ -133,7 +136,7 @@ where
133136
} else {
134137
i
135138
};
136-
Self::raw_set_bit(this, index + bit_offset, val_bit_is_set);
139+
unsafe { Self::raw_set_bit(this, index + bit_offset, val_bit_is_set) };
137140
}
138141
}
139142
}
@@ -3520,10 +3523,3 @@ const _: () = {
35203523
["Align of template specialization: pinned_ref_open0_jl_value_t_close0"]
35213524
[::std::mem::align_of::<pinned_ref<jl_value_t>>() - 8usize];
35223525
};
3523-
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
3524-
const _: () = {
3525-
["Size of template specialization: pinned_ref_open0_jl_value_t_close0"]
3526-
[::std::mem::size_of::<pinned_ref<jl_value_t>>() - 8usize];
3527-
["Align of template specialization: pinned_ref_open0_jl_value_t_close0"]
3528-
[::std::mem::align_of::<pinned_ref<jl_value_t>>() - 8usize];
3529-
};

mmtk/src/scanning.rs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Scanning<JuliaVM> for VMScanning {
7979
TASK_ROOTS.lock().unwrap().insert(
8080
ObjectReference::from_raw_address_unchecked(Address::from_ptr(task)),
8181
);
82-
log::info!(
82+
log::debug!(
8383
"Processing root task: {:?}",
8484
ObjectReference::from_raw_address_unchecked(Address::from_ptr(task))
8585
);
@@ -120,43 +120,33 @@ impl Scanning<JuliaVM> for VMScanning {
120120
use crate::conservative::is_potential_mmtk_object;
121121
use crate::conservative::CONSERVATIVE_ROOTS;
122122

123-
let mut eh = (*task).eh;
124-
loop {
125-
if !eh.is_null() {
126-
// conservatively deal with the scope objects
127-
// FIXME: we could potentially just add them to the node_buffer
128-
let scope_address = Address::from_ptr((*eh).scope);
129-
if let Some(obj) = is_potential_mmtk_object(scope_address) {
130-
CONSERVATIVE_ROOTS.lock().unwrap().insert(obj);
131-
}
123+
// NB: task.eh has a field `struct _jl_handler_t *prev` but it does not seem
124+
// like we need to traverse the whole list to capture all the handlers.
125+
// We might need to confirm this with the Julia devs.
126+
let eh = (*task).eh;
127+
128+
if !eh.is_null() {
129+
// FIXME: we could potentially just add these to the node_buffer
130+
let scope_address = Address::from_ptr((*eh).scope);
131+
if let Some(obj) = is_potential_mmtk_object(scope_address) {
132+
CONSERVATIVE_ROOTS.lock().unwrap().insert(obj);
133+
}
132134

133-
// conservatively scan eh_ctx and potentially traverse the list of handlers (_jl_handler_t *prev)
134-
let sigjump_buf = (*eh).eh_ctx[0].__jmpbuf;
135-
for buff in sigjump_buf {
135+
if let Some(jmpbuf) = (*eh).eh_ctx.get(0) {
136+
for buff in jmpbuf.__jmpbuf {
136137
if let Some(obj) =
137138
is_potential_mmtk_object(Address::from_usize(buff as usize))
138139
{
139-
// println!(
140-
// "buf_addr (mmtk object) = {:x} from root task = {:?}, type = {}",
141-
// buff,
142-
// task,
143-
// crate::julia_scanning::get_julia_object_type(
144-
// Address::from_usize(buff as usize)
145-
// )
146-
// );
147140
CONSERVATIVE_ROOTS.lock().unwrap().insert(obj);
148141
}
149142
}
143+
};
150144

151-
// Another option, call conservative_scan_range on the __jmpbuf array
152-
// use crate::conservative::conservative_scan_range;
153-
// use crate::conservative::get_range;
154-
// let (lo, hi) = get_range(&(*eh).eh_ctx[0].__jmpbuf);
155-
// conservative_scan_range(lo, hi);
156-
eh = (*eh).prev;
157-
} else {
158-
break;
159-
}
145+
// // Another option, call conservative_scan_range on the __jmpbuf array
146+
// use crate::conservative::conservative_scan_range;
147+
// use crate::conservative::get_range;
148+
// let (lo, hi) = get_range(&(*eh).eh_ctx[0].__jmpbuf);
149+
// conservative_scan_range(lo, hi);
160150
}
161151
}
162152

0 commit comments

Comments
 (0)