Commit b7d8cb4a authored by dusan.milosavljevic's avatar dusan.milosavljevic Committed by Commit bot

MIPS: Remove unsafe EmitLoadRegister usage in AddI/SubI for constant right operand.

TEST=test/mjsunit/regress/regress-500176
BUG=chromium:500176
LOG=N

Review URL: https://codereview.chromium.org/1185143002

Cr-Commit-Position: refs/heads/master@{#29030}
parent a7fce186
......@@ -1672,19 +1672,16 @@ void LCodeGen::DoSubI(LSubI* instr) {
} else { // can_overflow.
Register overflow = scratch0();
Register scratch = scratch1();
if (right->IsStackSlot() || right->IsConstantOperand()) {
if (right->IsStackSlot()) {
Register right_reg = EmitLoadRegister(right, scratch);
__ SubuAndCheckForOverflow(ToRegister(result),
ToRegister(left),
right_reg,
overflow); // Reg at also used as scratch.
} else {
DCHECK(right->IsRegister());
// Due to overflow check macros not supporting constant operands,
// handling the IsConstantOperand case was moved to prev if clause.
__ SubuAndCheckForOverflow(ToRegister(result),
ToRegister(left),
ToRegister(right),
DCHECK(right->IsRegister() || right->IsConstantOperand());
__ SubuAndCheckForOverflow(ToRegister(result), ToRegister(left),
ToOperand(right),
overflow); // Reg at also used as scratch.
}
DeoptimizeIf(lt, instr, Deoptimizer::kOverflow, overflow,
......@@ -1872,20 +1869,16 @@ void LCodeGen::DoAddI(LAddI* instr) {
} else { // can_overflow.
Register overflow = scratch0();
Register scratch = scratch1();
if (right->IsStackSlot() ||
right->IsConstantOperand()) {
if (right->IsStackSlot()) {
Register right_reg = EmitLoadRegister(right, scratch);
__ AdduAndCheckForOverflow(ToRegister(result),
ToRegister(left),
right_reg,
overflow); // Reg at also used as scratch.
} else {
DCHECK(right->IsRegister());
// Due to overflow check macros not supporting constant operands,
// handling the IsConstantOperand case was moved to prev if clause.
__ AdduAndCheckForOverflow(ToRegister(result),
ToRegister(left),
ToRegister(right),
DCHECK(right->IsRegister() || right->IsConstantOperand());
__ AdduAndCheckForOverflow(ToRegister(result), ToRegister(left),
ToOperand(right),
overflow); // Reg at also used as scratch.
}
DeoptimizeIf(lt, instr, Deoptimizer::kOverflow, overflow,
......
......@@ -4452,17 +4452,17 @@ void MacroAssembler::AdduAndCheckForOverflow(Register dst, Register left,
} else {
if (dst.is(left)) {
mov(scratch, left); // Preserve left.
addiu(dst, left, right.immediate()); // Left is overwritten.
Addu(dst, left, right.immediate()); // Left is overwritten.
xor_(scratch, dst, scratch); // Original left.
// Load right since xori takes uint16 as immediate.
addiu(t9, zero_reg, right.immediate());
Addu(t9, zero_reg, right);
xor_(overflow_dst, dst, t9);
and_(overflow_dst, overflow_dst, scratch);
} else {
addiu(dst, left, right.immediate());
xor_(overflow_dst, dst, left);
// Load right since xori takes uint16 as immediate.
addiu(t9, zero_reg, right.immediate());
Addu(t9, zero_reg, right);
xor_(scratch, dst, t9);
and_(overflow_dst, scratch, overflow_dst);
}
......@@ -4520,17 +4520,17 @@ void MacroAssembler::SubuAndCheckForOverflow(Register dst, Register left,
} else {
if (dst.is(left)) {
mov(scratch, left); // Preserve left.
addiu(dst, left, -(right.immediate())); // Left is overwritten.
Subu(dst, left, right); // Left is overwritten.
xor_(overflow_dst, dst, scratch); // scratch is original left.
// Load right since xori takes uint16 as immediate.
addiu(t9, zero_reg, right.immediate());
Addu(t9, zero_reg, right);
xor_(scratch, scratch, t9); // scratch is original left.
and_(overflow_dst, scratch, overflow_dst);
} else {
addiu(dst, left, -(right.immediate()));
Subu(dst, left, right);
xor_(overflow_dst, dst, left);
// Load right since xori takes uint16 as immediate.
addiu(t9, zero_reg, right.immediate());
Addu(t9, zero_reg, right);
xor_(scratch, left, t9);
and_(overflow_dst, scratch, overflow_dst);
}
......
// Copyright 2015 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.
function __f_0(p) {
var __v_0 = -2147483642;
for (var __v_1 = 0; __v_1 < 10; __v_1++) {
if (__v_1 > 5) { __v_0 = __v_0 + p; break;}
}
}
for (var __v_2 = 0; __v_2 < 100000; __v_2++) __f_0(42);
__v_2 = { f: function () { return x + y; },
2: function () { return x - y} };
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