Commit 61005594 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[liftoff] Switch stack checks to be Isolate independent.

This loads the stack limit address from the instance object instead of
embedding it into the instruction stream. It is another piece towards
making the generated code independent of the Isolate.

R=clemensh@chromium.org
BUG=v8:7424

Change-Id: I9381956adf2d7c42f6626708229cfdd5c4ca114f
Reviewed-on: https://chromium-review.googlesource.com/1117189
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54076}
parent 5b726287
......@@ -300,7 +300,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond");
}
void LiftoffAssembler::StackCheck(Label* ool_code) { BAILOUT("StackCheck"); }
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
BAILOUT("StackCheck");
}
void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting");
......
......@@ -834,14 +834,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
}
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
ExternalReference stack_limit =
ExternalReference::address_of_stack_limit(isolate());
UseScratchRegisterScope temps(this);
Register scratch = temps.AcquireX();
Mov(scratch, Operand(stack_limit));
Ldr(scratch, MemOperand(scratch));
Cmp(sp, scratch);
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
Ldr(limit_address, MemOperand(limit_address));
Cmp(sp, limit_address);
B(ool_code, ls);
}
......
......@@ -1460,9 +1460,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
liftoff::EmitFloatSetCond<&Assembler::ucomisd>(this, cond, dst, lhs, rhs);
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
cmp(esp,
Operand(Immediate(ExternalReference::address_of_stack_limit(isolate()))));
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
cmp(esp, Operand(limit_address, 0));
j(below_equal, ool_code);
}
......
......@@ -338,8 +338,10 @@ void LiftoffAssembler::CacheState::Split(const CacheState& source) {
// TODO(clemensh): Provide a reasonably sized buffer, based on wasm function
// size.
// TODO(mstarzinger): The Isolate is not passed to the base class constructor
// and only used to derive the default options. Remove the Isolate entirely.
LiftoffAssembler::LiftoffAssembler(Isolate* isolate)
: TurboAssembler(isolate, Assembler::DefaultOptions(isolate), nullptr, 0,
: TurboAssembler(nullptr, Assembler::DefaultOptions(isolate), nullptr, 0,
CodeObjectRequired::kNo) {
set_trap_on_abort(true); // Avoid calls to Abort.
}
......
......@@ -516,7 +516,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_f64_set_cond(Condition condition, Register dst,
DoubleRegister lhs, DoubleRegister rhs);
inline void StackCheck(Label* ool_code);
inline void StackCheck(Label* ool_code, Register limit_address);
inline void CallTrapCallbackForTesting();
......
......@@ -290,7 +290,9 @@ class LiftoffCompiler {
out_of_line_code_.push_back(
OutOfLineCode::StackCheck(position, __ cache_state()->used_registers));
OutOfLineCode& ool = out_of_line_code_.back();
__ StackCheck(ool.label.get());
LiftoffRegister limit_address = __ GetUnusedRegister(kGpReg);
LOAD_INSTANCE_FIELD(limit_address, StackLimitAddress, kPointerLoadType);
__ StackCheck(ool.label.get(), limit_address.gp());
__ bind(ool.continuation.get());
}
......
......@@ -1215,12 +1215,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
bind(&cont);
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
LiftoffRegister tmp = GetUnusedRegister(kGpReg);
TurboAssembler::li(
tmp.gp(), Operand(ExternalReference::address_of_stack_limit(isolate())));
TurboAssembler::Ulw(tmp.gp(), MemOperand(tmp.gp()));
TurboAssembler::Branch(ool_code, ule, sp, Operand(tmp.gp()));
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
TurboAssembler::Ulw(limit_address, MemOperand(limit_address));
TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address));
}
void LiftoffAssembler::CallTrapCallbackForTesting() {
......
......@@ -1079,12 +1079,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
bind(&cont);
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
LiftoffRegister tmp = GetUnusedRegister(kGpReg);
TurboAssembler::li(
tmp.gp(), Operand(ExternalReference::address_of_stack_limit(isolate())));
TurboAssembler::Uld(tmp.gp(), MemOperand(tmp.gp()));
TurboAssembler::Branch(ool_code, ule, sp, Operand(tmp.gp()));
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
TurboAssembler::Uld(limit_address, MemOperand(limit_address));
TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address));
}
void LiftoffAssembler::CallTrapCallbackForTesting() {
......
......@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond");
}
void LiftoffAssembler::StackCheck(Label* ool_code) { BAILOUT("StackCheck"); }
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
BAILOUT("StackCheck");
}
void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting");
......
......@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond");
}
void LiftoffAssembler::StackCheck(Label* ool_code) { BAILOUT("StackCheck"); }
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
BAILOUT("StackCheck");
}
void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting");
......
......@@ -1307,10 +1307,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
rhs);
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
Operand stack_limit = ExternalOperand(
ExternalReference::address_of_stack_limit(isolate()), kScratchRegister);
cmpp(rsp, stack_limit);
void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
cmpp(rsp, Operand(limit_address, 0));
j(below_equal, ool_code);
}
......
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