Flutter Engine
The Flutter Engine
stack_trace.h
Go to the documentation of this file.
1// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5#ifndef RUNTIME_VM_STACK_TRACE_H_
6#define RUNTIME_VM_STACK_TRACE_H_
7
8#include <functional>
9
10#include "vm/allocation.h"
11#include "vm/flag_list.h"
12#include "vm/object.h"
13#include "vm/symbols.h"
14
15namespace dart {
16
17class StackTraceUtils : public AllStatic {
18 public:
19 static constexpr uword kFutureListenerPcOffset = 1;
20
21 struct Frame {
22 // Corresponding on stack frame or |nullptr| if this is an awaiter frame
23 // or a gap.
25
26 // Code object corresponding to this frame.
27 const Code& code;
28
29 // Offset into the code object corresponding to this frame.
30 //
31 // Will be set to |kFutureListenerPcOffset| if this frame corresponds to
32 // future listener that is not yet executing.
34
35 // Closure corresponding to the awaiter frame or |null| if this is
36 // a synchronous frame or a gap.
38 };
39
40 // Returns |true| if this function is needed to correctly unwind through
41 // awaiter chains. This means AOT compiler should retain |Function| object,
42 // its signature and the corresponding |Code| object (so that we could
43 // perform the reverse lookup).
45
46 // Returns |true| if the given class might serve as an awaiter-link when
47 // unwinding an awaiter chain.
48 //
49 // This is used to eagerly mark tear-offs of methods on this class
50 // as having an awaiter-link.
51 static bool IsPossibleAwaiterLink(const Class& cls);
52
53 /// Collects all frames on the current stack until an async/async* frame is
54 /// hit which has yielded before (i.e. is not in sync-async case).
55 ///
56 /// From there on finds the closure of the async/async* frame and starts
57 /// traversing the listeners.
58 static void CollectFrames(
59 Thread* thread,
60 int skip_frames,
61 const std::function<void(const Frame&)>& handle_frame,
62 bool* has_async_catch_error = nullptr);
63
64 // If |closure| has an awaiter-link pointing to the |SuspendState|
65 // the return that object.
66 static bool GetSuspendState(const Closure& closure, Object* suspend_state);
67};
68
69} // namespace dart
70
71#endif // RUNTIME_VM_STACK_TRACE_H_
static bool IsNeededForAsyncAwareUnwinding(const Function &function)
Definition: stack_trace.cc:730
static bool GetSuspendState(const Closure &closure, Object *suspend_state)
Definition: stack_trace.cc:754
static void CollectFrames(Thread *thread, int skip_frames, const std::function< void(const Frame &)> &handle_frame, bool *has_async_catch_error=nullptr)
Definition: stack_trace.cc:745
static bool IsPossibleAwaiterLink(const Class &cls)
Definition: stack_trace.cc:711
static constexpr uword kFutureListenerPcOffset
Definition: stack_trace.h:19
Dart_NativeFunction function
Definition: fuchsia.cc:51
Definition: dart_vm.cc:33
uintptr_t uword
Definition: globals.h:501
std::function< void()> closure
Definition: closure.h:14