type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
const STATIC_KIND: Option<!> = None; // no copying of statics allowed
+ const ENABLE_PTR_TRACKING_HOOKS: bool = false; // we don't have no provenance
#[inline(always)]
fn enforce_validity(_ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool {
Misc => {
let src = self.read_value(src)?;
- if src.layout.ty.is_region_ptr() && dest.layout.ty.is_unsafe_ptr() {
+ if M::ENABLE_PTR_TRACKING_HOOKS &&
+ src.layout.ty.is_region_ptr() && dest.layout.ty.is_unsafe_ptr()
+ {
// For the purpose of the "ptr tag hooks", treat this as creating
// a new, raw reference.
let place = self.ref_to_mplace(src)?;
/// that is added to the memory so that the work is not done twice.
const STATIC_KIND: Option<Self::MemoryKinds>;
+ /// As an optimization, you can prevent the pointer tracking hooks from ever being
+ /// called. You should only do this if you do not care about provenance tracking.
+ /// This controls the `tag_reference` and `tag_dereference` hooks.
+ const ENABLE_PTR_TRACKING_HOOKS: bool;
+
/// Whether to enforce the validity invariant
fn enforce_validity(ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool;
val: ValTy<'tcx, M::PointerTag>,
) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
let ptr = match val.to_scalar_ptr()? {
- Scalar::Ptr(ptr) => {
+ Scalar::Ptr(ptr) if M::ENABLE_PTR_TRACKING_HOOKS => {
// Machine might want to track the `*` operator
let tag = M::tag_dereference(self, ptr, val.layout.ty)?;
Scalar::Ptr(Pointer::new_with_tag(ptr.alloc_id, ptr.offset, tag))
}
- scalar @ Scalar::Bits { .. } => scalar,
+ other => other,
};
let pointee_type = val.layout.ty.builtin_deref(true).unwrap().ty;
borrow_kind: Option<mir::BorrowKind>,
) -> EvalResult<'tcx, Value<M::PointerTag>> {
let ptr = match place.ptr {
- Scalar::Ptr(ptr) => {
+ Scalar::Ptr(ptr) if M::ENABLE_PTR_TRACKING_HOOKS => {
// Machine might want to track the `&` operator
let (size, _) = self.size_and_align_of_mplace(place)?
.expect("create_ref cannot determine size");
let tag = M::tag_reference(self, ptr, place.layout.ty, size, borrow_kind)?;
Scalar::Ptr(Pointer::new_with_tag(ptr.alloc_id, ptr.offset, tag))
},
- scalar @ Scalar::Bits { .. } => scalar,
+ other => other,
};
Ok(match place.meta {
None => Value::Scalar(ptr.into()),