allocate floats in dedicated buffer

This commit is contained in:
Mark Thom
2022-04-04 23:56:30 -06:00
parent 0ab928063e
commit 8c99d748e2
14 changed files with 204 additions and 195 deletions

View File

@@ -87,21 +87,8 @@ macro_rules! cell_as_atom_cell {
macro_rules! cell_as_f64_ptr {
($cell:expr) => {{
let cons_ptr = ConsPtr::from_bytes($cell.into_bytes());
match cons_ptr.get_tag() {
ConsPtrMaskTag::F64 => {
F64Ptr(TypedArenaPtr::new(
cons_ptr.as_ptr() as *mut OrderedFloat<f64>
))
}
ConsPtrMaskTag::Cons => {
let ptr = cell_as_untyped_arena_ptr!($cell).payload_offset();
unsafe {
F64Ptr(TypedArenaPtr::new(std::mem::transmute(ptr)))
}
}
}
let offset = $cell.get_value();
F64Ptr::from_offset(offset)
}};
}
@@ -257,13 +244,6 @@ macro_rules! match_untyped_arena_ptr_pat_body {
#[allow(unused_braces)]
$code
}};
($ptr:ident, F64, $n:ident, $code:expr) => {{
let payload_ptr =
unsafe { std::mem::transmute::<_, *mut OrderedFloat<f64>>($ptr.payload_offset()) };
let $n = TypedArenaPtr::new(payload_ptr);
#[allow(unused_braces)]
$code
}};
($ptr:ident, Rational, $n:ident, $code:expr) => {{
let payload_ptr = unsafe { std::mem::transmute::<_, *mut Rational>($ptr.payload_offset()) };
let $n = TypedArenaPtr::new(payload_ptr);