Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: runtime/vm/assembler_ia32_test.cc

Issue 92433002: Merge sin(a), cos(a) into one instruction. TODO: Implement for ARM and MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/code_generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 2009
2010 2010
2011 ASSEMBLER_TEST_RUN(Cosine, test) { 2011 ASSEMBLER_TEST_RUN(Cosine, test) {
2012 typedef float (*CosineCode)(float f); 2012 typedef float (*CosineCode)(float f);
2013 const float kFloatConst = 0.7; 2013 const float kFloatConst = 0.7;
2014 float res = reinterpret_cast<CosineCode>(test->entry())(kFloatConst); 2014 float res = reinterpret_cast<CosineCode>(test->entry())(kFloatConst);
2015 EXPECT_FLOAT_EQ(cos(kFloatConst), res, 0.0001); 2015 EXPECT_FLOAT_EQ(cos(kFloatConst), res, 0.0001);
2016 } 2016 }
2017 2017
2018 2018
2019 ASSEMBLER_TEST_GENERATE(SinCos, assembler) {
2020 __ fldl(Address(ESP, kWordSize));
2021 __ fsincos();
2022 __ subl(ESP, Immediate(2 * kWordSize));
2023 __ fstpl(Address(ESP, 0)); // cos result.
2024 __ movsd(XMM0, Address(ESP, 0));
2025 __ fstpl(Address(ESP, 0)); // sin result.
2026 __ movsd(XMM1, Address(ESP, 0));
2027 __ subsd(XMM1, XMM0); // sin - cos.
2028 __ movsd(Address(ESP, 0), XMM1);
2029 __ fldl(Address(ESP, 0));
2030 __ addl(ESP, Immediate(2 * kWordSize));
2031 __ ret();
2032 }
2033
2034
2035 ASSEMBLER_TEST_RUN(SinCos, test) {
2036 typedef double (*SinCosCode)(double d);
2037 const double arg = 1.2345;
2038 const double expected = sin(arg) - cos(arg);
2039 double res = reinterpret_cast<SinCosCode>(test->entry())(arg);
2040 EXPECT_FLOAT_EQ(expected, res, 0.000001);
2041 }
2042
2043
2019 ASSEMBLER_TEST_GENERATE(Tangent, assembler) { 2044 ASSEMBLER_TEST_GENERATE(Tangent, assembler) {
2020 __ fldl(Address(ESP, kWordSize)); 2045 __ fldl(Address(ESP, kWordSize));
2021 __ fptan(); 2046 __ fptan();
2022 __ ffree(0); 2047 __ ffree(0);
2023 __ fincstp(); 2048 __ fincstp();
2024 __ ret(); 2049 __ ret();
2025 } 2050 }
2026 2051
2027 2052
2028 ASSEMBLER_TEST_RUN(Tangent, test) { 2053 ASSEMBLER_TEST_RUN(Tangent, test) {
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 FieldAddress(ECX, GrowableObjectArray::data_offset()), 2898 FieldAddress(ECX, GrowableObjectArray::data_offset()),
2874 EAX); 2899 EAX);
2875 __ popl(EAX); 2900 __ popl(EAX);
2876 __ popl(CTX); 2901 __ popl(CTX);
2877 __ ret(); 2902 __ ret();
2878 } 2903 }
2879 2904
2880 } // namespace dart 2905 } // namespace dart
2881 2906
2882 #endif // defined TARGET_ARCH_IA32 2907 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/code_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698