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, ...@@ -300,7 +300,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond"); 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() { void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting"); BAILOUT("CallTrapCallbackForTesting");
......
...@@ -834,14 +834,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -834,14 +834,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
} }
} }
void LiftoffAssembler::StackCheck(Label* ool_code) { void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
ExternalReference stack_limit = Ldr(limit_address, MemOperand(limit_address));
ExternalReference::address_of_stack_limit(isolate()); Cmp(sp, limit_address);
UseScratchRegisterScope temps(this);
Register scratch = temps.AcquireX();
Mov(scratch, Operand(stack_limit));
Ldr(scratch, MemOperand(scratch));
Cmp(sp, scratch);
B(ool_code, ls); B(ool_code, ls);
} }
......
...@@ -1460,9 +1460,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -1460,9 +1460,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
liftoff::EmitFloatSetCond<&Assembler::ucomisd>(this, cond, dst, lhs, rhs); liftoff::EmitFloatSetCond<&Assembler::ucomisd>(this, cond, dst, lhs, rhs);
} }
void LiftoffAssembler::StackCheck(Label* ool_code) { void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
cmp(esp, cmp(esp, Operand(limit_address, 0));
Operand(Immediate(ExternalReference::address_of_stack_limit(isolate()))));
j(below_equal, ool_code); j(below_equal, ool_code);
} }
......
...@@ -338,8 +338,10 @@ void LiftoffAssembler::CacheState::Split(const CacheState& source) { ...@@ -338,8 +338,10 @@ void LiftoffAssembler::CacheState::Split(const CacheState& source) {
// TODO(clemensh): Provide a reasonably sized buffer, based on wasm function // TODO(clemensh): Provide a reasonably sized buffer, based on wasm function
// size. // 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) LiftoffAssembler::LiftoffAssembler(Isolate* isolate)
: TurboAssembler(isolate, Assembler::DefaultOptions(isolate), nullptr, 0, : TurboAssembler(nullptr, Assembler::DefaultOptions(isolate), nullptr, 0,
CodeObjectRequired::kNo) { CodeObjectRequired::kNo) {
set_trap_on_abort(true); // Avoid calls to Abort. set_trap_on_abort(true); // Avoid calls to Abort.
} }
......
...@@ -516,7 +516,7 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -516,7 +516,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_f64_set_cond(Condition condition, Register dst, inline void emit_f64_set_cond(Condition condition, Register dst,
DoubleRegister lhs, DoubleRegister rhs); DoubleRegister lhs, DoubleRegister rhs);
inline void StackCheck(Label* ool_code); inline void StackCheck(Label* ool_code, Register limit_address);
inline void CallTrapCallbackForTesting(); inline void CallTrapCallbackForTesting();
......
...@@ -290,7 +290,9 @@ class LiftoffCompiler { ...@@ -290,7 +290,9 @@ class LiftoffCompiler {
out_of_line_code_.push_back( out_of_line_code_.push_back(
OutOfLineCode::StackCheck(position, __ cache_state()->used_registers)); OutOfLineCode::StackCheck(position, __ cache_state()->used_registers));
OutOfLineCode& ool = out_of_line_code_.back(); 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()); __ bind(ool.continuation.get());
} }
......
...@@ -1215,12 +1215,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -1215,12 +1215,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
bind(&cont); bind(&cont);
} }
void LiftoffAssembler::StackCheck(Label* ool_code) { void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
LiftoffRegister tmp = GetUnusedRegister(kGpReg); TurboAssembler::Ulw(limit_address, MemOperand(limit_address));
TurboAssembler::li( TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address));
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::CallTrapCallbackForTesting() { void LiftoffAssembler::CallTrapCallbackForTesting() {
......
...@@ -1079,12 +1079,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -1079,12 +1079,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
bind(&cont); bind(&cont);
} }
void LiftoffAssembler::StackCheck(Label* ool_code) { void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
LiftoffRegister tmp = GetUnusedRegister(kGpReg); TurboAssembler::Uld(limit_address, MemOperand(limit_address));
TurboAssembler::li( TurboAssembler::Branch(ool_code, ule, sp, Operand(limit_address));
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::CallTrapCallbackForTesting() { void LiftoffAssembler::CallTrapCallbackForTesting() {
......
...@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond"); 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() { void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting"); BAILOUT("CallTrapCallbackForTesting");
......
...@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -309,7 +309,9 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
BAILOUT("emit_f64_set_cond"); 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() { void LiftoffAssembler::CallTrapCallbackForTesting() {
BAILOUT("CallTrapCallbackForTesting"); BAILOUT("CallTrapCallbackForTesting");
......
...@@ -1307,10 +1307,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst, ...@@ -1307,10 +1307,8 @@ void LiftoffAssembler::emit_f64_set_cond(Condition cond, Register dst,
rhs); rhs);
} }
void LiftoffAssembler::StackCheck(Label* ool_code) { void LiftoffAssembler::StackCheck(Label* ool_code, Register limit_address) {
Operand stack_limit = ExternalOperand( cmpp(rsp, Operand(limit_address, 0));
ExternalReference::address_of_stack_limit(isolate()), kScratchRegister);
cmpp(rsp, stack_limit);
j(below_equal, ool_code); 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