Skip to content

Commit b9a35dc

Browse files
committed
calling the ptr hooks no longer needs expensive preparation, remove the opt-out
1 parent f27cd60 commit b9a35dc

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

src/librustc_mir/const_eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
351351
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
352352

353353
const STATIC_KIND: Option<!> = None; // no copying of statics allowed
354-
const ENABLE_PTR_TRACKING_HOOKS: bool = false; // we don't have no provenance
355354

356355
#[inline(always)]
357356
fn enforce_validity(_ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool {

src/librustc_mir/interpret/machine.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ pub trait Machine<'a, 'mir, 'tcx>: Sized {
9595
/// that is added to the memory so that the work is not done twice.
9696
const STATIC_KIND: Option<Self::MemoryKinds>;
9797

98-
/// As an optimization, you can prevent the pointer tracking hooks from ever being
99-
/// called. You should only do this if you do not care about provenance tracking.
100-
/// This controls the `tag_reference` and `tag_dereference` hooks.
101-
const ENABLE_PTR_TRACKING_HOOKS: bool;
102-
10398
/// Whether to enforce the validity invariant
10499
fn enforce_validity(ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool;
105100

src/librustc_mir/interpret/place.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,14 @@ where
290290
let mplace = MemPlace { ptr, align, meta };
291291
let mut mplace = MPlaceTy { mplace, layout };
292292
// Pointer tag tracking might want to adjust the tag.
293-
if M::ENABLE_PTR_TRACKING_HOOKS {
294-
let mutbl = match val.layout.ty.sty {
295-
// `builtin_deref` considers boxes immutable, that's useless for our purposes
296-
ty::Ref(_, _, mutbl) => Some(mutbl),
297-
ty::Adt(def, _) if def.is_box() => Some(hir::MutMutable),
298-
ty::RawPtr(_) => None,
299-
_ => bug!("Unexpected pointer type {}", val.layout.ty.sty),
300-
};
301-
mplace.mplace.ptr = M::tag_dereference(self, mplace, mutbl)?;
302-
}
293+
let mutbl = match val.layout.ty.sty {
294+
// `builtin_deref` considers boxes immutable, that's useless for our purposes
295+
ty::Ref(_, _, mutbl) => Some(mutbl),
296+
ty::Adt(def, _) if def.is_box() => Some(hir::MutMutable),
297+
ty::RawPtr(_) => None,
298+
_ => bug!("Unexpected pointer type {}", val.layout.ty.sty),
299+
};
300+
mplace.mplace.ptr = M::tag_dereference(self, mplace, mutbl)?;
303301
// Done
304302
Ok(mplace)
305303
}

0 commit comments

Comments
 (0)