v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frames-inl.h
Go to the documentation of this file.
1// Copyright 2012 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_EXECUTION_FRAMES_INL_H_
6#define V8_EXECUTION_FRAMES_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include <optional>
12
13#include "src/base/memory.h"
18
19namespace v8 {
20namespace internal {
21
23 public:
33
34 explicit InnerPointerToCodeCache(Isolate* isolate) : isolate_(isolate) {
35 Flush();
36 }
37
40
41 void Flush() { memset(static_cast<void*>(&cache_[0]), 0, sizeof(cache_)); }
42
43 InnerPointerToCodeCacheEntry* GetCacheEntry(Address inner_pointer);
44
45 private:
47
49
50 static const int kInnerPointerToCodeCacheSize = 1024;
52};
53
55 return reinterpret_cast<Address>(const_cast<StackHandler*>(this));
56}
57
62
66
68 return reinterpret_cast<StackHandler*>(address);
69}
70
72 : iterator_(iterator), isolate_(iterator_->isolate()) {}
73
75 return iterator_->handler();
76}
77
78inline Address StackFrame::pc() const { return ReadPC(pc_address()); }
79
83
84// static
88
91 // Here the pc_address() is on the stack and properly authenticated.
92 return pc();
93 } else {
94 // For fast C calls pc_address() points into IsolateData and the pc in there
95 // is unauthenticated. For the profiler, the pc_address of the first visited
96 // frame is also not written by a call instruction.
97 // For wasm stacks, the exit frame's pc is stored in the jump buffer
98 // unsigned.
100 }
101}
102
106
108 if (return_address_location_resolver_ == nullptr) {
109 return pc_address;
110 } else {
111 return reinterpret_cast<Address*>(return_address_location_resolver_(
112 reinterpret_cast<uintptr_t>(pc_address)));
113 }
114}
115
117 : CommonFrame(iterator) {}
118
122
126
128 : TypedFrame(iterator) {}
129
131 : TypedFrame(iterator) {}
132
136
138 : TypedFrame(iterator) {}
139
142
147
152
157
162
166
171
175
180
182 Tagged<Object> function = *target_slot();
183 DCHECK(IsJSFunction(function) || IsFunctionTemplateInfo(function));
184 return Cast<HeapObject>(function);
185}
186
188 DCHECK(IsJSFunction(function) || IsFunctionTemplateInfo(function));
189 target_slot().store(function);
190}
191
193 int argc = static_cast<int>(base::Memory<Address>(
195 DCHECK_GE(argc, 0);
196 return argc;
197}
198
205
209 return !IsUndefined(new_context, isolate());
210}
211
215
220
224
228
232
236
238
240 : StackFrame(iterator) {}
241
245
246inline void CommonFrame::SetExpression(int index, Tagged<Object> value) {
247 base::Memory<Address>(GetExpressionAddress(index)) = value.ptr();
248}
249
253
255 return ReadPC(reinterpret_cast<Address*>(
257}
258
260 intptr_t frame_type =
262 return frame_type == StackFrame::TypeToMarker(StackFrame::CONSTRUCT) ||
263 frame_type == StackFrame::TypeToMarker(StackFrame::FAST_CONSTRUCT);
264}
265
268
270 DCHECK_LE(-1, index);
271 DCHECK_LT(index,
273 int parameter_offset = (index + 1) * kSystemPointerSize;
274 return caller_sp() + parameter_offset;
275}
276
278 return 0;
279}
280
284
290
295
299
301 : TypedFrame(iterator) {}
302
305
308
311
314
317
320
323
324#if V8_ENABLE_WEBASSEMBLY
325inline WasmFrame::WasmFrame(StackFrameIteratorBase* iterator)
326 : TypedFrame(iterator) {}
327
328inline WasmSegmentStartFrame::WasmSegmentStartFrame(
329 StackFrameIteratorBase* iterator)
330 : WasmFrame(iterator) {}
331
332inline WasmExitFrame::WasmExitFrame(StackFrameIteratorBase* iterator)
333 : WasmFrame(iterator) {}
334
335#if V8_ENABLE_DRUMBRAKE
336inline WasmInterpreterEntryFrame::WasmInterpreterEntryFrame(
337 StackFrameIteratorBase* iterator)
338 : WasmFrame(iterator) {}
339#endif // V8_ENABLE_DRUMBRAKE
340
341inline WasmDebugBreakFrame::WasmDebugBreakFrame(
342 StackFrameIteratorBase* iterator)
343 : TypedFrame(iterator) {}
344
345inline WasmToJsFrame::WasmToJsFrame(StackFrameIteratorBase* iterator)
346 : WasmFrame(iterator) {}
347
348inline WasmToJsFunctionFrame::WasmToJsFunctionFrame(
349 StackFrameIteratorBase* iterator)
350 : TypedFrame(iterator) {}
351
352inline JsToWasmFrame::JsToWasmFrame(StackFrameIteratorBase* iterator)
353 : StubFrame(iterator) {}
354
355inline StackSwitchFrame::StackSwitchFrame(StackFrameIteratorBase* iterator)
356 : ExitFrame(iterator) {}
357
358inline CWasmEntryFrame::CWasmEntryFrame(StackFrameIteratorBase* iterator)
359 : StubFrame(iterator) {}
360
361inline WasmLiftoffSetupFrame::WasmLiftoffSetupFrame(
362 StackFrameIteratorBase* iterator)
363 : TypedFrame(iterator) {}
364#endif // V8_ENABLE_WEBASSEMBLY
365
368
371
374
378
382
387
390
393#if V8_ENABLE_WEBASSEMBLY
394 DCHECK(frame->is_javascript() || frame->is_wasm());
395#else
397#endif // V8_ENABLE_WEBASSEMBLY
398 return static_cast<CommonFrame*>(frame);
399}
400
405
409
410#if V8_ENABLE_WEBASSEMBLY
411bool DebuggableStackFrameIterator::is_wasm() const {
412 return frame()->is_wasm();
413}
414
415#if V8_ENABLE_DRUMBRAKE
416bool DebuggableStackFrameIterator::is_wasm_interpreter_entry() const {
417 return frame()->is_wasm_interpreter_entry();
418}
419#endif // V8_ENABLE_DRUMBRAKE
420
421#endif // V8_ENABLE_WEBASSEMBLY
422
426
427// static
429 StackFrame::Type type) {
430#if V8_ENABLE_WEBASSEMBLY
431 DCHECK_NE(type, StackFrame::C_WASM_ENTRY);
432#endif // V8_ENABLE_WEBASSEMBLY
433 return StackFrame::IsJavaScript(type) || type == StackFrame::EXIT ||
434 type == StackFrame::BUILTIN_EXIT ||
435 type == StackFrame::API_ACCESSOR_EXIT ||
436 type == StackFrame::API_CALLBACK_EXIT ||
437#if V8_ENABLE_WEBASSEMBLY
438 type == StackFrame::WASM || type == StackFrame::WASM_TO_JS ||
439 type == StackFrame::JS_TO_WASM ||
440 type == StackFrame::WASM_SEGMENT_START ||
441#if V8_ENABLE_DRUMBRAKE
442 type == StackFrame::WASM_INTERPRETER_ENTRY ||
443#endif // V8_ENABLE_DRUMBRAKE
444#endif // V8_ENABLE_WEBASSEMBLY
445 false;
446}
447
453
454} // namespace internal
455} // namespace v8
456
457#endif // V8_EXECUTION_FRAMES_INL_H_
Isolate * isolate_
FullObjectSlot receiver_slot() const
Definition frames-inl.h:221
FullObjectSlot property_name_slot() const
Definition frames-inl.h:216
FullObjectSlot holder_slot() const
Definition frames-inl.h:225
Tagged< Object > receiver() const
Definition frames-inl.h:233
ApiAccessorExitFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:212
Tagged< Object > holder() const
Definition frames-inl.h:237
Tagged< Name > property_name() const
Definition frames-inl.h:229
FullObjectSlot target_slot() const
Definition frames-inl.h:172
void set_target(Tagged< HeapObject > function) const
Definition frames-inl.h:187
Tagged< Object > context() const override
Definition frames-inl.h:167
Tagged< HeapObject > target() const
Definition frames-inl.h:181
ApiCallbackExitFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:163
Tagged< Object > GetParameter(int i) const
Definition frames-inl.h:199
Tagged< Object > receiver() const
Definition frames-inl.h:176
BaselineFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:312
BuiltinContinuationFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:375
Tagged< Object > argc_slot_object() const
Definition frames-inl.h:148
Tagged< Object > new_target_slot_object() const
Definition frames-inl.h:158
Tagged< Object > receiver_slot_object() const
Definition frames-inl.h:143
BuiltinExitFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:140
Tagged< Object > target_slot_object() const
Definition frames-inl.h:153
BuiltinFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:321
virtual int ComputeParametersCount() const
Definition frames.cc:2624
Address GetParameterSlot(int index) const
Definition frames-inl.h:269
CommonFrameWithJSLinkage(StackFrameIteratorBase *iterator)
Definition frames-inl.h:119
virtual int GetActualArgumentCount() const
Definition frames-inl.h:277
static bool IsConstructFrame(Address fp)
Definition frames-inl.h:259
CommonFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:239
Address caller_fp() const
Definition frames-inl.h:250
void SetExpression(int index, Tagged< Object > value)
Definition frames-inl.h:246
Address caller_pc() const
Definition frames-inl.h:254
Tagged< Object > GetExpression(int index) const
Definition frames-inl.h:242
virtual Address GetExpressionAddress(int n) const
Definition frames.cc:1460
ConstructEntryFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:133
ConstructFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:369
JavaScriptFrame * javascript_frame() const
Definition frames-inl.h:423
EntryFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:130
ExitFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:137
FastConstructFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:372
void store(Tagged< Object > value) const
Definition slots-inl.h:54
InnerPointerToCodeCache & operator=(const InnerPointerToCodeCache &)=delete
InnerPointerToCodeCacheEntry * GetCacheEntry(Address inner_pointer)
Definition frames.cc:4144
InnerPointerToCodeCache(Isolate *isolate)
Definition frames-inl.h:34
InnerPointerToCodeCacheEntry cache_[kInnerPointerToCodeCacheSize]
Definition frames-inl.h:51
InnerPointerToCodeCacheEntry * cache(int index)
Definition frames-inl.h:46
static const int kInnerPointerToCodeCacheSize
Definition frames-inl.h:50
InnerPointerToCodeCache(const InnerPointerToCodeCache &)=delete
InternalFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:366
InterpretedFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:309
IrregexpFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:388
JavaScriptBuiltinContinuationFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:379
JavaScriptBuiltinContinuationWithCatchFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:384
Tagged< Object > function_slot_object() const
Definition frames-inl.h:291
JavaScriptFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:266
void set_receiver(Tagged< Object > value)
Definition frames-inl.h:281
static JavaScriptFrame * cast(StackFrame *frame)
Definition frames.h:805
MaglevFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:315
NativeFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:127
OptimizedJSFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:303
static V8_INLINE Address StripPAC(Address pc)
static V8_INLINE Address AuthenticatePC(Address *pc_address, unsigned offset_from_sp)
static bool IsValidFrameType(StackFrame::Type type)
Definition frames-inl.h:428
StackFrame * frame() const
Definition frames.h:1726
static constexpr int32_t TypeToMarker(Type type)
Definition frames.h:196
Address unauthenticated_pc() const
Definition frames-inl.h:80
bool is_stack_exit_frame() const
Definition frames.h:305
static ReturnAddressLocationResolver return_address_location_resolver_
Definition frames.h:392
Address caller_sp() const
Definition frames.h:300
bool is_profiler_entry_frame() const
Definition frames.h:302
static bool IsJavaScript(Type t)
Definition frames.h:284
virtual Type type() const =0
bool InFastCCall() const
Definition frames.h:320
bool is_javascript() const
Definition frames.h:290
Address * pc_address() const
Definition frames.h:327
Isolate * isolate() const
Definition frames.h:376
static Address * ResolveReturnAddressLocation(Address *pc_address)
Definition frames-inl.h:107
StackHandler * top_handler() const
Definition frames-inl.h:74
const StackFrameIteratorBase *const iterator_
Definition frames.h:386
Address pc() const
Definition frames-inl.h:78
Address fp() const
Definition frames.h:297
StackFrame(const StackFrame &original) V8_NOEXCEPT
Definition frames.h:224
Address maybe_unauthenticated_pc() const
Definition frames-inl.h:89
static Address ReadPC(Address *pc_address)
Definition frames-inl.h:103
static StackHandler * FromAddress(Address address)
Definition frames-inl.h:67
Address address() const
Definition frames-inl.h:54
StackHandler * next() const
Definition frames-inl.h:58
Address next_address() const
Definition frames-inl.h:63
StubFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:300
V8_INLINE constexpr StorageType ptr() const
TurbofanJSFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:318
TurbofanStubWithContextFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:296
static constexpr int kFrameTypeOffset
TypedFrameWithJSLinkage(StackFrameIteratorBase *iterator)
Definition frames-inl.h:123
TypedFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:116
UnoptimizedJSFrame(StackFrameIteratorBase *iterator)
Definition frames-inl.h:306
void SetFeedbackVector(Tagged< FeedbackVector > feedback_vector)
Definition frames-inl.h:285
int32_t offset
T & Memory(Address addr)
Definition memory.h:18
constexpr int kSystemPointerSize
Definition globals.h:410
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_LT(v1, v2)
Definition logging.h:489