Commit 66afdda6 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[ia32,root] Make stack comparisons ready for root support

Change-Id: I673c4bddca876dd506be4979bbf2208e6f0af329
Bug: v8:6666
Also-By: jgruber@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/1280326
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56675}
parent c45bc57d
......@@ -484,7 +484,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
// Check the stack for overflow. We are not trying to catch interruptions
// (i.e. debug break and preemption) here, so check the "real stack limit".
Label stack_overflow;
__ CompareRoot(esp, ecx, RootIndex::kRealStackLimit);
__ CompareRealStackLimit(esp);
__ j(below, &stack_overflow);
// Pop return address.
......@@ -875,9 +875,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
Label ok;
__ mov(eax, esp);
__ sub(eax, frame_size);
ExternalReference stack_limit =
ExternalReference::address_of_real_stack_limit(masm->isolate());
__ cmp(eax, __ StaticVariable(stack_limit));
__ CompareRealStackLimit(eax);
__ j(above_equal, &ok);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ bind(&ok);
......@@ -2071,7 +2069,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
// Check the stack for overflow. We are not trying to catch interruptions
// (i.e. debug break and preemption) here, so check the "real stack
// limit".
__ CompareRoot(esp, ecx, RootIndex::kRealStackLimit);
__ CompareRealStackLimit(esp);
__ j(above_equal, &done, Label::kNear);
// Restore the stack pointer.
__ lea(esp, Operand(esp, edx, times_pointer_size, 0));
......
......@@ -3660,10 +3660,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kIA32StackCheck: {
ExternalReference const stack_limit =
ExternalReference::address_of_stack_limit(__ isolate());
__ VerifyRootRegister();
__ cmp(esp, tasm()->StaticVariable(stack_limit));
__ CompareStackLimit(esp);
break;
}
case kIA32Word32AtomicPairLoad: {
......
......@@ -106,7 +106,7 @@ void TurboAssembler::LoadRoot(Register destination, RootIndex index) {
RelocInfo::EXTERNAL_REFERENCE));
}
void MacroAssembler::CompareRoot(Register with, Register scratch,
void TurboAssembler::CompareRoot(Register with, Register scratch,
RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) {
......@@ -121,7 +121,7 @@ void MacroAssembler::CompareRoot(Register with, Register scratch,
RelocInfo::EXTERNAL_REFERENCE));
}
void MacroAssembler::CompareRoot(Register with, RootIndex index) {
void TurboAssembler::CompareRoot(Register with, RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) {
Assembler::AllowExplicitEbxAccessScope read_only_access(this);
......@@ -138,6 +138,31 @@ void MacroAssembler::CompareRoot(Register with, RootIndex index) {
}
}
void TurboAssembler::CompareStackLimit(Register with) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) {
CompareRoot(with, RootIndex::kStackLimit);
return;
}
#endif
DCHECK(!options().isolate_independent_code);
ExternalReference ref = ExternalReference::address_of_stack_limit(isolate());
cmp(with, Operand(ref.address(), RelocInfo::EXTERNAL_REFERENCE));
}
void TurboAssembler::CompareRealStackLimit(Register with) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) {
CompareRoot(with, RootIndex::kRealStackLimit);
return;
}
#endif
DCHECK(!options().isolate_independent_code);
ExternalReference ref =
ExternalReference::address_of_real_stack_limit(isolate());
cmp(with, Operand(ref.address(), RelocInfo::EXTERNAL_REFERENCE));
}
void MacroAssembler::PushRoot(RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) {
......
......@@ -263,6 +263,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
pop(kRootRegister);
}
void CompareStackLimit(Register with);
void CompareRealStackLimit(Register with);
void CompareRoot(Register with, RootIndex index);
void CompareRoot(Register with, Register scratch, RootIndex index);
// Wrapper functions to ensure external reference operands produce
// isolate-independent code if needed.
Operand StaticVariable(const ExternalReference& ext);
......@@ -492,11 +497,6 @@ class MacroAssembler : public TurboAssembler {
}
void Set(Operand dst, int32_t x) { mov(dst, Immediate(x)); }
// Operations on roots in the root-array.
void CompareRoot(Register with, Register scratch, RootIndex index);
// These methods can only be used with constant roots (i.e. non-writable
// and not in new space).
void CompareRoot(Register with, RootIndex index);
void PushRoot(RootIndex index);
// Compare the object in a register to a value and jump if they are equal.
......
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