OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 4605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4616 __ SmiToInteger32(input, input); | 4616 __ SmiToInteger32(input, input); |
4617 } | 4617 } |
4618 | 4618 |
4619 | 4619 |
4620 void LCodeGen::EmitNumberUntagD(Register input_reg, | 4620 void LCodeGen::EmitNumberUntagD(Register input_reg, |
4621 XMMRegister result_reg, | 4621 XMMRegister result_reg, |
4622 bool can_convert_undefined_to_nan, | 4622 bool can_convert_undefined_to_nan, |
4623 bool deoptimize_on_minus_zero, | 4623 bool deoptimize_on_minus_zero, |
4624 LEnvironment* env, | 4624 LEnvironment* env, |
4625 NumberUntagDMode mode) { | 4625 NumberUntagDMode mode) { |
4626 Label load_smi, done; | 4626 Label convert, load_smi, done; |
4627 | 4627 |
4628 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { | 4628 if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) { |
4629 // Smi check. | 4629 // Smi check. |
4630 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); | 4630 __ JumpIfSmi(input_reg, &load_smi, Label::kNear); |
4631 | 4631 |
4632 // Heap number map check. | 4632 // Heap number map check. |
4633 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 4633 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
4634 Heap::kHeapNumberMapRootIndex); | 4634 Heap::kHeapNumberMapRootIndex); |
4635 if (!can_convert_undefined_to_nan) { | 4635 |
| 4636 // On x64 it is safe to load at heap number offset before evaluating the map |
| 4637 // check, since all heap objects are at least two words long. |
| 4638 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 4639 |
| 4640 if (can_convert_undefined_to_nan) { |
| 4641 __ j(not_equal, &convert); |
| 4642 } else { |
4636 DeoptimizeIf(not_equal, env); | 4643 DeoptimizeIf(not_equal, env); |
4637 } else { | 4644 } |
4638 Label heap_number, convert; | |
4639 __ j(equal, &heap_number, Label::kNear); | |
4640 | 4645 |
4641 // Convert undefined (and hole) to NaN. Compute NaN as 0/0. | |
4642 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); | |
4643 DeoptimizeIf(not_equal, env); | |
4644 | |
4645 __ bind(&convert); | |
4646 __ xorps(result_reg, result_reg); | |
4647 __ divsd(result_reg, result_reg); | |
4648 __ jmp(&done, Label::kNear); | |
4649 | |
4650 __ bind(&heap_number); | |
4651 } | |
4652 // Heap number to XMM conversion. | |
4653 __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
4654 if (deoptimize_on_minus_zero) { | 4646 if (deoptimize_on_minus_zero) { |
4655 XMMRegister xmm_scratch = xmm0; | 4647 XMMRegister xmm_scratch = xmm0; |
4656 __ xorps(xmm_scratch, xmm_scratch); | 4648 __ xorps(xmm_scratch, xmm_scratch); |
4657 __ ucomisd(xmm_scratch, result_reg); | 4649 __ ucomisd(xmm_scratch, result_reg); |
4658 __ j(not_equal, &done, Label::kNear); | 4650 __ j(not_equal, &done, Label::kNear); |
4659 __ movmskpd(kScratchRegister, result_reg); | 4651 __ movmskpd(kScratchRegister, result_reg); |
4660 __ testq(kScratchRegister, Immediate(1)); | 4652 __ testq(kScratchRegister, Immediate(1)); |
4661 DeoptimizeIf(not_zero, env); | 4653 DeoptimizeIf(not_zero, env); |
4662 } | 4654 } |
4663 __ jmp(&done, Label::kNear); | 4655 __ jmp(&done, Label::kNear); |
| 4656 |
| 4657 if (can_convert_undefined_to_nan) { |
| 4658 __ bind(&convert); |
| 4659 |
| 4660 // Convert undefined (and hole) to NaN. Compute NaN as 0/0. |
| 4661 __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex); |
| 4662 DeoptimizeIf(not_equal, env); |
| 4663 |
| 4664 __ xorps(result_reg, result_reg); |
| 4665 __ divsd(result_reg, result_reg); |
| 4666 __ jmp(&done, Label::kNear); |
| 4667 } |
4664 } else { | 4668 } else { |
4665 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); | 4669 ASSERT(mode == NUMBER_CANDIDATE_IS_SMI); |
4666 } | 4670 } |
4667 | 4671 |
4668 // Smi to XMM conversion | 4672 // Smi to XMM conversion |
4669 __ bind(&load_smi); | 4673 __ bind(&load_smi); |
4670 __ SmiToInteger32(kScratchRegister, input_reg); | 4674 __ SmiToInteger32(kScratchRegister, input_reg); |
4671 __ Cvtlsi2sd(result_reg, kScratchRegister); | 4675 __ Cvtlsi2sd(result_reg, kScratchRegister); |
4672 __ bind(&done); | 4676 __ bind(&done); |
4673 } | 4677 } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5493 FixedArray::kHeaderSize - kPointerSize)); | 5497 FixedArray::kHeaderSize - kPointerSize)); |
5494 __ bind(&done); | 5498 __ bind(&done); |
5495 } | 5499 } |
5496 | 5500 |
5497 | 5501 |
5498 #undef __ | 5502 #undef __ |
5499 | 5503 |
5500 } } // namespace v8::internal | 5504 } } // namespace v8::internal |
5501 | 5505 |
5502 #endif // V8_TARGET_ARCH_X64 | 5506 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |