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

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

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