OLD | NEW |
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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) { | 2023 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) { |
2024 static const struct ALIGN16 { | 2024 static const struct ALIGN16 { |
2025 double a; | 2025 double a; |
2026 double b; | 2026 double b; |
2027 } constant0 = { 1.0, 2.0 }; | 2027 } constant0 = { 1.0, 2.0 }; |
2028 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2028 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2029 __ LoadPoolPointer(PP); | 2029 __ LoadPoolPointer(); |
2030 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); | 2030 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); |
2031 __ movups(XMM10, Address(RAX, 0)); | 2031 __ movups(XMM10, Address(RAX, 0)); |
2032 __ negatepd(XMM10); | 2032 __ negatepd(XMM10); |
2033 __ movaps(XMM0, XMM10); | 2033 __ movaps(XMM0, XMM10); |
2034 __ popq(PP); // Restore caller's pool pointer. | 2034 __ popq(PP); // Restore caller's pool pointer. |
2035 __ ret(); | 2035 __ ret(); |
2036 } | 2036 } |
2037 | 2037 |
2038 | 2038 |
2039 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) { | 2039 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) { |
2040 typedef double (*PackedDoubleNegate)(); | 2040 typedef double (*PackedDoubleNegate)(); |
2041 double res = reinterpret_cast<PackedDoubleNegate>(test->entry())(); | 2041 double res = reinterpret_cast<PackedDoubleNegate>(test->entry())(); |
2042 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f); | 2042 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f); |
2043 } | 2043 } |
2044 | 2044 |
2045 | 2045 |
2046 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) { | 2046 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) { |
2047 static const struct ALIGN16 { | 2047 static const struct ALIGN16 { |
2048 double a; | 2048 double a; |
2049 double b; | 2049 double b; |
2050 } constant0 = { -1.0, 2.0 }; | 2050 } constant0 = { -1.0, 2.0 }; |
2051 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2051 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2052 __ LoadPoolPointer(PP); | 2052 __ LoadPoolPointer(); |
2053 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); | 2053 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); |
2054 __ movups(XMM10, Address(RAX, 0)); | 2054 __ movups(XMM10, Address(RAX, 0)); |
2055 __ abspd(XMM10); | 2055 __ abspd(XMM10); |
2056 __ movaps(XMM0, XMM10); | 2056 __ movaps(XMM0, XMM10); |
2057 __ popq(PP); // Restore caller's pool pointer. | 2057 __ popq(PP); // Restore caller's pool pointer. |
2058 __ ret(); | 2058 __ ret(); |
2059 } | 2059 } |
2060 | 2060 |
2061 | 2061 |
2062 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) { | 2062 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) { |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 | 2489 |
2490 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { | 2490 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { |
2491 typedef uint32_t (*PackedCompareNLECode)(); | 2491 typedef uint32_t (*PackedCompareNLECode)(); |
2492 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); | 2492 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); |
2493 EXPECT_EQ(static_cast<uword>(0x0), res); | 2493 EXPECT_EQ(static_cast<uword>(0x0), res); |
2494 } | 2494 } |
2495 | 2495 |
2496 | 2496 |
2497 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { | 2497 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { |
2498 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2498 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2499 __ LoadPoolPointer(PP); | 2499 __ LoadPoolPointer(); |
2500 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 2500 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
2501 __ movd(XMM0, RAX); | 2501 __ movd(XMM0, RAX); |
2502 __ shufps(XMM0, XMM0, Immediate(0x0)); | 2502 __ shufps(XMM0, XMM0, Immediate(0x0)); |
2503 __ negateps(XMM0); | 2503 __ negateps(XMM0); |
2504 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 2504 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
2505 __ popq(PP); // Restore caller's pool pointer. | 2505 __ popq(PP); // Restore caller's pool pointer. |
2506 __ ret(); | 2506 __ ret(); |
2507 } | 2507 } |
2508 | 2508 |
2509 | 2509 |
2510 ASSEMBLER_TEST_RUN(PackedNegate, test) { | 2510 ASSEMBLER_TEST_RUN(PackedNegate, test) { |
2511 typedef float (*PackedNegateCode)(); | 2511 typedef float (*PackedNegateCode)(); |
2512 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); | 2512 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); |
2513 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); | 2513 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); |
2514 } | 2514 } |
2515 | 2515 |
2516 | 2516 |
2517 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { | 2517 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { |
2518 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2518 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2519 __ LoadPoolPointer(PP); | 2519 __ LoadPoolPointer(); |
2520 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); | 2520 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); |
2521 __ movd(XMM0, RAX); | 2521 __ movd(XMM0, RAX); |
2522 __ shufps(XMM0, XMM0, Immediate(0x0)); | 2522 __ shufps(XMM0, XMM0, Immediate(0x0)); |
2523 __ absps(XMM0); | 2523 __ absps(XMM0); |
2524 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 2524 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
2525 __ popq(PP); // Restore caller's pool pointer. | 2525 __ popq(PP); // Restore caller's pool pointer. |
2526 __ ret(); | 2526 __ ret(); |
2527 } | 2527 } |
2528 | 2528 |
2529 | 2529 |
2530 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { | 2530 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { |
2531 typedef float (*PackedAbsoluteCode)(); | 2531 typedef float (*PackedAbsoluteCode)(); |
2532 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); | 2532 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); |
2533 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); | 2533 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); |
2534 } | 2534 } |
2535 | 2535 |
2536 | 2536 |
2537 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { | 2537 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { |
2538 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2538 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2539 __ LoadPoolPointer(PP); | 2539 __ LoadPoolPointer(); |
2540 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 2540 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
2541 __ zerowps(XMM0); | 2541 __ zerowps(XMM0); |
2542 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. | 2542 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. |
2543 __ popq(PP); // Restore caller's pool pointer. | 2543 __ popq(PP); // Restore caller's pool pointer. |
2544 __ ret(); | 2544 __ ret(); |
2545 } | 2545 } |
2546 | 2546 |
2547 | 2547 |
2548 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { | 2548 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { |
2549 typedef float (*PackedSetWZeroCode)(); | 2549 typedef float (*PackedSetWZeroCode)(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2651 | 2651 |
2652 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { | 2652 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { |
2653 static const struct ALIGN16 { | 2653 static const struct ALIGN16 { |
2654 uint32_t a; | 2654 uint32_t a; |
2655 uint32_t b; | 2655 uint32_t b; |
2656 uint32_t c; | 2656 uint32_t c; |
2657 uint32_t d; | 2657 uint32_t d; |
2658 } constant1 = | 2658 } constant1 = |
2659 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; | 2659 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; |
2660 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 2660 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
2661 __ LoadPoolPointer(PP); | 2661 __ LoadPoolPointer(); |
2662 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); | 2662 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1))); |
2663 __ movups(XMM9, Address(RAX, 0)); | 2663 __ movups(XMM9, Address(RAX, 0)); |
2664 __ notps(XMM9); | 2664 __ notps(XMM9); |
2665 __ movaps(XMM0, XMM9); | 2665 __ movaps(XMM0, XMM9); |
2666 __ pushq(RAX); | 2666 __ pushq(RAX); |
2667 __ movss(Address(RSP, 0), XMM0); | 2667 __ movss(Address(RSP, 0), XMM0); |
2668 __ popq(RAX); | 2668 __ popq(RAX); |
2669 __ popq(PP); // Restore caller's pool pointer. | 2669 __ popq(PP); // Restore caller's pool pointer. |
2670 __ ret(); | 2670 __ ret(); |
2671 } | 2671 } |
2672 | 2672 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3060 EXPECT_EQ(0, res); | 3060 EXPECT_EQ(0, res); |
3061 } | 3061 } |
3062 | 3062 |
3063 | 3063 |
3064 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { | 3064 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { |
3065 ObjectStore* object_store = Isolate::Current()->object_store(); | 3065 ObjectStore* object_store = Isolate::Current()->object_store(); |
3066 const Object& obj = Object::ZoneHandle(object_store->smi_class()); | 3066 const Object& obj = Object::ZoneHandle(object_store->smi_class()); |
3067 Label fail; | 3067 Label fail; |
3068 __ EnterFrame(0); | 3068 __ EnterFrame(0); |
3069 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 3069 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
3070 __ LoadPoolPointer(PP); | 3070 __ LoadPoolPointer(); |
3071 __ LoadObject(RAX, obj, PP); | 3071 __ LoadObject(RAX, obj); |
3072 __ CompareObject(RAX, obj, PP); | 3072 __ CompareObject(RAX, obj); |
3073 __ j(NOT_EQUAL, &fail); | 3073 __ j(NOT_EQUAL, &fail); |
3074 __ LoadObject(RCX, obj, PP); | 3074 __ LoadObject(RCX, obj); |
3075 __ CompareObject(RCX, obj, PP); | 3075 __ CompareObject(RCX, obj); |
3076 __ j(NOT_EQUAL, &fail); | 3076 __ j(NOT_EQUAL, &fail); |
3077 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); | 3077 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); |
3078 __ LoadObject(RCX, smi, PP); | 3078 __ LoadObject(RCX, smi); |
3079 __ CompareObject(RCX, smi, PP); | 3079 __ CompareObject(RCX, smi); |
3080 __ j(NOT_EQUAL, &fail); | 3080 __ j(NOT_EQUAL, &fail); |
3081 __ pushq(RAX); | 3081 __ pushq(RAX); |
3082 __ StoreObject(Address(RSP, 0), obj, PP); | 3082 __ StoreObject(Address(RSP, 0), obj); |
3083 __ popq(RCX); | 3083 __ popq(RCX); |
3084 __ CompareObject(RCX, obj, PP); | 3084 __ CompareObject(RCX, obj); |
3085 __ j(NOT_EQUAL, &fail); | 3085 __ j(NOT_EQUAL, &fail); |
3086 __ pushq(RAX); | 3086 __ pushq(RAX); |
3087 __ StoreObject(Address(RSP, 0), smi, PP); | 3087 __ StoreObject(Address(RSP, 0), smi); |
3088 __ popq(RCX); | 3088 __ popq(RCX); |
3089 __ CompareObject(RCX, smi, PP); | 3089 __ CompareObject(RCX, smi); |
3090 __ j(NOT_EQUAL, &fail); | 3090 __ j(NOT_EQUAL, &fail); |
3091 __ movl(RAX, Immediate(1)); // OK | 3091 __ movl(RAX, Immediate(1)); // OK |
3092 __ popq(PP); // Restore caller's pool pointer. | 3092 __ popq(PP); // Restore caller's pool pointer. |
3093 __ LeaveFrame(); | 3093 __ LeaveFrame(); |
3094 __ ret(); | 3094 __ ret(); |
3095 __ Bind(&fail); | 3095 __ Bind(&fail); |
3096 __ movl(RAX, Immediate(0)); // Fail. | 3096 __ movl(RAX, Immediate(0)); // Fail. |
3097 __ popq(PP); // Restore caller's pool pointer. | 3097 __ popq(PP); // Restore caller's pool pointer. |
3098 __ LeaveFrame(); | 3098 __ LeaveFrame(); |
3099 __ ret(); | 3099 __ ret(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3300 const double kDoubleConst = .7; | 3300 const double kDoubleConst = .7; |
3301 double res = | 3301 double res = |
3302 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); | 3302 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); |
3303 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 3303 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
3304 } | 3304 } |
3305 | 3305 |
3306 | 3306 |
3307 // Called from assembler_test.cc. | 3307 // Called from assembler_test.cc. |
3308 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 3308 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
3309 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 3309 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
3310 __ LoadPoolPointer(PP); | 3310 __ LoadPoolPointer(); |
3311 __ pushq(THR); | 3311 __ pushq(THR); |
3312 __ movq(THR, CallingConventions::kArg4Reg); | 3312 __ movq(THR, CallingConventions::kArg4Reg); |
3313 __ pushq(CTX); | 3313 __ pushq(CTX); |
3314 __ movq(CTX, CallingConventions::kArg1Reg); | 3314 __ movq(CTX, CallingConventions::kArg1Reg); |
3315 __ StoreIntoObject(CallingConventions::kArg3Reg, | 3315 __ StoreIntoObject(CallingConventions::kArg3Reg, |
3316 FieldAddress(CallingConventions::kArg3Reg, | 3316 FieldAddress(CallingConventions::kArg3Reg, |
3317 GrowableObjectArray::data_offset()), | 3317 GrowableObjectArray::data_offset()), |
3318 CallingConventions::kArg2Reg); | 3318 CallingConventions::kArg2Reg); |
3319 __ popq(CTX); | 3319 __ popq(CTX); |
3320 __ popq(THR); | 3320 __ popq(THR); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3426 EXPECT_EQ(12.0, res); | 3426 EXPECT_EQ(12.0, res); |
3427 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); | 3427 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); |
3428 EXPECT_EQ(-12.0, res); | 3428 EXPECT_EQ(-12.0, res); |
3429 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); | 3429 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); |
3430 EXPECT_EQ(-12.0, res); | 3430 EXPECT_EQ(-12.0, res); |
3431 } | 3431 } |
3432 | 3432 |
3433 | 3433 |
3434 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { | 3434 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { |
3435 __ pushq(PP); // Save caller's pool pointer and load a new one here. | 3435 __ pushq(PP); // Save caller's pool pointer and load a new one here. |
3436 __ LoadPoolPointer(PP); | 3436 __ LoadPoolPointer(); |
3437 __ DoubleAbs(XMM0); | 3437 __ DoubleAbs(XMM0); |
3438 __ popq(PP); // Restore caller's pool pointer. | 3438 __ popq(PP); // Restore caller's pool pointer. |
3439 __ ret(); | 3439 __ ret(); |
3440 } | 3440 } |
3441 | 3441 |
3442 | 3442 |
3443 ASSEMBLER_TEST_RUN(DoubleAbs, test) { | 3443 ASSEMBLER_TEST_RUN(DoubleAbs, test) { |
3444 typedef double (*DoubleAbsCode)(double d); | 3444 typedef double (*DoubleAbsCode)(double d); |
3445 double val = -12.45; | 3445 double val = -12.45; |
3446 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 3446 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3642 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); | 3642 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); |
3643 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); | 3643 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); |
3644 | 3644 |
3645 EXPECT_EQ(0, range_of(Bool::True().raw())); | 3645 EXPECT_EQ(0, range_of(Bool::True().raw())); |
3646 } | 3646 } |
3647 | 3647 |
3648 | 3648 |
3649 } // namespace dart | 3649 } // namespace dart |
3650 | 3650 |
3651 #endif // defined TARGET_ARCH_X64 | 3651 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |