| 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 2862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 // Square root. | 2873 // Square root. |
| 2874 __ bind(&sqrt); | 2874 __ bind(&sqrt); |
| 2875 __ xorps(xmm_scratch, xmm_scratch); | 2875 __ xorps(xmm_scratch, xmm_scratch); |
| 2876 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. | 2876 __ addsd(input_reg, xmm_scratch); // Convert -0 to +0. |
| 2877 __ sqrtsd(input_reg, input_reg); | 2877 __ sqrtsd(input_reg, input_reg); |
| 2878 __ bind(&done); | 2878 __ bind(&done); |
| 2879 } | 2879 } |
| 2880 | 2880 |
| 2881 | 2881 |
| 2882 void LCodeGen::DoPower(LPower* instr) { | 2882 void LCodeGen::DoPower(LPower* instr) { |
| 2883 LOperand* left = instr->InputAt(0); | |
| 2884 XMMRegister left_reg = ToDoubleRegister(left); | |
| 2885 ASSERT(!left_reg.is(xmm1)); | |
| 2886 LOperand* right = instr->InputAt(1); | |
| 2887 XMMRegister result_reg = ToDoubleRegister(instr->result()); | |
| 2888 Representation exponent_type = instr->hydrogen()->right()->representation(); | 2883 Representation exponent_type = instr->hydrogen()->right()->representation(); |
| 2889 if (exponent_type.IsDouble()) { | 2884 // Having marked this as a call, we can use any registers. |
| 2890 __ PrepareCallCFunction(2); | 2885 // Just make sure that the input/output registers are the expected ones. |
| 2891 // Move arguments to correct registers | 2886 |
| 2892 __ movaps(xmm0, left_reg); | 2887 // Choose register conforming to calling convention (when bailing out). |
| 2893 ASSERT(ToDoubleRegister(right).is(xmm1)); | 2888 #ifdef _WIN64 |
| 2894 __ CallCFunction( | 2889 Register exponent = rdx; |
| 2895 ExternalReference::power_double_double_function(isolate()), 2); | 2890 #else |
| 2891 Register exponent = rdi; |
| 2892 #endif |
| 2893 ASSERT(!instr->InputAt(1)->IsRegister() || |
| 2894 ToRegister(instr->InputAt(1)).is(exponent)); |
| 2895 ASSERT(!instr->InputAt(1)->IsDoubleRegister() || |
| 2896 ToDoubleRegister(instr->InputAt(1)).is(xmm1)); |
| 2897 ASSERT(ToDoubleRegister(instr->InputAt(0)).is(xmm2)); |
| 2898 ASSERT(ToDoubleRegister(instr->result()).is(xmm3)); |
| 2899 |
| 2900 if (exponent_type.IsTagged()) { |
| 2901 Label no_deopt; |
| 2902 __ JumpIfSmi(exponent, &no_deopt); |
| 2903 __ CmpObjectType(exponent, HEAP_NUMBER_TYPE, rcx); |
| 2904 DeoptimizeIf(not_equal, instr->environment()); |
| 2905 __ bind(&no_deopt); |
| 2906 MathPowStub stub(MathPowStub::TAGGED); |
| 2907 __ CallStub(&stub); |
| 2896 } else if (exponent_type.IsInteger32()) { | 2908 } else if (exponent_type.IsInteger32()) { |
| 2897 __ PrepareCallCFunction(2); | 2909 MathPowStub stub(MathPowStub::INTEGER); |
| 2898 // Move arguments to correct registers: xmm0 and edi (not rdi). | 2910 __ CallStub(&stub); |
| 2899 // On Windows, the registers are xmm0 and edx. | |
| 2900 __ movaps(xmm0, left_reg); | |
| 2901 #ifdef _WIN64 | |
| 2902 ASSERT(ToRegister(right).is(rdx)); | |
| 2903 #else | |
| 2904 ASSERT(ToRegister(right).is(rdi)); | |
| 2905 #endif | |
| 2906 __ CallCFunction( | |
| 2907 ExternalReference::power_double_int_function(isolate()), 2); | |
| 2908 } else { | 2911 } else { |
| 2909 ASSERT(exponent_type.IsTagged()); | 2912 ASSERT(exponent_type.IsDouble()); |
| 2910 Register right_reg = ToRegister(right); | 2913 MathPowStub stub(MathPowStub::DOUBLE); |
| 2911 | 2914 __ CallStub(&stub); |
| 2912 Label non_smi, call; | |
| 2913 __ JumpIfNotSmi(right_reg, &non_smi); | |
| 2914 __ SmiToInteger32(right_reg, right_reg); | |
| 2915 __ cvtlsi2sd(xmm1, right_reg); | |
| 2916 __ jmp(&call); | |
| 2917 | |
| 2918 __ bind(&non_smi); | |
| 2919 __ CmpObjectType(right_reg, HEAP_NUMBER_TYPE , kScratchRegister); | |
| 2920 DeoptimizeIf(not_equal, instr->environment()); | |
| 2921 __ movsd(xmm1, FieldOperand(right_reg, HeapNumber::kValueOffset)); | |
| 2922 | |
| 2923 __ bind(&call); | |
| 2924 __ PrepareCallCFunction(2); | |
| 2925 // Move arguments to correct registers xmm0 and xmm1. | |
| 2926 __ movaps(xmm0, left_reg); | |
| 2927 // Right argument is already in xmm1. | |
| 2928 __ CallCFunction( | |
| 2929 ExternalReference::power_double_double_function(isolate()), 2); | |
| 2930 } | 2915 } |
| 2931 // Return value is in xmm0. | |
| 2932 __ movaps(result_reg, xmm0); | |
| 2933 // Restore context register. | |
| 2934 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | |
| 2935 } | 2916 } |
| 2936 | 2917 |
| 2937 | 2918 |
| 2938 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { | 2919 void LCodeGen::DoMathLog(LUnaryMathOperation* instr) { |
| 2939 ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); | 2920 ASSERT(ToDoubleRegister(instr->result()).is(xmm1)); |
| 2940 TranscendentalCacheStub stub(TranscendentalCache::LOG, | 2921 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
| 2941 TranscendentalCacheStub::UNTAGGED); | 2922 TranscendentalCacheStub::UNTAGGED); |
| 2942 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 2923 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2943 } | 2924 } |
| 2944 | 2925 |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4345 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4326 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 4346 ASSERT(osr_pc_offset_ == -1); | 4327 ASSERT(osr_pc_offset_ == -1); |
| 4347 osr_pc_offset_ = masm()->pc_offset(); | 4328 osr_pc_offset_ = masm()->pc_offset(); |
| 4348 } | 4329 } |
| 4349 | 4330 |
| 4350 #undef __ | 4331 #undef __ |
| 4351 | 4332 |
| 4352 } } // namespace v8::internal | 4333 } } // namespace v8::internal |
| 4353 | 4334 |
| 4354 #endif // V8_TARGET_ARCH_X64 | 4335 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |