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 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 typedef int64_t (*DoubleToInt64ConversionCode)(); | 2153 typedef int64_t (*DoubleToInt64ConversionCode)(); |
2154 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); | 2154 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); |
2155 EXPECT_EQ(0, res); | 2155 EXPECT_EQ(0, res); |
2156 } | 2156 } |
2157 | 2157 |
2158 | 2158 |
2159 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { | 2159 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { |
2160 ObjectStore* object_store = Isolate::Current()->object_store(); | 2160 ObjectStore* object_store = Isolate::Current()->object_store(); |
2161 const Object& obj = Object::ZoneHandle(object_store->smi_class()); | 2161 const Object& obj = Object::ZoneHandle(object_store->smi_class()); |
2162 Label fail; | 2162 Label fail; |
2163 __ LoadObject(RAX, obj); | 2163 __ EnterDartFrame(0, PP, kNoRegister); |
| 2164 __ LoadObjectFromPool(RAX, obj, Assembler::kNotPatchable, PP); |
2164 __ CompareObject(RAX, obj); | 2165 __ CompareObject(RAX, obj); |
2165 __ j(NOT_EQUAL, &fail); | 2166 __ j(NOT_EQUAL, &fail); |
2166 __ LoadObject(RCX, obj); | 2167 __ LoadObjectFromPool(RCX, obj, Assembler::kNotPatchable, PP); |
2167 __ CompareObject(RCX, obj); | 2168 __ CompareObject(RCX, obj); |
2168 __ j(NOT_EQUAL, &fail); | 2169 __ j(NOT_EQUAL, &fail); |
2169 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); | 2170 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); |
2170 __ LoadObject(RCX, smi); | 2171 __ LoadObjectFromPool(RCX, smi, Assembler::kNotPatchable, PP); |
2171 __ CompareObject(RCX, smi); | 2172 __ CompareObject(RCX, smi); |
2172 __ j(NOT_EQUAL, &fail); | 2173 __ j(NOT_EQUAL, &fail); |
2173 __ pushq(RAX); | 2174 __ pushq(RAX); |
2174 __ StoreObject(Address(RSP, 0), obj); | 2175 __ StoreObject(Address(RSP, 0), obj); |
2175 __ popq(RCX); | 2176 __ popq(RCX); |
2176 __ CompareObject(RCX, obj); | 2177 __ CompareObject(RCX, obj); |
2177 __ j(NOT_EQUAL, &fail); | 2178 __ j(NOT_EQUAL, &fail); |
2178 __ pushq(RAX); | 2179 __ pushq(RAX); |
2179 __ StoreObject(Address(RSP, 0), smi); | 2180 __ StoreObject(Address(RSP, 0), smi); |
2180 __ popq(RCX); | 2181 __ popq(RCX); |
2181 __ CompareObject(RCX, smi); | 2182 __ CompareObject(RCX, smi); |
2182 __ j(NOT_EQUAL, &fail); | 2183 __ j(NOT_EQUAL, &fail); |
2183 __ movl(RAX, Immediate(1)); // OK | 2184 __ movl(RAX, Immediate(1)); // OK |
| 2185 __ LeaveFrameWithPP(); |
2184 __ ret(); | 2186 __ ret(); |
2185 __ Bind(&fail); | 2187 __ Bind(&fail); |
2186 __ movl(RAX, Immediate(0)); // Fail. | 2188 __ movl(RAX, Immediate(0)); // Fail. |
| 2189 __ LeaveFrameWithPP(); |
2187 __ ret(); | 2190 __ ret(); |
2188 } | 2191 } |
2189 | 2192 |
2190 | 2193 |
2191 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { | 2194 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { |
2192 typedef bool (*TestObjectCompare)(); | 2195 typedef bool (*TestObjectCompare)(); |
2193 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); | 2196 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); |
2194 EXPECT_EQ(true, res); | 2197 EXPECT_EQ(true, res); |
2195 } | 2198 } |
2196 | 2199 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 typedef double (*SquareRootDoubleCode)(double d); | 2390 typedef double (*SquareRootDoubleCode)(double d); |
2388 const double kDoubleConst = .7; | 2391 const double kDoubleConst = .7; |
2389 double res = | 2392 double res = |
2390 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); | 2393 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); |
2391 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 2394 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
2392 } | 2395 } |
2393 | 2396 |
2394 | 2397 |
2395 // Called from assembler_test.cc. | 2398 // Called from assembler_test.cc. |
2396 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 2399 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
| 2400 __ EnterDartFrame(0, PP, kNoRegister); |
2397 __ pushq(CTX); | 2401 __ pushq(CTX); |
2398 __ movq(CTX, RDI); | 2402 __ movq(CTX, RDI); |
2399 __ StoreIntoObject(RDX, | 2403 __ StoreIntoObject(RDX, |
2400 FieldAddress(RDX, GrowableObjectArray::data_offset()), | 2404 FieldAddress(RDX, GrowableObjectArray::data_offset()), |
2401 RSI); | 2405 RSI); |
2402 __ popq(CTX); | 2406 __ popq(CTX); |
| 2407 __ LeaveFrameWithPP(); |
2403 __ ret(); | 2408 __ ret(); |
2404 } | 2409 } |
2405 | 2410 |
2406 | 2411 |
2407 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { | 2412 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { |
2408 int64_t l = bit_cast<int64_t, double>(1024.67); | 2413 int64_t l = bit_cast<int64_t, double>(1024.67); |
2409 __ movq(RAX, Immediate(l)); | 2414 __ movq(RAX, Immediate(l)); |
2410 __ pushq(RAX); | 2415 __ pushq(RAX); |
2411 __ fldl(Address(RSP, 0)); | 2416 __ fldl(Address(RSP, 0)); |
2412 __ movq(Address(RSP, 0), Immediate(0)); | 2417 __ movq(Address(RSP, 0), Immediate(0)); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 EXPECT_EQ(1, res); // Greater equal. | 2615 EXPECT_EQ(1, res); // Greater equal. |
2611 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); | 2616 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); |
2612 EXPECT_EQ(1, res); // Greater equal. | 2617 EXPECT_EQ(1, res); // Greater equal. |
2613 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); | 2618 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); |
2614 EXPECT_EQ(-1, res); // Less. | 2619 EXPECT_EQ(-1, res); // Less. |
2615 } | 2620 } |
2616 | 2621 |
2617 } // namespace dart | 2622 } // namespace dart |
2618 | 2623 |
2619 #endif // defined TARGET_ARCH_X64 | 2624 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |