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

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

Issue 1494323002: Revert "Precompilation/x64: Load float vector constants via Thread." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/thread.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_X64) 6 #if defined(TARGET_ARCH_X64)
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 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 2014
2015 2015
2016 ASSEMBLER_TEST_RUN(PackedDoubleSub, test) { 2016 ASSEMBLER_TEST_RUN(PackedDoubleSub, test) {
2017 typedef double (*PackedDoubleSub)(); 2017 typedef double (*PackedDoubleSub)();
2018 double res = reinterpret_cast<PackedDoubleSub>(test->entry())(); 2018 double res = reinterpret_cast<PackedDoubleSub>(test->entry())();
2019 EXPECT_FLOAT_EQ(-2.0, res, 0.000001f); 2019 EXPECT_FLOAT_EQ(-2.0, res, 0.000001f);
2020 } 2020 }
2021 2021
2022 2022
2023 static void EnterTestFrame(Assembler* assembler) { 2023 static void EnterTestFrame(Assembler* assembler) {
2024 COMPILE_ASSERT(THR != CallingConventions::kArg1Reg);
2025 COMPILE_ASSERT(CODE_REG != CallingConventions::kArg2Reg);
2026 __ EnterFrame(0); 2024 __ EnterFrame(0);
2027 __ pushq(CODE_REG); 2025 __ pushq(CODE_REG);
2028 __ pushq(PP); 2026 __ pushq(PP);
2029 __ pushq(THR);
2030 __ movq(CODE_REG, Address(CallingConventions::kArg1Reg, 2027 __ movq(CODE_REG, Address(CallingConventions::kArg1Reg,
2031 VMHandles::kOffsetOfRawPtrInHandle)); 2028 VMHandles::kOffsetOfRawPtrInHandle));
2032 __ movq(THR, CallingConventions::kArg2Reg);
2033 __ LoadPoolPointer(PP); 2029 __ LoadPoolPointer(PP);
2034 } 2030 }
2035 2031
2036 2032
2037 static void LeaveTestFrame(Assembler* assembler) { 2033 static void LeaveTestFrame(Assembler* assembler) {
2038 __ popq(THR);
2039 __ popq(PP); 2034 __ popq(PP);
2040 __ popq(CODE_REG); 2035 __ popq(CODE_REG);
2041 __ LeaveFrame(); 2036 __ LeaveFrame();
2042 } 2037 }
2043 2038
2044 2039
2045 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) { 2040 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) {
2046 static const struct ALIGN16 { 2041 static const struct ALIGN16 {
2047 double a; 2042 double a;
2048 double b; 2043 double b;
2049 } constant0 = { 1.0, 2.0 }; 2044 } constant0 = { 1.0, 2.0 };
2050 EnterTestFrame(assembler); 2045 EnterTestFrame(assembler);
2051 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); 2046 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
2052 __ movups(XMM10, Address(RAX, 0)); 2047 __ movups(XMM10, Address(RAX, 0));
2053 __ negatepd(XMM10); 2048 __ negatepd(XMM10);
2054 __ movaps(XMM0, XMM10); 2049 __ movaps(XMM0, XMM10);
2055 LeaveTestFrame(assembler); 2050 LeaveTestFrame(assembler);
2056 __ ret(); 2051 __ ret();
2057 } 2052 }
2058 2053
2059 2054
2060 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) { 2055 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) {
2061 double res = test->InvokeWithCodeAndThread<double>(); 2056 double res = test->InvokeWithCode<double>();
2062 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f); 2057 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
2063 } 2058 }
2064 2059
2065 2060
2066 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) { 2061 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) {
2067 static const struct ALIGN16 { 2062 static const struct ALIGN16 {
2068 double a; 2063 double a;
2069 double b; 2064 double b;
2070 } constant0 = { -1.0, 2.0 }; 2065 } constant0 = { -1.0, 2.0 };
2071 EnterTestFrame(assembler); 2066 EnterTestFrame(assembler);
2072 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); 2067 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
2073 __ movups(XMM10, Address(RAX, 0)); 2068 __ movups(XMM10, Address(RAX, 0));
2074 __ abspd(XMM10); 2069 __ abspd(XMM10);
2075 __ movaps(XMM0, XMM10); 2070 __ movaps(XMM0, XMM10);
2076 LeaveTestFrame(assembler); 2071 LeaveTestFrame(assembler);
2077 __ ret(); 2072 __ ret();
2078 } 2073 }
2079 2074
2080 2075
2081 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) { 2076 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) {
2082 double res = test->InvokeWithCodeAndThread<double>(); 2077 double res = test->InvokeWithCode<double>();
2083 EXPECT_FLOAT_EQ(1.0, res, 0.000001f); 2078 EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
2084 } 2079 }
2085 2080
2086 2081
2087 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) { 2082 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) {
2088 static const struct ALIGN16 { 2083 static const struct ALIGN16 {
2089 double a; 2084 double a;
2090 double b; 2085 double b;
2091 } constant0 = { 3.0, 2.0 }; 2086 } constant0 = { 3.0, 2.0 };
2092 static const struct ALIGN16 { 2087 static const struct ALIGN16 {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2518 __ movd(XMM0, RAX); 2513 __ movd(XMM0, RAX);
2519 __ shufps(XMM0, XMM0, Immediate(0x0)); 2514 __ shufps(XMM0, XMM0, Immediate(0x0));
2520 __ negateps(XMM0); 2515 __ negateps(XMM0);
2521 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. 2516 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
2522 LeaveTestFrame(assembler); 2517 LeaveTestFrame(assembler);
2523 __ ret(); 2518 __ ret();
2524 } 2519 }
2525 2520
2526 2521
2527 ASSEMBLER_TEST_RUN(PackedNegate, test) { 2522 ASSEMBLER_TEST_RUN(PackedNegate, test) {
2528 float res = test->InvokeWithCodeAndThread<float>(); 2523 float res = test->InvokeWithCode<float>();
2529 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); 2524 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f);
2530 } 2525 }
2531 2526
2532 2527
2533 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { 2528 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) {
2534 EnterTestFrame(assembler); 2529 EnterTestFrame(assembler);
2535 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); 2530 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f)));
2536 __ movd(XMM0, RAX); 2531 __ movd(XMM0, RAX);
2537 __ shufps(XMM0, XMM0, Immediate(0x0)); 2532 __ shufps(XMM0, XMM0, Immediate(0x0));
2538 __ absps(XMM0); 2533 __ absps(XMM0);
2539 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. 2534 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
2540 LeaveTestFrame(assembler); 2535 LeaveTestFrame(assembler);
2541 __ ret(); 2536 __ ret();
2542 } 2537 }
2543 2538
2544 2539
2545 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { 2540 ASSEMBLER_TEST_RUN(PackedAbsolute, test) {
2546 float res = test->InvokeWithCodeAndThread<float>(); 2541 float res = test->InvokeWithCode<float>();
2547 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); 2542 EXPECT_FLOAT_EQ(15.3f, res, 0.001f);
2548 } 2543 }
2549 2544
2550 2545
2551 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { 2546 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) {
2552 EnterTestFrame(assembler); 2547 EnterTestFrame(assembler);
2553 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); 2548 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f)));
2554 __ zerowps(XMM0); 2549 __ zerowps(XMM0);
2555 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. 2550 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0.
2556 LeaveTestFrame(assembler); 2551 LeaveTestFrame(assembler);
2557 __ ret(); 2552 __ ret();
2558 } 2553 }
2559 2554
2560 2555
2561 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { 2556 ASSEMBLER_TEST_RUN(PackedSetWZero, test) {
2562 float res = test->InvokeWithCodeAndThread<float>(); 2557 float res = test->InvokeWithCode<float>();
2563 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); 2558 EXPECT_FLOAT_EQ(0.0f, res, 0.001f);
2564 } 2559 }
2565 2560
2566 2561
2567 ASSEMBLER_TEST_GENERATE(PackedMin, assembler) { 2562 ASSEMBLER_TEST_GENERATE(PackedMin, assembler) {
2568 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(2.0f))); 2563 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(2.0f)));
2569 __ set1ps(XMM1, RAX, Immediate(bit_cast<int32_t, float>(4.0f))); 2564 __ set1ps(XMM1, RAX, Immediate(bit_cast<int32_t, float>(4.0f)));
2570 __ minps(XMM0, XMM1); 2565 __ minps(XMM0, XMM1);
2571 __ ret(); 2566 __ ret();
2572 } 2567 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 __ movaps(XMM0, XMM9); 2671 __ movaps(XMM0, XMM9);
2677 __ pushq(RAX); 2672 __ pushq(RAX);
2678 __ movss(Address(RSP, 0), XMM0); 2673 __ movss(Address(RSP, 0), XMM0);
2679 __ popq(RAX); 2674 __ popq(RAX);
2680 LeaveTestFrame(assembler); 2675 LeaveTestFrame(assembler);
2681 __ ret(); 2676 __ ret();
2682 } 2677 }
2683 2678
2684 2679
2685 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { 2680 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) {
2686 uint32_t res = test->InvokeWithCodeAndThread<uint32_t>(); 2681 uint32_t res = test->InvokeWithCode<uint32_t>();
2687 EXPECT_EQ(static_cast<uword>(0x0), res); 2682 EXPECT_EQ(static_cast<uword>(0x0), res);
2688 } 2683 }
2689 2684
2690 2685
2691 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) { 2686 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) {
2692 static const struct ALIGN16 { 2687 static const struct ALIGN16 {
2693 float a; 2688 float a;
2694 float b; 2689 float b;
2695 float c; 2690 float c;
2696 float d; 2691 float d;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 __ LeaveFrame(); 3096 __ LeaveFrame();
3102 __ ret(); 3097 __ ret();
3103 __ Bind(&fail); 3098 __ Bind(&fail);
3104 __ movl(RAX, Immediate(0)); // Fail. 3099 __ movl(RAX, Immediate(0)); // Fail.
3105 LeaveTestFrame(assembler); 3100 LeaveTestFrame(assembler);
3106 __ ret(); 3101 __ ret();
3107 } 3102 }
3108 3103
3109 3104
3110 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { 3105 ASSEMBLER_TEST_RUN(TestObjectCompare, test) {
3111 bool res = test->InvokeWithCodeAndThread<bool>(); 3106 bool res = test->InvokeWithCode<bool>();
3112 EXPECT_EQ(true, res); 3107 EXPECT_EQ(true, res);
3113 } 3108 }
3114 3109
3115 3110
3116 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { 3111 ASSEMBLER_TEST_GENERATE(TestNop, assembler) {
3117 __ nop(1); 3112 __ nop(1);
3118 __ nop(2); 3113 __ nop(2);
3119 __ nop(3); 3114 __ nop(3);
3120 __ nop(4); 3115 __ nop(4);
3121 __ nop(5); 3116 __ nop(5);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); 3408 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3);
3414 EXPECT_EQ(-12.0, res); 3409 EXPECT_EQ(-12.0, res);
3415 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); 3410 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8);
3416 EXPECT_EQ(-12.0, res); 3411 EXPECT_EQ(-12.0, res);
3417 } 3412 }
3418 3413
3419 3414
3420 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { 3415 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) {
3421 EnterTestFrame(assembler); 3416 EnterTestFrame(assembler);
3422 #if defined(TARGET_OS_WINDOWS) 3417 #if defined(TARGET_OS_WINDOWS)
3423 // First argument is code object, second argument is thread. MSVC passes 3418 // First argument is code object, MSVC passes second argument in XMM1.
3424 // third argument in XMM2. 3419 __ DoubleAbs(XMM1);
3425 __ DoubleAbs(XMM2); 3420 __ movaps(XMM0, XMM1);
3426 __ movaps(XMM0, XMM2);
3427 #else 3421 #else
3428 // SysV ABI allocates integral and double registers for arguments
3429 // independently.
3430 __ DoubleAbs(XMM0); 3422 __ DoubleAbs(XMM0);
3431 #endif 3423 #endif
3432 LeaveTestFrame(assembler); 3424 LeaveTestFrame(assembler);
3433 __ ret(); 3425 __ ret();
3434 } 3426 }
3435 3427
3436 3428
3437 ASSEMBLER_TEST_RUN(DoubleAbs, test) { 3429 ASSEMBLER_TEST_RUN(DoubleAbs, test) {
3438 double val = -12.45; 3430 double val = -12.45;
3439 double res = test->InvokeWithCodeAndThread<double, double>(val); 3431 double res = test->InvokeWithCode<double, double>(val);
3440 EXPECT_FLOAT_EQ(-val, res, 0.001); 3432 EXPECT_FLOAT_EQ(-val, res, 0.001);
3441 val = 12.45; 3433 val = 12.45;
3442 res = test->InvokeWithCodeAndThread<double, double>(val); 3434 res = test->InvokeWithCode<double, double>(val);
3443 EXPECT_FLOAT_EQ(val, res, 0.001); 3435 EXPECT_FLOAT_EQ(val, res, 0.001);
3444 } 3436 }
3445 3437
3446 3438
3447 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { 3439 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) {
3448 __ movmskpd(RAX, XMM0); 3440 __ movmskpd(RAX, XMM0);
3449 __ andq(RAX, Immediate(0x1)); 3441 __ andq(RAX, Immediate(0x1));
3450 __ ret(); 3442 __ ret();
3451 } 3443 }
3452 3444
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); 3627 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64)));
3636 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); 3628 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64)));
3637 3629
3638 EXPECT_EQ(0, range_of(Bool::True().raw())); 3630 EXPECT_EQ(0, range_of(Bool::True().raw()));
3639 } 3631 }
3640 3632
3641 3633
3642 } // namespace dart 3634 } // namespace dart
3643 3635
3644 #endif // defined TARGET_ARCH_X64 3636 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698