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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); | 359 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); |
360 scope_->InsertParameterAt(pos++, variable); | 360 scope_->InsertParameterAt(pos++, variable); |
361 result_->type_arguments_variable = variable; | 361 result_->type_arguments_variable = variable; |
362 } | 362 } |
363 AddParameters(node, pos); | 363 AddParameters(node, pos); |
364 | 364 |
365 // We generate a syntethic body for implicit closure functions - which | 365 // We generate a syntethic body for implicit closure functions - which |
366 // will forward the call to the real function. | 366 // will forward the call to the real function. |
367 // -> see BuildGraphOfImplicitClosureFunction | 367 // -> see BuildGraphOfImplicitClosureFunction |
368 if (!function.IsImplicitClosureFunction()) { | 368 if (!function.IsImplicitClosureFunction()) { |
| 369 // TODO(jensj): HACK: Push the begin token to after any parameters to |
| 370 // avoid crash when breaking on definition line of async method in |
| 371 // debugger. It seems that another scope needs to be added |
| 372 // in which captures are made, but I can't make that work. |
| 373 // This 'solution' doesn't crash, but I cannot see the parameters at |
| 374 // that particular breakpoint either. |
| 375 // Also push the end token to after the "}" to avoid crashing on |
| 376 // stepping past the last line (to the "}" character). |
| 377 if (node->body() != NULL && node->body()->position().IsReal()) { |
| 378 scope_->set_begin_token_pos(node->body()->position()); |
| 379 } |
| 380 if (scope_->end_token_pos().IsReal()) { |
| 381 scope_->set_end_token_pos(scope_->end_token_pos().Next()); |
| 382 } |
369 node_->AcceptVisitor(this); | 383 node_->AcceptVisitor(this); |
370 } | 384 } |
371 break; | 385 break; |
372 } | 386 } |
373 case RawFunction::kImplicitGetter: | 387 case RawFunction::kImplicitGetter: |
374 case RawFunction::kImplicitStaticFinalGetter: | 388 case RawFunction::kImplicitStaticFinalGetter: |
375 case RawFunction::kImplicitSetter: { | 389 case RawFunction::kImplicitSetter: { |
376 ASSERT(node_->IsField()); | 390 ASSERT(node_->IsField()); |
377 if (IsStaticInitializer(function, Z)) { | 391 if (IsStaticInitializer(function, Z)) { |
378 node_->AcceptVisitor(this); | 392 node_->AcceptVisitor(this); |
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 argument->set_temp_index(argument->temp_index() - 1); | 2542 argument->set_temp_index(argument->temp_index() - 1); |
2529 ++pending_argument_count_; | 2543 ++pending_argument_count_; |
2530 | 2544 |
2531 return Fragment(argument); | 2545 return Fragment(argument); |
2532 } | 2546 } |
2533 | 2547 |
2534 | 2548 |
2535 Fragment FlowGraphBuilder::Return(TokenPosition position) { | 2549 Fragment FlowGraphBuilder::Return(TokenPosition position) { |
2536 Value* value = Pop(); | 2550 Value* value = Pop(); |
2537 ASSERT(stack_ == NULL); | 2551 ASSERT(stack_ == NULL); |
2538 ReturnInstr* return_instr = | 2552 |
2539 new (Z) ReturnInstr(TokenPosition::kNoSource, value); | 2553 Fragment fragment; |
| 2554 |
| 2555 const Function& function = parsed_function_->function(); |
| 2556 if (FLAG_support_debugger && position.IsDebugPause() && |
| 2557 !function.is_native()) { |
| 2558 fragment <<= |
| 2559 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall); |
| 2560 } |
| 2561 |
| 2562 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value); |
2540 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); | 2563 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); |
2541 return Fragment(return_instr).closed(); | 2564 fragment <<= return_instr; |
| 2565 return fragment.closed(); |
2542 } | 2566 } |
2543 | 2567 |
2544 | 2568 |
2545 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, | 2569 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, |
2546 const Function& target, | 2570 const Function& target, |
2547 intptr_t argument_count) { | 2571 intptr_t argument_count) { |
2548 return StaticCall(position, target, argument_count, Array::null_array()); | 2572 return StaticCall(position, target, argument_count, Array::null_array()); |
2549 } | 2573 } |
2550 | 2574 |
2551 | 2575 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 LocalVariable* variable) { | 2679 LocalVariable* variable) { |
2656 Fragment instructions; | 2680 Fragment instructions; |
2657 if (variable->is_captured()) { | 2681 if (variable->is_captured()) { |
2658 LocalVariable* value = MakeTemporary(); | 2682 LocalVariable* value = MakeTemporary(); |
2659 instructions += LoadContextAt(variable->owner()->context_level()); | 2683 instructions += LoadContextAt(variable->owner()->context_level()); |
2660 instructions += LoadLocal(value); | 2684 instructions += LoadLocal(value); |
2661 instructions += | 2685 instructions += |
2662 StoreInstanceField(Context::variable_offset(variable->index())); | 2686 StoreInstanceField(Context::variable_offset(variable->index())); |
2663 } else { | 2687 } else { |
2664 Value* value = Pop(); | 2688 Value* value = Pop(); |
| 2689 if (FLAG_support_debugger && position.IsDebugPause() && |
| 2690 !variable->IsInternal()) { |
| 2691 if (value->definition()->IsConstant() || |
| 2692 value->definition()->IsAllocateObject() || |
| 2693 (value->definition()->IsLoadLocal() && |
| 2694 !value->definition()->AsLoadLocal()->local().IsInternal())) { |
| 2695 instructions <<= new (Z) |
| 2696 DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall); |
| 2697 } |
| 2698 } |
| 2699 |
2665 StoreLocalInstr* store = | 2700 StoreLocalInstr* store = |
2666 new (Z) StoreLocalInstr(*variable, value, position); | 2701 new (Z) StoreLocalInstr(*variable, value, position); |
2667 instructions <<= store; | 2702 instructions <<= store; |
2668 Push(store); | 2703 Push(store); |
2669 } | 2704 } |
2670 return instructions; | 2705 return instructions; |
2671 } | 2706 } |
2672 | 2707 |
2673 | 2708 |
2674 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { | 2709 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3168 | 3203 |
3169 // False branch will contain the next comparison. | 3204 // False branch will contain the next comparison. |
3170 dispatch = Fragment(dispatch.entry, otherwise); | 3205 dispatch = Fragment(dispatch.entry, otherwise); |
3171 block = otherwise; | 3206 block = otherwise; |
3172 } | 3207 } |
3173 body = dispatch; | 3208 body = dispatch; |
3174 | 3209 |
3175 context_depth_ = current_context_depth; | 3210 context_depth_ = current_context_depth; |
3176 } | 3211 } |
3177 | 3212 |
| 3213 if (FLAG_support_debugger && function->position().IsDebugPause() && |
| 3214 !dart_function.is_native() && dart_function.is_debuggable()) { |
| 3215 // If a switch was added above: Start the switch by injecting a debugable |
| 3216 // safepoint so stepping over an await works. |
| 3217 // If not, still start the body with a debugable safepoint to ensure |
| 3218 // breaking on a method always happens, even if there are no |
| 3219 // assignments/calls/runtimecalls in the first basic block. |
| 3220 // Place this check at the last parameter to ensure parameters |
| 3221 // are in scope in the debugger at method entry. |
| 3222 const int num_params = dart_function.NumParameters(); |
| 3223 TokenPosition check_pos = TokenPosition::kNoSource; |
| 3224 if (num_params > 0) { |
| 3225 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 3226 const LocalVariable& parameter = *scope->VariableAt(num_params - 1); |
| 3227 check_pos = parameter.token_pos(); |
| 3228 } |
| 3229 if (!check_pos.IsDebugPause()) { |
| 3230 // No parameters or synthetic parameters. |
| 3231 check_pos = function->position(); |
| 3232 ASSERT(check_pos.IsDebugPause()); |
| 3233 } |
| 3234 Fragment check( |
| 3235 new (Z) DebugStepCheckInstr(check_pos, RawPcDescriptors::kRuntimeCall)); |
| 3236 body = check + body; |
| 3237 } |
| 3238 |
3178 normal_entry->LinkTo(body.entry); | 3239 normal_entry->LinkTo(body.entry); |
3179 | 3240 |
3180 // When compiling for OSR, use a depth first search to prune instructions | 3241 // When compiling for OSR, use a depth first search to prune instructions |
3181 // unreachable from the OSR entry. Catch entries are always considered | 3242 // unreachable from the OSR entry. Catch entries are always considered |
3182 // reachable, even if they become unreachable after OSR. | 3243 // reachable, even if they become unreachable after OSR. |
3183 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 3244 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
3184 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); | 3245 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); |
3185 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, | 3246 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, |
3186 block_marks); | 3247 block_marks); |
3187 ASSERT(found); | 3248 ASSERT(found); |
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6045 thread->clear_sticky_error(); | 6106 thread->clear_sticky_error(); |
6046 return error.raw(); | 6107 return error.raw(); |
6047 } | 6108 } |
6048 } | 6109 } |
6049 | 6110 |
6050 | 6111 |
6051 } // namespace kernel | 6112 } // namespace kernel |
6052 } // namespace dart | 6113 } // namespace dart |
6053 | 6114 |
6054 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6115 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |