Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index ed5bd47a403101735846ab11fefd8e08fa670594..d1c59ac693564c473ebf41850bd831015878e16c 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -5244,6 +5244,10 @@ void LCodeGen::EmitNumberUntagD(Register input_reg, |
void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
Register input_reg = ToRegister(instr->value()); |
+ // The input was optimistically untagged; revert it. |
+ STATIC_ASSERT(kSmiTagSize == 1); |
+ __ lea(input_reg, Operand(input_reg, times_2, kHeapObjectTag)); |
+ |
if (instr->truncating()) { |
Label no_heap_number, check_bools, check_false; |
@@ -5273,7 +5277,6 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr, Label* done) { |
__ RecordComment("Deferred TaggedToI: cannot truncate"); |
DeoptimizeIf(not_equal, instr->environment()); |
__ Set(input_reg, Immediate(0)); |
- __ jmp(done); |
} else { |
Label bailout; |
XMMRegister scratch = (instr->temp() != NULL) |
@@ -5313,9 +5316,13 @@ void LCodeGen::DoTaggedToI(LTaggedToI* instr) { |
} else { |
DeferredTaggedToI* deferred = |
new(zone()) DeferredTaggedToI(this, instr, x87_stack_); |
- |
- __ JumpIfNotSmi(input_reg, deferred->entry()); |
+ // Optimistically untag the input. |
+ // If the input is a HeapObject, SmiUntag will set the carry flag. |
+ STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
__ SmiUntag(input_reg); |
+ // Branch to deferred code if the input was tagged. |
+ // The deferred code will take care of restoring the tag. |
+ __ j(carry, deferred->entry()); |
__ bind(deferred->exit()); |
} |
} |