OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 __ Move(ToRegister(instr->result()), Immediate(instr->value())); | 1702 __ Move(ToRegister(instr->result()), Immediate(instr->value())); |
1703 } | 1703 } |
1704 | 1704 |
1705 | 1705 |
1706 void LCodeGen::DoConstantS(LConstantS* instr) { | 1706 void LCodeGen::DoConstantS(LConstantS* instr) { |
1707 __ Move(ToRegister(instr->result()), Immediate(instr->value())); | 1707 __ Move(ToRegister(instr->result()), Immediate(instr->value())); |
1708 } | 1708 } |
1709 | 1709 |
1710 | 1710 |
1711 void LCodeGen::DoConstantD(LConstantD* instr) { | 1711 void LCodeGen::DoConstantD(LConstantD* instr) { |
1712 double v = instr->value(); | 1712 uint64_t const bits = instr->bits(); |
1713 uint64_t int_val = bit_cast<uint64_t, double>(v); | 1713 uint32_t const lower = static_cast<uint32_t>(bits); |
1714 int32_t lower = static_cast<int32_t>(int_val); | 1714 uint32_t const upper = static_cast<uint32_t>(bits >> 32); |
1715 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | |
1716 DCHECK(instr->result()->IsDoubleRegister()); | 1715 DCHECK(instr->result()->IsDoubleRegister()); |
1717 | 1716 |
1718 XMMRegister res = ToDoubleRegister(instr->result()); | 1717 XMMRegister result = ToDoubleRegister(instr->result()); |
1719 if (int_val == 0) { | 1718 if (bits == 0u) { |
1720 __ xorps(res, res); | 1719 __ xorps(result, result); |
1721 } else { | 1720 } else { |
1722 Register temp = ToRegister(instr->temp()); | 1721 Register temp = ToRegister(instr->temp()); |
1723 if (CpuFeatures::IsSupported(SSE4_1)) { | 1722 if (CpuFeatures::IsSupported(SSE4_1)) { |
1724 CpuFeatureScope scope2(masm(), SSE4_1); | 1723 CpuFeatureScope scope2(masm(), SSE4_1); |
1725 if (lower != 0) { | 1724 if (lower != 0) { |
1726 __ Move(temp, Immediate(lower)); | 1725 __ Move(temp, Immediate(lower)); |
1727 __ movd(res, Operand(temp)); | 1726 __ movd(result, Operand(temp)); |
1728 __ Move(temp, Immediate(upper)); | 1727 __ Move(temp, Immediate(upper)); |
1729 __ pinsrd(res, Operand(temp), 1); | 1728 __ pinsrd(result, Operand(temp), 1); |
1730 } else { | 1729 } else { |
1731 __ xorps(res, res); | 1730 __ xorps(result, result); |
1732 __ Move(temp, Immediate(upper)); | 1731 __ Move(temp, Immediate(upper)); |
1733 __ pinsrd(res, Operand(temp), 1); | 1732 __ pinsrd(result, Operand(temp), 1); |
1734 } | 1733 } |
1735 } else { | 1734 } else { |
1736 __ Move(temp, Immediate(upper)); | 1735 __ Move(temp, Immediate(upper)); |
1737 __ movd(res, Operand(temp)); | 1736 __ movd(result, Operand(temp)); |
1738 __ psllq(res, 32); | 1737 __ psllq(result, 32); |
1739 if (lower != 0) { | 1738 if (lower != 0u) { |
1740 XMMRegister xmm_scratch = double_scratch0(); | 1739 XMMRegister xmm_scratch = double_scratch0(); |
1741 __ Move(temp, Immediate(lower)); | 1740 __ Move(temp, Immediate(lower)); |
1742 __ movd(xmm_scratch, Operand(temp)); | 1741 __ movd(xmm_scratch, Operand(temp)); |
1743 __ orps(res, xmm_scratch); | 1742 __ orps(result, xmm_scratch); |
1744 } | 1743 } |
1745 } | 1744 } |
1746 } | 1745 } |
1747 } | 1746 } |
1748 | 1747 |
1749 | 1748 |
1750 void LCodeGen::DoConstantE(LConstantE* instr) { | 1749 void LCodeGen::DoConstantE(LConstantE* instr) { |
1751 __ lea(ToRegister(instr->result()), Operand::StaticVariable(instr->value())); | 1750 __ lea(ToRegister(instr->result()), Operand::StaticVariable(instr->value())); |
1752 } | 1751 } |
1753 | 1752 |
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3887 | 3886 |
3888 void LCodeGen::DoMathLog(LMathLog* instr) { | 3887 void LCodeGen::DoMathLog(LMathLog* instr) { |
3889 DCHECK(instr->value()->Equals(instr->result())); | 3888 DCHECK(instr->value()->Equals(instr->result())); |
3890 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3889 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3891 XMMRegister xmm_scratch = double_scratch0(); | 3890 XMMRegister xmm_scratch = double_scratch0(); |
3892 Label positive, done, zero; | 3891 Label positive, done, zero; |
3893 __ xorps(xmm_scratch, xmm_scratch); | 3892 __ xorps(xmm_scratch, xmm_scratch); |
3894 __ ucomisd(input_reg, xmm_scratch); | 3893 __ ucomisd(input_reg, xmm_scratch); |
3895 __ j(above, &positive, Label::kNear); | 3894 __ j(above, &positive, Label::kNear); |
3896 __ j(not_carry, &zero, Label::kNear); | 3895 __ j(not_carry, &zero, Label::kNear); |
3897 ExternalReference nan = | 3896 __ pcmpeqd(input_reg, input_reg); |
3898 ExternalReference::address_of_canonical_non_hole_nan(); | |
3899 __ movsd(input_reg, Operand::StaticVariable(nan)); | |
3900 __ jmp(&done, Label::kNear); | 3897 __ jmp(&done, Label::kNear); |
3901 __ bind(&zero); | 3898 __ bind(&zero); |
3902 ExternalReference ninf = | 3899 ExternalReference ninf = |
3903 ExternalReference::address_of_negative_infinity(); | 3900 ExternalReference::address_of_negative_infinity(); |
3904 __ movsd(input_reg, Operand::StaticVariable(ninf)); | 3901 __ movsd(input_reg, Operand::StaticVariable(ninf)); |
3905 __ jmp(&done, Label::kNear); | 3902 __ jmp(&done, Label::kNear); |
3906 __ bind(&positive); | 3903 __ bind(&positive); |
3907 __ fldln2(); | 3904 __ fldln2(); |
3908 __ sub(Operand(esp), Immediate(kDoubleSize)); | 3905 __ sub(Operand(esp), Immediate(kDoubleSize)); |
3909 __ movsd(Operand(esp, 0), input_reg); | 3906 __ movsd(Operand(esp, 0), input_reg); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4243 case DICTIONARY_ELEMENTS: | 4240 case DICTIONARY_ELEMENTS: |
4244 case SLOPPY_ARGUMENTS_ELEMENTS: | 4241 case SLOPPY_ARGUMENTS_ELEMENTS: |
4245 UNREACHABLE(); | 4242 UNREACHABLE(); |
4246 break; | 4243 break; |
4247 } | 4244 } |
4248 } | 4245 } |
4249 } | 4246 } |
4250 | 4247 |
4251 | 4248 |
4252 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { | 4249 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { |
4253 ExternalReference canonical_nan_reference = | |
4254 ExternalReference::address_of_canonical_non_hole_nan(); | |
4255 Operand double_store_operand = BuildFastArrayOperand( | 4250 Operand double_store_operand = BuildFastArrayOperand( |
4256 instr->elements(), | 4251 instr->elements(), |
4257 instr->key(), | 4252 instr->key(), |
4258 instr->hydrogen()->key()->representation(), | 4253 instr->hydrogen()->key()->representation(), |
4259 FAST_DOUBLE_ELEMENTS, | 4254 FAST_DOUBLE_ELEMENTS, |
4260 instr->base_offset()); | 4255 instr->base_offset()); |
4261 | 4256 |
4262 XMMRegister value = ToDoubleRegister(instr->value()); | 4257 XMMRegister value = ToDoubleRegister(instr->value()); |
4263 | 4258 |
4264 if (instr->NeedsCanonicalization()) { | 4259 if (instr->NeedsCanonicalization()) { |
4265 Label have_value; | 4260 XMMRegister xmm_scratch = double_scratch0(); |
4266 | 4261 // Turn potential sNaN value into qNaN. |
4267 __ ucomisd(value, value); | 4262 __ xorps(xmm_scratch, xmm_scratch); |
4268 __ j(parity_odd, &have_value, Label::kNear); // NaN. | 4263 __ subsd(value, xmm_scratch); |
4269 | |
4270 __ movsd(value, Operand::StaticVariable(canonical_nan_reference)); | |
4271 __ bind(&have_value); | |
4272 } | 4264 } |
4273 | 4265 |
4274 __ movsd(double_store_operand, value); | 4266 __ movsd(double_store_operand, value); |
4275 } | 4267 } |
4276 | 4268 |
4277 | 4269 |
4278 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { | 4270 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
4279 Register elements = ToRegister(instr->elements()); | 4271 Register elements = ToRegister(instr->elements()); |
4280 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; | 4272 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
4281 | 4273 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4750 __ j(not_zero, &done, Label::kNear); | 4742 __ j(not_zero, &done, Label::kNear); |
4751 __ movmskpd(temp_reg, result_reg); | 4743 __ movmskpd(temp_reg, result_reg); |
4752 __ test_b(temp_reg, 1); | 4744 __ test_b(temp_reg, 1); |
4753 DeoptimizeIf(not_zero, instr, "minus zero"); | 4745 DeoptimizeIf(not_zero, instr, "minus zero"); |
4754 } | 4746 } |
4755 __ jmp(&done, Label::kNear); | 4747 __ jmp(&done, Label::kNear); |
4756 | 4748 |
4757 if (can_convert_undefined_to_nan) { | 4749 if (can_convert_undefined_to_nan) { |
4758 __ bind(&convert); | 4750 __ bind(&convert); |
4759 | 4751 |
4760 // Convert undefined (and hole) to NaN. | 4752 // Convert undefined to NaN. |
4761 __ cmp(input_reg, factory()->undefined_value()); | 4753 __ cmp(input_reg, factory()->undefined_value()); |
4762 DeoptimizeIf(not_equal, instr, "not a heap number/undefined"); | 4754 DeoptimizeIf(not_equal, instr, "not a heap number/undefined"); |
4763 | 4755 |
4764 ExternalReference nan = | 4756 __ pcmpeqd(result_reg, result_reg); |
4765 ExternalReference::address_of_canonical_non_hole_nan(); | |
4766 __ movsd(result_reg, Operand::StaticVariable(nan)); | |
4767 __ jmp(&done, Label::kNear); | 4757 __ jmp(&done, Label::kNear); |
4768 } | 4758 } |
4769 } else { | 4759 } else { |
4770 DCHECK(mode == NUMBER_CANDIDATE_IS_SMI); | 4760 DCHECK(mode == NUMBER_CANDIDATE_IS_SMI); |
4771 } | 4761 } |
4772 | 4762 |
4773 __ bind(&load_smi); | 4763 __ bind(&load_smi); |
4774 // Smi to XMM conversion. Clobbering a temp is faster than re-tagging the | 4764 // Smi to XMM conversion. Clobbering a temp is faster than re-tagging the |
4775 // input register since we avoid dependencies. | 4765 // input register since we avoid dependencies. |
4776 __ mov(temp_reg, input_reg); | 4766 __ mov(temp_reg, input_reg); |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5760 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5750 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5761 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5751 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5762 } | 5752 } |
5763 | 5753 |
5764 | 5754 |
5765 #undef __ | 5755 #undef __ |
5766 | 5756 |
5767 } } // namespace v8::internal | 5757 } } // namespace v8::internal |
5768 | 5758 |
5769 #endif // V8_TARGET_ARCH_IA32 | 5759 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |