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