Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 | 938 |
| 939 void LCodeGen::DoConstantD(LConstantD* instr) { | 939 void LCodeGen::DoConstantD(LConstantD* instr) { |
| 940 ASSERT(instr->result()->IsDoubleRegister()); | 940 ASSERT(instr->result()->IsDoubleRegister()); |
| 941 XMMRegister res = ToDoubleRegister(instr->result()); | 941 XMMRegister res = ToDoubleRegister(instr->result()); |
| 942 double v = instr->value(); | 942 double v = instr->value(); |
| 943 // Use xor to produce +0.0 in a fast and compact way, but avoid to | 943 // Use xor to produce +0.0 in a fast and compact way, but avoid to |
| 944 // do so if the constant is -0.0. | 944 // do so if the constant is -0.0. |
| 945 if (BitCast<uint64_t, double>(v) == 0) { | 945 if (BitCast<uint64_t, double>(v) == 0) { |
| 946 __ xorpd(res, res); | 946 __ xorpd(res, res); |
| 947 } else { | 947 } else { |
| 948 int32_t v_int32 = static_cast<int32_t>(v); | 948 Register temp = ToRegister(instr->TempAt(0)); |
| 949 if (static_cast<double>(v_int32) == v) { | 949 uint64_t int_val = BitCast<uint64_t, double>(v); |
| 950 __ push_imm32(v_int32); | 950 int32_t lower = static_cast<int32_t>(int_val); |
| 951 __ cvtsi2sd(res, Operand(esp, 0)); | 951 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); |
| 952 __ add(Operand(esp), Immediate(kPointerSize)); | 952 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 953 CpuFeatures::Scope scope(SSE4_1); | |
| 954 __ Set(temp, Immediate(upper)); | |
| 955 __ xorpd(res, res); | |
| 956 __ pinsrd(res, Operand(temp), 1); | |
| 957 if (lower != 0) { | |
| 958 __ Set(temp, Immediate(lower)); | |
| 959 __ pinsrd(res, Operand(temp), 0); | |
|
William Hesse
2011/02/09 12:30:51
Use movsd, before pinsrd(upper), and eliminate the
| |
| 960 } | |
| 953 } else { | 961 } else { |
| 954 uint64_t int_val = BitCast<uint64_t, double>(v); | 962 __ Set(temp, Immediate(upper)); |
| 955 int32_t lower = static_cast<int32_t>(int_val); | 963 __ movd(res, Operand(temp)); |
| 956 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 964 __ psllq(res, 32); |
| 957 __ push_imm32(upper); | 965 if (lower != 0) { |
| 958 __ push_imm32(lower); | 966 __ Set(temp, Immediate(lower)); |
| 959 __ movdbl(res, Operand(esp, 0)); | 967 __ movd(xmm0, Operand(temp)); |
| 960 __ add(Operand(esp), Immediate(2 * kPointerSize)); | 968 __ por(res, xmm0); |
| 969 } | |
| 961 } | 970 } |
| 962 } | 971 } |
| 963 } | 972 } |
| 964 | 973 |
| 965 | 974 |
| 966 void LCodeGen::DoConstantT(LConstantT* instr) { | 975 void LCodeGen::DoConstantT(LConstantT* instr) { |
| 967 ASSERT(instr->result()->IsRegister()); | 976 ASSERT(instr->result()->IsRegister()); |
| 968 __ Set(ToRegister(instr->result()), Immediate(instr->value())); | 977 __ Set(ToRegister(instr->result()), Immediate(instr->value())); |
| 969 } | 978 } |
| 970 | 979 |
| (...skipping 2723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3694 ASSERT(osr_pc_offset_ == -1); | 3703 ASSERT(osr_pc_offset_ == -1); |
| 3695 osr_pc_offset_ = masm()->pc_offset(); | 3704 osr_pc_offset_ = masm()->pc_offset(); |
| 3696 } | 3705 } |
| 3697 | 3706 |
| 3698 | 3707 |
| 3699 #undef __ | 3708 #undef __ |
| 3700 | 3709 |
| 3701 } } // namespace v8::internal | 3710 } } // namespace v8::internal |
| 3702 | 3711 |
| 3703 #endif // V8_TARGET_ARCH_IA32 | 3712 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |