Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index e4cd8c3519aecf531581c22b749eb1a066839d4b..15542147e7bec85624ccd357ed754728e9efabdc 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -3559,8 +3559,9 @@ void LCodeGen::DoSmiUntag(LSmiUntag* instr) { |
void LCodeGen::EmitNumberUntagD(Register input_reg, |
XMMRegister result_reg, |
+ bool deoptimize_on_undefined, |
LEnvironment* env) { |
- Label load_smi, heap_number, done; |
+ Label load_smi, done; |
// Smi check. |
__ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
@@ -3568,18 +3569,23 @@ void LCodeGen::EmitNumberUntagD(Register input_reg, |
// Heap number map check. |
__ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
Heap::kHeapNumberMapRootIndex); |
- __ j(equal, &heap_number, Label::kNear); |
+ if (deoptimize_on_undefined) { |
+ DeoptimizeIf(not_equal, env); |
+ } else { |
+ Label heap_number; |
+ __ j(equal, &heap_number, Label::kNear); |
- __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
- DeoptimizeIf(not_equal, env); |
+ __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
+ DeoptimizeIf(not_equal, env); |
- // Convert undefined to NaN. Compute NaN as 0/0. |
- __ xorps(result_reg, result_reg); |
- __ divsd(result_reg, result_reg); |
- __ jmp(&done, Label::kNear); |
+ // Convert undefined to NaN. Compute NaN as 0/0. |
+ __ xorps(result_reg, result_reg); |
+ __ divsd(result_reg, result_reg); |
+ __ jmp(&done, Label::kNear); |
+ __ bind(&heap_number); |
+ } |
// Heap number to XMM conversion. |
- __ bind(&heap_number); |
__ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
__ jmp(&done, Label::kNear); |
@@ -3670,7 +3676,9 @@ void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { |
Register input_reg = ToRegister(input); |
XMMRegister result_reg = ToDoubleRegister(result); |
- EmitNumberUntagD(input_reg, result_reg, instr->environment()); |
+ EmitNumberUntagD(input_reg, result_reg, |
+ instr->hydrogen()->deoptimize_on_undefined(), |
+ instr->environment()); |
} |