mirror of
https://github.com/urbit/ares.git
synced 2024-11-22 15:08:54 +03:00
[ares][stack] make in_frame take a generic pointer
This commit is contained in:
parent
9140984333
commit
bd44624e63
@ -269,8 +269,7 @@ impl<T: Copy> Hamt<T> {
|
||||
|
||||
impl<T: Copy + Preserve> Preserve for Hamt<T> {
|
||||
unsafe fn preserve(&mut self, stack: &mut NockStack) {
|
||||
// XX make in_frame not care about pointer type
|
||||
if stack.in_frame((*self).0.buffer as *const u64) {
|
||||
if stack.in_frame((*self).0.buffer) {
|
||||
let dest_buffer = stack.struct_alloc_in_previous_frame((*self).0.size());
|
||||
copy_nonoverlapping((*self).0.buffer, dest_buffer, (*self).0.size());
|
||||
(*self).0.buffer = dest_buffer;
|
||||
@ -294,7 +293,7 @@ impl<T: Copy + Preserve> Preserve for Hamt<T> {
|
||||
continue 'preserve_stem;
|
||||
}
|
||||
Some((Left(next_stem), idx)) => {
|
||||
if stack.in_frame(next_stem.buffer as *const u64) {
|
||||
if stack.in_frame(next_stem.buffer) {
|
||||
let dest_buffer =
|
||||
stack.struct_alloc_in_previous_frame(next_stem.size());
|
||||
copy_nonoverlapping(
|
||||
@ -319,7 +318,7 @@ impl<T: Copy + Preserve> Preserve for Hamt<T> {
|
||||
}
|
||||
}
|
||||
Some((Right(leaf), idx)) => {
|
||||
if stack.in_frame(leaf.buffer as *const u64) {
|
||||
if stack.in_frame(leaf.buffer) {
|
||||
let dest_buffer = stack.struct_alloc_in_previous_frame(leaf.len);
|
||||
copy_nonoverlapping(leaf.buffer, dest_buffer, leaf.len);
|
||||
let new_leaf = Leaf {
|
||||
|
@ -109,13 +109,14 @@ impl NockStack {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn in_frame(&self, ptr: *const u64) -> bool {
|
||||
pub fn in_frame<T>(&self, ptr: *const T) -> bool {
|
||||
let ptr_u64 = ptr as *const u64;
|
||||
match &self.polarity {
|
||||
Polarity::East => {
|
||||
ptr >= self.frame_pointer && ptr < self.stack_pointer
|
||||
ptr_u64 >= self.frame_pointer && ptr_u64 < self.stack_pointer
|
||||
},
|
||||
Polarity::West => {
|
||||
ptr >= self.stack_pointer && ptr < self.frame_pointer
|
||||
ptr_u64 >= self.stack_pointer && ptr_u64 < self.frame_pointer
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user