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 } | |
383 node_->AcceptVisitor(this); | 369 node_->AcceptVisitor(this); |
384 } | 370 } |
385 break; | 371 break; |
386 } | 372 } |
387 case RawFunction::kImplicitGetter: | 373 case RawFunction::kImplicitGetter: |
388 case RawFunction::kImplicitStaticFinalGetter: | 374 case RawFunction::kImplicitStaticFinalGetter: |
389 case RawFunction::kImplicitSetter: { | 375 case RawFunction::kImplicitSetter: { |
390 ASSERT(node_->IsField()); | 376 ASSERT(node_->IsField()); |
391 if (IsStaticInitializer(function, Z)) { | 377 if (IsStaticInitializer(function, Z)) { |
392 node_->AcceptVisitor(this); | 378 node_->AcceptVisitor(this); |
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 argument->set_temp_index(argument->temp_index() - 1); | 2528 argument->set_temp_index(argument->temp_index() - 1); |
2543 ++pending_argument_count_; | 2529 ++pending_argument_count_; |
2544 | 2530 |
2545 return Fragment(argument); | 2531 return Fragment(argument); |
2546 } | 2532 } |
2547 | 2533 |
2548 | 2534 |
2549 Fragment FlowGraphBuilder::Return(TokenPosition position) { | 2535 Fragment FlowGraphBuilder::Return(TokenPosition position) { |
2550 Value* value = Pop(); | 2536 Value* value = Pop(); |
2551 ASSERT(stack_ == NULL); | 2537 ASSERT(stack_ == NULL); |
2552 | 2538 ReturnInstr* return_instr = |
2553 Fragment fragment; | 2539 new (Z) ReturnInstr(TokenPosition::kNoSource, value); |
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); | |
2563 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); | 2540 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); |
2564 fragment <<= return_instr; | 2541 return Fragment(return_instr).closed(); |
2565 return fragment.closed(); | |
2566 } | 2542 } |
2567 | 2543 |
2568 | 2544 |
2569 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, | 2545 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, |
2570 const Function& target, | 2546 const Function& target, |
2571 intptr_t argument_count) { | 2547 intptr_t argument_count) { |
2572 return StaticCall(position, target, argument_count, Array::null_array()); | 2548 return StaticCall(position, target, argument_count, Array::null_array()); |
2573 } | 2549 } |
2574 | 2550 |
2575 | 2551 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 LocalVariable* variable) { | 2655 LocalVariable* variable) { |
2680 Fragment instructions; | 2656 Fragment instructions; |
2681 if (variable->is_captured()) { | 2657 if (variable->is_captured()) { |
2682 LocalVariable* value = MakeTemporary(); | 2658 LocalVariable* value = MakeTemporary(); |
2683 instructions += LoadContextAt(variable->owner()->context_level()); | 2659 instructions += LoadContextAt(variable->owner()->context_level()); |
2684 instructions += LoadLocal(value); | 2660 instructions += LoadLocal(value); |
2685 instructions += | 2661 instructions += |
2686 StoreInstanceField(Context::variable_offset(variable->index())); | 2662 StoreInstanceField(Context::variable_offset(variable->index())); |
2687 } else { | 2663 } else { |
2688 Value* value = Pop(); | 2664 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 | |
2700 StoreLocalInstr* store = | 2665 StoreLocalInstr* store = |
2701 new (Z) StoreLocalInstr(*variable, value, position); | 2666 new (Z) StoreLocalInstr(*variable, value, position); |
2702 instructions <<= store; | 2667 instructions <<= store; |
2703 Push(store); | 2668 Push(store); |
2704 } | 2669 } |
2705 return instructions; | 2670 return instructions; |
2706 } | 2671 } |
2707 | 2672 |
2708 | 2673 |
2709 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { | 2674 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3203 | 3168 |
3204 // False branch will contain the next comparison. | 3169 // False branch will contain the next comparison. |
3205 dispatch = Fragment(dispatch.entry, otherwise); | 3170 dispatch = Fragment(dispatch.entry, otherwise); |
3206 block = otherwise; | 3171 block = otherwise; |
3207 } | 3172 } |
3208 body = dispatch; | 3173 body = dispatch; |
3209 | 3174 |
3210 context_depth_ = current_context_depth; | 3175 context_depth_ = current_context_depth; |
3211 } | 3176 } |
3212 | 3177 |
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 | |
3239 normal_entry->LinkTo(body.entry); | 3178 normal_entry->LinkTo(body.entry); |
3240 | 3179 |
3241 // When compiling for OSR, use a depth first search to prune instructions | 3180 // When compiling for OSR, use a depth first search to prune instructions |
3242 // unreachable from the OSR entry. Catch entries are always considered | 3181 // unreachable from the OSR entry. Catch entries are always considered |
3243 // reachable, even if they become unreachable after OSR. | 3182 // reachable, even if they become unreachable after OSR. |
3244 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 3183 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
3245 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); | 3184 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); |
3246 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, | 3185 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, |
3247 block_marks); | 3186 block_marks); |
3248 ASSERT(found); | 3187 ASSERT(found); |
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6106 thread->clear_sticky_error(); | 6045 thread->clear_sticky_error(); |
6107 return error.raw(); | 6046 return error.raw(); |
6108 } | 6047 } |
6109 } | 6048 } |
6110 | 6049 |
6111 | 6050 |
6112 } // namespace kernel | 6051 } // namespace kernel |
6113 } // namespace dart | 6052 } // namespace dart |
6114 | 6053 |
6115 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6054 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |