Chromium Code Reviews| Index: runtime/vm/flow_graph_builder.cc |
| =================================================================== |
| --- runtime/vm/flow_graph_builder.cc (revision 41279) |
| +++ runtime/vm/flow_graph_builder.cc (working copy) |
| @@ -759,7 +759,7 @@ |
| intptr_t delta = |
| owner()->context_level() - local.owner()->context_level(); |
| ASSERT(delta >= 0); |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| while (delta-- > 0) { |
| context = Bind(new(I) LoadFieldInstr( |
| context, Context::parent_offset(), Type::ZoneHandle(I, Type::null()), |
| @@ -787,7 +787,7 @@ |
| intptr_t delta = |
| owner()->context_level() - local.owner()->context_level(); |
| ASSERT(delta >= 0); |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| while (delta-- > 0) { |
| context = Bind(new(I) LoadFieldInstr( |
| context, Context::parent_offset(), Type::ZoneHandle(I, Type::null()), |
| @@ -805,7 +805,7 @@ |
| // Stores current context into the 'variable' |
| void EffectGraphVisitor::BuildSaveContext(const LocalVariable& variable) { |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| Do(BuildStoreLocal(variable, context)); |
| } |
| @@ -813,10 +813,22 @@ |
| // Loads context saved in 'context_variable' into the current context. |
| void EffectGraphVisitor::BuildRestoreContext(const LocalVariable& variable) { |
| Value* load_saved_context = Bind(BuildLoadLocal(variable)); |
| - AddInstruction(new(I) StoreContextInstr(load_saved_context)); |
| + Do(BuildStoreContext(load_saved_context)); |
| } |
| +Definition* EffectGraphVisitor::BuildStoreContext(Value* value) { |
| + return new(I) StoreLocalInstr( |
| + *owner()->parsed_function()->saved_current_context_var(), value); |
|
Vyacheslav Egorov (Google)
2014/10/28 13:44:58
I would call it just current_context_var()
Florian Schneider
2014/10/28 19:04:31
Done. I just used the name of the variable that wa
|
| +} |
| + |
| + |
| +Definition* EffectGraphVisitor::BuildCurrentContext() { |
| + return new(I) LoadLocalInstr( |
| + *owner()->parsed_function()->saved_current_context_var()); |
| +} |
| + |
| + |
| void TestGraphVisitor::ConnectBranchesTo( |
| const GrowableArray<TargetEntryInstr**>& branches, |
| JoinEntryInstr* join) const { |
| @@ -1268,12 +1280,12 @@ |
| const String& name = String::ZoneHandle(I, Symbols::New(node->TokenName())); |
| const intptr_t kNumArgsChecked = 2; |
| InstanceCallInstr* call = new(I) InstanceCallInstr(node->token_pos(), |
| - name, |
| - node->kind(), |
| - arguments, |
| - Object::null_array(), |
| - kNumArgsChecked, |
| - owner()->ic_data_array()); |
| + name, |
| + node->kind(), |
| + arguments, |
| + Object::null_array(), |
| + kNumArgsChecked, |
| + owner()->ic_data_array()); |
| ReturnDefinition(call); |
| } |
| @@ -1366,12 +1378,12 @@ |
| arguments->Add(push_mask); |
| const intptr_t kNumArgsChecked = 2; |
| InstanceCallInstr* call = new(I) InstanceCallInstr(node->token_pos(), |
| - BinaryOpAndMaskName(node), |
| - Token::kILLEGAL, |
| - arguments, |
| - Object::null_array(), |
| - kNumArgsChecked, |
| - owner()->ic_data_array()); |
| + BinaryOpAndMaskName(node), |
| + Token::kILLEGAL, |
| + arguments, |
| + Object::null_array(), |
| + kNumArgsChecked, |
| + owner()->ic_data_array()); |
| ReturnDefinition(call); |
| } |
| @@ -1496,7 +1508,7 @@ |
| intptr_t delta = old_ctx_level - |
| continuation_result->owner()->context_level(); |
| ASSERT(delta >= 0); |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| while (delta-- > 0) { |
| context = Bind(new(I) LoadFieldInstr( |
| context, Context::parent_offset(), Type::ZoneHandle(I, Type::null()), |
| @@ -1744,14 +1756,14 @@ |
| PushArgumentInstr* push_right = PushArgument(for_right_value.value()); |
| arguments->Add(push_right); |
| - Definition* result = |
| - new(I) InstanceCallInstr(node->token_pos(), |
| - Symbols::EqualOperator(), |
| - Token::kEQ, // Result is negated later for kNE. |
| - arguments, |
| - Object::null_array(), |
| - 2, |
| - owner()->ic_data_array()); |
| + Definition* result = new(I) InstanceCallInstr( |
| + node->token_pos(), |
| + Symbols::EqualOperator(), |
| + Token::kEQ, // Result is negated later for kNE. |
| + arguments, |
| + Object::null_array(), |
| + 2, |
| + owner()->ic_data_array()); |
| if (node->kind() == Token::kNE) { |
| if (FLAG_enable_type_checks) { |
| Value* value = Bind(result); |
| @@ -1780,15 +1792,14 @@ |
| arguments->Add(push_right); |
| ASSERT(Token::IsRelationalOperator(node->kind())); |
| - InstanceCallInstr* comp = |
| - new(I) InstanceCallInstr(node->token_pos(), |
| - String::ZoneHandle( |
| - I, Symbols::New(node->TokenName())), |
| - node->kind(), |
| - arguments, |
| - Object::null_array(), |
| - 2, |
| - owner()->ic_data_array()); |
| + InstanceCallInstr* comp = new(I) InstanceCallInstr( |
| + node->token_pos(), |
| + String::ZoneHandle(I, Symbols::New(node->TokenName())), |
| + node->kind(), |
| + arguments, |
| + Object::null_array(), |
| + 2, |
| + owner()->ic_data_array()); |
| ReturnDefinition(comp); |
| } |
| @@ -1816,15 +1827,14 @@ |
| ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| new(I) ZoneGrowableArray<PushArgumentInstr*>(1); |
| arguments->Add(push_value); |
| - InstanceCallInstr* call = |
| - new(I) InstanceCallInstr(node->token_pos(), |
| - String::ZoneHandle( |
| - I, Symbols::New(node->TokenName())), |
| - node->kind(), |
| - arguments, |
| - Object::null_array(), |
| - 1, |
| - owner()->ic_data_array()); |
| + InstanceCallInstr* call = new(I) InstanceCallInstr( |
| + node->token_pos(), |
| + String::ZoneHandle(I, Symbols::New(node->TokenName())), |
| + node->kind(), |
| + arguments, |
| + Object::null_array(), |
| + 1, |
| + owner()->ic_data_array()); |
| ReturnDefinition(call); |
| } |
| @@ -2525,7 +2535,7 @@ |
| } else { |
| // Store current context in closure. |
| closure_tmp_val = Bind(new(I) LoadLocalInstr(*closure_tmp_var)); |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| Do(new(I) StoreInstanceFieldInstr(Closure::context_offset(), |
| closure_tmp_val, |
| context, |
| @@ -2611,10 +2621,10 @@ |
| BuildPushArguments(*node->arguments(), arguments); |
| StaticCallInstr* call = |
| new(I) StaticCallInstr(node->token_pos(), |
| - node->function(), |
| - node->arguments()->names(), |
| - arguments, |
| - owner()->ic_data_array()); |
| + node->function(), |
| + node->arguments()->names(), |
| + arguments, |
| + owner()->ic_data_array()); |
| if (node->function().is_native()) { |
| const intptr_t result_cid = GetResultCidOfNativeFactory(node->function()); |
| if (result_cid != kDynamicCid) { |
| @@ -2641,19 +2651,7 @@ |
| arguments->Add(push_closure); |
| BuildPushArguments(*node->arguments(), arguments); |
| - // Save context around the call. |
| - ASSERT(owner()->parsed_function()->saved_current_context_var() != NULL); |
| - BuildSaveContext(*owner()->parsed_function()->saved_current_context_var()); |
| closure_val = Bind(new(I) LoadLocalInstr(*tmp_var)); |
| - LoadFieldInstr* context_load = new(I) LoadFieldInstr( |
| - closure_val, |
| - Closure::context_offset(), |
| - AbstractType::ZoneHandle(I, AbstractType::null()), |
| - node->token_pos()); |
| - context_load->set_is_immutable(true); |
| - Value* context_val = Bind(context_load); |
| - AddInstruction(new(I) StoreContextInstr(context_val)); |
| - closure_val = Bind(new(I) LoadLocalInstr(*tmp_var)); |
| LoadFieldInstr* function_load = new(I) LoadFieldInstr( |
| closure_val, |
| Closure::function_offset(), |
| @@ -2661,22 +2659,24 @@ |
| node->token_pos()); |
| function_load->set_is_immutable(true); |
| Value* function_val = Bind(function_load); |
| + |
| + closure_val = Bind(new(I) LoadLocalInstr(*tmp_var)); |
| + LoadFieldInstr* context_load = new(I) LoadFieldInstr( |
| + closure_val, |
| + Closure::context_offset(), |
| + AbstractType::ZoneHandle(I, AbstractType::null()), |
| + node->token_pos()); |
| + context_load->set_is_immutable(true); |
| + Value* context_val = Bind(context_load); |
| Definition* closure_call = |
| - new(I) ClosureCallInstr(function_val, node, arguments); |
| + new(I) ClosureCallInstr(function_val, context_val, node, arguments); |
| if (result_needed) { |
| Value* result = Bind(closure_call); |
| Do(new(I) StoreLocalInstr(*tmp_var, result)); |
| - // Restore context from temp. |
| - BuildRestoreContext( |
| - *owner()->parsed_function()->saved_current_context_var()); |
| - ReturnDefinition(ExitTempLocalScope(tmp_var)); |
| } else { |
| Do(closure_call); |
| - // Restore context from saved location. |
| - BuildRestoreContext( |
| - *owner()->parsed_function()->saved_current_context_var()); |
| - Do(ExitTempLocalScope(tmp_var)); |
| } |
| + ReturnDefinition(ExitTempLocalScope(tmp_var)); |
| } |
| @@ -2697,9 +2697,9 @@ |
| void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| Value* clone = Bind(new(I) CloneContextInstr(node->token_pos(), context)); |
| - AddInstruction(new(I) StoreContextInstr(clone)); |
| + Do(BuildStoreContext(clone)); |
| } |
| @@ -2739,10 +2739,10 @@ |
| BuildPushArguments(*node->arguments(), arguments); |
| Do(new(I) StaticCallInstr(node->token_pos(), |
| - node->constructor(), |
| - node->arguments()->names(), |
| - arguments, |
| - owner()->ic_data_array())); |
| + node->constructor(), |
| + node->arguments()->names(), |
| + arguments, |
| + owner()->ic_data_array())); |
| } |
| @@ -2782,10 +2782,10 @@ |
| BuildPushArguments(*node->arguments(), arguments); |
| StaticCallInstr* call = |
| new(I) StaticCallInstr(node->token_pos(), |
| - node->constructor(), |
| - node->arguments()->names(), |
| - arguments, |
| - owner()->ic_data_array()); |
| + node->constructor(), |
| + node->arguments()->names(), |
| + arguments, |
| + owner()->ic_data_array()); |
| const intptr_t result_cid = GetResultCidOfListFactory(node); |
| if (result_cid != kDynamicCid) { |
| call->set_result_cid(result_cid); |
| @@ -3536,21 +3536,22 @@ |
| if (super_function != NULL) { |
| // Generate static call to super operator. |
| StaticCallInstr* load = new(I) StaticCallInstr(node->token_pos(), |
| - *super_function, |
| - Object::null_array(), |
| - arguments, |
| - owner()->ic_data_array()); |
| + *super_function, |
| + Object::null_array(), |
| + arguments, |
| + owner()->ic_data_array()); |
| ReturnDefinition(load); |
| } else { |
| // Generate dynamic call to index operator. |
| const intptr_t checked_argument_count = 1; |
| - InstanceCallInstr* load = new(I) InstanceCallInstr(node->token_pos(), |
| - Symbols::IndexToken(), |
| - Token::kINDEX, |
| - arguments, |
| - Object::null_array(), |
| - checked_argument_count, |
| - owner()->ic_data_array()); |
| + InstanceCallInstr* load = new(I) InstanceCallInstr( |
| + node->token_pos(), |
| + Symbols::IndexToken(), |
| + Token::kINDEX, |
| + arguments, |
| + Object::null_array(), |
| + checked_argument_count, |
| + owner()->ic_data_array()); |
| ReturnDefinition(load); |
| } |
| } |
| @@ -3617,10 +3618,10 @@ |
| StaticCallInstr* store = |
| new(I) StaticCallInstr(node->token_pos(), |
| - *super_function, |
| - Object::null_array(), |
| - arguments, |
| - owner()->ic_data_array()); |
| + *super_function, |
| + Object::null_array(), |
| + arguments, |
| + owner()->ic_data_array()); |
| if (result_is_needed) { |
| Do(store); |
| return BuildLoadExprTemp(); |
| @@ -3634,12 +3635,12 @@ |
| String::ZoneHandle(I, Symbols::New(Token::Str(Token::kASSIGN_INDEX))); |
| InstanceCallInstr* store = |
| new(I) InstanceCallInstr(node->token_pos(), |
| - name, |
| - Token::kASSIGN_INDEX, |
| - arguments, |
| - Object::null_array(), |
| - checked_argument_count, |
| - owner()->ic_data_array()); |
| + name, |
| + Token::kASSIGN_INDEX, |
| + arguments, |
| + Object::null_array(), |
| + checked_argument_count, |
| + owner()->ic_data_array()); |
| if (result_is_needed) { |
| Do(store); |
| return BuildLoadExprTemp(); |
| @@ -3668,7 +3669,7 @@ |
| void EffectGraphVisitor::UnchainContexts(intptr_t n) { |
| if (n > 0) { |
| - Value* context = Bind(new(I) CurrentContextInstr()); |
| + Value* context = Bind(BuildCurrentContext()); |
| while (n-- > 0) { |
| context = Bind( |
| new(I) LoadFieldInstr(context, |
| @@ -3677,7 +3678,7 @@ |
| Type::ZoneHandle(I, Type::null()), |
| Scanner::kNoSourcePos)); |
| } |
| - AddInstruction(new(I) StoreContextInstr(context)); |
| + Do(BuildStoreContext(context)); |
| } |
| } |
| @@ -3716,15 +3717,14 @@ |
| parent_context = Bind( |
| new(I) ConstantInstr(Object::ZoneHandle(I, Object::null()))); |
| } else { |
| - parent_context = Bind(new(I) CurrentContextInstr()); |
| + parent_context = Bind(BuildCurrentContext()); |
| } |
| Do(new(I) StoreInstanceFieldInstr(Context::parent_offset(), |
| tmp_val, |
| parent_context, |
| kEmitStoreBarrier, |
| Scanner::kNoSourcePos)); |
| - AddInstruction( |
| - new(I) StoreContextInstr(Bind(ExitTempLocalScope(tmp_var)))); |
| + Do(BuildStoreContext(Bind(ExitTempLocalScope(tmp_var)))); |
| } |
| // If this node_sequence is the body of the function being compiled, copy |
| @@ -3772,9 +3772,8 @@ |
| // object. |
| BuildSaveContext( |
| *owner()->parsed_function()->saved_entry_context_var()); |
| - AddInstruction( |
| - new(I) StoreContextInstr(Bind(new(I) ConstantInstr(Object::ZoneHandle( |
| - I, I->object_store()->empty_context()))))); |
| + Do(BuildStoreContext(Bind(new(I) ConstantInstr(Object::ZoneHandle( |
| + I, I->object_store()->empty_context()))))); |
| } |
| // This check may be deleted if the generated code is leaf. |