Commit c79fa418 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Use unsigned comparison for stack checks

We use signed comparison when we compare the difference
between SP and stack limit to the size we are going to push,
but need to use unsigned comparison when we compare SP and
stack limit directly.

R=mvstanton@chromium.org

Bug: chromium:876210
Change-Id: I3ca5233677c42aebadb78920592a7c6d8e33a825
Reviewed-on: https://chromium-review.googlesource.com/1206870Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55675}
parent 217cced9
......@@ -1860,7 +1860,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
// (i.e. debug break and preemption) here, so check the "real stack
// limit".
__ CompareRoot(sp, Heap::kRealStackLimitRootIndex);
__ b(gt, &done); // Signed comparison.
__ b(hs, &done);
// Restore the stack pointer.
__ add(sp, sp, Operand(r4, LSL, kPointerSizeLog2));
{
......
......@@ -2217,7 +2217,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
__ Sub(x10, sp, x10);
// Check if the arguments will overflow the stack.
__ Cmp(x10, Operand(bound_argc, LSL, kPointerSizeLog2));
__ B(gt, &done); // Signed comparison.
__ B(hs, &done);
__ TailCallRuntime(Runtime::kThrowStackOverflow);
__ Bind(&done);
}
......
......@@ -1992,7 +1992,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
// (i.e. debug break and preemption) here, so check the "real stack
// limit".
__ CompareRoot(esp, ecx, Heap::kRealStackLimitRootIndex);
__ j(greater, &done, Label::kNear); // Signed comparison.
__ j(above_equal, &done, Label::kNear);
// Restore the stack pointer.
__ lea(esp, Operand(esp, ebx, times_pointer_size, 0));
{
......
......@@ -1864,7 +1864,7 @@ void Builtins::Generate_CallBoundFunctionImpl(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".
__ LoadRoot(kScratchReg, Heap::kRealStackLimitRootIndex);
__ Branch(&done, gt, sp, Operand(kScratchReg)); // Signed comparison.
__ Branch(&done, hs, sp, Operand(kScratchReg));
// Restore the stack pointer.
__ Addu(sp, sp, Operand(t1));
{
......@@ -2022,7 +2022,7 @@ void Builtins::Generate_ConstructBoundFunction(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".
__ LoadRoot(kScratchReg, Heap::kRealStackLimitRootIndex);
__ Branch(&done, gt, sp, Operand(kScratchReg)); // Signed comparison.
__ Branch(&done, hs, sp, Operand(kScratchReg));
// Restore the stack pointer.
__ Addu(sp, sp, Operand(t1));
{
......
......@@ -1884,7 +1884,7 @@ void Builtins::Generate_CallBoundFunctionImpl(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".
__ LoadRoot(kScratchReg, Heap::kRealStackLimitRootIndex);
__ Branch(&done, gt, sp, Operand(kScratchReg)); // Signed comparison.
__ Branch(&done, hs, sp, Operand(kScratchReg));
// Restore the stack pointer.
__ Daddu(sp, sp, Operand(a5));
{
......@@ -2038,7 +2038,7 @@ void Builtins::Generate_ConstructBoundFunction(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".
__ LoadRoot(kScratchReg, Heap::kRealStackLimitRootIndex);
__ Branch(&done, gt, sp, Operand(kScratchReg)); // Signed comparison.
__ Branch(&done, hs, sp, Operand(kScratchReg));
// Restore the stack pointer.
__ Daddu(sp, sp, Operand(a5));
{
......
......@@ -2050,7 +2050,7 @@ void Generate_PushBoundArguments(MacroAssembler* masm) {
// (i.e. debug break and preemption) here, so check the "real stack
// limit".
__ CompareRoot(rsp, Heap::kRealStackLimitRootIndex);
__ j(greater, &done, Label::kNear); // Signed comparison.
__ j(above_equal, &done, Label::kNear);
// Restore the stack pointer.
__ leap(rsp, Operand(rsp, rbx, times_pointer_size, 0));
{
......
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