[Liftoff][x64] Improve stack check

Emit shorter code and avoid use of a register if the root array is
available.

R=mstarzinger@chromium.org

Bug: v8:6600
Change-Id: I20613af154c8dcc6dc22a81c77fd2faded2dad1e
Reviewed-on: https://chromium-review.googlesource.com/965061
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51986}
This commit is contained in:
Clemens Hammacher 2018-03-15 23:03:59 +01:00 committed by Commit Bot
parent 27e36250f7
commit 32e7290841
3 changed files with 24 additions and 25 deletions

View File

@ -767,9 +767,9 @@ void LiftoffAssembler::emit_f32_set_cond(Condition cond, Register dst,
}
void LiftoffAssembler::StackCheck(Label* ool_code) {
Register limit = GetUnusedRegister(kGpReg).gp();
LoadAddress(limit, ExternalReference::address_of_stack_limit(isolate()));
cmpp(rsp, Operand(limit, 0));
Operand stack_limit = ExternalOperand(
ExternalReference::address_of_stack_limit(isolate()), kScratchRegister);
cmpp(rsp, stack_limit);
j(below_equal, ool_code);
}

View File

@ -100,20 +100,6 @@ int64_t TurboAssembler::RootRegisterDelta(ExternalReference other) {
return delta;
}
Operand MacroAssembler::ExternalOperand(ExternalReference target,
Register scratch) {
if (root_array_available_ && !serializer_enabled()) {
int64_t delta = RootRegisterDelta(target);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
return Operand(kRootRegister, static_cast<int32_t>(delta));
}
}
Move(scratch, target);
return Operand(scratch, 0);
}
void MacroAssembler::Load(Register destination, ExternalReference source) {
if (root_array_available_ && !serializer_enabled()) {
int64_t delta = RootRegisterDelta(source);
@ -162,6 +148,18 @@ void TurboAssembler::LoadAddress(Register destination,
Move(destination, source);
}
Operand TurboAssembler::ExternalOperand(ExternalReference target,
Register scratch) {
if (root_array_available_ && !serializer_enabled()) {
int64_t delta = RootRegisterDelta(target);
if (delta != kInvalidRootRegisterDelta && is_int32(delta)) {
return Operand(kRootRegister, static_cast<int32_t>(delta));
}
}
Move(scratch, target);
return Operand(scratch, 0);
}
int TurboAssembler::LoadAddressSize(ExternalReference source) {
if (root_array_available_ && !serializer_enabled()) {
// This calculation depends on the internals of LoadAddress.

View File

@ -356,6 +356,15 @@ class TurboAssembler : public Assembler {
// register.
void LoadAddress(Register destination, ExternalReference source);
// Operand pointing to an external reference.
// May emit code to set up the scratch register. The operand is
// only guaranteed to be correct as long as the scratch register
// isn't changed.
// If the operand is used more than once, use a scratch register
// that is guaranteed not to be clobbered.
Operand ExternalOperand(ExternalReference reference,
Register scratch = kScratchRegister);
void Call(Operand op);
void Call(Handle<Code> code_object, RelocInfo::Mode rmode);
void Call(Address destination, RelocInfo::Mode rmode);
@ -542,14 +551,6 @@ class MacroAssembler : public TurboAssembler {
bool old_value_;
};
// Operand pointing to an external reference.
// May emit code to set up the scratch register. The operand is
// only guaranteed to be correct as long as the scratch register
// isn't changed.
// If the operand is used more than once, use a scratch register
// that is guaranteed not to be clobbered.
Operand ExternalOperand(ExternalReference reference,
Register scratch = kScratchRegister);
// Loads and stores the value of an external reference.
// Special case code for load and store to take advantage of
// load_rax/store_rax if possible/necessary.