| 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 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 | 1996 |
| 1997 __ bind(&return_left); | 1997 __ bind(&return_left); |
| 1998 } | 1998 } |
| 1999 } | 1999 } |
| 2000 | 2000 |
| 2001 | 2001 |
| 2002 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { | 2002 void LCodeGen::DoArithmeticD(LArithmeticD* instr) { |
| 2003 XMMRegister left = ToDoubleRegister(instr->left()); | 2003 XMMRegister left = ToDoubleRegister(instr->left()); |
| 2004 XMMRegister right = ToDoubleRegister(instr->right()); | 2004 XMMRegister right = ToDoubleRegister(instr->right()); |
| 2005 XMMRegister result = ToDoubleRegister(instr->result()); | 2005 XMMRegister result = ToDoubleRegister(instr->result()); |
| 2006 // All operations except MOD are computed in-place. |
| 2007 DCHECK(instr->op() == Token::MOD || left.is(result)); |
| 2006 switch (instr->op()) { | 2008 switch (instr->op()) { |
| 2007 case Token::ADD: | 2009 case Token::ADD: |
| 2008 if (CpuFeatures::IsSupported(AVX)) { | 2010 __ addsd(left, right); |
| 2009 CpuFeatureScope scope(masm(), AVX); | |
| 2010 __ vaddsd(result, left, right); | |
| 2011 } else { | |
| 2012 DCHECK(result.is(left)); | |
| 2013 __ addsd(left, right); | |
| 2014 } | |
| 2015 break; | 2011 break; |
| 2016 case Token::SUB: | 2012 case Token::SUB: |
| 2017 if (CpuFeatures::IsSupported(AVX)) { | 2013 __ subsd(left, right); |
| 2018 CpuFeatureScope scope(masm(), AVX); | |
| 2019 __ vsubsd(result, left, right); | |
| 2020 } else { | |
| 2021 DCHECK(result.is(left)); | |
| 2022 __ subsd(left, right); | |
| 2023 } | |
| 2024 break; | 2014 break; |
| 2025 case Token::MUL: | 2015 case Token::MUL: |
| 2026 if (CpuFeatures::IsSupported(AVX)) { | 2016 __ mulsd(left, right); |
| 2027 CpuFeatureScope scope(masm(), AVX); | |
| 2028 __ vmulsd(result, left, right); | |
| 2029 } else { | |
| 2030 DCHECK(result.is(left)); | |
| 2031 __ mulsd(left, right); | |
| 2032 } | |
| 2033 break; | 2017 break; |
| 2034 case Token::DIV: | 2018 case Token::DIV: |
| 2035 if (CpuFeatures::IsSupported(AVX)) { | 2019 __ divsd(left, right); |
| 2036 CpuFeatureScope scope(masm(), AVX); | 2020 // Don't delete this mov. It may improve performance on some CPUs, |
| 2037 __ vdivsd(result, left, right); | 2021 // when there is a mulsd depending on the result |
| 2038 } else { | 2022 __ movaps(left, left); |
| 2039 DCHECK(result.is(left)); | |
| 2040 __ divsd(left, right); | |
| 2041 // Don't delete this mov. It may improve performance on some CPUs, | |
| 2042 // when there is a mulsd depending on the result | |
| 2043 __ movaps(left, left); | |
| 2044 } | |
| 2045 break; | 2023 break; |
| 2046 case Token::MOD: { | 2024 case Token::MOD: { |
| 2047 XMMRegister xmm_scratch = double_scratch0(); | 2025 XMMRegister xmm_scratch = double_scratch0(); |
| 2048 __ PrepareCallCFunction(2); | 2026 __ PrepareCallCFunction(2); |
| 2049 __ movaps(xmm_scratch, left); | 2027 __ movaps(xmm_scratch, left); |
| 2050 DCHECK(right.is(xmm1)); | 2028 DCHECK(right.is(xmm1)); |
| 2051 __ CallCFunction( | 2029 __ CallCFunction( |
| 2052 ExternalReference::mod_two_doubles_operation(isolate()), 2); | 2030 ExternalReference::mod_two_doubles_operation(isolate()), 2); |
| 2053 __ movaps(result, xmm_scratch); | 2031 __ movaps(result, xmm_scratch); |
| 2054 break; | 2032 break; |
| (...skipping 3853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5908 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5886 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 5909 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5887 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5910 } | 5888 } |
| 5911 | 5889 |
| 5912 | 5890 |
| 5913 #undef __ | 5891 #undef __ |
| 5914 | 5892 |
| 5915 } } // namespace v8::internal | 5893 } } // namespace v8::internal |
| 5916 | 5894 |
| 5917 #endif // V8_TARGET_ARCH_X64 | 5895 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |