Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make eval_place iterate instead of recurse #61120

Merged
merged 1 commit into from
May 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,42 +607,42 @@ where
/// place; for reading, a more efficient alternative is `eval_place_for_read`.
pub fn eval_place(
&mut self,
mir_place: &mir::Place<'tcx>
mir_place: &mir::Place<'tcx>,
) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
use rustc::mir::Place::*;
use rustc::mir::PlaceBase;
let place = match mir_place {
Base(PlaceBase::Local(mir::RETURN_PLACE)) => match self.frame().return_place {
Some(return_place) =>
// We use our layout to verify our assumption; caller will validate
// their layout on return.
PlaceTy {
place: *return_place,
layout: self.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,

mir_place.iterate(|place_base, place_projection| {
let mut place = match place_base {
PlaceBase::Local(mir::RETURN_PLACE) => match self.frame().return_place {
Some(return_place) => {
// We use our layout to verify our assumption; caller will validate
// their layout on return.
PlaceTy {
place: *return_place,
layout: self
.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
}
}
None => return err!(InvalidNullPointerUsage),
},
PlaceBase::Local(local) => PlaceTy {
// This works even for dead/uninitialized locals; we check further when writing
place: Place::Local {
frame: self.cur_frame(),
local: *local,
},
None => return err!(InvalidNullPointerUsage),
},
Base(PlaceBase::Local(local)) => PlaceTy {
// This works even for dead/uninitialized locals; we check further when writing
place: Place::Local {
frame: self.cur_frame(),
local: *local,
layout: self.layout_of_local(self.frame(), *local, None)?,
},
layout: self.layout_of_local(self.frame(), *local, None)?,
},

Projection(proj) => {
let place = self.eval_place(&proj.base)?;
self.place_projection(place, &proj.elem)?
}
PlaceBase::Static(place_static) => self.eval_static_to_mplace(place_static)?.into(),
};

Base(PlaceBase::Static(place_static)) => {
self.eval_static_to_mplace(place_static)?.into()
for proj in place_projection {
place = self.place_projection(place, &proj.elem)?
}
};

self.dump_place(place.place);
Ok(place)
self.dump_place(place.place);
Ok(place)
})
}

/// Write a scalar to a place
Expand Down