Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: runtime/vm/kernel_to_il.cc

Issue 2690873005: Enable causal stacktrace in kernel (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 (depth_.function_ == 0) ? &result_->yield_context_variable : &temp, 713 (depth_.function_ == 0) ? &result_->yield_context_variable : &temp,
714 Symbols::AwaitContextVar()); 714 Symbols::AwaitContextVar());
715 } 715 }
716 { 716 {
717 LocalVariable* temp = 717 LocalVariable* temp =
718 scope_->LookupVariable(Symbols::AsyncOperation(), true); 718 scope_->LookupVariable(Symbols::AsyncOperation(), true);
719 if (temp != NULL) { 719 if (temp != NULL) {
720 scope_->CaptureVariable(temp); 720 scope_->CaptureVariable(temp);
721 } 721 }
722 } 722 }
723 if (FLAG_causal_async_stacks) {
724 LocalVariable* temp =
725 scope_->LookupVariable(Symbols::AsyncStackTraceVar(), true);
726 if (temp != NULL) {
727 scope_->CaptureVariable(temp);
728 }
729 }
723 } 730 }
724 } 731 }
725 732
726 733
727 void ScopeBuilder::VisitYieldStatement(YieldStatement* node) { 734 void ScopeBuilder::VisitYieldStatement(YieldStatement* node) {
728 ASSERT(node->is_native()); 735 ASSERT(node->is_native());
729 if (depth_.function_ == 0) { 736 if (depth_.function_ == 0) {
730 AddSwitchVariable(); 737 AddSwitchVariable();
731 // Promote all currently visible local variables into the context. 738 // Promote all currently visible local variables into the context.
732 // TODO(27590) CaptureLocalVariables promotes to many variables into 739 // TODO(27590) CaptureLocalVariables promotes to many variables into
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 Value* value = Pop(); 2555 Value* value = Pop();
2549 ASSERT(stack_ == NULL); 2556 ASSERT(stack_ == NULL);
2550 2557
2551 const Function& function = parsed_function_->function(); 2558 const Function& function = parsed_function_->function();
2552 if (FLAG_support_debugger && position.IsDebugPause() && 2559 if (FLAG_support_debugger && position.IsDebugPause() &&
2553 !function.is_native()) { 2560 !function.is_native()) {
2554 instructions <<= 2561 instructions <<=
2555 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall); 2562 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall);
2556 } 2563 }
2557 2564
2565 if (FLAG_causal_async_stacks &&
2566 function.name() == Symbols::AsyncOperation().raw()) {
2567 // We are returning from an asynchronous closure. Before we do that, be
2568 // sure to clear the thread's asynchronous stack trace.
2569 const Function& async_clear_thread_stack_trace = Function::ZoneHandle(
2570 Z, I->object_store()->async_clear_thread_stack_trace());
2571 ZoneGrowableArray<PushArgumentInstr*>* no_arguments =
2572 new (Z) ZoneGrowableArray<PushArgumentInstr*>(0);
2573 StaticCallInstr* call_async_clear_thread_stack_trace = new (Z)
2574 StaticCallInstr(TokenPosition::kNoSource,
2575 async_clear_thread_stack_trace, Object::null_array(),
2576 no_arguments, ic_data_array_);
2577 instructions <<= call_async_clear_thread_stack_trace;
kustermann 2017/02/14 14:45:53 Could you rewrite this using our helper functions,
jensj 2017/02/15 11:29:53 Done.
2578 }
2579
2558 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value); 2580 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value);
2559 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); 2581 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr);
2560 2582
2561 instructions <<= return_instr; 2583 instructions <<= return_instr;
2562 2584
2563 return instructions.closed(); 2585 return instructions.closed();
2564 } 2586 }
2565 2587
2566 2588
2567 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, 2589 Fragment FlowGraphBuilder::StaticCall(TokenPosition position,
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 3252
3231 // False branch will contain the next comparison. 3253 // False branch will contain the next comparison.
3232 dispatch = Fragment(dispatch.entry, otherwise); 3254 dispatch = Fragment(dispatch.entry, otherwise);
3233 block = otherwise; 3255 block = otherwise;
3234 } 3256 }
3235 body = dispatch; 3257 body = dispatch;
3236 3258
3237 context_depth_ = current_context_depth; 3259 context_depth_ = current_context_depth;
3238 } 3260 }
3239 3261
3262 if (FLAG_causal_async_stacks &&
3263 dart_function.name() == Symbols::AsyncOperation().raw()) {
3264 // The code we are building will be executed right after we enter
3265 // the function and before any nested contexts are allocated.
3266 // Reset current context_depth_ to match this.
3267 intptr_t current_context_depth = context_depth_;
kustermann 2017/02/14 14:45:53 nit: const (maybe also from the code you copied it
jensj 2017/02/15 11:29:53 Done.
3268 context_depth_ = scopes_->yield_jump_variable->owner()->context_level();
3269
3270 Fragment instructions;
3271 LocalScope* scope = parsed_function_->node_sequence()->scope();
3272 // Fetch the :async_stack_trace variable and store it into the thread.
kustermann 2017/02/14 14:45:53 Could you add empty lines before comments like thi
jensj 2017/02/15 11:29:53 Done.
3273 LocalVariable* async_stack_trace_var =
3274 scope->LookupVariable(Symbols::AsyncStackTraceVar(), false);
3275 ASSERT((async_stack_trace_var != NULL) &&
3276 async_stack_trace_var->is_captured());
3277 // Load :async_stack_trace
3278 instructions += LoadLocal(async_stack_trace_var);
3279 instructions += PushArgument();
3280 // Setup arguments for _asyncSetThreadStackTrace.
3281 ArgumentArray arguments = GetArguments(1);
3282
3283 const Function& async_set_thread_stack_trace = Function::ZoneHandle(
3284 Z, I->object_store()->async_set_thread_stack_trace());
3285 ASSERT(!async_set_thread_stack_trace.IsNull());
3286 // Call _asyncSetThreadStackTrace
3287 StaticCallInstr* call_async_set_thread_stack_trace = new (Z)
3288 StaticCallInstr(TokenPosition::kNoSource, async_set_thread_stack_trace,
3289 Object::null_array(), arguments, ic_data_array_);
3290 instructions <<= call_async_set_thread_stack_trace;
3291 body = instructions + body;
kustermann 2017/02/14 14:45:53 Could you also use StaticCall here i.e. replace m
jensj 2017/02/15 11:29:53 Done.
3292 context_depth_ = current_context_depth;
3293 }
3294
3240 if (FLAG_support_debugger && function->position().IsDebugPause() && 3295 if (FLAG_support_debugger && function->position().IsDebugPause() &&
3241 !dart_function.is_native() && dart_function.is_debuggable()) { 3296 !dart_function.is_native() && dart_function.is_debuggable()) {
3242 // If a switch was added above: Start the switch by injecting a debugable 3297 // If a switch was added above: Start the switch by injecting a debugable
3243 // safepoint so stepping over an await works. 3298 // safepoint so stepping over an await works.
3244 // If not, still start the body with a debugable safepoint to ensure 3299 // If not, still start the body with a debugable safepoint to ensure
3245 // breaking on a method always happens, even if there are no 3300 // breaking on a method always happens, even if there are no
3246 // assignments/calls/runtimecalls in the first basic block. 3301 // assignments/calls/runtimecalls in the first basic block.
3247 // Place this check at the last parameter to ensure parameters 3302 // Place this check at the last parameter to ensure parameters
3248 // are in scope in the debugger at method entry. 3303 // are in scope in the debugger at method entry.
3249 const int num_params = dart_function.NumParameters(); 3304 const int num_params = dart_function.NumParameters();
(...skipping 3030 matching lines...) Expand 10 before | Expand all | Expand 10 after
6280 thread->clear_sticky_error(); 6335 thread->clear_sticky_error();
6281 return error.raw(); 6336 return error.raw();
6282 } 6337 }
6283 } 6338 }
6284 6339
6285 6340
6286 } // namespace kernel 6341 } // namespace kernel
6287 } // namespace dart 6342 } // namespace dart
6288 6343
6289 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6344 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698