Skip to content

Commit 7bdec46

Browse files
committed
code review: comment fixes
1 parent ee64d21 commit 7bdec46

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/tools/miri/src/alloc_addresses/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
174174

175175
// This allocation does not have a base address yet, pick or reuse one.
176176
let base_addr = if ecx.machine.native_lib.is_some() {
177+
// In native lib mode, we use the "real" address of the bytes for this allocation.
178+
// This ensures the interpreted program and native code have the same view of memory.
177179
match kind {
178180
AllocKind::LiveData => {
179181
let ptr = if ecx.tcx.try_get_global_alloc(alloc_id).is_some() {
@@ -364,7 +366,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
364366
ecx.addr_from_alloc_id(id, kind)?;
365367
let mut global_state = ecx.machine.alloc_addresses.borrow_mut();
366368
// The memory we need here will have already been allocated during an earlier call to
367-
// `global_root_pointer` for this allocation. So don't create a new `MiriAllocBytes` here, instead
369+
// `addr_from_alloc_id` for this allocation. So don't create a new `MiriAllocBytes` here, instead
368370
// fetch the previously prepared bytes from `prepared_alloc_bytes`.
369371
let mut prepared_alloc_bytes = global_state
370372
.prepared_alloc_bytes

src/tools/miri/src/machine.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,6 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
12401240
alloc: &'b Allocation,
12411241
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
12421242
{
1243-
// The default implementation does a copy; CTFE machines have a more efficient implementation
1244-
// based on their particular choice for `Provenance`, `AllocExtra`, and `Bytes`.
12451243
let kind = Self::GLOBAL_KIND.unwrap().into();
12461244
let alloc = alloc.adjust_from_tcx(&ecx.tcx,
12471245
|bytes, align| ecx.get_global_alloc_bytes(id, kind, bytes, align),

0 commit comments

Comments
 (0)