OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 Condition is_smi = __ CheckSmi(input); | 3540 Condition is_smi = __ CheckSmi(input); |
3541 DeoptimizeIf(NegateCondition(is_smi), instr->environment()); | 3541 DeoptimizeIf(NegateCondition(is_smi), instr->environment()); |
3542 } | 3542 } |
3543 __ SmiToInteger32(input, input); | 3543 __ SmiToInteger32(input, input); |
3544 } | 3544 } |
3545 | 3545 |
3546 | 3546 |
3547 void LCodeGen::EmitNumberUntagD(Register input_reg, | 3547 void LCodeGen::EmitNumberUntagD(Register input_reg, |
3548 XMMRegister result_reg, | 3548 XMMRegister result_reg, |
3549 bool deoptimize_on_undefined, | 3549 bool deoptimize_on_undefined, |
| 3550 bool deoptimize_on_minus_zero, |
3550 LEnvironment* env) { | 3551 LEnvironment* env) { |
3551 Label load_smi, done; | 3552 Label load_smi, done; |
3552 | 3553 |
3553 // Smi check. | 3554 // Smi check. |
3554 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 3555 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
3555 | 3556 |
3556 // Heap number map check. | 3557 // Heap number map check. |
3557 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 3558 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
3558 Heap::kHeapNumberMapRootIndex); | 3559 Heap::kHeapNumberMapRootIndex); |
3559 if (deoptimize_on_undefined) { | 3560 if (deoptimize_on_undefined) { |
3560 DeoptimizeIf(not_equal, env); | 3561 DeoptimizeIf(not_equal, env); |
3561 } else { | 3562 } else { |
3562 Label heap_number; | 3563 Label heap_number; |
3563 __ j(equal, &heap_number, Label::kNear); | 3564 __ j(equal, &heap_number, Label::kNear); |
3564 | 3565 |
3565 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | 3566 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
3566 DeoptimizeIf(not_equal, env); | 3567 DeoptimizeIf(not_equal, env); |
3567 | 3568 |
3568 // Convert undefined to NaN. Compute NaN as 0/0. | 3569 // Convert undefined to NaN. Compute NaN as 0/0. |
3569 __ xorps(result_reg, result_reg); | 3570 __ xorps(result_reg, result_reg); |
3570 __ divsd(result_reg, result_reg); | 3571 __ divsd(result_reg, result_reg); |
3571 __ jmp(&done, Label::kNear); | 3572 __ jmp(&done, Label::kNear); |
3572 | 3573 |
3573 __ bind(&heap_number); | 3574 __ bind(&heap_number); |
3574 } | 3575 } |
3575 // Heap number to XMM conversion. | 3576 // Heap number to XMM conversion. |
3576 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 3577 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 3578 if (deoptimize_on_minus_zero) { |
| 3579 XMMRegister xmm_scratch = xmm0; |
| 3580 __ xorps(xmm_scratch, xmm_scratch); |
| 3581 __ ucomisd(xmm_scratch, result_reg); |
| 3582 __ j(not_equal, &done, Label::kNear); |
| 3583 __ movmskpd(kScratchRegister, result_reg); |
| 3584 __ testq(kScratchRegister, Immediate(1)); |
| 3585 DeoptimizeIf(not_zero, env); |
| 3586 } |
3577 __ jmp(&done, Label::kNear); | 3587 __ jmp(&done, Label::kNear); |
3578 | 3588 |
3579 // Smi to XMM conversion | 3589 // Smi to XMM conversion |
3580 __ bind(&load_smi); | 3590 __ bind(&load_smi); |
3581 __ SmiToInteger32(kScratchRegister, input_reg); | 3591 __ SmiToInteger32(kScratchRegister, input_reg); |
3582 __ cvtlsi2sd(result_reg, kScratchRegister); | 3592 __ cvtlsi2sd(result_reg, kScratchRegister); |
3583 __ bind(&done); | 3593 __ bind(&done); |
3584 } | 3594 } |
3585 | 3595 |
3586 | 3596 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3658 LOperand* input = instr->InputAt(0); | 3668 LOperand* input = instr->InputAt(0); |
3659 ASSERT(input->IsRegister()); | 3669 ASSERT(input->IsRegister()); |
3660 LOperand* result = instr->result(); | 3670 LOperand* result = instr->result(); |
3661 ASSERT(result->IsDoubleRegister()); | 3671 ASSERT(result->IsDoubleRegister()); |
3662 | 3672 |
3663 Register input_reg = ToRegister(input); | 3673 Register input_reg = ToRegister(input); |
3664 XMMRegister result_reg = ToDoubleRegister(result); | 3674 XMMRegister result_reg = ToDoubleRegister(result); |
3665 | 3675 |
3666 EmitNumberUntagD(input_reg, result_reg, | 3676 EmitNumberUntagD(input_reg, result_reg, |
3667 instr->hydrogen()->deoptimize_on_undefined(), | 3677 instr->hydrogen()->deoptimize_on_undefined(), |
| 3678 instr->hydrogen()->deoptimize_on_minus_zero(), |
3668 instr->environment()); | 3679 instr->environment()); |
3669 } | 3680 } |
3670 | 3681 |
3671 | 3682 |
3672 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { | 3683 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { |
3673 LOperand* input = instr->InputAt(0); | 3684 LOperand* input = instr->InputAt(0); |
3674 ASSERT(input->IsDoubleRegister()); | 3685 ASSERT(input->IsDoubleRegister()); |
3675 LOperand* result = instr->result(); | 3686 LOperand* result = instr->result(); |
3676 ASSERT(result->IsRegister()); | 3687 ASSERT(result->IsRegister()); |
3677 | 3688 |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4374 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4385 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4375 ASSERT(osr_pc_offset_ == -1); | 4386 ASSERT(osr_pc_offset_ == -1); |
4376 osr_pc_offset_ = masm()->pc_offset(); | 4387 osr_pc_offset_ = masm()->pc_offset(); |
4377 } | 4388 } |
4378 | 4389 |
4379 #undef __ | 4390 #undef __ |
4380 | 4391 |
4381 } } // namespace v8::internal | 4392 } } // namespace v8::internal |
4382 | 4393 |
4383 #endif // V8_TARGET_ARCH_X64 | 4394 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |