Chromium Code Reviews| Index: runtime/vm/flow_graph_compiler_ia32.cc |
| diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc |
| index 15761b3c4210d39e308eeac76e768f2e171a7ff1..3c721cfd1744be28280f28d3b5dea827b237bf8e 100644 |
| --- a/runtime/vm/flow_graph_compiler_ia32.cc |
| +++ b/runtime/vm/flow_graph_compiler_ia32.cc |
| @@ -37,24 +37,30 @@ void DeoptimizationStub::GenerateCode(FlowGraphCompiler* compiler) { |
| } |
| } |
| } else { |
| - // We have a deoptimization environment, we have to tear down optimized |
| - // frame and recreate non-optimized one. |
| - __ leal(ESP, |
| - Address(EBP, ParsedFunction::kFirstLocalSlotIndex * kWordSize)); |
| + // We have a deoptimization environment, we have to tear down the |
| + // optimized frame and recreate a non-optimized one. |
| + // 1. Set the stack pointer to the top of the non-optimized frame. |
| const GrowableArray<Value*>& values = deoptimization_env_->values(); |
| + const int top_offset = |
|
srdjan
2012/07/25 17:25:52
s/int/intptr_t/
|
| + ParsedFunction::kFirstLocalSlotIndex - values.length(); |
| + __ leal(ESP, Address(EBP, top_offset * kWordSize)); |
| + // 2. Build and emit a parallel move representing the frame translation. |
| + ParallelMoveInstr* move = new ParallelMoveInstr(); |
| for (intptr_t i = 0; i < values.length(); i++) { |
| - const Location loc = deoptimization_env_->LocationAt(i); |
| - if (loc.IsInvalid()) { |
| - ASSERT(values[i]->IsConstant()); |
| - __ PushObject(values[i]->AsConstant()->value()); |
| - } else if (loc.IsRegister()) { |
| - __ pushl(loc.reg()); |
| - } else { |
| + Location destination = Location::SpillSlot(i); |
| + Location source = deoptimization_env_->LocationAt(i); |
| + if (!source.IsRegister() && !source.IsInvalid()) { |
| compiler->Bailout("unsupported deoptimization state"); |
| } |
| + if (source.IsInvalid()) { |
| + ASSERT(values[i]->IsConstant()); |
| + source = Location::Constant(values[i]->AsConstant()->value()); |
| + } |
| + move->AddMove(destination, source); |
| } |
| + compiler->parallel_move_resolver()->EmitNativeCode(move); |
| } |
| if (compiler->IsLeaf()) { |