v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
debug-frames.cc
Go to the documentation of this file.
1// Copyright 2015 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
6
10
11#if V8_ENABLE_WEBASSEMBLY
13#endif // V8_ENABLE_WEBASSEMBLY
14
15namespace v8 {
16namespace internal {
17
18FrameInspector::FrameInspector(CommonFrame* frame, int inlined_frame_index,
19 Isolate* isolate)
20 : frame_(frame),
21 inlined_frame_index_(inlined_frame_index),
22 isolate_(isolate) {
23 // Extract the relevant information from the frame summary and discard it.
26
29 script_ = Cast<Script>(summary.script());
30 receiver_ = summary.receiver();
31
32 if (summary.IsJavaScript()) {
33 function_ = summary.AsJavaScript().function();
34 }
35
36#if V8_ENABLE_WEBASSEMBLY
37 JavaScriptFrame* js_frame =
38 frame->is_javascript() ? javascript_frame() : nullptr;
39 DCHECK(js_frame || frame->is_wasm());
40#else
42#endif // V8_ENABLE_WEBASSEMBLY
43 is_optimized_ = js_frame && js_frame->is_optimized();
44
45 // Calculate the deoptimized frame.
46 if (is_optimized_) {
47 DCHECK_NOT_NULL(js_frame);
49 js_frame, inlined_frame_index, isolate));
50 }
51}
52
53// Destructor needs to be defined in the .cc file, because it instantiates
54// std::unique_ptr destructors but the types are not known in the header.
56
60
62 if (is_optimized_) return deoptimized_frame_->GetParameter(index);
65}
66
68 return is_optimized_ ? deoptimized_frame_->GetExpression(index)
70}
71
76
78#if V8_ENABLE_WEBASSEMBLY
79 if (IsWasm()) {
80#if V8_ENABLE_DRUMBRAKE
81 if (IsWasmInterpreter()) {
82 auto wasm_frame = WasmInterpreterEntryFrame::cast(frame_);
83 auto instance_data =
84 handle(wasm_frame->trusted_instance_data(), isolate_);
87 wasm_frame->function_index(inlined_frame_index_));
88 }
89#endif // V8_ENABLE_DRUMBRAKE
90 auto wasm_frame = WasmFrame::cast(frame_);
91 auto instance_data = handle(wasm_frame->trusted_instance_data(), isolate_);
93 wasm_frame->function_index());
94 }
95#endif // V8_ENABLE_WEBASSEMBLY
97}
98
99#if V8_ENABLE_WEBASSEMBLY
100bool FrameInspector::IsWasm() { return frame_->is_wasm(); }
101#if V8_ENABLE_DRUMBRAKE
102bool FrameInspector::IsWasmInterpreter() {
103 return frame_->is_wasm_interpreter_entry();
104}
105#endif // V8_ENABLE_DRUMBRAKE
106#endif // V8_ENABLE_WEBASSEMBLY
107
109
111 DirectHandle<ScopeInfo> info, DirectHandle<String> parameter_name) {
112 return info->ContextSlotIndex(parameter_name) != -1;
113}
114
116 Isolate* isolate, Tagged<SharedFunctionInfo> shared, Mode mode)
117 : shared_(shared), mode_(mode) {
118 DCHECK(shared->HasBytecodeArray());
120 shared->HasDebugInfo(isolate));
121}
122
124 ThreadLocalTop* top) {
125 for (JavaScriptStackFrameIterator it(isolate, top); !it.done();
126 it.Advance()) {
127 JavaScriptFrame* frame = it.frame();
128 Tagged<JSFunction> function = frame->function();
129 if (!frame->is_interpreted()) continue;
130 if (function->shared() != shared_) continue;
131 InterpretedFrame* interpreted_frame =
132 reinterpret_cast<InterpretedFrame*>(frame);
133 Tagged<BytecodeArray> bytecode =
135 ? shared_->GetDebugInfo(isolate)->DebugBytecodeArray(isolate)
136 : shared_->GetBytecodeArray(isolate);
137 interpreted_frame->PatchBytecodeArray(bytecode);
138 }
139}
140
141} // namespace internal
142} // namespace v8
Isolate * isolate_
virtual Tagged< Object > context() const
Definition frames.cc:1470
Tagged< Object > GetExpression(int index) const
Definition frames-inl.h:242
static DeoptimizedFrameInfo * DebuggerInspectableFrame(JavaScriptFrame *frame, int jsframe_index, Isolate *isolate)
Handle< Object > GetParameter(int index)
Handle< Object > GetExpression(int index)
bool ParameterIsShadowedByContextLocal(DirectHandle< ScopeInfo > info, DirectHandle< String > parameter_name)
FrameInspector(CommonFrame *frame, int inlined_frame_index, Isolate *isolate)
Handle< JSFunction > function_
JavaScriptFrame * javascript_frame()
DirectHandle< String > GetFunctionName()
std::unique_ptr< DeoptimizedFrameInfo > deoptimized_frame_
Handle< Object > GetContext()
static FrameSummary Get(const CommonFrame *frame, int index)
Definition frames.cc:2981
Handle< Object > script() const
Handle< Object > receiver() const
void EnsureSourcePositionsAvailable()
Definition frames.cc:2711
void PatchBytecodeArray(Tagged< BytecodeArray > bytecode_array)
Definition frames.cc:3344
static DirectHandle< String > GetDebugName(DirectHandle< JSFunction > function)
Tagged< JSFunction > function() const override
Definition frames.cc:2492
static JavaScriptFrame * cast(StackFrame *frame)
Definition frames.h:805
void VisitThread(Isolate *isolate, ThreadLocalTop *top) override
RedirectActiveFunctions(Isolate *isolate, Tagged< SharedFunctionInfo > shared, Mode mode)
Tagged< SharedFunctionInfo > shared_
bool is_javascript() const
Definition frames.h:290
bool is_interpreted() const
Definition frames.h:241
RecordWriteMode const mode_
WasmFrame *const frame_
Tagged< SharedFunctionInfo > shared_
Definition debug.cc:1741
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
Definition handles-inl.h:72
kWasmInternalFunctionIndirectPointerTag instance_data
DirectHandle< String > GetWasmFunctionDebugName(Isolate *isolate, DirectHandle< WasmTrustedInstanceData > instance_data, uint32_t func_index)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493
#define DCHECK(condition)
Definition logging.h:482