Commit 9d3c9d47 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[wasm-gc][liftoff] Reserve a stack slot for feedback

So far the slot is set to 0; in an upcoming CL it will be
used for an actual feedback vector.

Bug: v8:7748
Change-Id: I79f7502757d2cd8b07ced7105bf7532f5bc9b4f0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3205898
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77279}
parent 6123c571
......@@ -968,6 +968,7 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
bool is_wasm = false;
#if V8_ENABLE_WEBASSEMBLY
bool has_wasm_feedback_slot = false;
if (auto* wasm_code = wasm::GetWasmCodeManager()->LookupCode(inner_pointer)) {
is_wasm = true;
SafepointTable table(wasm_code);
......@@ -978,6 +979,9 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
wasm_code->kind() != wasm::WasmCode::kWasmToCapiWrapper;
first_tagged_parameter_slot = wasm_code->first_tagged_parameter_slot();
num_tagged_parameter_slots = wasm_code->num_tagged_parameter_slots();
if (wasm_code->is_liftoff() && FLAG_wasm_speculative_inlining) {
has_wasm_feedback_slot = true;
}
}
#endif // V8_ENABLE_WEBASSEMBLY
......@@ -1041,6 +1045,7 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
case WASM:
case WASM_COMPILE_LAZY:
frame_header_size = WasmFrameConstants::kFixedFrameSizeFromFp;
if (has_wasm_feedback_slot) frame_header_size += kSystemPointerSize;
break;
case WASM_EXIT:
// The last value in the frame header is the calling PC, which should
......
......@@ -1046,6 +1046,8 @@ DEFINE_BOOL(wasm_math_intrinsics, true,
DEFINE_BOOL(
wasm_inlining, false,
"enable inlining of wasm functions into wasm functions (experimental)")
DEFINE_BOOL(wasm_speculative_inlining, false,
"enable speculative inlining of call_ref targets (experimental)")
DEFINE_BOOL(wasm_loop_unrolling, true,
"enable loop unrolling for wasm functions")
DEFINE_BOOL(wasm_fuzzer_gen_test, false,
......
......@@ -57,17 +57,19 @@ inline constexpr Condition ToCondition(LiftoffCondition liftoff_cond) {
// -----+--------------------+ <-- frame ptr (fp)
// -1 | 0xa: WASM |
// -2 | instance |
// -3 | feedback vector |
// -----+--------------------+---------------------------
// -3 | slot 0 (high) | ^
// -4 | slot 0 (low) | |
// -5 | slot 1 (high) | Frame slots
// -6 | slot 1 (low) | |
// -4 | slot 0 (high) | ^
// -5 | slot 0 (low) | |
// -6 | slot 1 (high) | Frame slots
// -7 | slot 1 (low) | |
// | | v
// -----+--------------------+ <-- stack ptr (sp)
//
static_assert(2 * kSystemPointerSize == LiftoffAssembler::kStackSlotSize,
"Slot size should be twice the size of the 32 bit pointer.");
constexpr int kInstanceOffset = 2 * kSystemPointerSize;
constexpr int kFeedbackVectorOffset = 3 * kSystemPointerSize;
// kPatchInstructionsRequired sets a maximum limit of how many instructions that
// PatchPrepareStackFrame will use in order to increase the stack appropriately.
// Three instructions are required to sub a large constant, movw + movt + sub.
......@@ -557,7 +559,7 @@ void LiftoffAssembler::AbortCompilation() { AbortedCodeGeneration(); }
// static
constexpr int LiftoffAssembler::StaticStackFrameSize() {
return liftoff::kInstanceOffset;
return liftoff::kFeedbackVectorOffset;
}
int LiftoffAssembler::SlotSizeForType(ValueKind kind) {
......
......@@ -57,9 +57,10 @@ inline constexpr Condition ToCondition(LiftoffCondition liftoff_cond) {
// -----+--------------------+ <-- frame ptr (fp)
// -1 | 0xa: WASM |
// -2 | instance |
// -3 | feedback vector|
// -----+--------------------+---------------------------
// -3 | slot 0 | ^
// -4 | slot 1 | |
// -4 | slot 0 | ^
// -5 | slot 1 | |
// | | Frame slots
// | | |
// | | v
......@@ -68,6 +69,7 @@ inline constexpr Condition ToCondition(LiftoffCondition liftoff_cond) {
//
constexpr int kInstanceOffset = 2 * kSystemPointerSize;
constexpr int kFeedbackVectorOffset = 3 * kSystemPointerSize;
inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); }
......@@ -384,7 +386,7 @@ void LiftoffAssembler::AbortCompilation() { AbortedCodeGeneration(); }
// static
constexpr int LiftoffAssembler::StaticStackFrameSize() {
return liftoff::kInstanceOffset;
return liftoff::kFeedbackVectorOffset;
}
int LiftoffAssembler::SlotSizeForType(ValueKind kind) {
......
......@@ -51,6 +51,7 @@ inline constexpr Condition ToCondition(LiftoffCondition liftoff_cond) {
// ebp-4 holds the stack marker, ebp-8 is the instance parameter.
constexpr int kInstanceOffset = 8;
constexpr int kFeedbackVectorOffset = 12; // ebp-12 is the feedback vector.
inline Operand GetStackSlot(int offset) { return Operand(ebp, -offset); }
......@@ -307,7 +308,7 @@ void LiftoffAssembler::AbortCompilation() {}
// static
constexpr int LiftoffAssembler::StaticStackFrameSize() {
return liftoff::kInstanceOffset;
return liftoff::kFeedbackVectorOffset;
}
int LiftoffAssembler::SlotSizeForType(ValueKind kind) {
......
......@@ -752,6 +752,12 @@ class LiftoffCompiler {
descriptor_->GetInputLocation(kInstanceParameterIndex)
.AsRegister()));
__ cache_state()->SetInstanceCacheRegister(kWasmInstanceRegister);
// Load the feedback vector and cache it in a stack slot.
if (FLAG_wasm_speculative_inlining) {
UNIMPLEMENTED();
} else {
__ Spill(liftoff::kFeedbackVectorOffset, WasmValue::ForUintPtr(0));
}
if (for_debugging_) __ ResetOSRTarget();
// Process parameters.
......@@ -2205,7 +2211,7 @@ class LiftoffCompiler {
state.dec_used(slot_reg);
dst_slot->MakeStack();
}
DCHECK_EQ(kind, __ local_kind(local_index));
DCHECK(CheckCompatibleStackSlotTypes(kind, __ local_kind(local_index)));
RegClass rc = reg_class_for(kind);
LiftoffRegister dst_reg = __ GetUnusedRegister(rc, {});
__ Fill(dst_reg, src_slot.offset(), kind);
......
......@@ -65,6 +65,7 @@ static_assert((kLiftoffAssemblerFpCacheRegs &
// rbp-8 holds the stack marker, rbp-16 is the instance parameter.
constexpr int kInstanceOffset = 16;
constexpr int kFeedbackVectorOffset = 24; // rbp-24 is the feedback vector.
inline Operand GetStackSlot(int offset) { return Operand(rbp, -offset); }
......
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