Commit d6c4901a authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][debug] Remove WasmCompiledFrameSummary

All wasm code is compiled now. Hence merge the
{WasmCompiledFrameSummary} into {WasmFrameSummary} and remove the
dispatch. Also, rename {IsWasmCompiled} to {IsWasm} and {AsWasmCompiled}
to {AsWasm}.

R=jkummerow@chromium.org

Bug: v8:10389
Change-Id: I33e413c7d0fa622249563091925b29631472b40c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187170Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67689}
parent 9a68fa13
......@@ -109,20 +109,17 @@ std::vector<wasm_addr_t> WasmModuleDebug::GetCallStack(
summary.AsJavaScript();
offset = java_script.code_offset();
script = Handle<Script>::cast(java_script.script());
} else if (summary.IsWasmCompiled()) {
FrameSummary::WasmCompiledFrameSummary const& wasm_compiled =
summary.AsWasmCompiled();
offset =
GetWasmFunctionOffset(wasm_compiled.wasm_instance()->module(),
wasm_compiled.function_index()) +
wasm_compiled.byte_offset();
script = wasm_compiled.script();
} else if (summary.IsWasm()) {
FrameSummary::WasmFrameSummary const& wasm = summary.AsWasm();
offset = GetWasmFunctionOffset(wasm.wasm_instance()->module(),
wasm.function_index()) +
wasm.byte_offset();
script = wasm.script();
bool zeroth_frame = call_stack.empty();
if (!zeroth_frame) {
const NativeModule* native_module = wasm_compiled.wasm_instance()
->module_object()
.native_module();
const NativeModule* native_module =
wasm.wasm_instance()->module_object().native_module();
offset = ReturnPc(native_module, offset);
}
}
......@@ -232,7 +229,7 @@ bool WasmModuleDebug::GetWasmLocal(Isolate* isolate, uint32_t frame_index,
int reversed_index = static_cast<int>(frames.size() - 1 - frame_index);
const FrameSummary& summary = frames[reversed_index];
if (summary.IsWasmCompiled()) {
if (summary.IsWasm()) {
Handle<WasmInstanceObject> instance = summary.AsWasm().wasm_instance();
if (!instance.is_null()) {
Handle<WasmModuleObject> module_object(instance->module_object(),
......@@ -265,7 +262,7 @@ bool WasmModuleDebug::GetWasmStackValue(Isolate* isolate, uint32_t frame_index,
int reversed_index = static_cast<int>(frames.size() - 1 - frame_index);
const FrameSummary& summary = frames[reversed_index];
if (summary.IsWasmCompiled()) {
if (summary.IsWasm()) {
Handle<WasmInstanceObject> instance = summary.AsWasm().wasm_instance();
if (!instance.is_null()) {
Handle<WasmModuleObject> module_object(instance->module_object(),
......
......@@ -1392,27 +1392,25 @@ Handle<Context> FrameSummary::JavaScriptFrameSummary::native_context() const {
}
FrameSummary::WasmFrameSummary::WasmFrameSummary(
Isolate* isolate, FrameSummary::Kind kind,
Handle<WasmInstanceObject> instance, bool at_to_number_conversion)
: FrameSummaryBase(isolate, kind),
Isolate* isolate, Handle<WasmInstanceObject> instance, wasm::WasmCode* code,
int code_offset, bool at_to_number_conversion)
: FrameSummaryBase(isolate, WASM),
wasm_instance_(instance),
at_to_number_conversion_(at_to_number_conversion) {}
at_to_number_conversion_(at_to_number_conversion),
code_(code),
code_offset_(code_offset) {}
Handle<Object> FrameSummary::WasmFrameSummary::receiver() const {
return wasm_instance_->GetIsolate()->global_proxy();
}
// TODO(clemensb): Remove this dispatch.
#define WASM_SUMMARY_DISPATCH(type, name) \
type FrameSummary::WasmFrameSummary::name() const { \
DCHECK_EQ(Kind::WASM_COMPILED, kind()); \
return static_cast<const WasmCompiledFrameSummary*>(this)->name(); \
}
WASM_SUMMARY_DISPATCH(uint32_t, function_index)
WASM_SUMMARY_DISPATCH(int, byte_offset)
uint32_t FrameSummary::WasmFrameSummary::function_index() const {
return code()->index();
}
#undef WASM_SUMMARY_DISPATCH
int FrameSummary::WasmFrameSummary::byte_offset() const {
return code_->GetSourcePositionBefore(code_offset());
}
int FrameSummary::WasmFrameSummary::SourcePosition() const {
const wasm::WasmModule* module = wasm_instance()->module_object().module();
......@@ -1436,22 +1434,6 @@ Handle<Context> FrameSummary::WasmFrameSummary::native_context() const {
return handle(wasm_instance()->native_context(), isolate());
}
FrameSummary::WasmCompiledFrameSummary::WasmCompiledFrameSummary(
Isolate* isolate, Handle<WasmInstanceObject> instance, wasm::WasmCode* code,
int code_offset, bool at_to_number_conversion)
: WasmFrameSummary(isolate, WASM_COMPILED, instance,
at_to_number_conversion),
code_(code),
code_offset_(code_offset) {}
uint32_t FrameSummary::WasmCompiledFrameSummary::function_index() const {
return code()->index();
}
int FrameSummary::WasmCompiledFrameSummary::byte_offset() const {
return code_->GetSourcePositionBefore(code_offset());
}
FrameSummary::~FrameSummary() {
#define FRAME_SUMMARY_DESTR(kind, type, field, desc) \
case kind: \
......@@ -1491,16 +1473,16 @@ FrameSummary FrameSummary::Get(const StandardFrame* frame, int index) {
return frames[index];
}
#define FRAME_SUMMARY_DISPATCH(ret, name) \
ret FrameSummary::name() const { \
switch (base_.kind()) { \
case JAVA_SCRIPT: \
return java_script_summary_.name(); \
case WASM_COMPILED: \
return wasm_compiled_summary_.name(); \
default: \
UNREACHABLE(); \
} \
#define FRAME_SUMMARY_DISPATCH(ret, name) \
ret FrameSummary::name() const { \
switch (base_.kind()) { \
case JAVA_SCRIPT: \
return java_script_summary_.name(); \
case WASM: \
return wasm_summary_.name(); \
default: \
UNREACHABLE(); \
} \
}
FRAME_SUMMARY_DISPATCH(Handle<Object>, receiver)
......@@ -1887,7 +1869,7 @@ WasmModuleObject WasmCompiledFrame::module_object() const {
}
uint32_t WasmCompiledFrame::function_index() const {
return FrameSummary::GetSingle(this).AsWasmCompiled().function_index();
return FrameSummary::GetSingle(this).AsWasm().function_index();
}
Script WasmCompiledFrame::script() const { return module_object().script(); }
......@@ -1917,8 +1899,8 @@ void WasmCompiledFrame::Summarize(std::vector<FrameSummary>* functions) const {
wasm::WasmCode* code = wasm_code();
int offset = static_cast<int>(pc() - code->instruction_start());
Handle<WasmInstanceObject> instance(wasm_instance(), isolate());
FrameSummary::WasmCompiledFrameSummary summary(
isolate(), instance, code, offset, at_to_number_conversion());
FrameSummary::WasmFrameSummary summary(isolate(), instance, code, offset,
at_to_number_conversion());
functions->push_back(summary);
}
......
......@@ -454,8 +454,7 @@ class V8_EXPORT_PRIVATE FrameSummary {
// Subclasses for the different summary kinds:
#define FRAME_SUMMARY_VARIANTS(F) \
F(JAVA_SCRIPT, JavaScriptFrameSummary, java_script_summary_, JavaScript) \
F(WASM_COMPILED, WasmCompiledFrameSummary, wasm_compiled_summary_, \
WasmCompiled)
F(WASM, WasmFrameSummary, wasm_summary_, Wasm)
#define FRAME_SUMMARY_KIND(kind, type, field, desc) kind,
enum Kind { FRAME_SUMMARY_VARIANTS(FRAME_SUMMARY_KIND) };
......@@ -506,14 +505,15 @@ class V8_EXPORT_PRIVATE FrameSummary {
};
class WasmFrameSummary : public FrameSummaryBase {
protected:
WasmFrameSummary(Isolate*, Kind, Handle<WasmInstanceObject>,
bool at_to_number_conversion);
public:
WasmFrameSummary(Isolate*, Handle<WasmInstanceObject>, wasm::WasmCode*,
int code_offset, bool at_to_number_conversion);
Handle<Object> receiver() const;
uint32_t function_index() const;
int byte_offset() const;
wasm::WasmCode* code() const { return code_; }
int code_offset() const { return code_offset_; }
V8_EXPORT_PRIVATE int byte_offset() const;
bool is_constructor() const { return false; }
bool is_subject_to_debugging() const { return true; }
int SourcePosition() const;
......@@ -527,19 +527,6 @@ class V8_EXPORT_PRIVATE FrameSummary {
private:
Handle<WasmInstanceObject> wasm_instance_;
bool at_to_number_conversion_;
};
class WasmCompiledFrameSummary : public WasmFrameSummary {
public:
WasmCompiledFrameSummary(Isolate*, Handle<WasmInstanceObject>,
wasm::WasmCode*, int code_offset,
bool at_to_number_conversion);
uint32_t function_index() const;
wasm::WasmCode* code() const { return code_; }
int code_offset() const { return code_offset_; }
V8_EXPORT_PRIVATE int byte_offset() const;
private:
wasm::WasmCode* const code_;
int code_offset_;
};
......@@ -579,10 +566,6 @@ class V8_EXPORT_PRIVATE FrameSummary {
FRAME_SUMMARY_VARIANTS(FRAME_SUMMARY_CAST)
#undef FRAME_SUMMARY_CAST
// TODO(clemensb): Remove {IsWasmCompiled()} and {AsWasmCompiled()}.
bool IsWasm() const { return IsWasmCompiled(); }
const WasmFrameSummary& AsWasm() const { return AsWasmCompiled(); }
private:
#define FRAME_SUMMARY_FIELD(kind, type, field, desc) type field;
union {
......
......@@ -631,8 +631,7 @@ class FrameArrayBuilder {
abstract_code, offset, flags, parameters);
}
void AppendWasmCompiledFrame(
FrameSummary::WasmCompiledFrameSummary const& summary) {
void AppendWasmFrame(FrameSummary::WasmFrameSummary const& summary) {
if (summary.code()->kind() != wasm::WasmCode::kFunction) return;
Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = 0;
......@@ -960,12 +959,12 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
//=========================================================
auto const& java_script = summary.AsJavaScript();
builder.AppendJavaScriptFrame(java_script);
} else if (summary.IsWasmCompiled()) {
} else if (summary.IsWasm()) {
//=========================================================
// Handle a Wasm compiled frame.
// Handle a Wasm frame.
//=========================================================
auto const& wasm_compiled = summary.AsWasmCompiled();
builder.AppendWasmCompiledFrame(wasm_compiled);
auto const& wasm = summary.AsWasm();
builder.AppendWasmFrame(wasm);
}
}
break;
......
......@@ -116,7 +116,7 @@ class BreakHandler : public debug::DebugDelegate {
// Check the current position.
StackTraceFrameIterator frame_it(isolate_);
auto summ = FrameSummary::GetTop(frame_it.frame()).AsWasmCompiled();
auto summ = FrameSummary::GetTop(frame_it.frame()).AsWasm();
CHECK_EQ(expected_breaks_[count_].position, summ.byte_offset());
expected_breaks_[count_].pre_action();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment