[ia32] Refactor stack overflow check in CallOrConstructVarargs
R=jgruber@chromium.org Bug: v8:6666, v8:8015 Change-Id: I37c4fc6771247c448ec3194790fe9fad3c9bdebf Reviewed-on: https://chromium-review.googlesource.com/1236054 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#56096}
This commit is contained in:
parent
d9fbfeb894
commit
adcc88fc32
@ -1583,21 +1583,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
__ bind(&ok);
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(scratch, RootIndex::kRealStackLimit);
|
||||
// The stack might already be overflowed here which will cause 'scratch' to
|
||||
// become negative.
|
||||
__ sub(scratch, sp, scratch);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ cmp(scratch, Operand(r4, LSL, kPointerSizeLog2));
|
||||
__ b(gt, &done); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, r4, scratch, &stack_overflow);
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
@ -1620,6 +1607,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1917,21 +1917,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
Register argc = x0;
|
||||
Register len = x4;
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(x10, RootIndex::kRealStackLimit);
|
||||
// Make x10 the space we have left. The stack might already be overflowed
|
||||
// here which will cause x10 to become negative.
|
||||
__ Sub(x10, sp, x10);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ Cmp(x10, Operand(len, LSL, kPointerSizeLog2));
|
||||
__ B(gt, &done); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ Bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, len, &stack_overflow);
|
||||
|
||||
// Skip argument setup if we don't need to push any varargs.
|
||||
Label done;
|
||||
@ -1964,6 +1951,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1750,25 +1750,10 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
__ bind(&ok);
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
ExternalReference real_stack_limit =
|
||||
ExternalReference::address_of_real_stack_limit(masm->isolate());
|
||||
__ mov(edx, __ StaticVariable(real_stack_limit));
|
||||
// Make edx the space we have left. The stack might already be overflowed
|
||||
// here which will cause edx to become negative.
|
||||
__ neg(edx);
|
||||
__ add(edx, esp);
|
||||
__ sar(edx, kPointerSizeLog2);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ cmp(edx, kArgumentsLength);
|
||||
__ j(greater, &done, Label::kNear); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
// 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;
|
||||
Generate_StackOverflowCheck(masm, kArgumentsLength, edx, &stack_overflow);
|
||||
|
||||
// Push additional arguments onto the stack.
|
||||
{
|
||||
@ -1802,6 +1787,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1858,28 +1846,11 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
|
||||
}
|
||||
__ bind(&arguments_done);
|
||||
|
||||
Label stack_done;
|
||||
Label stack_done, stack_overflow;
|
||||
__ sub(edx, ecx);
|
||||
__ j(less_equal, &stack_done);
|
||||
{
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(ecx, RootIndex::kRealStackLimit);
|
||||
// Make ecx the space we have left. The stack might already be
|
||||
// overflowed here which will cause ecx to become negative.
|
||||
__ neg(ecx);
|
||||
__ add(ecx, esp);
|
||||
__ sar(ecx, kPointerSizeLog2);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ cmp(ecx, edx);
|
||||
__ j(greater, &done, Label::kNear); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Generate_StackOverflowCheck(masm, edx, ecx, &stack_overflow);
|
||||
|
||||
// Forward the arguments from the caller frame.
|
||||
{
|
||||
@ -1902,6 +1873,9 @@ void Builtins::Generate_CallOrConstructForwardVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the {code} handler.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1587,20 +1587,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(t1, RootIndex::kRealStackLimit);
|
||||
// Make ip the space we have left. The stack might already be overflowed
|
||||
// here which will cause ip to become negative.
|
||||
__ Subu(t1, sp, t1);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ sll(kScratchReg, t0, kPointerSizeLog2);
|
||||
__ Branch(&done, gt, t1, Operand(kScratchReg)); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, t0, kScratchReg, t1, &stack_overflow);
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
@ -1623,6 +1611,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1604,20 +1604,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
Register len = a4;
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(a5, RootIndex::kRealStackLimit);
|
||||
// Make ip the space we have left. The stack might already be overflowed
|
||||
// here which will cause ip to become negative.
|
||||
__ Dsubu(a5, sp, a5);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ dsll(kScratchReg, len, kPointerSizeLog2);
|
||||
__ Branch(&done, gt, a5, Operand(kScratchReg)); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, len, kScratchReg, a5, &stack_overflow);
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
@ -1644,6 +1632,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1649,21 +1649,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(ip, RootIndex::kRealStackLimit);
|
||||
// Make ip the space we have left. The stack might already be overflowed
|
||||
// here which will cause ip to become negative.
|
||||
__ sub(ip, sp, ip);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ ShiftLeftImm(r0, r7, Operand(kPointerSizeLog2));
|
||||
__ cmp(ip, r0); // Signed comparison.
|
||||
__ bgt(&done);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, r7, ip, &stack_overflow);
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
@ -1687,6 +1674,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1653,21 +1653,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(ip, RootIndex::kRealStackLimit);
|
||||
// Make ip the space we have left. The stack might already be overflowed
|
||||
// here which will cause ip to become negative.
|
||||
__ SubP(ip, sp, ip);
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ ShiftLeftP(r0, r6, Operand(kPointerSizeLog2));
|
||||
__ CmpP(ip, r0); // Signed comparison.
|
||||
__ bgt(&done);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, r6, ip, &stack_overflow);
|
||||
|
||||
// Push arguments onto the stack (thisArgument is already on the stack).
|
||||
{
|
||||
@ -1692,6 +1679,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -1774,23 +1774,8 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
__ bind(&ok);
|
||||
}
|
||||
|
||||
// Check for stack overflow.
|
||||
{
|
||||
// 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 done;
|
||||
__ LoadRoot(kScratchRegister, RootIndex::kRealStackLimit);
|
||||
__ movp(r8, rsp);
|
||||
// Make r8 the space we have left. The stack might already be overflowed
|
||||
// here which will cause r8 to become negative.
|
||||
__ subp(r8, kScratchRegister);
|
||||
__ sarp(r8, Immediate(kPointerSizeLog2));
|
||||
// Check if the arguments will overflow the stack.
|
||||
__ cmpp(r8, rcx);
|
||||
__ j(greater, &done, Label::kNear); // Signed comparison.
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
__ bind(&done);
|
||||
}
|
||||
Label stack_overflow;
|
||||
Generate_StackOverflowCheck(masm, rcx, r8, &stack_overflow, Label::kNear);
|
||||
|
||||
// Push additional arguments onto the stack.
|
||||
{
|
||||
@ -1817,6 +1802,9 @@ void Builtins::Generate_CallOrConstructVarargs(MacroAssembler* masm,
|
||||
|
||||
// Tail-call to the actual Call or Construct builtin.
|
||||
__ Jump(code, RelocInfo::CODE_TARGET);
|
||||
|
||||
__ bind(&stack_overflow);
|
||||
__ TailCallRuntime(Runtime::kThrowStackOverflow);
|
||||
}
|
||||
|
||||
// static
|
||||
|
Loading…
Reference in New Issue
Block a user