V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
frame-array.h
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_FRAME_ARRAY_H_
6 #define V8_OBJECTS_FRAME_ARRAY_H_
7 
8 #include "src/objects.h"
9 #include "src/wasm/wasm-objects.h"
10 
11 // Has to be the last include (doesn't have include guards):
12 #include "src/objects/object-macros.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 template <typename T>
18 class Handle;
19 
20 #define FRAME_ARRAY_FIELD_LIST(V) \
21  V(WasmInstance, WasmInstanceObject) \
22  V(WasmFunctionIndex, Smi) \
23  V(WasmCodeObject, Foreign) \
24  V(Receiver, Object) \
25  V(Function, JSFunction) \
26  V(Code, AbstractCode) \
27  V(Offset, Smi) \
28  V(Flags, Smi)
29 
30 // Container object for data collected during simple stack trace captures.
31 class FrameArray : public FixedArray {
32  public:
33 #define DECL_FRAME_ARRAY_ACCESSORS(name, type) \
34  inline type##ArgType name(int frame_ix) const; \
35  inline void Set##name(int frame_ix, type##ArgType value);
36  FRAME_ARRAY_FIELD_LIST(DECL_FRAME_ARRAY_ACCESSORS)
37 #undef DECL_FRAME_ARRAY_ACCESSORS
38 
39  inline bool IsWasmFrame(int frame_ix) const;
40  inline bool IsWasmInterpretedFrame(int frame_ix) const;
41  inline bool IsAsmJsWasmFrame(int frame_ix) const;
42  inline int FrameCount() const;
43 
44  void ShrinkToFit(Isolate* isolate);
45 
46  // Flags.
47  enum Flag {
48  kIsWasmFrame = 1 << 0,
49  kIsWasmInterpretedFrame = 1 << 1,
50  kIsAsmJsWasmFrame = 1 << 2,
51  kIsStrict = 1 << 3,
52  kIsConstructor = 1 << 4,
53  kAsmJsAtNumberConversion = 1 << 5,
54  kIsAsync = 1 << 6,
55  kIsPromiseAll = 1 << 7
56  };
57 
58  static Handle<FrameArray> AppendJSFrame(Handle<FrameArray> in,
59  Handle<Object> receiver,
60  Handle<JSFunction> function,
61  Handle<AbstractCode> code, int offset,
62  int flags);
63  static Handle<FrameArray> AppendWasmFrame(
65  int wasm_function_index, wasm::WasmCode* code, int offset, int flags);
66 
67  DECL_CAST2(FrameArray)
68 
69  private:
70  // The underlying fixed array embodies a captured stack trace. Frame i
71  // occupies indices
72  //
73  // kFirstIndex + 1 + [i * kElementsPerFrame, (i + 1) * kElementsPerFrame[,
74  //
75  // with internal offsets as below:
76 
77  static const int kWasmInstanceOffset = 0;
78  static const int kWasmFunctionIndexOffset = 1;
79  static const int kWasmCodeObjectOffset = 2;
80 
81  static const int kReceiverOffset = 0;
82  static const int kFunctionOffset = 1;
83 
84  static const int kCodeOffset = 2;
85  static const int kOffsetOffset = 3;
86 
87  static const int kFlagsOffset = 4;
88 
89  static const int kElementsPerFrame = 5;
90 
91  // Array layout indices.
92 
93  static const int kFrameCountIndex = 0;
94  static const int kFirstIndex = 1;
95 
96  static int LengthFor(int frame_count) {
97  return kFirstIndex + frame_count * kElementsPerFrame;
98  }
99 
100  static Handle<FrameArray> EnsureSpace(Isolate* isolate,
101  Handle<FrameArray> array, int length);
102 
103  friend class Factory;
104  OBJECT_CONSTRUCTORS(FrameArray, FixedArray);
105 };
106 
107 } // namespace internal
108 } // namespace v8
109 
110 #include "src/objects/object-macros-undef.h"
111 
112 #endif // V8_OBJECTS_FRAME_ARRAY_H_
Definition: libplatform.h:13