| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 Definition* EffectGraphVisitor::BuildStoreLocal(const LocalVariable& local, | 710 Definition* EffectGraphVisitor::BuildStoreLocal(const LocalVariable& local, |
| 711 Value* value) { | 711 Value* value) { |
| 712 if (local.is_captured()) { | 712 if (local.is_captured()) { |
| 713 LocalVariable* tmp_var = EnterTempLocalScope(value); | 713 LocalVariable* tmp_var = EnterTempLocalScope(value); |
| 714 intptr_t delta = | 714 intptr_t delta = |
| 715 owner()->context_level() - local.owner()->context_level(); | 715 owner()->context_level() - local.owner()->context_level(); |
| 716 ASSERT(delta >= 0); | 716 ASSERT(delta >= 0); |
| 717 Value* context = Bind(new CurrentContextInstr()); | 717 Value* context = Bind(new CurrentContextInstr()); |
| 718 while (delta-- > 0) { | 718 while (delta-- > 0) { |
| 719 context = Bind(new LoadFieldInstr( | 719 context = Bind(new LoadFieldInstr( |
| 720 context, Context::parent_offset(), Type::ZoneHandle())); | 720 context, Context::parent_offset(), Type::ZoneHandle(), kNoTokenPos)); |
| 721 } | 721 } |
| 722 Value* tmp_val = Bind(new LoadLocalInstr(*tmp_var)); | 722 Value* tmp_val = Bind(new LoadLocalInstr(*tmp_var)); |
| 723 StoreInstanceFieldInstr* store = | 723 StoreInstanceFieldInstr* store = |
| 724 new StoreInstanceFieldInstr(Context::variable_offset(local.index()), | 724 new StoreInstanceFieldInstr(Context::variable_offset(local.index()), |
| 725 context, | 725 context, |
| 726 tmp_val, | 726 tmp_val, |
| 727 kEmitStoreBarrier); | 727 kEmitStoreBarrier, |
| 728 kNoTokenPos); |
| 728 Do(store); | 729 Do(store); |
| 729 return ExitTempLocalScope(tmp_var); | 730 return ExitTempLocalScope(tmp_var); |
| 730 } else { | 731 } else { |
| 731 return new StoreLocalInstr(local, value); | 732 return new StoreLocalInstr(local, value); |
| 732 } | 733 } |
| 733 } | 734 } |
| 734 | 735 |
| 735 | 736 |
| 736 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { | 737 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { |
| 737 if (local.IsConst()) { | 738 if (local.IsConst()) { |
| 738 return new ConstantInstr(*local.ConstValue()); | 739 return new ConstantInstr(*local.ConstValue()); |
| 739 } else if (local.is_captured()) { | 740 } else if (local.is_captured()) { |
| 740 intptr_t delta = | 741 intptr_t delta = |
| 741 owner()->context_level() - local.owner()->context_level(); | 742 owner()->context_level() - local.owner()->context_level(); |
| 742 ASSERT(delta >= 0); | 743 ASSERT(delta >= 0); |
| 743 Value* context = Bind(new CurrentContextInstr()); | 744 Value* context = Bind(new CurrentContextInstr()); |
| 744 while (delta-- > 0) { | 745 while (delta-- > 0) { |
| 745 context = Bind(new LoadFieldInstr( | 746 context = Bind(new LoadFieldInstr( |
| 746 context, Context::parent_offset(), Type::ZoneHandle())); | 747 context, Context::parent_offset(), Type::ZoneHandle(), kNoTokenPos)); |
| 747 } | 748 } |
| 748 return new LoadFieldInstr(context, | 749 return new LoadFieldInstr(context, |
| 749 Context::variable_offset(local.index()), | 750 Context::variable_offset(local.index()), |
| 750 local.type()); | 751 local.type(), |
| 752 kNoTokenPos); |
| 751 } else { | 753 } else { |
| 752 return new LoadLocalInstr(local); | 754 return new LoadLocalInstr(local); |
| 753 } | 755 } |
| 754 } | 756 } |
| 755 | 757 |
| 756 | 758 |
| 757 // Stores current context into the 'variable' | 759 // Stores current context into the 'variable' |
| 758 void EffectGraphVisitor::BuildSaveContext(const LocalVariable& variable) { | 760 void EffectGraphVisitor::BuildSaveContext(const LocalVariable& variable) { |
| 759 Value* context = Bind(new CurrentContextInstr()); | 761 Value* context = Bind(new CurrentContextInstr()); |
| 760 Do(BuildStoreLocal(variable, context)); | 762 Do(BuildStoreLocal(variable, context)); |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 ValueGraphVisitor for_value(owner()); | 2144 ValueGraphVisitor for_value(owner()); |
| 2143 node->ElementAt(i)->Visit(&for_value); | 2145 node->ElementAt(i)->Visit(&for_value); |
| 2144 Append(for_value); | 2146 Append(for_value); |
| 2145 // No store barrier needed for constants. | 2147 // No store barrier needed for constants. |
| 2146 const StoreBarrierType emit_store_barrier = | 2148 const StoreBarrierType emit_store_barrier = |
| 2147 for_value.value()->BindsToConstant() | 2149 for_value.value()->BindsToConstant() |
| 2148 ? kNoStoreBarrier | 2150 ? kNoStoreBarrier |
| 2149 : kEmitStoreBarrier; | 2151 : kEmitStoreBarrier; |
| 2150 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id); | 2152 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id); |
| 2151 StoreIndexedInstr* store = new StoreIndexedInstr( | 2153 StoreIndexedInstr* store = new StoreIndexedInstr( |
| 2152 array, index, for_value.value(), | 2154 array, index, for_value.value(), emit_store_barrier, |
| 2153 emit_store_barrier, index_scale, class_id, deopt_id); | 2155 index_scale, class_id, deopt_id, node->token_pos()); |
| 2154 Do(store); | 2156 Do(store); |
| 2155 } | 2157 } |
| 2156 ReturnDefinition(ExitTempLocalScope(tmp_var)); | 2158 ReturnDefinition(ExitTempLocalScope(tmp_var)); |
| 2157 } | 2159 } |
| 2158 } | 2160 } |
| 2159 | 2161 |
| 2160 | 2162 |
| 2161 void EffectGraphVisitor::VisitStringInterpolateNode( | 2163 void EffectGraphVisitor::VisitStringInterpolateNode( |
| 2162 StringInterpolateNode* node) { | 2164 StringInterpolateNode* node) { |
| 2163 ValueGraphVisitor for_argument(owner()); | 2165 ValueGraphVisitor for_argument(owner()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 | 2241 |
| 2240 Value* closure_val = Bind(alloc); | 2242 Value* closure_val = Bind(alloc); |
| 2241 { LocalVariable* closure_tmp_var = EnterTempLocalScope(closure_val); | 2243 { LocalVariable* closure_tmp_var = EnterTempLocalScope(closure_val); |
| 2242 // Store function. | 2244 // Store function. |
| 2243 Value* closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); | 2245 Value* closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); |
| 2244 Value* func_val = | 2246 Value* func_val = |
| 2245 Bind(new ConstantInstr(Function::ZoneHandle(function.raw()))); | 2247 Bind(new ConstantInstr(Function::ZoneHandle(function.raw()))); |
| 2246 Do(new StoreInstanceFieldInstr(Closure::function_offset(), | 2248 Do(new StoreInstanceFieldInstr(Closure::function_offset(), |
| 2247 closure_tmp_val, | 2249 closure_tmp_val, |
| 2248 func_val, | 2250 func_val, |
| 2249 kEmitStoreBarrier)); | 2251 kEmitStoreBarrier, |
| 2252 node->token_pos())); |
| 2250 if (is_implicit) { | 2253 if (is_implicit) { |
| 2251 // Create new context containing the receiver. | 2254 // Create new context containing the receiver. |
| 2252 const intptr_t kNumContextVariables = 1; // The receiver. | 2255 const intptr_t kNumContextVariables = 1; // The receiver. |
| 2253 Value* allocated_context = | 2256 Value* allocated_context = |
| 2254 Bind(new AllocateContextInstr(node->token_pos(), | 2257 Bind(new AllocateContextInstr(node->token_pos(), |
| 2255 kNumContextVariables)); | 2258 kNumContextVariables)); |
| 2256 { LocalVariable* context_tmp_var = EnterTempLocalScope(allocated_context); | 2259 { LocalVariable* context_tmp_var = EnterTempLocalScope(allocated_context); |
| 2257 // Store receiver in context. | 2260 // Store receiver in context. |
| 2258 Value* context_tmp_val = Bind(new LoadLocalInstr(*context_tmp_var)); | 2261 Value* context_tmp_val = Bind(new LoadLocalInstr(*context_tmp_var)); |
| 2259 ValueGraphVisitor for_receiver(owner()); | 2262 ValueGraphVisitor for_receiver(owner()); |
| 2260 node->receiver()->Visit(&for_receiver); | 2263 node->receiver()->Visit(&for_receiver); |
| 2261 Append(for_receiver); | 2264 Append(for_receiver); |
| 2262 Value* receiver = for_receiver.value(); | 2265 Value* receiver = for_receiver.value(); |
| 2263 Do(new StoreInstanceFieldInstr(Context::variable_offset(0), | 2266 Do(new StoreInstanceFieldInstr(Context::variable_offset(0), |
| 2264 context_tmp_val, | 2267 context_tmp_val, |
| 2265 receiver, | 2268 receiver, |
| 2266 kEmitStoreBarrier)); | 2269 kEmitStoreBarrier, |
| 2270 node->token_pos())); |
| 2267 // Store new context in closure. | 2271 // Store new context in closure. |
| 2268 closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); | 2272 closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); |
| 2269 context_tmp_val = Bind(new LoadLocalInstr(*context_tmp_var)); | 2273 context_tmp_val = Bind(new LoadLocalInstr(*context_tmp_var)); |
| 2270 Do(new StoreInstanceFieldInstr(Closure::context_offset(), | 2274 Do(new StoreInstanceFieldInstr(Closure::context_offset(), |
| 2271 closure_tmp_val, | 2275 closure_tmp_val, |
| 2272 context_tmp_val, | 2276 context_tmp_val, |
| 2273 kEmitStoreBarrier)); | 2277 kEmitStoreBarrier, |
| 2278 node->token_pos())); |
| 2274 Do(ExitTempLocalScope(context_tmp_var)); | 2279 Do(ExitTempLocalScope(context_tmp_var)); |
| 2275 } | 2280 } |
| 2276 } else { | 2281 } else { |
| 2277 // Store current context in closure. | 2282 // Store current context in closure. |
| 2278 closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); | 2283 closure_tmp_val = Bind(new LoadLocalInstr(*closure_tmp_var)); |
| 2279 Value* context = Bind(new CurrentContextInstr()); | 2284 Value* context = Bind(new CurrentContextInstr()); |
| 2280 Do(new StoreInstanceFieldInstr(Closure::context_offset(), | 2285 Do(new StoreInstanceFieldInstr(Closure::context_offset(), |
| 2281 closure_tmp_val, | 2286 closure_tmp_val, |
| 2282 context, | 2287 context, |
| 2283 kEmitStoreBarrier)); | 2288 kEmitStoreBarrier, |
| 2289 node->token_pos())); |
| 2284 } | 2290 } |
| 2285 ReturnDefinition(ExitTempLocalScope(closure_tmp_var)); | 2291 ReturnDefinition(ExitTempLocalScope(closure_tmp_var)); |
| 2286 } | 2292 } |
| 2287 } | 2293 } |
| 2288 | 2294 |
| 2289 | 2295 |
| 2290 void EffectGraphVisitor::BuildPushArguments( | 2296 void EffectGraphVisitor::BuildPushArguments( |
| 2291 const ArgumentListNode& node, | 2297 const ArgumentListNode& node, |
| 2292 ZoneGrowableArray<PushArgumentInstr*>* values) { | 2298 ZoneGrowableArray<PushArgumentInstr*>* values) { |
| 2293 for (intptr_t i = 0; i < node.length(); ++i) { | 2299 for (intptr_t i = 0; i < node.length(); ++i) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2588 // The receiver cannot be null; extract its TypeArguments object. | 2594 // The receiver cannot be null; extract its TypeArguments object. |
| 2589 // Note that in the factory case, the instantiator is the first parameter | 2595 // Note that in the factory case, the instantiator is the first parameter |
| 2590 // of the factory, i.e. already a TypeArguments object. | 2596 // of the factory, i.e. already a TypeArguments object. |
| 2591 intptr_t type_arguments_field_offset = | 2597 intptr_t type_arguments_field_offset = |
| 2592 instantiator_class.type_arguments_field_offset(); | 2598 instantiator_class.type_arguments_field_offset(); |
| 2593 ASSERT(type_arguments_field_offset != Class::kNoTypeArguments); | 2599 ASSERT(type_arguments_field_offset != Class::kNoTypeArguments); |
| 2594 | 2600 |
| 2595 return Bind(new LoadFieldInstr( | 2601 return Bind(new LoadFieldInstr( |
| 2596 instantiator, | 2602 instantiator, |
| 2597 type_arguments_field_offset, | 2603 type_arguments_field_offset, |
| 2598 Type::ZoneHandle())); // Not an instance, no type. | 2604 Type::ZoneHandle(), // Not an instance, no type. |
| 2605 kNoTokenPos)); |
| 2599 } | 2606 } |
| 2600 | 2607 |
| 2601 | 2608 |
| 2602 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( | 2609 Value* EffectGraphVisitor::BuildInstantiatedTypeArguments( |
| 2603 intptr_t token_pos, | 2610 intptr_t token_pos, |
| 2604 const TypeArguments& type_arguments) { | 2611 const TypeArguments& type_arguments) { |
| 2605 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { | 2612 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { |
| 2606 return Bind(new ConstantInstr(type_arguments)); | 2613 return Bind(new ConstantInstr(type_arguments)); |
| 2607 } | 2614 } |
| 2608 // The type arguments are uninstantiated. | 2615 // The type arguments are uninstantiated. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2937 Value* receiver = Bind(BuildLoadThisVar(node->scope())); | 2944 Value* receiver = Bind(BuildLoadThisVar(node->scope())); |
| 2938 // Treat length loads as mutable (i.e. affected by side effects) to | 2945 // Treat length loads as mutable (i.e. affected by side effects) to |
| 2939 // avoid hoisting them since we can't hoist the preceding class-check. | 2946 // avoid hoisting them since we can't hoist the preceding class-check. |
| 2940 // This is because of externalization of strings that affects their | 2947 // This is because of externalization of strings that affects their |
| 2941 // class-id. | 2948 // class-id. |
| 2942 const bool is_immutable = false; | 2949 const bool is_immutable = false; |
| 2943 LoadFieldInstr* load = new LoadFieldInstr( | 2950 LoadFieldInstr* load = new LoadFieldInstr( |
| 2944 receiver, | 2951 receiver, |
| 2945 String::length_offset(), | 2952 String::length_offset(), |
| 2946 Type::ZoneHandle(Type::SmiType()), | 2953 Type::ZoneHandle(Type::SmiType()), |
| 2954 node->token_pos(), |
| 2947 is_immutable); | 2955 is_immutable); |
| 2948 load->set_result_cid(kSmiCid); | 2956 load->set_result_cid(kSmiCid); |
| 2949 load->set_recognized_kind(MethodRecognizer::kStringBaseLength); | 2957 load->set_recognized_kind(MethodRecognizer::kStringBaseLength); |
| 2950 if (kind == MethodRecognizer::kStringBaseLength) { | 2958 if (kind == MethodRecognizer::kStringBaseLength) { |
| 2951 return ReturnDefinition(load); | 2959 return ReturnDefinition(load); |
| 2952 } | 2960 } |
| 2953 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); | 2961 ASSERT(kind == MethodRecognizer::kStringBaseIsEmpty); |
| 2954 Value* zero_val = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(0)))); | 2962 Value* zero_val = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(0)))); |
| 2955 Value* load_val = Bind(load); | 2963 Value* load_val = Bind(load); |
| 2956 StrictCompareInstr* compare = | 2964 StrictCompareInstr* compare = |
| 2957 new StrictCompareInstr(node->token_pos(), | 2965 new StrictCompareInstr(node->token_pos(), |
| 2958 Token::kEQ_STRICT, | 2966 Token::kEQ_STRICT, |
| 2959 load_val, | 2967 load_val, |
| 2960 zero_val, | 2968 zero_val, |
| 2961 false); // No number check. | 2969 false); // No number check. |
| 2962 return ReturnDefinition(compare); | 2970 return ReturnDefinition(compare); |
| 2963 } | 2971 } |
| 2964 case MethodRecognizer::kGrowableArrayLength: | 2972 case MethodRecognizer::kGrowableArrayLength: |
| 2965 case MethodRecognizer::kObjectArrayLength: | 2973 case MethodRecognizer::kObjectArrayLength: |
| 2966 case MethodRecognizer::kImmutableArrayLength: | 2974 case MethodRecognizer::kImmutableArrayLength: |
| 2967 case MethodRecognizer::kTypedDataLength: { | 2975 case MethodRecognizer::kTypedDataLength: { |
| 2968 Value* receiver = Bind(BuildLoadThisVar(node->scope())); | 2976 Value* receiver = Bind(BuildLoadThisVar(node->scope())); |
| 2969 const bool is_immutable = | 2977 const bool is_immutable = |
| 2970 (kind != MethodRecognizer::kGrowableArrayLength); | 2978 (kind != MethodRecognizer::kGrowableArrayLength); |
| 2971 LoadFieldInstr* load = new LoadFieldInstr( | 2979 LoadFieldInstr* load = new LoadFieldInstr( |
| 2972 receiver, | 2980 receiver, |
| 2973 OffsetForLengthGetter(kind), | 2981 OffsetForLengthGetter(kind), |
| 2974 Type::ZoneHandle(Type::SmiType()), | 2982 Type::ZoneHandle(Type::SmiType()), |
| 2983 node->token_pos(), |
| 2975 is_immutable); | 2984 is_immutable); |
| 2976 load->set_result_cid(kSmiCid); | 2985 load->set_result_cid(kSmiCid); |
| 2977 load->set_recognized_kind(kind); | 2986 load->set_recognized_kind(kind); |
| 2978 return ReturnDefinition(load); | 2987 return ReturnDefinition(load); |
| 2979 } | 2988 } |
| 2980 case MethodRecognizer::kObjectCid: | 2989 case MethodRecognizer::kObjectCid: |
| 2981 case MethodRecognizer::kTypedListBaseCid: { | 2990 case MethodRecognizer::kTypedListBaseCid: { |
| 2982 Value* receiver = Bind(BuildLoadThisVar(node->scope())); | 2991 Value* receiver = Bind(BuildLoadThisVar(node->scope())); |
| 2983 LoadClassIdInstr* load = new LoadClassIdInstr(receiver); | 2992 LoadClassIdInstr* load = new LoadClassIdInstr(receiver); |
| 2984 return ReturnDefinition(load); | 2993 return ReturnDefinition(load); |
| 2985 } | 2994 } |
| 2986 case MethodRecognizer::kGrowableArrayCapacity: { | 2995 case MethodRecognizer::kGrowableArrayCapacity: { |
| 2987 Value* receiver = Bind(BuildLoadThisVar(node->scope())); | 2996 Value* receiver = Bind(BuildLoadThisVar(node->scope())); |
| 2988 LoadFieldInstr* data_load = new LoadFieldInstr( | 2997 LoadFieldInstr* data_load = new LoadFieldInstr( |
| 2989 receiver, | 2998 receiver, |
| 2990 Array::data_offset(), | 2999 Array::data_offset(), |
| 2991 Type::ZoneHandle(Type::DynamicType())); | 3000 Type::ZoneHandle(Type::DynamicType()), |
| 3001 node->token_pos()); |
| 2992 data_load->set_result_cid(kArrayCid); | 3002 data_load->set_result_cid(kArrayCid); |
| 2993 Value* data = Bind(data_load); | 3003 Value* data = Bind(data_load); |
| 2994 LoadFieldInstr* length_load = new LoadFieldInstr( | 3004 LoadFieldInstr* length_load = new LoadFieldInstr( |
| 2995 data, | 3005 data, |
| 2996 Array::length_offset(), | 3006 Array::length_offset(), |
| 2997 Type::ZoneHandle(Type::SmiType())); | 3007 Type::ZoneHandle(Type::SmiType()), |
| 3008 node->token_pos()); |
| 2998 length_load->set_result_cid(kSmiCid); | 3009 length_load->set_result_cid(kSmiCid); |
| 2999 length_load->set_recognized_kind(MethodRecognizer::kObjectArrayLength); | 3010 length_load->set_recognized_kind(MethodRecognizer::kObjectArrayLength); |
| 3000 return ReturnDefinition(length_load); | 3011 return ReturnDefinition(length_load); |
| 3001 } | 3012 } |
| 3002 default: | 3013 default: |
| 3003 break; | 3014 break; |
| 3004 } | 3015 } |
| 3005 } | 3016 } |
| 3006 InlineBailout("EffectGraphVisitor::VisitNativeBodyNode"); | 3017 InlineBailout("EffectGraphVisitor::VisitNativeBodyNode"); |
| 3007 NativeCallInstr* native_call = new NativeCallInstr(node); | 3018 NativeCallInstr* native_call = new NativeCallInstr(node); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 | 3066 |
| 3056 | 3067 |
| 3057 void EffectGraphVisitor::VisitLoadInstanceFieldNode( | 3068 void EffectGraphVisitor::VisitLoadInstanceFieldNode( |
| 3058 LoadInstanceFieldNode* node) { | 3069 LoadInstanceFieldNode* node) { |
| 3059 ValueGraphVisitor for_instance(owner()); | 3070 ValueGraphVisitor for_instance(owner()); |
| 3060 node->instance()->Visit(&for_instance); | 3071 node->instance()->Visit(&for_instance); |
| 3061 Append(for_instance); | 3072 Append(for_instance); |
| 3062 LoadFieldInstr* load = new LoadFieldInstr( | 3073 LoadFieldInstr* load = new LoadFieldInstr( |
| 3063 for_instance.value(), | 3074 for_instance.value(), |
| 3064 &node->field(), | 3075 &node->field(), |
| 3065 AbstractType::ZoneHandle(node->field().type())); | 3076 AbstractType::ZoneHandle(node->field().type()), |
| 3077 node->token_pos()); |
| 3066 if (node->field().guarded_cid() != kIllegalCid) { | 3078 if (node->field().guarded_cid() != kIllegalCid) { |
| 3067 if (!node->field().is_nullable() || | 3079 if (!node->field().is_nullable() || |
| 3068 (node->field().guarded_cid() == kNullCid)) { | 3080 (node->field().guarded_cid() == kNullCid)) { |
| 3069 load->set_result_cid(node->field().guarded_cid()); | 3081 load->set_result_cid(node->field().guarded_cid()); |
| 3070 } | 3082 } |
| 3071 FlowGraph::AddToGuardedFields(owner()->guarded_fields(), &node->field()); | 3083 FlowGraph::AddToGuardedFields(owner()->guarded_fields(), &node->field()); |
| 3072 } | 3084 } |
| 3073 ReturnDefinition(load); | 3085 ReturnDefinition(load); |
| 3074 } | 3086 } |
| 3075 | 3087 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3098 node->field(), | 3110 node->field(), |
| 3099 Isolate::Current()->GetNextDeoptId()); | 3111 Isolate::Current()->GetNextDeoptId()); |
| 3100 AddInstruction(guard); | 3112 AddInstruction(guard); |
| 3101 | 3113 |
| 3102 store_value = Bind(BuildLoadExprTemp()); | 3114 store_value = Bind(BuildLoadExprTemp()); |
| 3103 StoreInstanceFieldInstr* store = | 3115 StoreInstanceFieldInstr* store = |
| 3104 new StoreInstanceFieldInstr(node->field(), | 3116 new StoreInstanceFieldInstr(node->field(), |
| 3105 for_instance.value(), | 3117 for_instance.value(), |
| 3106 store_value, | 3118 store_value, |
| 3107 kEmitStoreBarrier, | 3119 kEmitStoreBarrier, |
| 3120 node->token_pos(), |
| 3108 true); // Maybe initializing store. | 3121 true); // Maybe initializing store. |
| 3109 ReturnDefinition(store); | 3122 ReturnDefinition(store); |
| 3110 } | 3123 } |
| 3111 | 3124 |
| 3112 | 3125 |
| 3113 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { | 3126 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { |
| 3114 if (node->field().is_const()) { | 3127 if (node->field().is_const()) { |
| 3115 ASSERT(node->field().value() != Object::sentinel().raw()); | 3128 ASSERT(node->field().value() != Object::sentinel().raw()); |
| 3116 ASSERT(node->field().value() != Object::transition_sentinel().raw()); | 3129 ASSERT(node->field().value() != Object::transition_sentinel().raw()); |
| 3117 Definition* result = | 3130 Definition* result = |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3334 } | 3347 } |
| 3335 | 3348 |
| 3336 | 3349 |
| 3337 void EffectGraphVisitor::UnchainContexts(intptr_t n) { | 3350 void EffectGraphVisitor::UnchainContexts(intptr_t n) { |
| 3338 if (n > 0) { | 3351 if (n > 0) { |
| 3339 Value* context = Bind(new CurrentContextInstr()); | 3352 Value* context = Bind(new CurrentContextInstr()); |
| 3340 while (n-- > 0) { | 3353 while (n-- > 0) { |
| 3341 context = Bind( | 3354 context = Bind( |
| 3342 new LoadFieldInstr(context, | 3355 new LoadFieldInstr(context, |
| 3343 Context::parent_offset(), | 3356 Context::parent_offset(), |
| 3344 Type::ZoneHandle())); // Not an instance, no type. | 3357 Type::ZoneHandle(), |
| 3358 kNoTokenPos)); // Not an instance, no type. |
| 3345 } | 3359 } |
| 3346 AddInstruction(new StoreContextInstr(context)); | 3360 AddInstruction(new StoreContextInstr(context)); |
| 3347 } | 3361 } |
| 3348 } | 3362 } |
| 3349 | 3363 |
| 3350 | 3364 |
| 3351 // <Statement> ::= Sequence { scope: LocalScope | 3365 // <Statement> ::= Sequence { scope: LocalScope |
| 3352 // nodes: <Statement>* | 3366 // nodes: <Statement>* |
| 3353 // label: SourceLabel } | 3367 // label: SourceLabel } |
| 3354 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { | 3368 void EffectGraphVisitor::VisitSequenceNode(SequenceNode* node) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3379 if (MustSaveRestoreContext(node)) { | 3393 if (MustSaveRestoreContext(node)) { |
| 3380 BuildSaveContext( | 3394 BuildSaveContext( |
| 3381 *owner()->parsed_function()->saved_entry_context_var()); | 3395 *owner()->parsed_function()->saved_entry_context_var()); |
| 3382 parent_context = Bind(new ConstantInstr(Object::ZoneHandle())); | 3396 parent_context = Bind(new ConstantInstr(Object::ZoneHandle())); |
| 3383 } else { | 3397 } else { |
| 3384 parent_context = Bind(new CurrentContextInstr()); | 3398 parent_context = Bind(new CurrentContextInstr()); |
| 3385 } | 3399 } |
| 3386 Do(new StoreInstanceFieldInstr(Context::parent_offset(), | 3400 Do(new StoreInstanceFieldInstr(Context::parent_offset(), |
| 3387 tmp_val, | 3401 tmp_val, |
| 3388 parent_context, | 3402 parent_context, |
| 3389 kEmitStoreBarrier)); | 3403 kEmitStoreBarrier, |
| 3404 kNoTokenPos)); |
| 3390 AddInstruction( | 3405 AddInstruction( |
| 3391 new StoreContextInstr(Bind(ExitTempLocalScope(tmp_var)))); | 3406 new StoreContextInstr(Bind(ExitTempLocalScope(tmp_var)))); |
| 3392 } | 3407 } |
| 3393 | 3408 |
| 3394 // If this node_sequence is the body of the function being compiled, copy | 3409 // If this node_sequence is the body of the function being compiled, copy |
| 3395 // the captured parameters from the frame into the context. | 3410 // the captured parameters from the frame into the context. |
| 3396 if (node == owner()->parsed_function()->node_sequence()) { | 3411 if (node == owner()->parsed_function()->node_sequence()) { |
| 3397 ASSERT(scope->context_level() == 1); | 3412 ASSERT(scope->context_level() == 1); |
| 3398 const Function& function = owner()->parsed_function()->function(); | 3413 const Function& function = owner()->parsed_function()->function(); |
| 3399 const int num_params = function.NumParameters(); | 3414 const int num_params = function.NumParameters(); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3858 function.token_pos(), | 3873 function.token_pos(), |
| 3859 LanguageError::kError, | 3874 LanguageError::kError, |
| 3860 Heap::kNew, | 3875 Heap::kNew, |
| 3861 "FlowGraphBuilder Bailout: %s %s", | 3876 "FlowGraphBuilder Bailout: %s %s", |
| 3862 String::Handle(function.name()).ToCString(), | 3877 String::Handle(function.name()).ToCString(), |
| 3863 reason)); | 3878 reason)); |
| 3864 Isolate::Current()->long_jump_base()->Jump(1, error); | 3879 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3865 } | 3880 } |
| 3866 | 3881 |
| 3867 } // namespace dart | 3882 } // namespace dart |
| OLD | NEW |