Chromium Code Reviews| Index: runtime/vm/flow_graph_compiler_x64.cc |
| diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc |
| index 7668eeac94e8e6c09b9689024924e70bc8a5f824..2e6481373946836dddd0c1b0b5eac6ec002bbb40 100644 |
| --- a/runtime/vm/flow_graph_compiler_x64.cc |
| +++ b/runtime/vm/flow_graph_compiler_x64.cc |
| @@ -37,23 +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. |
| - __ leaq(RSP, |
| - Address(RBP, 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 = |
| + ParsedFunction::kFirstLocalSlotIndex - values.length(); |
|
Vyacheslav Egorov (Google)
2012/07/26 12:59:56
this should have been actually ParsedFunction::kFi
|
| + __ leaq(RSP, Address(RBP, 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()) { |
| - __ pushq(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()) { |