| Index: runtime/vm/assembler_x64_test.cc
|
| diff --git a/runtime/vm/assembler_x64_test.cc b/runtime/vm/assembler_x64_test.cc
|
| index a10b52eeca8b1f11163cd174ad3a59a8479ac5bd..0498e68f734557183378aef8a537c094a06fb061 100644
|
| --- a/runtime/vm/assembler_x64_test.cc
|
| +++ b/runtime/vm/assembler_x64_test.cc
|
| @@ -2020,48 +2020,80 @@ ASSEMBLER_TEST_RUN(PackedDoubleSub, test) {
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedDoubleNegate, assembler) {
|
| +static void EnterTestFrame(Assembler* assembler) {
|
| + __ EnterFrame(0);
|
| + __ pushq(CODE_REG);
|
| + __ pushq(PP);
|
| + __ movq(CODE_REG, Address(CallingConventions::kArg1Reg,
|
| + VMHandles::kOffsetOfRawPtrInHandle));
|
| + __ LoadPoolPointer(PP);
|
| +}
|
| +
|
| +
|
| +static void LeaveTestFrame(Assembler* assembler) {
|
| + __ popq(PP);
|
| + __ popq(CODE_REG);
|
| + __ LeaveFrame();
|
| +}
|
| +
|
| +
|
| +#define ASSEMBLER_TEST_WITH_POOL_GENERATE(name, assembler) \
|
| + void AssemblerTestGenerate##name##Body(Assembler* assembler); \
|
| + ASSEMBLER_TEST_GENERATE(name, assembler) { \
|
| + EnterTestFrame(assembler); \
|
| + AssemblerTestGenerate##name##Body(assembler); \
|
| + LeaveTestFrame(assembler); \
|
| + __ ret(); \
|
| + } \
|
| + void AssemblerTestGenerate##name##Body(Assembler* assembler)
|
| +
|
| +
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedDoubleNegate, assembler) {
|
| static const struct ALIGN16 {
|
| double a;
|
| double b;
|
| } constant0 = { 1.0, 2.0 };
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
|
| __ movups(XMM10, Address(RAX, 0));
|
| __ negatepd(XMM10);
|
| __ movaps(XMM0, XMM10);
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| +}
|
| +
|
| +
|
| +template<typename Result>
|
| +Result Invoke(const AssemblerTest* test) {
|
| + typedef Result (*FunctionType) (const Code&);
|
| + return reinterpret_cast<FunctionType>(test->entry())(test->code());
|
| +}
|
| +
|
| +
|
| +template<typename Result, typename Arg0Type>
|
| +Result Invoke(const AssemblerTest* test, Arg0Type arg0) {
|
| + typedef Result (*FunctionType) (const Code&, Arg0Type);
|
| + return reinterpret_cast<FunctionType>(test->entry())(test->code(), arg0);
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) {
|
| - typedef double (*PackedDoubleNegate)();
|
| - double res = reinterpret_cast<PackedDoubleNegate>(test->entry())();
|
| + double res = Invoke<double>(test);
|
| EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedDoubleAbsolute, assembler) {
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedDoubleAbsolute, assembler) {
|
| static const struct ALIGN16 {
|
| double a;
|
| double b;
|
| } constant0 = { -1.0, 2.0 };
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| __ movq(RAX, Immediate(reinterpret_cast<uword>(&constant0)));
|
| __ movups(XMM10, Address(RAX, 0));
|
| __ abspd(XMM10);
|
| __ movaps(XMM0, XMM10);
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedDoubleAbsolute, test) {
|
| - typedef double (*PackedDoubleAbsolute)();
|
| - double res = reinterpret_cast<PackedDoubleAbsolute>(test->entry())();
|
| + double res = Invoke<double>(test);
|
| EXPECT_FLOAT_EQ(1.0, res, 0.000001f);
|
| }
|
|
|
| @@ -2494,60 +2526,45 @@ ASSEMBLER_TEST_RUN(PackedCompareNLE, test) {
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedNegate, assembler) {
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedNegate, assembler) {
|
| __ movl(RAX, Immediate(bit_cast<int32_t, float>(12.3f)));
|
| __ movd(XMM0, RAX);
|
| __ shufps(XMM0, XMM0, Immediate(0x0));
|
| __ negateps(XMM0);
|
| __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedNegate, test) {
|
| - typedef float (*PackedNegateCode)();
|
| - float res = reinterpret_cast<PackedNegateCode>(test->entry())();
|
| + float res = Invoke<float>(test);
|
| EXPECT_FLOAT_EQ(-12.3f, res, 0.001f);
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedAbsolute, assembler) {
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedAbsolute, assembler) {
|
| __ movl(RAX, Immediate(bit_cast<int32_t, float>(-15.3f)));
|
| __ movd(XMM0, RAX);
|
| __ shufps(XMM0, XMM0, Immediate(0x0));
|
| __ absps(XMM0);
|
| __ shufps(XMM0, XMM0, Immediate(0xAA)); // Copy third lane into all 4 lanes.
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedAbsolute, test) {
|
| - typedef float (*PackedAbsoluteCode)();
|
| - float res = reinterpret_cast<PackedAbsoluteCode>(test->entry())();
|
| + float res = Invoke<float>(test);
|
| EXPECT_FLOAT_EQ(15.3f, res, 0.001f);
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedSetWZero, assembler) {
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedSetWZero, assembler) {
|
| __ set1ps(XMM0, RAX, Immediate(bit_cast<int32_t, float>(12.3f)));
|
| __ zerowps(XMM0);
|
| __ shufps(XMM0, XMM0, Immediate(0xFF)); // Copy the W lane which is now 0.0.
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedSetWZero, test) {
|
| - typedef float (*PackedSetWZeroCode)();
|
| - float res = reinterpret_cast<PackedSetWZeroCode>(test->entry())();
|
| + float res = Invoke<float>(test);
|
| EXPECT_FLOAT_EQ(0.0f, res, 0.001f);
|
| }
|
|
|
| @@ -2649,7 +2666,7 @@ ASSEMBLER_TEST_RUN(PackedLogicalAnd, test) {
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) {
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(PackedLogicalNot, assembler) {
|
| static const struct ALIGN16 {
|
| uint32_t a;
|
| uint32_t b;
|
| @@ -2657,8 +2674,6 @@ ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) {
|
| uint32_t d;
|
| } constant1 =
|
| { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| __ LoadImmediate(RAX, Immediate(reinterpret_cast<intptr_t>(&constant1)), PP);
|
| __ movups(XMM9, Address(RAX, 0));
|
| __ notps(XMM9);
|
| @@ -2666,14 +2681,11 @@ ASSEMBLER_TEST_GENERATE(PackedLogicalNot, assembler) {
|
| __ pushq(RAX);
|
| __ movss(Address(RSP, 0), XMM0);
|
| __ popq(RAX);
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(PackedLogicalNot, test) {
|
| - typedef uint32_t (*PackedLogicalNotCode)();
|
| - uint32_t res = reinterpret_cast<PackedLogicalNotCode>(test->entry())();
|
| + uint32_t res = Invoke<uint32_t>(test);
|
| EXPECT_EQ(static_cast<uword>(0x0), res);
|
| }
|
|
|
| @@ -3061,13 +3073,10 @@ ASSEMBLER_TEST_RUN(DoubleToInt64Conversion, test) {
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) {
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(TestObjectCompare, assembler) {
|
| ObjectStore* object_store = Isolate::Current()->object_store();
|
| const Object& obj = Object::ZoneHandle(object_store->smi_class());
|
| Label fail;
|
| - __ EnterFrame(0);
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| __ LoadObject(RAX, obj, PP);
|
| __ CompareObject(RAX, obj, PP);
|
| __ j(NOT_EQUAL, &fail);
|
| @@ -3094,15 +3103,11 @@ ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) {
|
| __ ret();
|
| __ Bind(&fail);
|
| __ movl(RAX, Immediate(0)); // Fail.
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ LeaveFrame();
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(TestObjectCompare, test) {
|
| - typedef bool (*TestObjectCompare)();
|
| - bool res = reinterpret_cast<TestObjectCompare>(test->entry())();
|
| + bool res = Invoke<bool>(test);
|
| EXPECT_EQ(true, res);
|
| }
|
|
|
| @@ -3305,21 +3310,14 @@ ASSEMBLER_TEST_RUN(SquareRootDouble, test) {
|
|
|
|
|
| // Called from assembler_test.cc.
|
| -ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) {
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(StoreIntoObject, assembler) {
|
| __ pushq(THR);
|
| __ movq(THR, CallingConventions::kArg4Reg);
|
| - __ pushq(CTX);
|
| - __ movq(CTX, CallingConventions::kArg1Reg);
|
| __ StoreIntoObject(CallingConventions::kArg3Reg,
|
| FieldAddress(CallingConventions::kArg3Reg,
|
| GrowableObjectArray::data_offset()),
|
| CallingConventions::kArg2Reg);
|
| - __ popq(CTX);
|
| __ popq(THR);
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| @@ -3431,22 +3429,17 @@ ASSEMBLER_TEST_RUN(DoubleToDoubleTrunc, test) {
|
| }
|
|
|
|
|
| -ASSEMBLER_TEST_GENERATE(DoubleAbs, assembler) {
|
| - __ pushq(PP); // Save caller's pool pointer and load a new one here.
|
| - __ LoadPoolPointer(PP);
|
| +ASSEMBLER_TEST_WITH_POOL_GENERATE(DoubleAbs, assembler) {
|
| __ DoubleAbs(XMM0);
|
| - __ popq(PP); // Restore caller's pool pointer.
|
| - __ ret();
|
| }
|
|
|
|
|
| ASSEMBLER_TEST_RUN(DoubleAbs, test) {
|
| - typedef double (*DoubleAbsCode)(double d);
|
| double val = -12.45;
|
| - double res = reinterpret_cast<DoubleAbsCode>(test->entry())(val);
|
| + double res = Invoke<double, double>(test, val);
|
| EXPECT_FLOAT_EQ(-val, res, 0.001);
|
| val = 12.45;
|
| - res = reinterpret_cast<DoubleAbsCode>(test->entry())(val);
|
| + res = Invoke<double, double>(test, val);
|
| EXPECT_FLOAT_EQ(val, res, 0.001);
|
| }
|
|
|
|
|