Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 9160f3f3b422e29d800839668a38088c700d1858..cfcb52b3c4c224740d7329557bdc91bfa0e1b612 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -449,7 +449,8 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, |
translation->MarkDuplicate(); |
AddToTranslation(translation, |
environment->spilled_registers()[value->index()], |
- environment->HasTaggedValueAt(i)); |
+ environment->HasTaggedValueAt(i), |
+ environment->HasUint32ValueAt(i)); |
} else if ( |
value->IsDoubleRegister() && |
environment->spilled_double_registers()[value->index()] != NULL) { |
@@ -457,18 +458,23 @@ void LCodeGen::WriteTranslation(LEnvironment* environment, |
AddToTranslation( |
translation, |
environment->spilled_double_registers()[value->index()], |
+ false, |
false); |
} |
} |
- AddToTranslation(translation, value, environment->HasTaggedValueAt(i)); |
+ AddToTranslation(translation, |
+ value, |
+ environment->HasTaggedValueAt(i), |
+ environment->HasUint32ValueAt(i)); |
} |
} |
void LCodeGen::AddToTranslation(Translation* translation, |
LOperand* op, |
- bool is_tagged) { |
+ bool is_tagged, |
+ bool is_uint32) { |
if (op == NULL) { |
// TODO(twuerthinger): Introduce marker operands to indicate that this value |
// is not present and must be reconstructed from the deoptimizer. Currently |
@@ -477,6 +483,8 @@ void LCodeGen::AddToTranslation(Translation* translation, |
} else if (op->IsStackSlot()) { |
if (is_tagged) { |
translation->StoreStackSlot(op->index()); |
+ } else if (is_uint32) { |
+ translation->StoreUint32StackSlot(op->index()); |
} else { |
translation->StoreInt32StackSlot(op->index()); |
} |
@@ -490,6 +498,8 @@ void LCodeGen::AddToTranslation(Translation* translation, |
Register reg = ToRegister(op); |
if (is_tagged) { |
translation->StoreRegister(reg); |
+ } else if (is_uint32) { |
+ translation->StoreUint32Register(reg); |
} else { |
translation->StoreInt32Register(reg); |
} |
@@ -2835,11 +2845,10 @@ void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
break; |
case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
__ mov(result, operand); |
- __ test(result, Operand(result)); |
- // TODO(danno): we could be more clever here, perhaps having a special |
- // version of the stub that detects if the overflow case actually |
- // happens, and generate code that returns a double rather than int. |
- DeoptimizeIf(negative, instr->environment()); |
+ if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) { |
+ __ test(result, Operand(result)); |
+ DeoptimizeIf(negative, instr->environment()); |
+ } |
break; |
case EXTERNAL_FLOAT_ELEMENTS: |
case EXTERNAL_DOUBLE_ELEMENTS: |
@@ -4058,12 +4067,25 @@ void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) { |
} |
+void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) { |
+ LOperand* input = instr->InputAt(0); |
+ LOperand* output = instr->result(); |
+ LOperand* temp = instr->TempAt(0); |
+ |
+ __ LoadUint32(ToDoubleRegister(output), |
+ ToRegister(input), |
+ ToDoubleRegister(temp)); |
+} |
+ |
+ |
void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
class DeferredNumberTagI: public LDeferredCode { |
public: |
DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr) |
: LDeferredCode(codegen), instr_(instr) { } |
- virtual void Generate() { codegen()->DoDeferredNumberTagI(instr_); } |
+ virtual void Generate() { |
+ codegen()->DoDeferredNumberTagI(instr_, SIGNED_INT32); |
+ } |
virtual LInstruction* instr() { return instr_; } |
private: |
LNumberTagI* instr_; |
@@ -4080,7 +4102,33 @@ void LCodeGen::DoNumberTagI(LNumberTagI* instr) { |
} |
-void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { |
+void LCodeGen::DoNumberTagU(LNumberTagU* instr) { |
+ class DeferredNumberTagU: public LDeferredCode { |
+ public: |
+ DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr) |
+ : LDeferredCode(codegen), instr_(instr) { } |
+ virtual void Generate() { |
+ codegen()->DoDeferredNumberTagI(instr_, UNSIGNED_INT32); |
+ } |
+ virtual LInstruction* instr() { return instr_; } |
+ private: |
+ LNumberTagU* instr_; |
+ }; |
+ |
+ LOperand* input = instr->InputAt(0); |
+ ASSERT(input->IsRegister() && input->Equals(instr->result())); |
+ Register reg = ToRegister(input); |
+ |
+ DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr); |
+ __ cmp(reg, Immediate(Smi::kMaxValue)); |
+ __ j(above, deferred->entry()); |
+ __ SmiTag(reg); |
+ __ bind(deferred->exit()); |
+} |
+ |
+ |
+void LCodeGen::DoDeferredNumberTagI(LInstruction* instr, |
+ IntegerSignedness signedness) { |
Label slow; |
Register reg = ToRegister(instr->InputAt(0)); |
Register tmp = reg.is(eax) ? ecx : eax; |
@@ -4088,13 +4136,19 @@ void LCodeGen::DoDeferredNumberTagI(LNumberTagI* instr) { |
// Preserve the value of all registers. |
PushSafepointRegistersScope scope(this); |
- // There was overflow, so bits 30 and 31 of the original integer |
- // disagree. Try to allocate a heap number in new space and store |
- // the value in there. If that fails, call the runtime system. |
Label done; |
- __ SmiUntag(reg); |
- __ xor_(reg, 0x80000000); |
- __ cvtsi2sd(xmm0, Operand(reg)); |
+ |
+ if (signedness == SIGNED_INT32) { |
+ // There was overflow, so bits 30 and 31 of the original integer |
+ // disagree. Try to allocate a heap number in new space and store |
+ // the value in there. If that fails, call the runtime system. |
+ __ SmiUntag(reg); |
+ __ xor_(reg, 0x80000000); |
+ __ cvtsi2sd(xmm0, Operand(reg)); |
+ } else { |
+ __ LoadUint32(xmm0, reg, xmm1); |
+ } |
+ |
if (FLAG_inline_new) { |
__ AllocateHeapNumber(reg, tmp, no_reg, &slow); |
__ jmp(&done, Label::kNear); |