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