Skip to content

Commit

Permalink
Pointer tagging should be OR not left-shift.
Browse files Browse the repository at this point in the history
  • Loading branch information
ltratt committed Dec 4, 2020
1 parent 56d0156 commit 6c30bf8
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ykrt/src/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
},
thread::{self, JoinHandle},
};
use ykcompile::{CompiledTrace, TraceCompiler};
use ykcompile::TraceCompiler;
use yktrace::{sir::SIR, start_tracing, tir::TirTrace, ThreadTracer, TracingKind};

pub type HotThreshold = usize;
Expand Down Expand Up @@ -296,20 +296,17 @@ impl MTThread {
// FIXME: free up the memory when the trace is no longer used.
let ptr = Box::into_raw(Box::new(ct)) as usize;

let new_pack = PHASE_COMPILED | (ptr << PHASE_NUM_BITS);
let new_pack = ptr | PHASE_COMPILED;
loc.pack.store(new_pack, Ordering::Release);
// Free the small block of memory we used as a Location ID.
unsafe { Box::from_raw(loc_id) };
Rc::get_mut(&mut self.inner).unwrap().tracer = None;
return None;
}
PHASE_COMPILED => {
let ptr = (lp >> PHASE_NUM_BITS) as *const u8;
let bct = unsafe { Box::from_raw(ptr as *mut CompiledTrace<I>) };
let tptr = bct.ptr();
let func: fn(&mut I) -> bool = unsafe { mem::transmute(tptr) };
mem::forget(bct);
return Some(func);
let p = (lp & !PHASE_TAG) as *const ();
let f = unsafe { mem::transmute::<_, fn(&mut I) -> bool>(p) };
return Some(f);
}
_ => unreachable!(),
}
Expand Down

0 comments on commit 6c30bf8

Please sign in to comment.