Commit 2dde677f authored by jkummerow's avatar jkummerow Committed by Commit bot

[Crankshaft] ia32/x64: Fix environment handling for LMulI

This is the ia32/x64 version of https://codereview.chromium.org/873703002,
which fixed the same problem on arm/arm64.

BUG=chromium:553441
LOG=n
R=yangguo@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#33386}
parent 722909f3
......@@ -1524,14 +1524,22 @@ LInstruction* LChunkBuilder::DoMul(HMul* instr) {
DCHECK(instr->left()->representation().Equals(instr->representation()));
DCHECK(instr->right()->representation().Equals(instr->representation()));
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseOrConstant(instr->BetterRightOperand());
HValue* h_right = instr->BetterRightOperand();
LOperand* right = UseOrConstant(h_right);
LOperand* temp = NULL;
if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
temp = TempRegister();
}
LMulI* mul = new(zone()) LMulI(left, right, temp);
if (instr->CheckFlag(HValue::kCanOverflow) ||
instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
int constant_value =
h_right->IsConstant() ? HConstant::cast(h_right)->Integer32Value() : 0;
// |needs_environment| must mirror the cases where LCodeGen::DoMulI calls
// |DeoptimizeIf|.
bool needs_environment =
instr->CheckFlag(HValue::kCanOverflow) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
(!right->IsConstantOperand() || constant_value <= 0));
if (needs_environment) {
AssignEnvironment(mul);
}
return DefineSameAsFirst(mul);
......
......@@ -1511,10 +1511,18 @@ LInstruction* LChunkBuilder::DoMul(HMul* instr) {
DCHECK(instr->left()->representation().Equals(instr->representation()));
DCHECK(instr->right()->representation().Equals(instr->representation()));
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
LOperand* right = UseOrConstant(instr->BetterRightOperand());
HValue* h_right = instr->BetterRightOperand();
LOperand* right = UseOrConstant(h_right);
LMulI* mul = new(zone()) LMulI(left, right);
if (instr->CheckFlag(HValue::kCanOverflow) ||
instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
int constant_value =
h_right->IsConstant() ? HConstant::cast(h_right)->Integer32Value() : 0;
// |needs_environment| must mirror the cases where LCodeGen::DoMulI calls
// |DeoptimizeIf|.
bool needs_environment =
instr->CheckFlag(HValue::kCanOverflow) ||
(instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
(!right->IsConstantOperand() || constant_value <= 0));
if (needs_environment) {
AssignEnvironment(mul);
}
return DefineSameAsFirst(mul);
......
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