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 __ Set(temp, Immediate(upper)); |
953 } else { | 953 __ movd(res, Operand(temp)); |
954 uint64_t int_val = BitCast<uint64_t, double>(v); | 954 __ psllq(res, 32); |
955 int32_t lower = static_cast<int32_t>(int_val); | 955 __ Set(temp, Immediate(lower)); |
William Hesse
2011/02/08 13:21:10
Have you considered using the pinsrd instruction t
| |
956 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 956 __ movd(xmm0, Operand(temp)); |
957 __ push_imm32(upper); | 957 __ por(res, xmm0); |
958 __ push_imm32(lower); | |
959 __ movdbl(res, Operand(esp, 0)); | |
960 __ add(Operand(esp), Immediate(2 * kPointerSize)); | |
961 } | |
962 } | 958 } |
963 } | 959 } |
964 | 960 |
965 | 961 |
966 void LCodeGen::DoConstantT(LConstantT* instr) { | 962 void LCodeGen::DoConstantT(LConstantT* instr) { |
967 ASSERT(instr->result()->IsRegister()); | 963 ASSERT(instr->result()->IsRegister()); |
968 __ Set(ToRegister(instr->result()), Immediate(instr->value())); | 964 __ Set(ToRegister(instr->result()), Immediate(instr->value())); |
969 } | 965 } |
970 | 966 |
971 | 967 |
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3694 ASSERT(osr_pc_offset_ == -1); | 3690 ASSERT(osr_pc_offset_ == -1); |
3695 osr_pc_offset_ = masm()->pc_offset(); | 3691 osr_pc_offset_ = masm()->pc_offset(); |
3696 } | 3692 } |
3697 | 3693 |
3698 | 3694 |
3699 #undef __ | 3695 #undef __ |
3700 | 3696 |
3701 } } // namespace v8::internal | 3697 } } // namespace v8::internal |
3702 | 3698 |
3703 #endif // V8_TARGET_ARCH_IA32 | 3699 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |