Commit 14a9968f authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Add a separate frame type for debug break frames

The frame created by the WasmDebugBreak builtin now has a separate frame
type, which will (later) allow to inspect the spilled registers.

Once Liftoff supports reference types, this frame will also need special
GC support for spilled heap references.

R=jkummerow@chromium.org

Bug: v8:10222
Change-Id: I110e51d1e6d09b0f44dcdd1cdcaafa2eaa64fddd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083013Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66531}
parent 64ae870e
......@@ -2501,8 +2501,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
FrameAndConstantPoolScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -3017,8 +3017,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameScope scope(masm, StackFrame::INTERNAL);
FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2672,8 +2672,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameScope scope(masm, StackFrame::INTERNAL);
FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2484,8 +2484,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameScope scope(masm, StackFrame::INTERNAL);
FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2523,8 +2523,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameScope scope(masm, StackFrame::INTERNAL);
FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2601,8 +2601,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
FrameAndConstantPoolScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2661,8 +2661,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
FrameAndConstantPoolScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2643,8 +2643,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
{
// TODO(clemensb): Use a separate frame type and make it inspectable.
FrameScope scope(masm, StackFrame::INTERNAL);
FrameScope scope(masm, StackFrame::WASM_DEBUG_BREAK);
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
......
......@@ -2285,11 +2285,10 @@ void TurboAssembler::Prologue() {
void TurboAssembler::EnterFrame(StackFrame::Type type) {
UseScratchRegisterScope temps(this);
if (type == StackFrame::INTERNAL) {
if (type == StackFrame::INTERNAL || type == StackFrame::WASM_DEBUG_BREAK) {
Register type_reg = temps.AcquireX();
Mov(type_reg, StackFrame::TypeToMarker(type));
// type_reg pushed twice for alignment.
Push<TurboAssembler::kSignLR>(lr, fp, type_reg, type_reg);
Push<TurboAssembler::kSignLR>(lr, fp, type_reg, padreg);
const int kFrameSize =
TypedFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize;
Add(fp, sp, kFrameSize);
......
......@@ -246,6 +246,10 @@ inline WasmInterpreterEntryFrame::WasmInterpreterEntryFrame(
StackFrameIteratorBase* iterator)
: StandardFrame(iterator) {}
inline WasmDebugBreakFrame::WasmDebugBreakFrame(
StackFrameIteratorBase* iterator)
: StandardFrame(iterator) {}
inline WasmToJsFrame::WasmToJsFrame(StackFrameIteratorBase* iterator)
: StubFrame(iterator) {}
......
......@@ -622,6 +622,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
case WASM_COMPILED:
case WASM_COMPILE_LAZY:
case WASM_EXIT:
case WASM_DEBUG_BREAK:
return candidate;
case JS_TO_WASM:
case OPTIMIZED:
......@@ -968,6 +969,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const {
case CONSTRUCT:
case JS_TO_WASM:
case C_WASM_ENTRY:
case WASM_DEBUG_BREAK:
frame_header_size = TypedFrameConstants::kFixedFrameSizeFromFp;
break;
case WASM_TO_JS:
......@@ -2031,6 +2033,26 @@ Address WasmInterpreterEntryFrame::GetCallerStackPointer() const {
return fp() + ExitFrameConstants::kCallerSPOffset;
}
void WasmDebugBreakFrame::Iterate(RootVisitor* v) const {
// Nothing to iterate here. This will change once we support references in
// Liftoff.
}
Code WasmDebugBreakFrame::unchecked_code() const { return Code(); }
void WasmDebugBreakFrame::Print(StringStream* accumulator, PrintMode mode,
int index) const {
PrintIndex(accumulator, mode, index);
accumulator->Add("WASM DEBUG BREAK");
if (mode != OVERVIEW) accumulator->Add("\n");
}
Address WasmDebugBreakFrame::GetCallerStackPointer() const {
// WasmDebugBreak does not receive any arguments, hence the stack pointer of
// the caller is at a fixed offset from the frame pointer.
return fp() + StandardFrameConstants::kCallerSPOffset;
}
Code WasmCompileLazyFrame::unchecked_code() const { return Code(); }
WasmInstanceObject WasmCompileLazyFrame::wasm_instance() const {
......
......@@ -70,6 +70,7 @@ class StackHandler {
V(WASM_TO_JS, WasmToJsFrame) \
V(JS_TO_WASM, JsToWasmFrame) \
V(WASM_INTERPRETER_ENTRY, WasmInterpreterEntryFrame) \
V(WASM_DEBUG_BREAK, WasmDebugBreakFrame) \
V(C_WASM_ENTRY, CWasmEntryFrame) \
V(WASM_EXIT, WasmExitFrame) \
V(WASM_COMPILE_LAZY, WasmCompileLazyFrame) \
......@@ -181,6 +182,7 @@ class StackFrame {
bool is_interpreted() const { return type() == INTERPRETED; }
bool is_wasm_compiled() const { return type() == WASM_COMPILED; }
bool is_wasm_compile_lazy() const { return type() == WASM_COMPILE_LAZY; }
bool is_wasm_debug_break() const { return type() == WASM_DEBUG_BREAK; }
bool is_wasm_interpreter_entry() const {
return type() == WASM_INTERPRETER_ENTRY;
}
......@@ -1030,6 +1032,32 @@ class WasmInterpreterEntryFrame final : public StandardFrame {
WasmModuleObject module_object() const;
};
class WasmDebugBreakFrame final : public StandardFrame {
public:
Type type() const override { return WASM_DEBUG_BREAK; }
// GC support.
void Iterate(RootVisitor* v) const override;
Code unchecked_code() const override;
void Print(StringStream* accumulator, PrintMode mode,
int index) const override;
static WasmDebugBreakFrame* cast(StackFrame* frame) {
DCHECK(frame->is_wasm_debug_break());
return static_cast<WasmDebugBreakFrame*>(frame);
}
protected:
inline explicit WasmDebugBreakFrame(StackFrameIteratorBase*);
Address GetCallerStackPointer() const override;
private:
friend class StackFrameIteratorBase;
};
class WasmToJsFrame : public StubFrame {
public:
Type type() const override { return WASM_TO_JS; }
......
......@@ -617,7 +617,7 @@ RUNTIME_FUNCTION(Runtime_WasmNewMultiReturnJSArray) {
RUNTIME_FUNCTION(Runtime_WasmDebugBreak) {
HandleScope scope(isolate);
DCHECK_EQ(0, args.length());
FrameFinder<WasmCompiledFrame, StackFrame::EXIT, StackFrame::INTERNAL>
FrameFinder<WasmCompiledFrame, StackFrame::EXIT, StackFrame::WASM_DEBUG_BREAK>
frame_finder(isolate);
auto instance = handle(frame_finder.frame()->wasm_instance(), isolate);
int position = frame_finder.frame()->position();
......
......@@ -438,6 +438,7 @@ FRAME_MARKERS = (
"WASM_TO_JS",
"JS_TO_WASM",
"WASM_INTERPRETER_ENTRY",
"WASM_DEBUG_BREAK",
"C_WASM_ENTRY",
"WASM_EXIT",
"WASM_COMPILE_LAZY",
......
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