a0ee5b24db
This CL improves the stack traces that accompany exceptions. Whenever an async function is entered, we remember how we got there. This is similar in spirit to package:stack_trace but the implementation is more efficient and memory usage can be more easily reasoned about. Tracking causal stack traces: - [x] Upon entry to an async function, capture the synchronous stack trace prefix and store it into the closure. - [x] Upon entry to an async* function, capture the synchronous stack trace prefix and store it into the closure. - [x] Before returning from an async function, clear the Thread's asynchronous stack trace. - [x] After resuming an async function, load the sychronous stack trace prefix into the Thread. - [x] Filter stack traces to remove async machinery. Service protocol changes: - [x] Send causal async stack trace. Observatory changes: - [x] Display causal async stack trace below async functions. Fixes https://github.com/dart-lang/sdk/issues/27661 R=asiva@google.com, rmacnak@google.com Comparisons: https://docs.google.com/a/google.com/document/d/10r6jEqr8OCiDZ4y9SYU_uOimcHiOGAZMly2ghTErALI/edit?usp=sharing Review-Url: https://codereview.chromium.org/2646443005 .
112 lines
2.7 KiB
C++
112 lines
2.7 KiB
C++
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/globals.h"
|
|
#if defined(TARGET_ARCH_DBC)
|
|
|
|
#include "vm/assembler.h"
|
|
#include "vm/code_generator.h"
|
|
#include "vm/cpu.h"
|
|
#include "vm/compiler.h"
|
|
#include "vm/dart_entry.h"
|
|
#include "vm/flow_graph_compiler.h"
|
|
#include "vm/heap.h"
|
|
#include "vm/instructions.h"
|
|
#include "vm/object_store.h"
|
|
#include "vm/stack_frame.h"
|
|
#include "vm/stub_code.h"
|
|
#include "vm/tags.h"
|
|
|
|
#define __ assembler->
|
|
|
|
namespace dart {
|
|
|
|
DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
|
|
DEFINE_FLAG(bool,
|
|
use_slow_path,
|
|
false,
|
|
"Set to true for debugging & verifying the slow paths.");
|
|
DECLARE_FLAG(bool, trace_optimized_ic_calls);
|
|
|
|
void StubCode::GenerateLazyCompileStub(Assembler* assembler) {
|
|
__ Compile();
|
|
}
|
|
|
|
|
|
// Not executed, but used as a stack marker when calling
|
|
// DRT_OptimizeInvokedFunction.
|
|
void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// Not executed, but used as a sentinel in Simulator::JumpToFrame.
|
|
void StubCode::GenerateRunExceptionHandlerStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// Not executed, but used as a sentinel in Simulator::JumpToFrame.
|
|
void StubCode::GenerateDeoptForRewindStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// TODO(vegorov) Don't generate this stub.
|
|
void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// TODO(vegorov) Don't generate these stubs.
|
|
void StubCode::GenerateAllocationStubForClass(Assembler* assembler,
|
|
const Class& cls) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// TODO(vegorov) Don't generate this stub.
|
|
void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// These deoptimization stubs are only used to populate stack frames
|
|
// with something meaningful to make sure GC can scan the stack during
|
|
// the last phase of deoptimization which materializes objects.
|
|
void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
void StubCode::GenerateDeoptimizeLazyFromThrowStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
void StubCode::GenerateDeoptimizeStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) {
|
|
__ Trap();
|
|
}
|
|
|
|
|
|
// Print the stop message.
|
|
DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, 1, const char* message) {
|
|
OS::Print("Stop message: %s\n", message);
|
|
}
|
|
END_LEAF_RUNTIME_ENTRY
|
|
|
|
} // namespace dart
|
|
|
|
#endif // defined TARGET_ARCH_DBC
|