| 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 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 } | 2013 } |
| 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 ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) { | 2023 static void EnterTestFrame(Assembler* assembler) { |
| 2024 __ EnterFrame(0); |
| 2025 __ pushq(CODE_REG); |
| 2026 __ pushq(PP); |
| 2027 __ movq(CODE_REG, Address(CallingConventions::kArg1Reg, |
| 2028 VMHandles::kOffsetOfRawPtrInHandle)); |
| 2029 __ LoadPoolPointer(PP); |
| 2030 } |
| 2031 |
| 2032 |
| 2033 static void LeaveTestFrame(Assembler* assembler) { |
| 2034 __ popq(PP); |
| 2035 __ popq(CODE_REG); |
| 2036 __ LeaveFrame(); |
| 2037 } |
| 2038 |
| 2039 |
| 2040 #define ASSEMBLER_TEST_WITH_POOL_GENERATE(name, assembler) \ |
| 2041 void AssemblerTestGenerate##name##Body(Assembler* assembler); \ |
| 2042 ASSEMBLER_TEST_GENERATE(name, assembler) { \ |
| 2043 EnterTestFrame(assembler); \ |
| 2044 AssemblerTestGenerate##name##Body(assembler); \ |
| 2045 LeaveTestFrame(assembler); \ |
| 2046 __ ret(); \ |
| 2047 } \ |
| 2048 void AssemblerTestGenerate##name##Body(Assembler* assembler) |
| 2049 |
| 2050 |
| 2051 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedDoubleNegate, assembler) { |
| 2024 static const struct ALIGN16 { | 2052 static const struct ALIGN16 { |
| 2025 double a; | 2053 double a; |
| 2026 double b; | 2054 double b; |
| 2027 } constant0 = { 1.0, 2.0 }; | 2055 } constant0 = { 1.0, 2.0 }; |
| 2028 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2029 __ LoadPoolPointer(PP); | |
| 2030 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); | 2056 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); |
| 2031 __ movups(XMM10, Address(RAX, 0)); | 2057 __ movups(XMM10, Address(RAX, 0)); |
| 2032 __ negatepd(XMM10); | 2058 __ negatepd(XMM10); |
| 2033 __ movaps(XMM0, XMM10); | 2059 __ movaps(XMM0, XMM10); |
| 2034 __ popq(PP); // Restore caller's pool pointer. | 2060 } |
| 2035 __ ret(); | 2061 |
| 2062 |
| 2063 template<typename Result> |
| 2064 Result Invoke(const AssemblerTest* test) { |
| 2065 typedef Result (*FunctionType) (const Code&); |
| 2066 return reinterpret_cast<FunctionType>(test->entry())(test->code()); |
| 2067 } |
| 2068 |
| 2069 |
| 2070 template<typename Result, typename Arg0Type> |
| 2071 Result Invoke(const AssemblerTest* test, Arg0Type arg0) { |
| 2072 typedef Result (*FunctionType) (const Code&, Arg0Type); |
| 2073 return reinterpret_cast<FunctionType>(test->entry())(test->code(), arg0); |
| 2036 } | 2074 } |
| 2037 | 2075 |
| 2038 | 2076 |
| 2039 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) { | 2077 ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) { |
| 2040 typedef double (*PackedDoubleNegate)(); | 2078 double res = Invoke<double>(test); |
| 2041 double res = reinterpret_cast<PackedDoubleNegate>(test->entry())(); | |
| 2042 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f); | 2079 EXPECT_FLOAT_EQ(-1.0, res, 0.000001f); |
| 2043 } | 2080 } |
| 2044 | 2081 |
| 2045 | 2082 |
| 2046 ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) { | 2083 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedDoubleAbsolute, assembler) { |
| 2047 static const struct ALIGN16 { | 2084 static const struct ALIGN16 { |
| 2048 double a; | 2085 double a; |
| 2049 double b; | 2086 double b; |
| 2050 } constant0 = { -1.0, 2.0 }; | 2087 } constant0 = { -1.0, 2.0 }; |
| 2051 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2052 __ LoadPoolPointer(PP); | |
| 2053 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); | 2088 __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0))); |
| 2054 __ movups(XMM10, Address(RAX, 0)); | 2089 __ movups(XMM10, Address(RAX, 0)); |
| 2055 __ abspd(XMM10); | 2090 __ abspd(XMM10); |
| 2056 __ movaps(XMM0, XMM10); | 2091 __ movaps(XMM0, XMM10); |
| 2057 __ popq(PP); // Restore caller's pool pointer. | |
| 2058 __ ret(); | |
| 2059 } | 2092 } |
| 2060 | 2093 |
| 2061 | 2094 |
| 2062 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) { | 2095 ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) { |
| 2063 typedef double (*PackedDoubleAbsolute)(); | 2096 double res = Invoke<double>(test); |
| 2064 double res = reinterpret_cast<PackedDoubleAbsolute>(test->entry())(); | |
| 2065 EXPECT_FLOAT_EQ(1.0, res, 0.000001f); | 2097 EXPECT_FLOAT_EQ(1.0, res, 0.000001f); |
| 2066 } | 2098 } |
| 2067 | 2099 |
| 2068 | 2100 |
| 2069 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) { | 2101 ASSEMBLER_TEST_GENERATE(PackedDoubleMul, assembler) { |
| 2070 static const struct ALIGN16 { | 2102 static const struct ALIGN16 { |
| 2071 double a; | 2103 double a; |
| 2072 double b; | 2104 double b; |
| 2073 } constant0 = { 3.0, 2.0 }; | 2105 } constant0 = { 3.0, 2.0 }; |
| 2074 static const struct ALIGN16 { | 2106 static const struct ALIGN16 { |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2487 } | 2519 } |
| 2488 | 2520 |
| 2489 | 2521 |
| 2490 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { | 2522 ASSEMBLER_TEST_RUN(PackedCompareNLE, test) { |
| 2491 typedef uint32_t (*PackedCompareNLECode)(); | 2523 typedef uint32_t (*PackedCompareNLECode)(); |
| 2492 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); | 2524 uint32_t res = reinterpret_cast<PackedCompareNLECode>(test->entry())(); |
| 2493 EXPECT_EQ(static_cast<uword>(0x0), res); | 2525 EXPECT_EQ(static_cast<uword>(0x0), res); |
| 2494 } | 2526 } |
| 2495 | 2527 |
| 2496 | 2528 |
| 2497 ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) { | 2529 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedNegate, assembler) { |
| 2498 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2499 __ LoadPoolPointer(PP); | |
| 2500 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 2530 __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
| 2501 __ movd(XMM0, RAX); | 2531 __ movd(XMM0, RAX); |
| 2502 __ shufps(XMM0, XMM0, Immediate(0x0)); | 2532 __ shufps(XMM0, XMM0, Immediate(0x0)); |
| 2503 __ negateps(XMM0); | 2533 __ negateps(XMM0); |
| 2504 __ 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. |
| 2505 __ popq(PP); // Restore caller's pool pointer. | |
| 2506 __ ret(); | |
| 2507 } | 2535 } |
| 2508 | 2536 |
| 2509 | 2537 |
| 2510 ASSEMBLER_TEST_RUN(PackedNegate, test) { | 2538 ASSEMBLER_TEST_RUN(PackedNegate, test) { |
| 2511 typedef float (*PackedNegateCode)(); | 2539 float res = Invoke<float>(test); |
| 2512 float res = reinterpret_cast<PackedNegateCode>(test->entry())(); | |
| 2513 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); | 2540 EXPECT_FLOAT_EQ(-12.3f, res, 0.001f); |
| 2514 } | 2541 } |
| 2515 | 2542 |
| 2516 | 2543 |
| 2517 ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) { | 2544 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedAbsolute, assembler) { |
| 2518 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2519 __ LoadPoolPointer(PP); | |
| 2520 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); | 2545 __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f))); |
| 2521 __ movd(XMM0, RAX); | 2546 __ movd(XMM0, RAX); |
| 2522 __ shufps(XMM0, XMM0, Immediate(0x0)); | 2547 __ shufps(XMM0, XMM0, Immediate(0x0)); |
| 2523 __ absps(XMM0); | 2548 __ absps(XMM0); |
| 2524 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. | 2549 __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes. |
| 2525 __ popq(PP); // Restore caller's pool pointer. | |
| 2526 __ ret(); | |
| 2527 } | 2550 } |
| 2528 | 2551 |
| 2529 | 2552 |
| 2530 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { | 2553 ASSEMBLER_TEST_RUN(PackedAbsolute, test) { |
| 2531 typedef float (*PackedAbsoluteCode)(); | 2554 float res = Invoke<float>(test); |
| 2532 float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())(); | |
| 2533 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); | 2555 EXPECT_FLOAT_EQ(15.3f, res, 0.001f); |
| 2534 } | 2556 } |
| 2535 | 2557 |
| 2536 | 2558 |
| 2537 ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) { | 2559 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedSetWZero, assembler) { |
| 2538 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2539 __ LoadPoolPointer(PP); | |
| 2540 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); | 2560 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f))); |
| 2541 __ zerowps(XMM0); | 2561 __ zerowps(XMM0); |
| 2542 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. | 2562 __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0. |
| 2543 __ popq(PP); // Restore caller's pool pointer. | |
| 2544 __ ret(); | |
| 2545 } | 2563 } |
| 2546 | 2564 |
| 2547 | 2565 |
| 2548 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { | 2566 ASSEMBLER_TEST_RUN(PackedSetWZero, test) { |
| 2549 typedef float (*PackedSetWZeroCode)(); | 2567 float res = Invoke<float>(test); |
| 2550 float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())(); | |
| 2551 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); | 2568 EXPECT_FLOAT_EQ(0.0f, res, 0.001f); |
| 2552 } | 2569 } |
| 2553 | 2570 |
| 2554 | 2571 |
| 2555 ASSEMBLER_TEST_GENERATE(PackedMin, assembler) { | 2572 ASSEMBLER_TEST_GENERATE(PackedMin, assembler) { |
| 2556 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(2.0f))); | 2573 __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(2.0f))); |
| 2557 __ set1ps(XMM1, RAX, Immediate(bit_cast<int32_t, float>(4.0f))); | 2574 __ set1ps(XMM1, RAX, Immediate(bit_cast<int32_t, float>(4.0f))); |
| 2558 __ minps(XMM0, XMM1); | 2575 __ minps(XMM0, XMM1); |
| 2559 __ ret(); | 2576 __ ret(); |
| 2560 } | 2577 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 } | 2659 } |
| 2643 | 2660 |
| 2644 | 2661 |
| 2645 ASSEMBLER_TEST_RUN(PackedLogicalAnd, test) { | 2662 ASSEMBLER_TEST_RUN(PackedLogicalAnd, test) { |
| 2646 typedef uint32_t (*PackedLogicalAndCode)(); | 2663 typedef uint32_t (*PackedLogicalAndCode)(); |
| 2647 uint32_t res = reinterpret_cast<PackedLogicalAndCode>(test->entry())(); | 2664 uint32_t res = reinterpret_cast<PackedLogicalAndCode>(test->entry())(); |
| 2648 EXPECT_EQ(static_cast<uword>(0x0000F000), res); | 2665 EXPECT_EQ(static_cast<uword>(0x0000F000), res); |
| 2649 } | 2666 } |
| 2650 | 2667 |
| 2651 | 2668 |
| 2652 ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) { | 2669 ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedLogicalNot, assembler) { |
| 2653 static const struct ALIGN16 { | 2670 static const struct ALIGN16 { |
| 2654 uint32_t a; | 2671 uint32_t a; |
| 2655 uint32_t b; | 2672 uint32_t b; |
| 2656 uint32_t c; | 2673 uint32_t c; |
| 2657 uint32_t d; | 2674 uint32_t d; |
| 2658 } constant1 = | 2675 } constant1 = |
| 2659 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; | 2676 { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; |
| 2660 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 2661 __ LoadPoolPointer(PP); | |
| 2662 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); | 2677 __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP); |
| 2663 __ movups(XMM9, Address(RAX, 0)); | 2678 __ movups(XMM9, Address(RAX, 0)); |
| 2664 __ notps(XMM9); | 2679 __ notps(XMM9); |
| 2665 __ movaps(XMM0, XMM9); | 2680 __ movaps(XMM0, XMM9); |
| 2666 __ pushq(RAX); | 2681 __ pushq(RAX); |
| 2667 __ movss(Address(RSP, 0), XMM0); | 2682 __ movss(Address(RSP, 0), XMM0); |
| 2668 __ popq(RAX); | 2683 __ popq(RAX); |
| 2669 __ popq(PP); // Restore caller's pool pointer. | |
| 2670 __ ret(); | |
| 2671 } | 2684 } |
| 2672 | 2685 |
| 2673 | 2686 |
| 2674 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { | 2687 ASSEMBLER_TEST_RUN(PackedLogicalNot, test) { |
| 2675 typedef uint32_t (*PackedLogicalNotCode)(); | 2688 uint32_t res = Invoke<uint32_t>(test); |
| 2676 uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())(); | |
| 2677 EXPECT_EQ(static_cast<uword>(0x0), res); | 2689 EXPECT_EQ(static_cast<uword>(0x0), res); |
| 2678 } | 2690 } |
| 2679 | 2691 |
| 2680 | 2692 |
| 2681 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) { | 2693 ASSEMBLER_TEST_GENERATE(PackedMoveHighLow, assembler) { |
| 2682 static const struct ALIGN16 { | 2694 static const struct ALIGN16 { |
| 2683 float a; | 2695 float a; |
| 2684 float b; | 2696 float b; |
| 2685 float c; | 2697 float c; |
| 2686 float d; | 2698 float d; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3054 } | 3066 } |
| 3055 | 3067 |
| 3056 | 3068 |
| 3057 ASSEMBLER_TEST_RUN(DoubleToInt64Conversion, test) { | 3069 ASSEMBLER_TEST_RUN(DoubleToInt64Conversion, test) { |
| 3058 typedef int64_t (*DoubleToInt64ConversionCode)(); | 3070 typedef int64_t (*DoubleToInt64ConversionCode)(); |
| 3059 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); | 3071 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); |
| 3060 EXPECT_EQ(0, res); | 3072 EXPECT_EQ(0, res); |
| 3061 } | 3073 } |
| 3062 | 3074 |
| 3063 | 3075 |
| 3064 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { | 3076 ASSEMBLER_TEST_WITH_POOL_GENERATE(TestObjectCompare, assembler) { |
| 3065 ObjectStore* object_store = Isolate::Current()->object_store(); | 3077 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 3066 const Object& obj = Object::ZoneHandle(object_store->smi_class()); | 3078 const Object& obj = Object::ZoneHandle(object_store->smi_class()); |
| 3067 Label fail; | 3079 Label fail; |
| 3068 __ EnterFrame(0); | |
| 3069 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 3070 __ LoadPoolPointer(PP); | |
| 3071 __ LoadObject(RAX, obj, PP); | 3080 __ LoadObject(RAX, obj, PP); |
| 3072 __ CompareObject(RAX, obj, PP); | 3081 __ CompareObject(RAX, obj, PP); |
| 3073 __ j(NOT_EQUAL, &fail); | 3082 __ j(NOT_EQUAL, &fail); |
| 3074 __ LoadObject(RCX, obj, PP); | 3083 __ LoadObject(RCX, obj, PP); |
| 3075 __ CompareObject(RCX, obj, PP); | 3084 __ CompareObject(RCX, obj, PP); |
| 3076 __ j(NOT_EQUAL, &fail); | 3085 __ j(NOT_EQUAL, &fail); |
| 3077 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); | 3086 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); |
| 3078 __ LoadObject(RCX, smi, PP); | 3087 __ LoadObject(RCX, smi, PP); |
| 3079 __ CompareObject(RCX, smi, PP); | 3088 __ CompareObject(RCX, smi, PP); |
| 3080 __ j(NOT_EQUAL, &fail); | 3089 __ j(NOT_EQUAL, &fail); |
| 3081 __ pushq(RAX); | 3090 __ pushq(RAX); |
| 3082 __ StoreObject(Address(RSP, 0), obj, PP); | 3091 __ StoreObject(Address(RSP, 0), obj, PP); |
| 3083 __ popq(RCX); | 3092 __ popq(RCX); |
| 3084 __ CompareObject(RCX, obj, PP); | 3093 __ CompareObject(RCX, obj, PP); |
| 3085 __ j(NOT_EQUAL, &fail); | 3094 __ j(NOT_EQUAL, &fail); |
| 3086 __ pushq(RAX); | 3095 __ pushq(RAX); |
| 3087 __ StoreObject(Address(RSP, 0), smi, PP); | 3096 __ StoreObject(Address(RSP, 0), smi, PP); |
| 3088 __ popq(RCX); | 3097 __ popq(RCX); |
| 3089 __ CompareObject(RCX, smi, PP); | 3098 __ CompareObject(RCX, smi, PP); |
| 3090 __ j(NOT_EQUAL, &fail); | 3099 __ j(NOT_EQUAL, &fail); |
| 3091 __ movl(RAX, Immediate(1)); // OK | 3100 __ movl(RAX, Immediate(1)); // OK |
| 3092 __ popq(PP); // Restore caller's pool pointer. | 3101 __ popq(PP); // Restore caller's pool pointer. |
| 3093 __ LeaveFrame(); | 3102 __ LeaveFrame(); |
| 3094 __ ret(); | 3103 __ ret(); |
| 3095 __ Bind(&fail); | 3104 __ Bind(&fail); |
| 3096 __ movl(RAX, Immediate(0)); // Fail. | 3105 __ movl(RAX, Immediate(0)); // Fail. |
| 3097 __ popq(PP); // Restore caller's pool pointer. | |
| 3098 __ LeaveFrame(); | |
| 3099 __ ret(); | |
| 3100 } | 3106 } |
| 3101 | 3107 |
| 3102 | 3108 |
| 3103 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { | 3109 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { |
| 3104 typedef bool (*TestObjectCompare)(); | 3110 bool res = Invoke<bool>(test); |
| 3105 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); | |
| 3106 EXPECT_EQ(true, res); | 3111 EXPECT_EQ(true, res); |
| 3107 } | 3112 } |
| 3108 | 3113 |
| 3109 | 3114 |
| 3110 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { | 3115 ASSEMBLER_TEST_GENERATE(TestNop, assembler) { |
| 3111 __ nop(1); | 3116 __ nop(1); |
| 3112 __ nop(2); | 3117 __ nop(2); |
| 3113 __ nop(3); | 3118 __ nop(3); |
| 3114 __ nop(4); | 3119 __ nop(4); |
| 3115 __ nop(5); | 3120 __ nop(5); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 ASSEMBLER_TEST_RUN(SquareRootDouble, test) { | 3303 ASSEMBLER_TEST_RUN(SquareRootDouble, test) { |
| 3299 typedef double (*SquareRootDoubleCode)(double d); | 3304 typedef double (*SquareRootDoubleCode)(double d); |
| 3300 const double kDoubleConst = .7; | 3305 const double kDoubleConst = .7; |
| 3301 double res = | 3306 double res = |
| 3302 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); | 3307 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); |
| 3303 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 3308 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
| 3304 } | 3309 } |
| 3305 | 3310 |
| 3306 | 3311 |
| 3307 // Called from assembler_test.cc. | 3312 // Called from assembler_test.cc. |
| 3308 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 3313 ASSEMBLER_TEST_WITH_POOL_GENERATE(StoreIntoObject, assembler) { |
| 3309 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 3310 __ LoadPoolPointer(PP); | |
| 3311 __ pushq(THR); | 3314 __ pushq(THR); |
| 3312 __ movq(THR, CallingConventions::kArg4Reg); | 3315 __ movq(THR, CallingConventions::kArg4Reg); |
| 3313 __ pushq(CTX); | |
| 3314 __ movq(CTX, CallingConventions::kArg1Reg); | |
| 3315 __ StoreIntoObject(CallingConventions::kArg3Reg, | 3316 __ StoreIntoObject(CallingConventions::kArg3Reg, |
| 3316 FieldAddress(CallingConventions::kArg3Reg, | 3317 FieldAddress(CallingConventions::kArg3Reg, |
| 3317 GrowableObjectArray::data_offset()), | 3318 GrowableObjectArray::data_offset()), |
| 3318 CallingConventions::kArg2Reg); | 3319 CallingConventions::kArg2Reg); |
| 3319 __ popq(CTX); | |
| 3320 __ popq(THR); | 3320 __ popq(THR); |
| 3321 __ popq(PP); // Restore caller's pool pointer. | |
| 3322 __ ret(); | |
| 3323 } | 3321 } |
| 3324 | 3322 |
| 3325 | 3323 |
| 3326 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { | 3324 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { |
| 3327 int64_t l = bit_cast<int64_t, double>(1024.67); | 3325 int64_t l = bit_cast<int64_t, double>(1024.67); |
| 3328 __ movq(RAX, Immediate(l)); | 3326 __ movq(RAX, Immediate(l)); |
| 3329 __ pushq(RAX); | 3327 __ pushq(RAX); |
| 3330 __ fldl(Address(RSP, 0)); | 3328 __ fldl(Address(RSP, 0)); |
| 3331 __ movq(Address(RSP, 0), Immediate(0)); | 3329 __ movq(Address(RSP, 0), Immediate(0)); |
| 3332 __ fstpl(Address(RSP, 0)); | 3330 __ fstpl(Address(RSP, 0)); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3424 EXPECT_EQ(12.0, res); | 3422 EXPECT_EQ(12.0, res); |
| 3425 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); | 3423 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(12.8); |
| 3426 EXPECT_EQ(12.0, res); | 3424 EXPECT_EQ(12.0, res); |
| 3427 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); | 3425 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.3); |
| 3428 EXPECT_EQ(-12.0, res); | 3426 EXPECT_EQ(-12.0, res); |
| 3429 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); | 3427 res = reinterpret_cast<DoubleToDoubleTruncCode>(test->entry())(-12.8); |
| 3430 EXPECT_EQ(-12.0, res); | 3428 EXPECT_EQ(-12.0, res); |
| 3431 } | 3429 } |
| 3432 | 3430 |
| 3433 | 3431 |
| 3434 ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) { | 3432 ASSEMBLER_TEST_WITH_POOL_GENERATE(DoubleAbs, assembler) { |
| 3435 __ pushq(PP); // Save caller's pool pointer and load a new one here. | |
| 3436 __ LoadPoolPointer(PP); | |
| 3437 __ DoubleAbs(XMM0); | 3433 __ DoubleAbs(XMM0); |
| 3438 __ popq(PP); // Restore caller's pool pointer. | |
| 3439 __ ret(); | |
| 3440 } | 3434 } |
| 3441 | 3435 |
| 3442 | 3436 |
| 3443 ASSEMBLER_TEST_RUN(DoubleAbs, test) { | 3437 ASSEMBLER_TEST_RUN(DoubleAbs, test) { |
| 3444 typedef double (*DoubleAbsCode)(double d); | |
| 3445 double val = -12.45; | 3438 double val = -12.45; |
| 3446 double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 3439 double res = Invoke<double, double>(test, val); |
| 3447 EXPECT_FLOAT_EQ(-val, res, 0.001); | 3440 EXPECT_FLOAT_EQ(-val, res, 0.001); |
| 3448 val = 12.45; | 3441 val = 12.45; |
| 3449 res = reinterpret_cast<DoubleAbsCode>(test->entry())(val); | 3442 res = Invoke<double, double>(test, val); |
| 3450 EXPECT_FLOAT_EQ(val, res, 0.001); | 3443 EXPECT_FLOAT_EQ(val, res, 0.001); |
| 3451 } | 3444 } |
| 3452 | 3445 |
| 3453 | 3446 |
| 3454 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { | 3447 ASSEMBLER_TEST_GENERATE(ExtractSignBits, assembler) { |
| 3455 __ movmskpd(RAX, XMM0); | 3448 __ movmskpd(RAX, XMM0); |
| 3456 __ andq(RAX, Immediate(0x1)); | 3449 __ andq(RAX, Immediate(0x1)); |
| 3457 __ ret(); | 3450 __ ret(); |
| 3458 } | 3451 } |
| 3459 | 3452 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3642 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); | 3635 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); |
| 3643 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); | 3636 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); |
| 3644 | 3637 |
| 3645 EXPECT_EQ(0, range_of(Bool::True().raw())); | 3638 EXPECT_EQ(0, range_of(Bool::True().raw())); |
| 3646 } | 3639 } |
| 3647 | 3640 |
| 3648 | 3641 |
| 3649 } // namespace dart | 3642 } // namespace dart |
| 3650 | 3643 |
| 3651 #endif // defined TARGET_ARCH_X64 | 3644 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |