OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 | 2008 |
2009 __ bind(&return_left); | 2009 __ bind(&return_left); |
2010 } | 2010 } |
2011 } | 2011 } |
2012 | 2012 |
2013 | 2013 |
2014 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { | 2014 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { |
2015 XMMRegister left = ToDoubleRegister(instr->left()); | 2015 XMMRegister left = ToDoubleRegister(instr->left()); |
2016 XMMRegister right = ToDoubleRegister(instr->right()); | 2016 XMMRegister right = ToDoubleRegister(instr->right()); |
2017 XMMRegister result = ToDoubleRegister(instr->result()); | 2017 XMMRegister result = ToDoubleRegister(instr->result()); |
| 2018 // All operations except MOD are computed in-place. |
| 2019 DCHECK(instr->op() == Token::MOD || left.is(result)); |
2018 switch (instr->op()) { | 2020 switch (instr->op()) { |
2019 case Token::ADD: | 2021 case Token::ADD: |
2020 if (CpuFeatures::IsSupported(AVX)) { | 2022 __ addsd(left, right); |
2021 CpuFeatureScope scope(masm(), AVX); | |
2022 __ vaddsd(result, left, right); | |
2023 } else { | |
2024 DCHECK(result.is(left)); | |
2025 __ addsd(left, right); | |
2026 } | |
2027 break; | 2023 break; |
2028 case Token::SUB: | 2024 case Token::SUB: |
2029 if (CpuFeatures::IsSupported(AVX)) { | 2025 __ subsd(left, right); |
2030 CpuFeatureScope scope(masm(), AVX); | |
2031 __ vsubsd(result, left, right); | |
2032 } else { | |
2033 DCHECK(result.is(left)); | |
2034 __ subsd(left, right); | |
2035 } | |
2036 break; | 2026 break; |
2037 case Token::MUL: | 2027 case Token::MUL: |
2038 if (CpuFeatures::IsSupported(AVX)) { | 2028 __ mulsd(left, right); |
2039 CpuFeatureScope scope(masm(), AVX); | |
2040 __ vmulsd(result, left, right); | |
2041 } else { | |
2042 DCHECK(result.is(left)); | |
2043 __ mulsd(left, right); | |
2044 } | |
2045 break; | 2029 break; |
2046 case Token::DIV: | 2030 case Token::DIV: |
2047 if (CpuFeatures::IsSupported(AVX)) { | 2031 __ divsd(left, right); |
2048 CpuFeatureScope scope(masm(), AVX); | 2032 // Don't delete this mov. It may improve performance on some CPUs, |
2049 __ vdivsd(result, left, right); | 2033 // when there is a mulsd depending on the result |
2050 } else { | 2034 __ movaps(left, left); |
2051 DCHECK(result.is(left)); | |
2052 __ divsd(left, right); | |
2053 // Don't delete this mov. It may improve performance on some CPUs, | |
2054 // when there is a mulsd depending on the result | |
2055 __ movaps(left, left); | |
2056 } | |
2057 break; | 2035 break; |
2058 case Token::MOD: { | 2036 case Token::MOD: { |
2059 XMMRegister xmm_scratch = double_scratch0(); | 2037 XMMRegister xmm_scratch = double_scratch0(); |
2060 __ PrepareCallCFunction(2); | 2038 __ PrepareCallCFunction(2); |
2061 __ movaps(xmm_scratch, left); | 2039 __ movaps(xmm_scratch, left); |
2062 DCHECK(right.is(xmm1)); | 2040 DCHECK(right.is(xmm1)); |
2063 __ CallCFunction( | 2041 __ CallCFunction( |
2064 ExternalReference::mod_two_doubles_operation(isolate()), 2); | 2042 ExternalReference::mod_two_doubles_operation(isolate()), 2); |
2065 __ movaps(result, xmm_scratch); | 2043 __ movaps(result, xmm_scratch); |
2066 break; | 2044 break; |
(...skipping 3864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5931 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5909 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
5932 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5910 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5933 } | 5911 } |
5934 | 5912 |
5935 | 5913 |
5936 #undef __ | 5914 #undef __ |
5937 | 5915 |
5938 } } // namespace v8::internal | 5916 } } // namespace v8::internal |
5939 | 5917 |
5940 #endif // V8_TARGET_ARCH_X64 | 5918 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |