From 336206cec24b9e4bc38445f490ee4d32c9c815a1 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 9 Jun 2016 17:23:58 +0200 Subject: [PATCH] the `type_size` method's `substs` argument allows computing the locals before pushing the stack frame --- src/interpreter/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index e70fe5e93f3..a7a57a79601 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -353,11 +353,16 @@ fn push_stack_frame(&mut self, def_id: DefId, span: codemap::Span, mir: CachedMi ::log_settings::settings().indentation += 1; + let locals: Vec = arg_tys.chain(var_tys).chain(temp_tys).map(|ty| { + let size = self.type_size(ty, substs); + self.memory.allocate(size) + }).collect(); + self.stack.push(Frame { mir: mir.clone(), next_block: mir::START_BLOCK, return_ptr: return_ptr, - locals: Vec::new(), + locals: locals, var_offset: num_args, temp_offset: num_args + num_vars, span: span, @@ -365,13 +370,6 @@ fn push_stack_frame(&mut self, def_id: DefId, span: codemap::Span, mir: CachedMi substs: substs, stmt: 0, }); - - let locals: Vec = arg_tys.chain(var_tys).chain(temp_tys).map(|ty| { - let size = self.type_size(ty, self.substs()); - self.memory.allocate(size) - }).collect(); - - self.frame_mut().locals = locals; } fn pop_stack_frame(&mut self) { -- 2.44.0