Commit eaa86cbf authored by ivica.bogosavljevic's avatar ivica.bogosavljevic Committed by Commit bot

MIPS: Fix infinite loop in Math.pow(2,-2147483648)

BUG=v8:5213

Review-Url: https://codereview.chromium.org/2163963003
Cr-Commit-Position: refs/heads/master@{#37955}
parent 6f31bc9c
......@@ -823,10 +823,14 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ Move(double_result, 1.0);
// Get absolute value of exponent.
Label positive_exponent;
Label positive_exponent, bail_out;
__ Branch(&positive_exponent, ge, scratch, Operand(zero_reg));
__ Subu(scratch, zero_reg, scratch);
// Check when Subu overflows and we get negative result
// (happens only when input is MIN_INT).
__ Branch(&bail_out, gt, zero_reg, Operand(scratch));
__ bind(&positive_exponent);
__ Assert(ge, kUnexpectedNegativeValue, scratch, Operand(zero_reg));
Label while_true, no_carry, loop_end;
__ bind(&while_true);
......@@ -859,6 +863,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ cvt_d_w(double_exponent, single_scratch);
// Returning or bailing out.
__ bind(&bail_out);
__ push(ra);
{
AllowExternalCallThatCantCauseGC scope(masm);
......
......@@ -820,10 +820,14 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ Move(double_result, 1.0);
// Get absolute value of exponent.
Label positive_exponent;
Label positive_exponent, bail_out;
__ Branch(&positive_exponent, ge, scratch, Operand(zero_reg));
__ Dsubu(scratch, zero_reg, scratch);
// Check when Dsubu overflows and we get negative result
// (happens only when input is MIN_INT).
__ Branch(&bail_out, gt, zero_reg, Operand(scratch));
__ bind(&positive_exponent);
__ Assert(ge, kUnexpectedNegativeValue, scratch, Operand(zero_reg));
Label while_true, no_carry, loop_end;
__ bind(&while_true);
......@@ -856,6 +860,7 @@ void MathPowStub::Generate(MacroAssembler* masm) {
__ cvt_d_w(double_exponent, single_scratch);
// Returning or bailing out.
__ bind(&bail_out);
__ push(ra);
{
AllowExternalCallThatCantCauseGC scope(masm);
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// See http://code.google.com/p/v8/issues/detail?id=5213
assertEquals(0, Math.pow(2,-2147483648));
assertEquals(0, Math.pow(2,-9223372036854775808));
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