[Liftoff] Fix stack space reservation
When reserving stack space by decrementing rsp/esp, we were ignoring the constant size needed for the stack marker and the wasm context. Later, we were using that space anyway, which can lead to errors if e.g. interrupt handlers kick in and use that space below rsp/esp. R=ahaas@chromium.org Bug: v8:7366, v8:6600 Change-Id: I2f49ef5785d33e98c29c5cf4fe7624a02e8c7628 Reviewed-on: https://chromium-review.googlesource.com/883881 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#50843}
This commit is contained in:
parent
6342828391
commit
5c7b116199
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -16,12 +16,15 @@ namespace wasm {
|
||||
|
||||
namespace liftoff {
|
||||
|
||||
// ebp-8 holds the stack marker, ebp-16 is the wasm context, first stack slot
|
||||
// is located at ebp-24.
|
||||
constexpr int32_t kConstantStackSpace = 16;
|
||||
constexpr int32_t kFirstStackSlotOffset =
|
||||
kConstantStackSpace + LiftoffAssembler::kStackSlotSize;
|
||||
|
||||
inline Operand GetStackSlot(uint32_t index) {
|
||||
// ebp-8 holds the stack marker, ebp-16 is the wasm context, first stack slot
|
||||
// is located at ebp-24.
|
||||
constexpr int32_t kFirstStackSlotOffset = -24;
|
||||
return Operand(
|
||||
ebp, kFirstStackSlotOffset - index * LiftoffAssembler::kStackSlotSize);
|
||||
ebp, -kFirstStackSlotOffset - index * LiftoffAssembler::kStackSlotSize);
|
||||
}
|
||||
|
||||
// TODO(clemensh): Make this a constexpr variable once Operand is constexpr.
|
||||
@ -41,7 +44,8 @@ static constexpr Register kCCallLastArgAddrReg = eax;
|
||||
|
||||
static constexpr DoubleRegister kScratchDoubleReg = xmm7;
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) {
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
|
||||
DCHECK_LE(bytes, kMaxInt);
|
||||
sub(esp, Immediate(bytes));
|
||||
}
|
||||
|
@ -240,8 +240,7 @@ class LiftoffCompiler {
|
||||
}
|
||||
__ EnterFrame(StackFrame::WASM_COMPILED);
|
||||
__ set_has_frame(true);
|
||||
__ ReserveStackSpace(LiftoffAssembler::kStackSlotSize *
|
||||
__ GetTotalFrameSlotCount());
|
||||
__ ReserveStackSpace(__ GetTotalFrameSlotCount());
|
||||
// Parameter 0 is the wasm context.
|
||||
uint32_t num_params =
|
||||
static_cast<uint32_t>(call_desc_->ParameterCount()) - 1;
|
||||
|
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -11,7 +11,9 @@ namespace v8 {
|
||||
namespace internal {
|
||||
namespace wasm {
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) { UNIMPLEMENTED(); }
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
|
||||
RelocInfo::Mode rmode) {
|
||||
|
@ -16,12 +16,15 @@ namespace wasm {
|
||||
|
||||
namespace liftoff {
|
||||
|
||||
// rbp-8 holds the stack marker, rbp-16 is the wasm context, first stack slot
|
||||
// is located at rbp-24.
|
||||
constexpr int32_t kConstantStackSpace = 16;
|
||||
constexpr int32_t kFirstStackSlotOffset =
|
||||
kConstantStackSpace + LiftoffAssembler::kStackSlotSize;
|
||||
|
||||
inline Operand GetStackSlot(uint32_t index) {
|
||||
// rbp-8 holds the stack marker, rbp-16 is the wasm context, first stack slot
|
||||
// is located at rbp-24.
|
||||
constexpr int32_t kFirstStackSlotOffset = -24;
|
||||
return Operand(
|
||||
rbp, kFirstStackSlotOffset - index * LiftoffAssembler::kStackSlotSize);
|
||||
rbp, -kFirstStackSlotOffset - index * LiftoffAssembler::kStackSlotSize);
|
||||
}
|
||||
|
||||
// TODO(clemensh): Make this a constexpr variable once Operand is constexpr.
|
||||
@ -33,7 +36,8 @@ static constexpr Register kCCallLastArgAddrReg = rax;
|
||||
|
||||
} // namespace liftoff
|
||||
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t bytes) {
|
||||
void LiftoffAssembler::ReserveStackSpace(uint32_t stack_slots) {
|
||||
uint32_t bytes = liftoff::kConstantStackSpace + kStackSlotSize * stack_slots;
|
||||
DCHECK_LE(bytes, kMaxInt);
|
||||
subp(rsp, Immediate(bytes));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user