Index: src/debug/debug-frames.cc |
diff --git a/src/debug/debug-frames.cc b/src/debug/debug-frames.cc |
index d331087bdd74945eafe6c96781ecc5a7def78332..e4652a93934e2221d1bf0483c01b5f85ae1e2d22 100644 |
--- a/src/debug/debug-frames.cc |
+++ b/src/debug/debug-frames.cc |
@@ -5,19 +5,19 @@ |
#include "src/debug/debug-frames.h" |
#include "src/frames-inl.h" |
+#include "src/wasm/wasm-module.h" |
namespace v8 { |
namespace internal { |
-FrameInspector::FrameInspector(StandardFrame* frame, int inlined_jsframe_index, |
+FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index, |
Isolate* isolate) |
- : frame_(frame), deoptimized_frame_(NULL), isolate_(isolate) { |
+ : frame_(frame), isolate_(isolate) { |
JavaScriptFrame* js_frame = |
frame->is_java_script() ? javascript_frame() : nullptr; |
DCHECK(js_frame || frame->is_wasm()); |
has_adapted_arguments_ = js_frame && js_frame->has_adapted_arguments(); |
- is_bottommost_ = inlined_jsframe_index == 0; |
- is_optimized_ = frame_->is_optimized(); |
+ is_bottommost_ = inlined_frame_index == 0; |
is_interpreted_ = frame_->is_interpreted(); |
// Calculate the deoptimized frame. |
if (frame->is_optimized()) { |
@@ -26,45 +26,62 @@ FrameInspector::FrameInspector(StandardFrame* frame, int inlined_jsframe_index, |
if (js_frame->LookupCode()->is_turbofanned() && |
js_frame->function()->shared()->asm_function() && |
!FLAG_turbo_asm_deoptimization) { |
- is_optimized_ = false; |
return; |
} |
- deoptimized_frame_ = Deoptimizer::DebuggerInspectableFrame( |
- js_frame, inlined_jsframe_index, isolate); |
- } |
-} |
- |
- |
-FrameInspector::~FrameInspector() { |
- // Get rid of the calculated deoptimized frame if any. |
- if (deoptimized_frame_ != NULL) { |
- Deoptimizer::DeleteDebuggerInspectableFrame(deoptimized_frame_, isolate_); |
+ deoptimized_frame_.reset(Deoptimizer::DebuggerInspectableFrame( |
+ js_frame, inlined_frame_index, isolate)); |
+ } else if (frame->is_wasm_interpreted()) { |
+ // Get wasm interpreted frame information. |
+ Handle<JSObject> wasm(JSObject::cast(WasmFrame::cast(frame)->wasm_obj()), |
+ isolate); |
+ wasm::InterpreterFrameIterator frame_it = |
+ wasm::GetDebugInfo(wasm)->GetInterpreterFrameIterator(); |
+ for (int count = inlined_frame_index; count > 0; --count) frame_it.Next(); |
+ DCHECK(!frame_it.Done()); |
+ wasm_interpreted_frame_.reset( |
+ new wasm::InterpreterFrameInfo(frame_it.GetFrameInfo())); |
} |
} |
int FrameInspector::GetParametersCount() { |
- return is_optimized_ ? deoptimized_frame_->parameters_count() |
- : frame_->ComputeParametersCount(); |
+ return deoptimized_frame_ ? deoptimized_frame_->parameters_count() |
+ : frame_->ComputeParametersCount(); |
} |
Handle<Script> FrameInspector::GetScript() { |
- Object* script = is_optimized_ |
+ Object* script = deoptimized_frame_ |
? deoptimized_frame_->GetFunction()->shared()->script() |
- : frame_->script(); |
+ : wasm_interpreted_frame_ |
+ ? wasm_interpreted_frame_->GetScript() |
+ : frame_->script(); |
return handle(Script::cast(script), isolate_); |
} |
+bool FrameInspector::HasFunction() { |
+ return frame_->is_java_script() || frame_->is_arguments_adaptor(); |
+} |
+ |
Handle<JSFunction> FrameInspector::GetFunction() { |
- DCHECK(!frame_->is_wasm()); |
- return is_optimized_ ? deoptimized_frame_->GetFunction() |
- : handle(javascript_frame()->function(), isolate_); |
+ DCHECK(HasFunction()); |
+ return deoptimized_frame_ ? deoptimized_frame_->GetFunction() |
+ : handle(javascript_frame()->function(), isolate_); |
+} |
+ |
+Handle<String> FrameInspector::GetFunctionName() { |
+ if (!frame_->is_wasm()) return JSFunction::GetDebugName(GetFunction()); |
+ Handle<JSObject> wasm_obj(JSObject::cast(WasmFrame::cast(frame_)->wasm_obj()), |
+ isolate_); |
+ int func_index = wasm_interpreted_frame_ |
+ ? wasm_interpreted_frame_->func_index() |
+ : WasmCompiledFrame::cast(frame_)->function_index(); |
+ return wasm::GetWasmFunctionName(isolate_, wasm_obj, func_index); |
} |
Handle<Object> FrameInspector::GetParameter(int index) { |
- return is_optimized_ ? deoptimized_frame_->GetParameter(index) |
- : handle(frame_->GetParameter(index), isolate_); |
+ return deoptimized_frame_ ? deoptimized_frame_->GetParameter(index) |
+ : handle(frame_->GetParameter(index), isolate_); |
} |
Handle<Object> FrameInspector::GetExpression(int index) { |
@@ -75,35 +92,34 @@ Handle<Object> FrameInspector::GetExpression(int index) { |
!FLAG_turbo_asm_deoptimization) { |
return isolate_->factory()->undefined_value(); |
} |
- return is_optimized_ ? deoptimized_frame_->GetExpression(index) |
- : handle(frame_->GetExpression(index), isolate_); |
+ return deoptimized_frame_ ? deoptimized_frame_->GetExpression(index) |
+ : handle(frame_->GetExpression(index), isolate_); |
} |
int FrameInspector::GetSourcePosition() { |
- if (is_optimized_) { |
- return deoptimized_frame_->GetSourcePosition(); |
- } else if (is_interpreted_) { |
+ if (deoptimized_frame_) return deoptimized_frame_->GetSourcePosition(); |
+ if (wasm_interpreted_frame_) return wasm_interpreted_frame_->pc_offset(); |
+ if (is_interpreted_) { |
InterpretedFrame* frame = reinterpret_cast<InterpretedFrame*>(frame_); |
BytecodeArray* bytecode_array = frame->GetBytecodeArray(); |
return bytecode_array->SourcePosition(frame->GetBytecodeOffset()); |
- } else { |
- Code* code = frame_->LookupCode(); |
- int offset = static_cast<int>(frame_->pc() - code->instruction_start()); |
- return code->SourcePosition(offset); |
} |
+ Code* code = frame_->LookupCode(); |
+ int offset = static_cast<int>(frame_->pc() - code->instruction_start()); |
+ return code->SourcePosition(offset); |
} |
bool FrameInspector::IsConstructor() { |
- return is_optimized_ && !is_bottommost_ |
+ return deoptimized_frame_ && !is_bottommost_ |
? deoptimized_frame_->HasConstructStub() |
: frame_->IsConstructor(); |
} |
Handle<Object> FrameInspector::GetContext() { |
- return is_optimized_ ? deoptimized_frame_->GetContext() |
- : handle(frame_->context(), isolate_); |
+ return deoptimized_frame_ ? deoptimized_frame_->GetContext() |
+ : handle(frame_->context(), isolate_); |
} |
@@ -113,9 +129,9 @@ void FrameInspector::SetArgumentsFrame(StandardFrame* frame) { |
DCHECK(has_adapted_arguments_); |
DCHECK(frame->is_arguments_adaptor()); |
frame_ = frame; |
- is_optimized_ = frame_->is_optimized(); |
+ DCHECK(!frame_->is_optimized()); |
+ deoptimized_frame_ = nullptr; |
is_interpreted_ = frame_->is_interpreted(); |
- DCHECK(!is_optimized_); |
} |
@@ -171,7 +187,7 @@ void FrameInspector::MaterializeStackLocals(Handle<JSObject> target, |
void FrameInspector::UpdateStackLocalsFromMaterializedObject( |
Handle<JSObject> target, Handle<ScopeInfo> scope_info) { |
// Optimized frames and wasm frames are not supported. Simply give up. |
- if (is_optimized_ || frame_->is_wasm()) return; |
+ if (deoptimized_frame_ || frame_->is_wasm()) return; |
HandleScope scope(isolate_); |
@@ -224,15 +240,11 @@ int DebugFrameHelper::FindIndexedNonNativeFrame(StackTraceFrameIterator* it, |
int index) { |
int count = -1; |
for (; !it->done(); it->Advance()) { |
- if (it->is_wasm()) { |
- if (++count == index) return 0; |
- continue; |
- } |
List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
- it->javascript_frame()->Summarize(&frames); |
+ it->frame()->Summarize(&frames); |
for (int i = frames.length() - 1; i >= 0; i--) { |
// Omit functions from native and extension scripts. |
- if (!frames[i].function()->shared()->IsSubjectToDebugging()) continue; |
+ if (!frames[i].is_subject_to_debugging()) continue; |
if (++count == index) return i; |
} |
} |