Commit 16a4129e authored by plind44@gmail.com's avatar plind44@gmail.com

MIPS: Fix uses of range analysis results in HChange.

Port r19872 (6d8679b)

BUG=v8:3204
LOG=y
R=plind44@gmail.com

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

Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19899 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 64539289
......@@ -4456,22 +4456,6 @@ void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
}
void LCodeGen::DoInteger32ToSmi(LInteger32ToSmi* instr) {
LOperand* input = instr->value();
LOperand* output = instr->result();
Register scratch = scratch0();
ASSERT(output->IsRegister());
if (!instr->hydrogen()->value()->HasRange() ||
!instr->hydrogen()->value()->range()->IsInSmiRange()) {
__ SmiTagCheckOverflow(ToRegister(output), ToRegister(input), scratch);
DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg));
} else {
__ SmiTag(ToRegister(output), ToRegister(input));
}
}
void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) {
LOperand* input = instr->value();
LOperand* output = instr->result();
......@@ -4482,19 +4466,6 @@ void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) {
}
void LCodeGen::DoUint32ToSmi(LUint32ToSmi* instr) {
LOperand* input = instr->value();
LOperand* output = instr->result();
if (!instr->hydrogen()->value()->HasRange() ||
!instr->hydrogen()->value()->range()->IsInSmiRange()) {
Register scratch = scratch0();
__ And(scratch, ToRegister(input), Operand(0xc0000000));
DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
}
__ SmiTag(ToRegister(output), ToRegister(input));
}
void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
class DeferredNumberTagI V8_FINAL : public LDeferredCode {
public:
......@@ -4675,8 +4646,21 @@ void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) {
void LCodeGen::DoSmiTag(LSmiTag* instr) {
ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow));
__ SmiTag(ToRegister(instr->result()), ToRegister(instr->value()));
HChange* hchange = instr->hydrogen();
Register input = ToRegister(instr->value());
Register output = ToRegister(instr->result());
if (hchange->CheckFlag(HValue::kCanOverflow) &&
hchange->value()->CheckFlag(HValue::kUint32)) {
__ And(at, input, Operand(0xc0000000));
DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg));
}
if (hchange->CheckFlag(HValue::kCanOverflow) &&
!hchange->value()->CheckFlag(HValue::kUint32)) {
__ SmiTagCheckOverflow(output, input, at);
DeoptimizeIf(lt, instr->environment(), at, Operand(zero_reg));
} else {
__ SmiTag(output, input);
}
}
......
......@@ -1799,13 +1799,13 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
if (to.IsTagged()) {
HValue* val = instr->value();
LOperand* value = UseRegisterAtStart(val);
if (val->CheckFlag(HInstruction::kUint32)) {
if (!instr->CheckFlag(HValue::kCanOverflow)) {
return DefineAsRegister(new(zone()) LSmiTag(value));
} else if (val->CheckFlag(HInstruction::kUint32)) {
LOperand* temp1 = TempRegister();
LOperand* temp2 = TempRegister();
LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2);
return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
} else if (val->HasRange() && val->range()->IsInSmiRange()) {
return DefineAsRegister(new(zone()) LSmiTag(value));
} else {
LOperand* temp1 = TempRegister();
LOperand* temp2 = TempRegister();
......@@ -1815,13 +1815,11 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
} else if (to.IsSmi()) {
HValue* val = instr->value();
LOperand* value = UseRegister(val);
LInstruction* result = val->CheckFlag(HInstruction::kUint32)
? DefineAsRegister(new(zone()) LUint32ToSmi(value))
: DefineAsRegister(new(zone()) LInteger32ToSmi(value));
if (val->HasRange() && val->range()->IsInSmiRange()) {
return result;
LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value));
if (instr->CheckFlag(HValue::kCanOverflow)) {
result = AssignEnvironment(result);
}
return AssignEnvironment(result);
return result;
} else {
ASSERT(to.IsDouble());
if (instr->value()->CheckFlag(HInstruction::kUint32)) {
......
......@@ -107,7 +107,6 @@ class LCodeGen;
V(InstanceOfKnownGlobal) \
V(InstructionGap) \
V(Integer32ToDouble) \
V(Integer32ToSmi) \
V(InvokeFunction) \
V(IsConstructCallAndBranch) \
V(IsObjectAndBranch) \
......@@ -177,7 +176,6 @@ class LCodeGen;
V(Typeof) \
V(TypeofIsAndBranch) \
V(Uint32ToDouble) \
V(Uint32ToSmi) \
V(UnknownOSRValue) \
V(WrapReceiver)
......@@ -1917,19 +1915,6 @@ class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
};
class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
public:
explicit LInteger32ToSmi(LOperand* value) {
inputs_[0] = value;
}
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
DECLARE_HYDROGEN_ACCESSOR(Change)
};
class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
public:
explicit LUint32ToDouble(LOperand* value) {
......@@ -1942,19 +1927,6 @@ class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
};
class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
public:
explicit LUint32ToSmi(LOperand* value) {
inputs_[0] = value;
}
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
DECLARE_HYDROGEN_ACCESSOR(Change)
};
class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
public:
LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
......@@ -2066,6 +2038,7 @@ class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
DECLARE_HYDROGEN_ACCESSOR(Change)
};
......
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