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) { ...@@ -484,7 +484,7 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
// Check the stack for overflow. We are not trying to catch interruptions // 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". // (i.e. debug break and preemption) here, so check the "real stack limit".
Label stack_overflow; Label stack_overflow;
__ CompareRoot(esp, ecx, RootIndex::kRealStackLimit); __ CompareRealStackLimit(esp);
__ j(below, &stack_overflow); __ j(below, &stack_overflow);
// Pop return address. // Pop return address.
...@@ -875,9 +875,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -875,9 +875,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
Label ok; Label ok;
__ mov(eax, esp); __ mov(eax, esp);
__ sub(eax, frame_size); __ sub(eax, frame_size);
ExternalReference stack_limit = __ CompareRealStackLimit(eax);
ExternalReference::address_of_real_stack_limit(masm->isolate());
__ cmp(eax, __ StaticVariable(stack_limit));
__ j(above_equal, &ok); __ j(above_equal, &ok);
__ CallRuntime(Runtime::kThrowStackOverflow); __ CallRuntime(Runtime::kThrowStackOverflow);
__ bind(&ok); __ bind(&ok);
...@@ -2071,7 +2069,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) { ...@@ -2071,7 +2069,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
// Check the stack for overflow. We are not trying to catch interruptions // Check the stack for overflow. We are not trying to catch interruptions
// (i.e. debug break and preemption) here, so check the "real stack // (i.e. debug break and preemption) here, so check the "real stack
// limit". // limit".
__ CompareRoot(esp, ecx, RootIndex::kRealStackLimit); __ CompareRealStackLimit(esp);
__ j(above_equal, &done, Label::kNear); __ j(above_equal, &done, Label::kNear);
// Restore the stack pointer. // Restore the stack pointer.
__ lea(esp, Operand(esp, edx, times_pointer_size, 0)); __ lea(esp, Operand(esp, edx, times_pointer_size, 0));
......
...@@ -3660,10 +3660,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3660,10 +3660,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
} }
case kIA32StackCheck: { case kIA32StackCheck: {
ExternalReference const stack_limit =
ExternalReference::address_of_stack_limit(__ isolate());
__ VerifyRootRegister(); __ VerifyRootRegister();
__ cmp(esp, tasm()->StaticVariable(stack_limit)); __ CompareStackLimit(esp);
break; break;
} }
case kIA32Word32AtomicPairLoad: { case kIA32Word32AtomicPairLoad: {
......
...@@ -106,7 +106,7 @@ void TurboAssembler::LoadRoot(Register destination, RootIndex index) { ...@@ -106,7 +106,7 @@ void TurboAssembler::LoadRoot(Register destination, RootIndex index) {
RelocInfo::EXTERNAL_REFERENCE)); RelocInfo::EXTERNAL_REFERENCE));
} }
void MacroAssembler::CompareRoot(Register with, Register scratch, void TurboAssembler::CompareRoot(Register with, Register scratch,
RootIndex index) { RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) { if (root_array_available()) {
...@@ -121,7 +121,7 @@ void MacroAssembler::CompareRoot(Register with, Register scratch, ...@@ -121,7 +121,7 @@ void MacroAssembler::CompareRoot(Register with, Register scratch,
RelocInfo::EXTERNAL_REFERENCE)); RelocInfo::EXTERNAL_REFERENCE));
} }
void MacroAssembler::CompareRoot(Register with, RootIndex index) { void TurboAssembler::CompareRoot(Register with, RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) { if (root_array_available()) {
Assembler::AllowExplicitEbxAccessScope read_only_access(this); Assembler::AllowExplicitEbxAccessScope read_only_access(this);
...@@ -138,6 +138,31 @@ void MacroAssembler::CompareRoot(Register with, RootIndex index) { ...@@ -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) { void MacroAssembler::PushRoot(RootIndex index) {
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
if (root_array_available()) { if (root_array_available()) {
......
...@@ -263,6 +263,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -263,6 +263,11 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
pop(kRootRegister); 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 // Wrapper functions to ensure external reference operands produce
// isolate-independent code if needed. // isolate-independent code if needed.
Operand StaticVariable(const ExternalReference& ext); Operand StaticVariable(const ExternalReference& ext);
...@@ -492,11 +497,6 @@ class MacroAssembler : public TurboAssembler { ...@@ -492,11 +497,6 @@ class MacroAssembler : public TurboAssembler {
} }
void Set(Operand dst, int32_t x) { mov(dst, Immediate(x)); } 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); void PushRoot(RootIndex index);
// Compare the object in a register to a value and jump if they are equal. // 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