Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
| 10 | 10 |
| (...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 if (named->length() == 0) return Array::ZoneHandle(Z); | 1321 if (named->length() == 0) return Array::ZoneHandle(Z); |
| 1322 | 1322 |
| 1323 const Array& names = | 1323 const Array& names = |
| 1324 Array::ZoneHandle(Z, Array::New(named->length(), Heap::kOld)); | 1324 Array::ZoneHandle(Z, Array::New(named->length(), Heap::kOld)); |
| 1325 for (intptr_t i = 0; i < named->length(); ++i) { | 1325 for (intptr_t i = 0; i < named->length(); ++i) { |
| 1326 names.SetAt(i, DartSymbol((*named)[i]->name())); | 1326 names.SetAt(i, DartSymbol((*named)[i]->name())); |
| 1327 } | 1327 } |
| 1328 return names; | 1328 return names; |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 bool TranslationHelper::ShouldAddDebugInstruction(const Function& function, | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Rename this to something like NeedsDebugStepCheck.
jensj
2017/02/13 14:04:17
Done.
| |
| 1332 TokenPosition position) { | |
| 1333 if (!(FLAG_support_debugger && position.IsDebugPause())) return false; | |
|
Kevin Millikin (Google)
2017/02/08 15:37:53
I think this reads better as:
return FLAG_support
jensj
2017/02/13 14:04:17
Semi-done. git cl format runtime has a different i
| |
| 1334 return !function.is_native() && function.is_debuggable(); | |
| 1335 } | |
| 1336 | |
| 1337 | |
| 1338 bool TranslationHelper::ShouldAddDebugInstruction(Value* value, | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
This function's implementation is cluttered. Sugg
jensj
2017/02/13 14:04:17
Acknowledged.
| |
| 1339 TokenPosition position) { | |
| 1340 if (!(FLAG_support_debugger && position.IsDebugPause())) return false; | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Push negation in (something like negation normal f
jensj
2017/02/13 14:04:17
Done.
| |
| 1341 if (value->definition()->IsConstant()) return true; | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Name value->definition(), it will not change and w
jensj
2017/02/13 14:04:17
Done.
| |
| 1342 if (value->definition()->IsAllocateObject()) { | |
| 1343 return !value->definition() | |
| 1344 ->AsAllocateObject() | |
| 1345 ->closure_function() | |
| 1346 .IsNull(); | |
| 1347 } | |
| 1348 if (value->definition()->IsLoadLocal() && | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Just return the value of the last test:
return de
jensj
2017/02/13 14:04:17
Done.
| |
| 1349 !value->definition()->AsLoadLocal()->local().IsInternal()) { | |
| 1350 return true; | |
| 1351 } | |
| 1352 if (value->definition()->IsLoadStaticField()) return true; | |
| 1353 return false; | |
| 1354 } | |
| 1355 | |
| 1356 Fragment TranslationHelper::GetDebugInstruction(TokenPosition position) { | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Move this to the graph builder. Use the same name
jensj
2017/02/13 14:04:17
Done.
| |
| 1357 return Fragment( | |
| 1358 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall)); | |
| 1359 } | |
| 1360 | |
| 1331 | 1361 |
| 1332 ConstantEvaluator::ConstantEvaluator(FlowGraphBuilder* builder, | 1362 ConstantEvaluator::ConstantEvaluator(FlowGraphBuilder* builder, |
| 1333 Zone* zone, | 1363 Zone* zone, |
| 1334 TranslationHelper* h, | 1364 TranslationHelper* h, |
| 1335 DartTypeTranslator* type_translator) | 1365 DartTypeTranslator* type_translator) |
| 1336 : builder_(builder), | 1366 : builder_(builder), |
| 1337 isolate_(Isolate::Current()), | 1367 isolate_(Isolate::Current()), |
| 1338 zone_(zone), | 1368 zone_(zone), |
| 1339 translation_helper_(*h), | 1369 translation_helper_(*h), |
| 1340 type_translator_(*type_translator), | 1370 type_translator_(*type_translator), |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2060 return instructions; | 2090 return instructions; |
| 2061 } | 2091 } |
| 2062 | 2092 |
| 2063 | 2093 |
| 2064 Fragment FlowGraphBuilder::PushContext(int size) { | 2094 Fragment FlowGraphBuilder::PushContext(int size) { |
| 2065 ASSERT(size > 0); | 2095 ASSERT(size > 0); |
| 2066 Fragment instructions = AllocateContext(size); | 2096 Fragment instructions = AllocateContext(size); |
| 2067 LocalVariable* context = MakeTemporary(); | 2097 LocalVariable* context = MakeTemporary(); |
| 2068 instructions += LoadLocal(context); | 2098 instructions += LoadLocal(context); |
| 2069 instructions += LoadLocal(parsed_function_->current_context_var()); | 2099 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 2070 instructions += StoreInstanceField(Context::parent_offset()); | 2100 instructions += |
| 2101 StoreInstanceField(TokenPosition::kNoSource, Context::parent_offset()); | |
| 2071 instructions += StoreLocal(TokenPosition::kNoSource, | 2102 instructions += StoreLocal(TokenPosition::kNoSource, |
| 2072 parsed_function_->current_context_var()); | 2103 parsed_function_->current_context_var()); |
| 2073 ++context_depth_; | 2104 ++context_depth_; |
| 2074 return instructions; | 2105 return instructions; |
| 2075 } | 2106 } |
| 2076 | 2107 |
| 2077 | 2108 |
| 2078 Fragment FlowGraphBuilder::PopContext() { | 2109 Fragment FlowGraphBuilder::PopContext() { |
| 2079 return AdjustContextTo(context_depth_ - 1); | 2110 return AdjustContextTo(context_depth_ - 1); |
| 2080 } | 2111 } |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2541 | 2572 |
| 2542 | 2573 |
| 2543 Fragment FlowGraphBuilder::Return(TokenPosition position) { | 2574 Fragment FlowGraphBuilder::Return(TokenPosition position) { |
| 2544 Fragment instructions; | 2575 Fragment instructions; |
| 2545 | 2576 |
| 2546 instructions += CheckReturnTypeInCheckedMode(); | 2577 instructions += CheckReturnTypeInCheckedMode(); |
| 2547 | 2578 |
| 2548 Value* value = Pop(); | 2579 Value* value = Pop(); |
| 2549 ASSERT(stack_ == NULL); | 2580 ASSERT(stack_ == NULL); |
| 2550 | 2581 |
| 2551 const Function& function = parsed_function_->function(); | 2582 if (H.ShouldAddDebugInstruction(parsed_function_->function(), position)) { |
| 2552 if (FLAG_support_debugger && position.IsDebugPause() && | 2583 instructions += H.GetDebugInstruction(position); |
| 2553 !function.is_native()) { | |
| 2554 instructions <<= | |
| 2555 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall); | |
| 2556 } | 2584 } |
| 2557 | 2585 |
| 2558 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value); | 2586 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value); |
| 2559 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); | 2587 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); |
| 2560 | 2588 |
| 2561 instructions <<= return_instr; | 2589 instructions <<= return_instr; |
| 2562 | 2590 |
| 2563 return instructions.closed(); | 2591 return instructions.closed(); |
| 2564 } | 2592 } |
| 2565 | 2593 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2663 instructions += GuardFieldClass(field_clone, H.thread()->GetNextDeoptId()); | 2691 instructions += GuardFieldClass(field_clone, H.thread()->GetNextDeoptId()); |
| 2664 instructions += LoadLocal(store_expression); | 2692 instructions += LoadLocal(store_expression); |
| 2665 instructions += GuardFieldLength(field_clone, H.thread()->GetNextDeoptId()); | 2693 instructions += GuardFieldLength(field_clone, H.thread()->GetNextDeoptId()); |
| 2666 } | 2694 } |
| 2667 instructions += StoreInstanceField(field_clone, is_initialization_store); | 2695 instructions += StoreInstanceField(field_clone, is_initialization_store); |
| 2668 return instructions; | 2696 return instructions; |
| 2669 } | 2697 } |
| 2670 | 2698 |
| 2671 | 2699 |
| 2672 Fragment FlowGraphBuilder::StoreInstanceField( | 2700 Fragment FlowGraphBuilder::StoreInstanceField( |
| 2701 TokenPosition position, | |
| 2673 intptr_t offset, | 2702 intptr_t offset, |
| 2674 StoreBarrierType emit_store_barrier) { | 2703 StoreBarrierType emit_store_barrier) { |
| 2675 Value* value = Pop(); | 2704 Value* value = Pop(); |
| 2676 if (value->BindsToConstant()) { | 2705 if (value->BindsToConstant()) { |
| 2677 emit_store_barrier = kNoStoreBarrier; | 2706 emit_store_barrier = kNoStoreBarrier; |
| 2678 } | 2707 } |
| 2679 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( | 2708 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( |
| 2680 offset, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); | 2709 offset, Pop(), value, emit_store_barrier, position); |
| 2681 return Fragment(store); | 2710 return Fragment(store); |
| 2682 } | 2711 } |
| 2683 | 2712 |
| 2684 | 2713 |
| 2685 Fragment FlowGraphBuilder::StoreLocal(TokenPosition position, | 2714 Fragment FlowGraphBuilder::StoreLocal(TokenPosition position, |
| 2686 LocalVariable* variable) { | 2715 LocalVariable* variable) { |
| 2687 Fragment instructions; | 2716 Fragment instructions; |
| 2688 if (variable->is_captured()) { | 2717 if (variable->is_captured()) { |
| 2689 LocalVariable* value = MakeTemporary(); | 2718 LocalVariable* value = MakeTemporary(); |
| 2690 instructions += LoadContextAt(variable->owner()->context_level()); | 2719 instructions += LoadContextAt(variable->owner()->context_level()); |
| 2691 instructions += LoadLocal(value); | 2720 instructions += LoadLocal(value); |
| 2692 instructions += | 2721 instructions += StoreInstanceField( |
| 2693 StoreInstanceField(Context::variable_offset(variable->index())); | 2722 position, Context::variable_offset(variable->index())); |
| 2694 } else { | 2723 } else { |
| 2695 Value* value = Pop(); | 2724 Value* value = Pop(); |
| 2696 if (FLAG_support_debugger && position.IsDebugPause() && | |
| 2697 !variable->IsInternal()) { | |
| 2698 if (value->definition()->IsConstant() || | |
| 2699 value->definition()->IsAllocateObject() || | |
| 2700 (value->definition()->IsLoadLocal() && | |
| 2701 !value->definition()->AsLoadLocal()->local().IsInternal())) { | |
| 2702 instructions <<= new (Z) | |
| 2703 DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall); | |
| 2704 } | |
| 2705 } | |
| 2706 | |
| 2707 StoreLocalInstr* store = | 2725 StoreLocalInstr* store = |
| 2708 new (Z) StoreLocalInstr(*variable, value, position); | 2726 new (Z) StoreLocalInstr(*variable, value, position); |
| 2709 instructions <<= store; | 2727 instructions <<= store; |
| 2710 Push(store); | 2728 Push(store); |
| 2711 } | 2729 } |
| 2712 return instructions; | 2730 return instructions; |
| 2713 } | 2731 } |
| 2714 | 2732 |
| 2715 | 2733 |
| 2716 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { | 2734 Fragment FlowGraphBuilder::StoreStaticField(TokenPosition position, |
| 2717 return Fragment(new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), | 2735 const dart::Field& field) { |
| 2718 TokenPosition::kNoSource)); | 2736 return Fragment( |
| 2737 new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), position)); | |
| 2719 } | 2738 } |
| 2720 | 2739 |
| 2721 | 2740 |
| 2722 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { | 2741 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { |
| 2723 Value* array = Pop(); | 2742 Value* array = Pop(); |
| 2724 StringInterpolateInstr* interpolate = | 2743 StringInterpolateInstr* interpolate = |
| 2725 new (Z) StringInterpolateInstr(array, position); | 2744 new (Z) StringInterpolateInstr(array, position); |
| 2726 Push(interpolate); | 2745 Push(interpolate); |
| 2727 return Fragment(interpolate); | 2746 return Fragment(interpolate); |
| 2728 } | 2747 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3079 parameter->set_index(parameter_index); | 3098 parameter->set_index(parameter_index); |
| 3080 // Mark the stack variable so it will be ignored by the code for | 3099 // Mark the stack variable so it will be ignored by the code for |
| 3081 // try/catch. | 3100 // try/catch. |
| 3082 parameter->set_is_captured_parameter(true); | 3101 parameter->set_is_captured_parameter(true); |
| 3083 | 3102 |
| 3084 // Copy the parameter from the stack to the context. Overwrite it | 3103 // Copy the parameter from the stack to the context. Overwrite it |
| 3085 // with a null constant on the stack so the original value is | 3104 // with a null constant on the stack so the original value is |
| 3086 // eligible for garbage collection. | 3105 // eligible for garbage collection. |
| 3087 body += LoadLocal(context); | 3106 body += LoadLocal(context); |
| 3088 body += LoadLocal(parameter); | 3107 body += LoadLocal(parameter); |
| 3089 body += StoreInstanceField(Context::variable_offset(variable->index())); | 3108 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3109 Context::variable_offset(variable->index())); | |
| 3090 body += NullConstant(); | 3110 body += NullConstant(); |
| 3091 body += StoreLocal(TokenPosition::kNoSource, parameter); | 3111 body += StoreLocal(TokenPosition::kNoSource, parameter); |
| 3092 body += Drop(); | 3112 body += Drop(); |
| 3093 } | 3113 } |
| 3094 } | 3114 } |
| 3095 body += Drop(); // The context. | 3115 body += Drop(); // The context. |
| 3096 } | 3116 } |
| 3097 if (constructor != NULL) { | 3117 if (constructor != NULL) { |
| 3098 // TODO(27590): Currently the [VariableDeclaration]s from the | 3118 // TODO(27590): Currently the [VariableDeclaration]s from the |
| 3099 // initializers will be visible inside the entire body of the constructor. | 3119 // initializers will be visible inside the entire body of the constructor. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3220 TargetEntryInstr* otherwise; | 3240 TargetEntryInstr* otherwise; |
| 3221 dispatch += LoadLocal(scopes_->switch_variable); | 3241 dispatch += LoadLocal(scopes_->switch_variable); |
| 3222 dispatch += IntConstant(i); | 3242 dispatch += IntConstant(i); |
| 3223 dispatch += BranchIfStrictEqual(&then, &otherwise); | 3243 dispatch += BranchIfStrictEqual(&then, &otherwise); |
| 3224 | 3244 |
| 3225 // True branch is linked to appropriate continuation point. | 3245 // True branch is linked to appropriate continuation point. |
| 3226 // Note: continuations start with nop DropTemps instruction | 3246 // Note: continuations start with nop DropTemps instruction |
| 3227 // which acts like an anchor, so we need to skip it. | 3247 // which acts like an anchor, so we need to skip it. |
| 3228 then->LinkTo(yield_continuations_[i].entry->next()); | 3248 then->LinkTo(yield_continuations_[i].entry->next()); |
| 3229 then->set_try_index(yield_continuations_[i].try_index); | 3249 then->set_try_index(yield_continuations_[i].try_index); |
| 3230 | |
| 3231 // False branch will contain the next comparison. | 3250 // False branch will contain the next comparison. |
| 3232 dispatch = Fragment(dispatch.entry, otherwise); | 3251 dispatch = Fragment(dispatch.entry, otherwise); |
| 3233 block = otherwise; | 3252 block = otherwise; |
| 3234 } | 3253 } |
| 3235 body = dispatch; | 3254 body = dispatch; |
| 3236 | 3255 |
| 3237 context_depth_ = current_context_depth; | 3256 context_depth_ = current_context_depth; |
| 3238 } | 3257 } |
| 3239 | 3258 |
| 3240 if (FLAG_support_debugger && function->position().IsDebugPause() && | 3259 if (H.ShouldAddDebugInstruction(dart_function, function->position())) { |
| 3241 !dart_function.is_native() && dart_function.is_debuggable()) { | |
| 3242 // If a switch was added above: Start the switch by injecting a debugable | 3260 // If a switch was added above: Start the switch by injecting a debugable |
| 3243 // safepoint so stepping over an await works. | 3261 // safepoint so stepping over an await works. |
| 3244 // If not, still start the body with a debugable safepoint to ensure | 3262 // If not, still start the body with a debugable safepoint to ensure |
| 3245 // breaking on a method always happens, even if there are no | 3263 // breaking on a method always happens, even if there are no |
| 3246 // assignments/calls/runtimecalls in the first basic block. | 3264 // assignments/calls/runtimecalls in the first basic block. |
| 3247 // Place this check at the last parameter to ensure parameters | 3265 // Place this check at the last parameter to ensure parameters |
| 3248 // are in scope in the debugger at method entry. | 3266 // are in scope in the debugger at method entry. |
| 3249 const int num_params = dart_function.NumParameters(); | 3267 const int num_params = dart_function.NumParameters(); |
| 3250 TokenPosition check_pos = TokenPosition::kNoSource; | 3268 TokenPosition check_pos = TokenPosition::kNoSource; |
| 3251 if (num_params > 0) { | 3269 if (num_params > 0) { |
| 3252 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 3270 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 3253 const LocalVariable& parameter = *scope->VariableAt(num_params - 1); | 3271 const LocalVariable& parameter = *scope->VariableAt(num_params - 1); |
| 3254 check_pos = parameter.token_pos(); | 3272 check_pos = parameter.token_pos(); |
| 3255 } | 3273 } |
| 3256 if (!check_pos.IsDebugPause()) { | 3274 if (!check_pos.IsDebugPause()) { |
| 3257 // No parameters or synthetic parameters. | 3275 // No parameters or synthetic parameters. |
| 3258 check_pos = function->position(); | 3276 check_pos = function->position(); |
| 3259 ASSERT(check_pos.IsDebugPause()); | 3277 ASSERT(check_pos.IsDebugPause()); |
| 3260 } | 3278 } |
| 3261 Fragment check( | 3279 body = H.GetDebugInstruction(check_pos) + body; |
| 3262 new (Z) DebugStepCheckInstr(check_pos, RawPcDescriptors::kRuntimeCall)); | |
| 3263 body = check + body; | |
| 3264 } | 3280 } |
| 3265 | 3281 |
| 3266 normal_entry->LinkTo(body.entry); | 3282 normal_entry->LinkTo(body.entry); |
| 3267 | 3283 |
| 3268 // When compiling for OSR, use a depth first search to prune instructions | 3284 // When compiling for OSR, use a depth first search to prune instructions |
| 3269 // unreachable from the OSR entry. Catch entries are always considered | 3285 // unreachable from the OSR entry. Catch entries are always considered |
| 3270 // reachable, even if they become unreachable after OSR. | 3286 // reachable, even if they become unreachable after OSR. |
| 3271 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 3287 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
| 3272 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); | 3288 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); |
| 3273 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, | 3289 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3358 break; | 3374 break; |
| 3359 case MethodRecognizer::kLinkedHashMap_getIndex: | 3375 case MethodRecognizer::kLinkedHashMap_getIndex: |
| 3360 body += LoadLocal(scopes_->this_variable); | 3376 body += LoadLocal(scopes_->this_variable); |
| 3361 body += LoadNativeField(kind, LinkedHashMap::index_offset(), | 3377 body += LoadNativeField(kind, LinkedHashMap::index_offset(), |
| 3362 Object::dynamic_type(), kDynamicCid); | 3378 Object::dynamic_type(), kDynamicCid); |
| 3363 break; | 3379 break; |
| 3364 case MethodRecognizer::kLinkedHashMap_setIndex: | 3380 case MethodRecognizer::kLinkedHashMap_setIndex: |
| 3365 body += LoadLocal(scopes_->this_variable); | 3381 body += LoadLocal(scopes_->this_variable); |
| 3366 body += LoadLocal( | 3382 body += LoadLocal( |
| 3367 LookupVariable(kernel_function->positional_parameters()[0])); | 3383 LookupVariable(kernel_function->positional_parameters()[0])); |
| 3368 body += StoreInstanceField(LinkedHashMap::index_offset()); | 3384 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3385 LinkedHashMap::index_offset()); | |
| 3369 body += NullConstant(); | 3386 body += NullConstant(); |
| 3370 break; | 3387 break; |
| 3371 case MethodRecognizer::kLinkedHashMap_getData: | 3388 case MethodRecognizer::kLinkedHashMap_getData: |
| 3372 body += LoadLocal(scopes_->this_variable); | 3389 body += LoadLocal(scopes_->this_variable); |
| 3373 body += LoadNativeField(kind, LinkedHashMap::data_offset(), | 3390 body += LoadNativeField(kind, LinkedHashMap::data_offset(), |
| 3374 Object::dynamic_type(), kArrayCid); | 3391 Object::dynamic_type(), kArrayCid); |
| 3375 break; | 3392 break; |
| 3376 case MethodRecognizer::kLinkedHashMap_setData: | 3393 case MethodRecognizer::kLinkedHashMap_setData: |
| 3377 body += LoadLocal(scopes_->this_variable); | 3394 body += LoadLocal(scopes_->this_variable); |
| 3378 body += LoadLocal( | 3395 body += LoadLocal( |
| 3379 LookupVariable(kernel_function->positional_parameters()[0])); | 3396 LookupVariable(kernel_function->positional_parameters()[0])); |
| 3380 body += StoreInstanceField(LinkedHashMap::data_offset()); | 3397 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3398 LinkedHashMap::data_offset()); | |
| 3381 body += NullConstant(); | 3399 body += NullConstant(); |
| 3382 break; | 3400 break; |
| 3383 case MethodRecognizer::kLinkedHashMap_getHashMask: | 3401 case MethodRecognizer::kLinkedHashMap_getHashMask: |
| 3384 body += LoadLocal(scopes_->this_variable); | 3402 body += LoadLocal(scopes_->this_variable); |
| 3385 body += LoadNativeField(kind, LinkedHashMap::hash_mask_offset(), | 3403 body += LoadNativeField(kind, LinkedHashMap::hash_mask_offset(), |
| 3386 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); | 3404 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); |
| 3387 break; | 3405 break; |
| 3388 case MethodRecognizer::kLinkedHashMap_setHashMask: | 3406 case MethodRecognizer::kLinkedHashMap_setHashMask: |
| 3389 body += LoadLocal(scopes_->this_variable); | 3407 body += LoadLocal(scopes_->this_variable); |
| 3390 body += LoadLocal( | 3408 body += LoadLocal( |
| 3391 LookupVariable(kernel_function->positional_parameters()[0])); | 3409 LookupVariable(kernel_function->positional_parameters()[0])); |
| 3392 body += StoreInstanceField(LinkedHashMap::hash_mask_offset(), | 3410 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3411 LinkedHashMap::hash_mask_offset(), | |
| 3393 kNoStoreBarrier); | 3412 kNoStoreBarrier); |
| 3394 body += NullConstant(); | 3413 body += NullConstant(); |
| 3395 break; | 3414 break; |
| 3396 case MethodRecognizer::kLinkedHashMap_getUsedData: | 3415 case MethodRecognizer::kLinkedHashMap_getUsedData: |
| 3397 body += LoadLocal(scopes_->this_variable); | 3416 body += LoadLocal(scopes_->this_variable); |
| 3398 body += LoadNativeField(kind, LinkedHashMap::used_data_offset(), | 3417 body += LoadNativeField(kind, LinkedHashMap::used_data_offset(), |
| 3399 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); | 3418 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); |
| 3400 break; | 3419 break; |
| 3401 case MethodRecognizer::kLinkedHashMap_setUsedData: | 3420 case MethodRecognizer::kLinkedHashMap_setUsedData: |
| 3402 body += LoadLocal(scopes_->this_variable); | 3421 body += LoadLocal(scopes_->this_variable); |
| 3403 body += LoadLocal( | 3422 body += LoadLocal( |
| 3404 LookupVariable(kernel_function->positional_parameters()[0])); | 3423 LookupVariable(kernel_function->positional_parameters()[0])); |
| 3405 body += StoreInstanceField(LinkedHashMap::used_data_offset(), | 3424 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3425 LinkedHashMap::used_data_offset(), | |
| 3406 kNoStoreBarrier); | 3426 kNoStoreBarrier); |
| 3407 body += NullConstant(); | 3427 body += NullConstant(); |
| 3408 break; | 3428 break; |
| 3409 case MethodRecognizer::kLinkedHashMap_getDeletedKeys: | 3429 case MethodRecognizer::kLinkedHashMap_getDeletedKeys: |
| 3410 body += LoadLocal(scopes_->this_variable); | 3430 body += LoadLocal(scopes_->this_variable); |
| 3411 body += LoadNativeField(kind, LinkedHashMap::deleted_keys_offset(), | 3431 body += LoadNativeField(kind, LinkedHashMap::deleted_keys_offset(), |
| 3412 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); | 3432 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid); |
| 3413 break; | 3433 break; |
| 3414 case MethodRecognizer::kLinkedHashMap_setDeletedKeys: | 3434 case MethodRecognizer::kLinkedHashMap_setDeletedKeys: |
| 3415 body += LoadLocal(scopes_->this_variable); | 3435 body += LoadLocal(scopes_->this_variable); |
| 3416 body += LoadLocal( | 3436 body += LoadLocal( |
| 3417 LookupVariable(kernel_function->positional_parameters()[0])); | 3437 LookupVariable(kernel_function->positional_parameters()[0])); |
| 3418 body += StoreInstanceField(LinkedHashMap::deleted_keys_offset(), | 3438 body += StoreInstanceField(TokenPosition::kNoSource, |
| 3439 LinkedHashMap::deleted_keys_offset(), | |
| 3419 kNoStoreBarrier); | 3440 kNoStoreBarrier); |
| 3420 body += NullConstant(); | 3441 body += NullConstant(); |
| 3421 break; | 3442 break; |
| 3422 case MethodRecognizer::kBigint_getNeg: | 3443 case MethodRecognizer::kBigint_getNeg: |
| 3423 body += LoadLocal(scopes_->this_variable); | 3444 body += LoadLocal(scopes_->this_variable); |
| 3424 body += LoadNativeField(kind, Bigint::neg_offset(), | 3445 body += LoadNativeField(kind, Bigint::neg_offset(), |
| 3425 Type::ZoneHandle(Z, Type::BoolType()), kBoolCid); | 3446 Type::ZoneHandle(Z, Type::BoolType()), kBoolCid); |
| 3426 break; | 3447 break; |
| 3427 default: { | 3448 default: { |
| 3428 dart::String& name = dart::String::ZoneHandle(Z, function.native_name()); | 3449 dart::String& name = dart::String::ZoneHandle(Z, function.native_name()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3449 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); | 3470 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
| 3450 | 3471 |
| 3451 Fragment body(normal_entry); | 3472 Fragment body(normal_entry); |
| 3452 if (is_setter) { | 3473 if (is_setter) { |
| 3453 if (is_method) { | 3474 if (is_method) { |
| 3454 body += LoadLocal(scopes_->this_variable); | 3475 body += LoadLocal(scopes_->this_variable); |
| 3455 body += LoadLocal(setter_value); | 3476 body += LoadLocal(setter_value); |
| 3456 body += StoreInstanceFieldGuarded(field, false); | 3477 body += StoreInstanceFieldGuarded(field, false); |
| 3457 } else { | 3478 } else { |
| 3458 body += LoadLocal(setter_value); | 3479 body += LoadLocal(setter_value); |
| 3459 body += StoreStaticField(field); | 3480 body += StoreStaticField(TokenPosition::kNoSource, field); |
| 3460 } | 3481 } |
| 3461 body += NullConstant(); | 3482 body += NullConstant(); |
| 3462 } else if (is_method) { | 3483 } else if (is_method) { |
| 3463 body += LoadLocal(scopes_->this_variable); | 3484 body += LoadLocal(scopes_->this_variable); |
| 3464 body += LoadField(field); | 3485 body += LoadField(field); |
| 3465 } else if (field.is_const()) { | 3486 } else if (field.is_const()) { |
| 3466 // If the parser needs to know the value of an uninitialized constant field | 3487 // If the parser needs to know the value of an uninitialized constant field |
| 3467 // it will set the value to the transition sentinel (used to detect circular | 3488 // it will set the value to the transition sentinel (used to detect circular |
| 3468 // initialization) and then call the implicit getter. Thus, the getter | 3489 // initialization) and then call the implicit getter. Thus, the getter |
| 3469 // cannot contain the InitStaticField instruction that normal static getters | 3490 // cannot contain the InitStaticField instruction that normal static getters |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3518 fragment += AllocateObject(closure_class, target); | 3539 fragment += AllocateObject(closure_class, target); |
| 3519 LocalVariable* closure = MakeTemporary(); | 3540 LocalVariable* closure = MakeTemporary(); |
| 3520 | 3541 |
| 3521 // Allocate a context that closes over `this`. | 3542 // Allocate a context that closes over `this`. |
| 3522 fragment += AllocateContext(1); | 3543 fragment += AllocateContext(1); |
| 3523 LocalVariable* context = MakeTemporary(); | 3544 LocalVariable* context = MakeTemporary(); |
| 3524 | 3545 |
| 3525 // Store the function and the context in the closure. | 3546 // Store the function and the context in the closure. |
| 3526 fragment += LoadLocal(closure); | 3547 fragment += LoadLocal(closure); |
| 3527 fragment += Constant(target); | 3548 fragment += Constant(target); |
| 3528 fragment += StoreInstanceField(Closure::function_offset()); | 3549 fragment += |
| 3550 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); | |
| 3529 | 3551 |
| 3530 fragment += LoadLocal(closure); | 3552 fragment += LoadLocal(closure); |
| 3531 fragment += LoadLocal(context); | 3553 fragment += LoadLocal(context); |
| 3532 fragment += StoreInstanceField(Closure::context_offset()); | 3554 fragment += |
| 3555 StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset()); | |
| 3533 | 3556 |
| 3534 // The context is on top of the operand stack. Store `this`. The context | 3557 // The context is on top of the operand stack. Store `this`. The context |
| 3535 // doesn't need a parent pointer because it doesn't close over anything | 3558 // doesn't need a parent pointer because it doesn't close over anything |
| 3536 // else. | 3559 // else. |
| 3537 fragment += LoadLocal(scopes_->this_variable); | 3560 fragment += LoadLocal(scopes_->this_variable); |
| 3538 fragment += StoreInstanceField(Context::variable_offset(0)); | 3561 fragment += |
| 3562 StoreInstanceField(TokenPosition::kNoSource, Context::variable_offset(0)); | |
| 3539 | 3563 |
| 3540 return fragment; | 3564 return fragment; |
| 3541 } | 3565 } |
| 3542 | 3566 |
| 3543 | 3567 |
| 3544 Fragment FlowGraphBuilder::GuardFieldLength(const dart::Field& field, | 3568 Fragment FlowGraphBuilder::GuardFieldLength(const dart::Field& field, |
| 3545 intptr_t deopt_id) { | 3569 intptr_t deopt_id) { |
| 3546 return Fragment(new (Z) GuardFieldLengthInstr(Pop(), field, deopt_id)); | 3570 return Fragment(new (Z) GuardFieldLengthInstr(Pop(), field, deopt_id)); |
| 3547 } | 3571 } |
| 3548 | 3572 |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4477 | 4501 |
| 4478 | 4502 |
| 4479 void FlowGraphBuilder::VisitVariableGet(VariableGet* node) { | 4503 void FlowGraphBuilder::VisitVariableGet(VariableGet* node) { |
| 4480 fragment_ = LoadLocal(LookupVariable(node->variable())); | 4504 fragment_ = LoadLocal(LookupVariable(node->variable())); |
| 4481 } | 4505 } |
| 4482 | 4506 |
| 4483 | 4507 |
| 4484 void FlowGraphBuilder::VisitVariableSet(VariableSet* node) { | 4508 void FlowGraphBuilder::VisitVariableSet(VariableSet* node) { |
| 4485 Fragment instructions = TranslateExpression(node->expression()); | 4509 Fragment instructions = TranslateExpression(node->expression()); |
| 4486 instructions += CheckVariableTypeInCheckedMode(node->variable()); | 4510 instructions += CheckVariableTypeInCheckedMode(node->variable()); |
| 4511 if (H.ShouldAddDebugInstruction(stack_, node->position())) { | |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
It's not usual that we build the graph by prependi
jensj
2017/02/13 14:04:17
You're right. I think it was somewhat of a 'bad me
| |
| 4512 instructions = H.GetDebugInstruction(node->position()) + instructions; | |
| 4513 } | |
| 4487 instructions += | 4514 instructions += |
| 4488 StoreLocal(node->position(), LookupVariable(node->variable())); | 4515 StoreLocal(node->position(), LookupVariable(node->variable())); |
| 4489 fragment_ = instructions; | 4516 fragment_ = instructions; |
| 4490 } | 4517 } |
| 4491 | 4518 |
| 4492 | 4519 |
| 4493 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) { | 4520 void FlowGraphBuilder::VisitStaticGet(StaticGet* node) { |
| 4494 Member* target = node->target(); | 4521 Member* target = node->target(); |
| 4495 if (target->IsField()) { | 4522 if (target->IsField()) { |
| 4496 Field* kernel_field = Field::Cast(target); | 4523 Field* kernel_field = Field::Cast(target); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4530 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { | 4557 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { |
| 4531 Member* target = node->target(); | 4558 Member* target = node->target(); |
| 4532 if (target->IsField()) { | 4559 if (target->IsField()) { |
| 4533 Field* kernel_field = Field::Cast(target); | 4560 Field* kernel_field = Field::Cast(target); |
| 4534 const dart::Field& field = | 4561 const dart::Field& field = |
| 4535 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); | 4562 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); |
| 4536 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); | 4563 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); |
| 4537 Fragment instructions = TranslateExpression(node->expression()); | 4564 Fragment instructions = TranslateExpression(node->expression()); |
| 4538 instructions += CheckAssignableInCheckedMode( | 4565 instructions += CheckAssignableInCheckedMode( |
| 4539 dst_type, dart::String::ZoneHandle(Z, field.name())); | 4566 dst_type, dart::String::ZoneHandle(Z, field.name())); |
| 4567 if (H.ShouldAddDebugInstruction(stack_, node->position())) { | |
| 4568 instructions = H.GetDebugInstruction(node->position()) + instructions; | |
|
Kevin Millikin (Google)
2017/02/08 15:37:53
Call DebugStepCheck() after TranslateExpression, n
jensj
2017/02/13 14:04:17
Done.
| |
| 4569 } | |
| 4540 LocalVariable* variable = MakeTemporary(); | 4570 LocalVariable* variable = MakeTemporary(); |
| 4541 instructions += LoadLocal(variable); | 4571 instructions += LoadLocal(variable); |
| 4542 fragment_ = instructions + StoreStaticField(field); | 4572 fragment_ = instructions + StoreStaticField(node->position(), field); |
| 4543 } else { | 4573 } else { |
| 4544 ASSERT(target->IsProcedure()); | 4574 ASSERT(target->IsProcedure()); |
| 4545 | 4575 |
| 4546 // Evaluate the expression on the right hand side. | 4576 // Evaluate the expression on the right hand side. |
| 4547 Fragment instructions = TranslateExpression(node->expression()); | 4577 Fragment instructions = TranslateExpression(node->expression()); |
| 4548 LocalVariable* variable = MakeTemporary(); | 4578 LocalVariable* variable = MakeTemporary(); |
| 4549 | 4579 |
| 4550 // Prepare argument. | 4580 // Prepare argument. |
| 4551 instructions += LoadLocal(variable); | 4581 instructions += LoadLocal(variable); |
| 4552 instructions += PushArgument(); | 4582 instructions += PushArgument(); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4958 instructions += LoadInstantiatorTypeArguments(); | 4988 instructions += LoadInstantiatorTypeArguments(); |
| 4959 } else { | 4989 } else { |
| 4960 instructions += NullConstant(); | 4990 instructions += NullConstant(); |
| 4961 } | 4991 } |
| 4962 instructions += PushArgument(); // Type arguments. | 4992 instructions += PushArgument(); // Type arguments. |
| 4963 | 4993 |
| 4964 instructions += Constant(type); | 4994 instructions += Constant(type); |
| 4965 instructions += PushArgument(); // Type. | 4995 instructions += PushArgument(); // Type. |
| 4966 | 4996 |
| 4967 instructions += InstanceCall( | 4997 instructions += InstanceCall( |
| 4968 TokenPosition::kNoSource, | 4998 node->position(), dart::Library::PrivateCoreLibName(Symbols::_as()), |
| 4969 dart::Library::PrivateCoreLibName(Symbols::_as()), Token::kAS, 3); | 4999 Token::kAS, 3); |
| 4970 } | 5000 } |
| 4971 | 5001 |
| 4972 fragment_ = instructions; | 5002 fragment_ = instructions; |
| 4973 } | 5003 } |
| 4974 | 5004 |
| 4975 | 5005 |
| 4976 void FlowGraphBuilder::VisitConditionalExpression(ConditionalExpression* node) { | 5006 void FlowGraphBuilder::VisitConditionalExpression(ConditionalExpression* node) { |
| 4977 bool negate; | 5007 bool negate; |
| 4978 Fragment instructions = TranslateCondition(node->condition(), &negate); | 5008 Fragment instructions = TranslateCondition(node->condition(), &negate); |
| 4979 | 5009 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5183 Fragment instructions = TranslateStatement(node->variable()); | 5213 Fragment instructions = TranslateStatement(node->variable()); |
| 5184 instructions += TranslateExpression(node->body()); | 5214 instructions += TranslateExpression(node->body()); |
| 5185 fragment_ = instructions; | 5215 fragment_ = instructions; |
| 5186 } | 5216 } |
| 5187 | 5217 |
| 5188 | 5218 |
| 5189 void FlowGraphBuilder::VisitThrow(Throw* node) { | 5219 void FlowGraphBuilder::VisitThrow(Throw* node) { |
| 5190 Fragment instructions; | 5220 Fragment instructions; |
| 5191 | 5221 |
| 5192 instructions += TranslateExpression(node->expression()); | 5222 instructions += TranslateExpression(node->expression()); |
| 5223 if (H.ShouldAddDebugInstruction(stack_, node->position())) { | |
| 5224 instructions = H.GetDebugInstruction(node->position()) + instructions; | |
| 5225 } | |
| 5193 instructions += PushArgument(); | 5226 instructions += PushArgument(); |
| 5194 instructions += ThrowException(node->position()); | 5227 instructions += ThrowException(node->position()); |
| 5195 ASSERT(instructions.is_closed()); | 5228 ASSERT(instructions.is_closed()); |
| 5196 | 5229 |
| 5197 fragment_ = instructions; | 5230 fragment_ = instructions; |
| 5198 } | 5231 } |
| 5199 | 5232 |
| 5200 | 5233 |
| 5201 void FlowGraphBuilder::VisitRethrow(Rethrow* node) { | 5234 void FlowGraphBuilder::VisitRethrow(Rethrow* node) { |
| 5202 Fragment instructions; | 5235 Fragment instructions; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5261 | 5294 |
| 5262 void FlowGraphBuilder::VisitReturnStatement(ReturnStatement* node) { | 5295 void FlowGraphBuilder::VisitReturnStatement(ReturnStatement* node) { |
| 5263 bool inside_try_finally = try_finally_block_ != NULL; | 5296 bool inside_try_finally = try_finally_block_ != NULL; |
| 5264 | 5297 |
| 5265 Fragment instructions = node->expression() == NULL | 5298 Fragment instructions = node->expression() == NULL |
| 5266 ? NullConstant() | 5299 ? NullConstant() |
| 5267 : TranslateExpression(node->expression()); | 5300 : TranslateExpression(node->expression()); |
| 5268 if (instructions.is_open()) { | 5301 if (instructions.is_open()) { |
| 5269 if (inside_try_finally) { | 5302 if (inside_try_finally) { |
| 5270 ASSERT(scopes_->finally_return_variable != NULL); | 5303 ASSERT(scopes_->finally_return_variable != NULL); |
| 5271 instructions += StoreLocal(TokenPosition::kNoSource, | 5304 const Function& function = parsed_function_->function(); |
| 5272 scopes_->finally_return_variable); | 5305 if (H.ShouldAddDebugInstruction(function, node->position())) { |
| 5306 instructions += H.GetDebugInstruction(node->position()); | |
| 5307 } | |
| 5308 instructions += | |
| 5309 StoreLocal(node->position(), scopes_->finally_return_variable); | |
| 5273 instructions += Drop(); | 5310 instructions += Drop(); |
| 5274 instructions += TranslateFinallyFinalizers(NULL, -1); | 5311 instructions += TranslateFinallyFinalizers(NULL, -1); |
| 5275 if (instructions.is_open()) { | 5312 if (instructions.is_open()) { |
| 5276 instructions += LoadLocal(scopes_->finally_return_variable); | 5313 instructions += LoadLocal(scopes_->finally_return_variable); |
| 5277 instructions += Return(node->position()); | 5314 instructions += Return(TokenPosition::kNoSource); |
| 5278 } | 5315 } |
| 5279 } else { | 5316 } else { |
| 5280 instructions += Return(node->position()); | 5317 instructions += Return(node->position()); |
| 5281 } | 5318 } |
| 5282 } else { | 5319 } else { |
| 5283 Pop(); | 5320 Pop(); |
| 5284 } | 5321 } |
| 5285 fragment_ = instructions; | 5322 fragment_ = instructions; |
| 5286 } | 5323 } |
| 5287 | 5324 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 5304 if (node->IsConst()) { | 5341 if (node->IsConst()) { |
| 5305 const Instance& constant_value = | 5342 const Instance& constant_value = |
| 5306 constant_evaluator_.EvaluateExpression(initializer); | 5343 constant_evaluator_.EvaluateExpression(initializer); |
| 5307 variable->SetConstValue(constant_value); | 5344 variable->SetConstValue(constant_value); |
| 5308 instructions += Constant(constant_value); | 5345 instructions += Constant(constant_value); |
| 5309 } else { | 5346 } else { |
| 5310 instructions += TranslateExpression(initializer); | 5347 instructions += TranslateExpression(initializer); |
| 5311 instructions += CheckVariableTypeInCheckedMode(node); | 5348 instructions += CheckVariableTypeInCheckedMode(node); |
| 5312 } | 5349 } |
| 5313 } | 5350 } |
| 5314 instructions += StoreLocal(variable->token_pos(), variable); | 5351 // In parser.cc's Parser::ParseVariableDeclaration the position is actually |
|
Kevin Millikin (Google)
2017/02/08 15:37:52
Don't refer to the (other) producer(s) of this val
jensj
2017/02/13 14:04:17
Done.
| |
| 5352 // the position of the equal sign, or in the case of no initialization the | |
| 5353 // identifier token position. Taking the max of position (the identifier | |
| 5354 // position) and equals_position (the position of equals, or noSource) | |
| 5355 // gives the same result. | |
| 5356 TokenPosition debug_position = | |
| 5357 Utils::Maximum(node->position(), node->equals_position()); | |
| 5358 if (H.ShouldAddDebugInstruction(stack_, debug_position)) { | |
| 5359 instructions = H.GetDebugInstruction(debug_position) + instructions; | |
| 5360 } | |
| 5361 instructions += StoreLocal(node->position(), variable); | |
| 5315 instructions += Drop(); | 5362 instructions += Drop(); |
| 5316 fragment_ = instructions; | 5363 fragment_ = instructions; |
| 5317 } | 5364 } |
| 5318 | 5365 |
| 5319 | 5366 |
| 5320 void FlowGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { | 5367 void FlowGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* node) { |
| 5321 Fragment instructions = TranslateFunctionNode(node->function(), node); | 5368 Fragment instructions = H.GetDebugInstruction(node->position()); |
| 5369 instructions += TranslateFunctionNode(node->function(), node); | |
| 5322 instructions += | 5370 instructions += |
| 5323 StoreLocal(TokenPosition::kNoSource, LookupVariable(node->variable())); | 5371 StoreLocal(node->position(), LookupVariable(node->variable())); |
| 5324 instructions += Drop(); | 5372 instructions += Drop(); |
| 5325 fragment_ = instructions; | 5373 fragment_ = instructions; |
| 5326 } | 5374 } |
| 5327 | 5375 |
| 5328 | 5376 |
| 5329 void FlowGraphBuilder::VisitIfStatement(IfStatement* node) { | 5377 void FlowGraphBuilder::VisitIfStatement(IfStatement* node) { |
| 5330 bool negate; | 5378 bool negate; |
| 5331 Fragment instructions = TranslateCondition(node->condition(), &negate); | 5379 Fragment instructions = TranslateCondition(node->condition(), &negate); |
| 5332 TargetEntryInstr* then_entry; | 5380 TargetEntryInstr* then_entry; |
| 5333 TargetEntryInstr* otherwise_entry; | 5381 TargetEntryInstr* otherwise_entry; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5552 void FlowGraphBuilder::VisitBreakStatement(BreakStatement* node) { | 5600 void FlowGraphBuilder::VisitBreakStatement(BreakStatement* node) { |
| 5553 TryFinallyBlock* outer_finally = NULL; | 5601 TryFinallyBlock* outer_finally = NULL; |
| 5554 intptr_t target_context_depth = -1; | 5602 intptr_t target_context_depth = -1; |
| 5555 JoinEntryInstr* destination = breakable_block_->BreakDestination( | 5603 JoinEntryInstr* destination = breakable_block_->BreakDestination( |
| 5556 node->target(), &outer_finally, &target_context_depth); | 5604 node->target(), &outer_finally, &target_context_depth); |
| 5557 | 5605 |
| 5558 Fragment instructions; | 5606 Fragment instructions; |
| 5559 instructions += | 5607 instructions += |
| 5560 TranslateFinallyFinalizers(outer_finally, target_context_depth); | 5608 TranslateFinallyFinalizers(outer_finally, target_context_depth); |
| 5561 if (instructions.is_open()) { | 5609 if (instructions.is_open()) { |
| 5610 if (H.ShouldAddDebugInstruction(parsed_function_->function(), | |
| 5611 node->position())) { | |
| 5612 instructions += H.GetDebugInstruction(node->position()); | |
| 5613 } | |
| 5562 instructions += Goto(destination); | 5614 instructions += Goto(destination); |
| 5563 } | 5615 } |
| 5564 fragment_ = instructions; | 5616 fragment_ = instructions; |
| 5565 } | 5617 } |
| 5566 | 5618 |
| 5567 | 5619 |
| 5568 void FlowGraphBuilder::VisitSwitchStatement(SwitchStatement* node) { | 5620 void FlowGraphBuilder::VisitSwitchStatement(SwitchStatement* node) { |
| 5569 SwitchBlock block(this, node); | 5621 SwitchBlock block(this, node); |
| 5570 | 5622 |
| 5571 // Instead of using a variable we should reuse the expression on the stack, | 5623 // Instead of using a variable we should reuse the expression on the stack, |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6157 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); | 6209 dart::Class::ZoneHandle(Z, I->object_store()->closure_class()); |
| 6158 ASSERT(!closure_class.IsNull()); | 6210 ASSERT(!closure_class.IsNull()); |
| 6159 Fragment instructions = AllocateObject(closure_class, function); | 6211 Fragment instructions = AllocateObject(closure_class, function); |
| 6160 LocalVariable* closure = MakeTemporary(); | 6212 LocalVariable* closure = MakeTemporary(); |
| 6161 | 6213 |
| 6162 // TODO(27590): Generic closures need type arguments. | 6214 // TODO(27590): Generic closures need type arguments. |
| 6163 | 6215 |
| 6164 // Store the function and the context in the closure. | 6216 // Store the function and the context in the closure. |
| 6165 instructions += LoadLocal(closure); | 6217 instructions += LoadLocal(closure); |
| 6166 instructions += Constant(function); | 6218 instructions += Constant(function); |
| 6167 instructions += StoreInstanceField(Closure::function_offset()); | 6219 instructions += |
| 6220 StoreInstanceField(TokenPosition::kNoSource, Closure::function_offset()); | |
| 6168 | 6221 |
| 6169 instructions += LoadLocal(closure); | 6222 instructions += LoadLocal(closure); |
| 6170 instructions += LoadLocal(parsed_function_->current_context_var()); | 6223 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 6171 instructions += StoreInstanceField(Closure::context_offset()); | 6224 instructions += |
| 6225 StoreInstanceField(TokenPosition::kNoSource, Closure::context_offset()); | |
| 6172 | 6226 |
| 6173 return instructions; | 6227 return instructions; |
| 6174 } | 6228 } |
| 6175 | 6229 |
| 6176 | 6230 |
| 6177 RawObject* EvaluateMetadata(TreeNode* const kernel_node) { | 6231 RawObject* EvaluateMetadata(TreeNode* const kernel_node) { |
| 6178 LongJumpScope jump; | 6232 LongJumpScope jump; |
| 6179 if (setjmp(*jump.Set()) == 0) { | 6233 if (setjmp(*jump.Set()) == 0) { |
| 6180 Thread* thread = Thread::Current(); | 6234 Thread* thread = Thread::Current(); |
| 6181 Zone* zone_ = thread->zone(); | 6235 Zone* zone_ = thread->zone(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6280 thread->clear_sticky_error(); | 6334 thread->clear_sticky_error(); |
| 6281 return error.raw(); | 6335 return error.raw(); |
| 6282 } | 6336 } |
| 6283 } | 6337 } |
| 6284 | 6338 |
| 6285 | 6339 |
| 6286 } // namespace kernel | 6340 } // namespace kernel |
| 6287 } // namespace dart | 6341 } // namespace dart |
| 6288 | 6342 |
| 6289 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6343 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |