| 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 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 | 1132 |
| 1133 void LCodeGen::DoConstantD(LConstantD* instr) { | 1133 void LCodeGen::DoConstantD(LConstantD* instr) { |
| 1134 ASSERT(instr->result()->IsDoubleRegister()); | 1134 ASSERT(instr->result()->IsDoubleRegister()); |
| 1135 XMMRegister res = ToDoubleRegister(instr->result()); | 1135 XMMRegister res = ToDoubleRegister(instr->result()); |
| 1136 double v = instr->value(); | 1136 double v = instr->value(); |
| 1137 // Use xor to produce +0.0 in a fast and compact way, but avoid to | 1137 // Use xor to produce +0.0 in a fast and compact way, but avoid to |
| 1138 // do so if the constant is -0.0. | 1138 // do so if the constant is -0.0. |
| 1139 if (BitCast<uint64_t, double>(v) == 0) { | 1139 if (BitCast<uint64_t, double>(v) == 0) { |
| 1140 __ xorpd(res, res); | 1140 __ xorps(res, res); |
| 1141 } else { | 1141 } else { |
| 1142 Register temp = ToRegister(instr->TempAt(0)); | 1142 Register temp = ToRegister(instr->TempAt(0)); |
| 1143 uint64_t int_val = BitCast<uint64_t, double>(v); | 1143 uint64_t int_val = BitCast<uint64_t, double>(v); |
| 1144 int32_t lower = static_cast<int32_t>(int_val); | 1144 int32_t lower = static_cast<int32_t>(int_val); |
| 1145 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); | 1145 int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt)); |
| 1146 if (CpuFeatures::IsSupported(SSE4_1)) { | 1146 if (CpuFeatures::IsSupported(SSE4_1)) { |
| 1147 CpuFeatures::Scope scope(SSE4_1); | 1147 CpuFeatures::Scope scope(SSE4_1); |
| 1148 if (lower != 0) { | 1148 if (lower != 0) { |
| 1149 __ Set(temp, Immediate(lower)); | 1149 __ Set(temp, Immediate(lower)); |
| 1150 __ movd(res, Operand(temp)); | 1150 __ movd(res, Operand(temp)); |
| 1151 __ Set(temp, Immediate(upper)); | 1151 __ Set(temp, Immediate(upper)); |
| 1152 __ pinsrd(res, Operand(temp), 1); | 1152 __ pinsrd(res, Operand(temp), 1); |
| 1153 } else { | 1153 } else { |
| 1154 __ xorpd(res, res); | 1154 __ xorps(res, res); |
| 1155 __ Set(temp, Immediate(upper)); | 1155 __ Set(temp, Immediate(upper)); |
| 1156 __ pinsrd(res, Operand(temp), 1); | 1156 __ pinsrd(res, Operand(temp), 1); |
| 1157 } | 1157 } |
| 1158 } else { | 1158 } else { |
| 1159 __ Set(temp, Immediate(upper)); | 1159 __ Set(temp, Immediate(upper)); |
| 1160 __ movd(res, Operand(temp)); | 1160 __ movd(res, Operand(temp)); |
| 1161 __ psllq(res, 32); | 1161 __ psllq(res, 32); |
| 1162 if (lower != 0) { | 1162 if (lower != 0) { |
| 1163 __ Set(temp, Immediate(lower)); | 1163 __ Set(temp, Immediate(lower)); |
| 1164 __ movd(xmm0, Operand(temp)); | 1164 __ movd(xmm0, Operand(temp)); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 int true_block = chunk_->LookupDestination(instr->true_block_id()); | 1334 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1335 int false_block = chunk_->LookupDestination(instr->false_block_id()); | 1335 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1336 | 1336 |
| 1337 Representation r = instr->hydrogen()->representation(); | 1337 Representation r = instr->hydrogen()->representation(); |
| 1338 if (r.IsInteger32()) { | 1338 if (r.IsInteger32()) { |
| 1339 Register reg = ToRegister(instr->InputAt(0)); | 1339 Register reg = ToRegister(instr->InputAt(0)); |
| 1340 __ test(reg, Operand(reg)); | 1340 __ test(reg, Operand(reg)); |
| 1341 EmitBranch(true_block, false_block, not_zero); | 1341 EmitBranch(true_block, false_block, not_zero); |
| 1342 } else if (r.IsDouble()) { | 1342 } else if (r.IsDouble()) { |
| 1343 XMMRegister reg = ToDoubleRegister(instr->InputAt(0)); | 1343 XMMRegister reg = ToDoubleRegister(instr->InputAt(0)); |
| 1344 __ xorpd(xmm0, xmm0); | 1344 __ xorps(xmm0, xmm0); |
| 1345 __ ucomisd(reg, xmm0); | 1345 __ ucomisd(reg, xmm0); |
| 1346 EmitBranch(true_block, false_block, not_equal); | 1346 EmitBranch(true_block, false_block, not_equal); |
| 1347 } else { | 1347 } else { |
| 1348 ASSERT(r.IsTagged()); | 1348 ASSERT(r.IsTagged()); |
| 1349 Register reg = ToRegister(instr->InputAt(0)); | 1349 Register reg = ToRegister(instr->InputAt(0)); |
| 1350 if (instr->hydrogen()->type().IsBoolean()) { | 1350 if (instr->hydrogen()->type().IsBoolean()) { |
| 1351 __ cmp(reg, factory()->true_value()); | 1351 __ cmp(reg, factory()->true_value()); |
| 1352 EmitBranch(true_block, false_block, equal); | 1352 EmitBranch(true_block, false_block, equal); |
| 1353 } else { | 1353 } else { |
| 1354 Label* true_label = chunk_->GetAssemblyLabel(true_block); | 1354 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| (...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2711 private: | 2711 private: |
| 2712 LUnaryMathOperation* instr_; | 2712 LUnaryMathOperation* instr_; |
| 2713 }; | 2713 }; |
| 2714 | 2714 |
| 2715 ASSERT(instr->InputAt(0)->Equals(instr->result())); | 2715 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 2716 Representation r = instr->hydrogen()->value()->representation(); | 2716 Representation r = instr->hydrogen()->value()->representation(); |
| 2717 | 2717 |
| 2718 if (r.IsDouble()) { | 2718 if (r.IsDouble()) { |
| 2719 XMMRegister scratch = xmm0; | 2719 XMMRegister scratch = xmm0; |
| 2720 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2720 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2721 __ pxor(scratch, scratch); | 2721 __ xorps(scratch, scratch); |
| 2722 __ subsd(scratch, input_reg); | 2722 __ subsd(scratch, input_reg); |
| 2723 __ pand(input_reg, scratch); | 2723 __ pand(input_reg, scratch); |
| 2724 } else if (r.IsInteger32()) { | 2724 } else if (r.IsInteger32()) { |
| 2725 EmitIntegerMathAbs(instr); | 2725 EmitIntegerMathAbs(instr); |
| 2726 } else { // Tagged case. | 2726 } else { // Tagged case. |
| 2727 DeferredMathAbsTaggedHeapNumber* deferred = | 2727 DeferredMathAbsTaggedHeapNumber* deferred = |
| 2728 new DeferredMathAbsTaggedHeapNumber(this, instr); | 2728 new DeferredMathAbsTaggedHeapNumber(this, instr); |
| 2729 Register input_reg = ToRegister(instr->InputAt(0)); | 2729 Register input_reg = ToRegister(instr->InputAt(0)); |
| 2730 // Smi check. | 2730 // Smi check. |
| 2731 __ test(input_reg, Immediate(kSmiTagMask)); | 2731 __ test(input_reg, Immediate(kSmiTagMask)); |
| 2732 __ j(not_zero, deferred->entry()); | 2732 __ j(not_zero, deferred->entry()); |
| 2733 EmitIntegerMathAbs(instr); | 2733 EmitIntegerMathAbs(instr); |
| 2734 __ bind(deferred->exit()); | 2734 __ bind(deferred->exit()); |
| 2735 } | 2735 } |
| 2736 } | 2736 } |
| 2737 | 2737 |
| 2738 | 2738 |
| 2739 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2739 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
| 2740 XMMRegister xmm_scratch = xmm0; | 2740 XMMRegister xmm_scratch = xmm0; |
| 2741 Register output_reg = ToRegister(instr->result()); | 2741 Register output_reg = ToRegister(instr->result()); |
| 2742 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2742 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2743 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. | 2743 __ xorps(xmm_scratch, xmm_scratch); // Zero the register. |
| 2744 __ ucomisd(input_reg, xmm_scratch); | 2744 __ ucomisd(input_reg, xmm_scratch); |
| 2745 | 2745 |
| 2746 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 2746 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 2747 DeoptimizeIf(below_equal, instr->environment()); | 2747 DeoptimizeIf(below_equal, instr->environment()); |
| 2748 } else { | 2748 } else { |
| 2749 DeoptimizeIf(below, instr->environment()); | 2749 DeoptimizeIf(below, instr->environment()); |
| 2750 } | 2750 } |
| 2751 | 2751 |
| 2752 // Use truncating instruction (OK because input is positive). | 2752 // Use truncating instruction (OK because input is positive). |
| 2753 __ cvttsd2si(output_reg, Operand(input_reg)); | 2753 __ cvttsd2si(output_reg, Operand(input_reg)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2809 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2809 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2810 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2810 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
| 2811 __ sqrtsd(input_reg, input_reg); | 2811 __ sqrtsd(input_reg, input_reg); |
| 2812 } | 2812 } |
| 2813 | 2813 |
| 2814 | 2814 |
| 2815 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { | 2815 void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) { |
| 2816 XMMRegister xmm_scratch = xmm0; | 2816 XMMRegister xmm_scratch = xmm0; |
| 2817 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2817 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2818 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 2818 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
| 2819 __ xorpd(xmm_scratch, xmm_scratch); | 2819 __ xorps(xmm_scratch, xmm_scratch); |
| 2820 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. | 2820 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. |
| 2821 __ sqrtsd(input_reg, input_reg); | 2821 __ sqrtsd(input_reg, input_reg); |
| 2822 } | 2822 } |
| 2823 | 2823 |
| 2824 | 2824 |
| 2825 void LCodeGen::DoPower(LPower* instr) { | 2825 void LCodeGen::DoPower(LPower* instr) { |
| 2826 LOperand* left = instr->InputAt(0); | 2826 LOperand* left = instr->InputAt(0); |
| 2827 LOperand* right = instr->InputAt(1); | 2827 LOperand* right = instr->InputAt(1); |
| 2828 DoubleRegister result_reg = ToDoubleRegister(instr->result()); | 2828 DoubleRegister result_reg = ToDoubleRegister(instr->result()); |
| 2829 Representation exponent_type = instr->hydrogen()->right()->representation(); | 2829 Representation exponent_type = instr->hydrogen()->right()->representation(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 __ fstp_d(Operand(esp, 0)); | 2879 __ fstp_d(Operand(esp, 0)); |
| 2880 __ movdbl(result_reg, Operand(esp, 0)); | 2880 __ movdbl(result_reg, Operand(esp, 0)); |
| 2881 __ add(Operand(esp), Immediate(kDoubleSize)); | 2881 __ add(Operand(esp), Immediate(kDoubleSize)); |
| 2882 } | 2882 } |
| 2883 | 2883 |
| 2884 | 2884 |
| 2885 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { | 2885 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { |
| 2886 ASSERT(instr->InputAt(0)->Equals(instr->result())); | 2886 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 2887 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2887 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2888 NearLabel positive, done, zero, negative; | 2888 NearLabel positive, done, zero, negative; |
| 2889 __ xorpd(xmm0, xmm0); | 2889 __ xorps(xmm0, xmm0); |
| 2890 __ ucomisd(input_reg, xmm0); | 2890 __ ucomisd(input_reg, xmm0); |
| 2891 __ j(above, &positive); | 2891 __ j(above, &positive); |
| 2892 __ j(equal, &zero); | 2892 __ j(equal, &zero); |
| 2893 ExternalReference nan = ExternalReference::address_of_nan(); | 2893 ExternalReference nan = ExternalReference::address_of_nan(); |
| 2894 __ movdbl(input_reg, Operand::StaticVariable(nan)); | 2894 __ movdbl(input_reg, Operand::StaticVariable(nan)); |
| 2895 __ jmp(&done); | 2895 __ jmp(&done); |
| 2896 __ bind(&zero); | 2896 __ bind(&zero); |
| 2897 __ push(Immediate(0xFFF00000)); | 2897 __ push(Immediate(0xFFF00000)); |
| 2898 __ push(Immediate(0)); | 2898 __ push(Immediate(0)); |
| 2899 __ movdbl(input_reg, Operand(esp, 0)); | 2899 __ movdbl(input_reg, Operand(esp, 0)); |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4297 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 4297 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 4298 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, &safepoint_generator); | 4298 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, &safepoint_generator); |
| 4299 } | 4299 } |
| 4300 | 4300 |
| 4301 | 4301 |
| 4302 #undef __ | 4302 #undef __ |
| 4303 | 4303 |
| 4304 } } // namespace v8::internal | 4304 } } // namespace v8::internal |
| 4305 | 4305 |
| 4306 #endif // V8_TARGET_ARCH_IA32 | 4306 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |