Index: runtime/vm/flow_graph_compiler_dbc.cc |
diff --git a/runtime/vm/flow_graph_compiler_dbc.cc b/runtime/vm/flow_graph_compiler_dbc.cc |
index 4450561dddf7cbe65856ed954d4ae8cd8119d24a..5e0f8bce871702bc31336f5531f12c7461e89934 100644 |
--- a/runtime/vm/flow_graph_compiler_dbc.cc |
+++ b/runtime/vm/flow_graph_compiler_dbc.cc |
@@ -400,17 +400,23 @@ void FlowGraphCompiler::EmitFrameEntry() { |
} |
if (function.IsClosureFunction()) { |
- Register reg = |
+ // In optimized mode the register allocator expects CurrentContext in the |
+ // flow_graph_.num_copied_params() register at function entry. |
+ // (see FlowGraphAllocator::ProcessInitialDefinition) |
+ Register context_reg = |
is_optimizing() ? flow_graph_.num_copied_params() : context_index; |
- Register closure_reg = reg; |
LocalScope* scope = parsed_function().node_sequence()->scope(); |
LocalVariable* local = scope->VariableAt(0); |
+ |
+ Register closure_reg; |
if (local->index() > 0) { |
- __ Move(reg, -local->index()); |
+ __ Move(context_reg, -local->index()); |
+ closure_reg = context_reg; |
} else { |
closure_reg = -local->index() - 1; |
} |
- __ LoadField(reg, closure_reg, Closure::context_offset() / kWordSize); |
+ __ LoadField(context_reg, closure_reg, |
+ Closure::context_offset() / kWordSize); |
} else if (has_optional_params && !is_optimizing()) { |
__ LoadConstant(context_index, Object::empty_context()); |
} |
@@ -440,6 +446,14 @@ uint16_t FlowGraphCompiler::ToEmbeddableCid(intptr_t cid, |
} |
+intptr_t FlowGraphCompiler::CatchEntryRegForVariable(const LocalVariable& var) { |
+ ASSERT(is_optimizing()); |
+ ASSERT(var.index() <= 0); |
+ return kNumberOfCpuRegisters - |
+ (flow_graph().num_non_copied_params() - var.index()); |
+} |
+ |
+ |
#undef __ |
#define __ compiler_->assembler()-> |