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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 __ movq(RAX, Address(R12, RAX, TIMES_2, 256 * kWordSize)); | 193 __ movq(RAX, Address(R12, RAX, TIMES_2, 256 * kWordSize)); |
194 __ movq(RAX, Address(R12, R10, TIMES_2, 256 * kWordSize)); | 194 __ movq(RAX, Address(R12, R10, TIMES_2, 256 * kWordSize)); |
195 __ movq(RAX, Address(R12, R12, TIMES_2, 256 * kWordSize)); | 195 __ movq(RAX, Address(R12, R12, TIMES_2, 256 * kWordSize)); |
196 __ movq(RAX, Address(R12, R13, TIMES_2, 256 * kWordSize)); | 196 __ movq(RAX, Address(R12, R13, TIMES_2, 256 * kWordSize)); |
197 | 197 |
198 __ movq(RAX, Address(R13, RBP, TIMES_2, 256 * kWordSize)); | 198 __ movq(RAX, Address(R13, RBP, TIMES_2, 256 * kWordSize)); |
199 __ movq(RAX, Address(R13, RAX, TIMES_2, 256 * kWordSize)); | 199 __ movq(RAX, Address(R13, RAX, TIMES_2, 256 * kWordSize)); |
200 __ movq(RAX, Address(R13, R10, TIMES_2, 256 * kWordSize)); | 200 __ movq(RAX, Address(R13, R10, TIMES_2, 256 * kWordSize)); |
201 __ movq(RAX, Address(R13, R12, TIMES_2, 256 * kWordSize)); | 201 __ movq(RAX, Address(R13, R12, TIMES_2, 256 * kWordSize)); |
202 __ movq(RAX, Address(R13, R13, TIMES_2, 256 * kWordSize)); | 202 __ movq(RAX, Address(R13, R13, TIMES_2, 256 * kWordSize)); |
| 203 |
| 204 __ movq(RAX, Address::AddressBaseImm32(RSP, 0)); |
| 205 __ movq(RAX, Address::AddressBaseImm32(RBP, 0)); |
| 206 __ movq(RAX, Address::AddressBaseImm32(RAX, 0)); |
| 207 __ movq(RAX, Address::AddressBaseImm32(R10, 0)); |
| 208 __ movq(RAX, Address::AddressBaseImm32(R12, 0)); |
| 209 __ movq(RAX, Address::AddressBaseImm32(R13, 0)); |
| 210 __ movq(R10, Address::AddressBaseImm32(RAX, 0)); |
| 211 |
| 212 __ movq(RAX, Address::AddressBaseImm32(RSP, kWordSize)); |
| 213 __ movq(RAX, Address::AddressBaseImm32(RBP, kWordSize)); |
| 214 __ movq(RAX, Address::AddressBaseImm32(RAX, kWordSize)); |
| 215 __ movq(RAX, Address::AddressBaseImm32(R10, kWordSize)); |
| 216 __ movq(RAX, Address::AddressBaseImm32(R12, kWordSize)); |
| 217 __ movq(RAX, Address::AddressBaseImm32(R13, kWordSize)); |
| 218 |
| 219 __ movq(RAX, Address::AddressBaseImm32(RSP, -kWordSize)); |
| 220 __ movq(RAX, Address::AddressBaseImm32(RBP, -kWordSize)); |
| 221 __ movq(RAX, Address::AddressBaseImm32(RAX, -kWordSize)); |
| 222 __ movq(RAX, Address::AddressBaseImm32(R10, -kWordSize)); |
| 223 __ movq(RAX, Address::AddressBaseImm32(R12, -kWordSize)); |
| 224 __ movq(RAX, Address::AddressBaseImm32(R13, -kWordSize)); |
203 } | 225 } |
204 | 226 |
205 | 227 |
206 ASSEMBLER_TEST_RUN(AddressingModes, test) { | 228 ASSEMBLER_TEST_RUN(AddressingModes, test) { |
207 // Avoid running the code since it is constructed to lead to crashes. | 229 // Avoid running the code since it is constructed to lead to crashes. |
208 } | 230 } |
209 | 231 |
210 | 232 |
211 ASSEMBLER_TEST_GENERATE(JumpAroundCrash, assembler) { | 233 ASSEMBLER_TEST_GENERATE(JumpAroundCrash, assembler) { |
212 Label done; | 234 Label done; |
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 typedef int64_t (*DoubleToInt64ConversionCode)(); | 2174 typedef int64_t (*DoubleToInt64ConversionCode)(); |
2153 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); | 2175 int64_t res = reinterpret_cast<DoubleToInt64ConversionCode>(test->entry())(); |
2154 EXPECT_EQ(0, res); | 2176 EXPECT_EQ(0, res); |
2155 } | 2177 } |
2156 | 2178 |
2157 | 2179 |
2158 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { | 2180 ASSEMBLER_TEST_GENERATE(TestObjectCompare, assembler) { |
2159 ObjectStore* object_store = Isolate::Current()->object_store(); | 2181 ObjectStore* object_store = Isolate::Current()->object_store(); |
2160 const Object& obj = Object::ZoneHandle(object_store->smi_class()); | 2182 const Object& obj = Object::ZoneHandle(object_store->smi_class()); |
2161 Label fail; | 2183 Label fail; |
2162 __ LoadObject(RAX, obj); | 2184 __ EnterDartFrame(0); |
| 2185 __ LoadObject(RAX, obj, PP); |
2163 __ CompareObject(RAX, obj); | 2186 __ CompareObject(RAX, obj); |
2164 __ j(NOT_EQUAL, &fail); | 2187 __ j(NOT_EQUAL, &fail); |
2165 __ LoadObject(RCX, obj); | 2188 __ LoadObject(RCX, obj, PP); |
2166 __ CompareObject(RCX, obj); | 2189 __ CompareObject(RCX, obj); |
2167 __ j(NOT_EQUAL, &fail); | 2190 __ j(NOT_EQUAL, &fail); |
2168 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); | 2191 const Smi& smi = Smi::ZoneHandle(Smi::New(15)); |
2169 __ LoadObject(RCX, smi); | 2192 __ LoadObject(RCX, smi, PP); |
2170 __ CompareObject(RCX, smi); | 2193 __ CompareObject(RCX, smi); |
2171 __ j(NOT_EQUAL, &fail); | 2194 __ j(NOT_EQUAL, &fail); |
2172 __ pushq(RAX); | 2195 __ pushq(RAX); |
2173 __ StoreObject(Address(RSP, 0), obj); | 2196 __ StoreObject(Address(RSP, 0), obj); |
2174 __ popq(RCX); | 2197 __ popq(RCX); |
2175 __ CompareObject(RCX, obj); | 2198 __ CompareObject(RCX, obj); |
2176 __ j(NOT_EQUAL, &fail); | 2199 __ j(NOT_EQUAL, &fail); |
2177 __ pushq(RAX); | 2200 __ pushq(RAX); |
2178 __ StoreObject(Address(RSP, 0), smi); | 2201 __ StoreObject(Address(RSP, 0), smi); |
2179 __ popq(RCX); | 2202 __ popq(RCX); |
2180 __ CompareObject(RCX, smi); | 2203 __ CompareObject(RCX, smi); |
2181 __ j(NOT_EQUAL, &fail); | 2204 __ j(NOT_EQUAL, &fail); |
2182 __ movl(RAX, Immediate(1)); // OK | 2205 __ movl(RAX, Immediate(1)); // OK |
| 2206 __ LeaveFrameWithPP(); |
2183 __ ret(); | 2207 __ ret(); |
2184 __ Bind(&fail); | 2208 __ Bind(&fail); |
2185 __ movl(RAX, Immediate(0)); // Fail. | 2209 __ movl(RAX, Immediate(0)); // Fail. |
| 2210 __ LeaveFrameWithPP(); |
2186 __ ret(); | 2211 __ ret(); |
2187 } | 2212 } |
2188 | 2213 |
2189 | 2214 |
2190 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { | 2215 ASSEMBLER_TEST_RUN(TestObjectCompare, test) { |
2191 typedef bool (*TestObjectCompare)(); | 2216 typedef bool (*TestObjectCompare)(); |
2192 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); | 2217 bool res = reinterpret_cast<TestObjectCompare>(test->entry())(); |
2193 EXPECT_EQ(true, res); | 2218 EXPECT_EQ(true, res); |
2194 } | 2219 } |
2195 | 2220 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 typedef double (*SquareRootDoubleCode)(double d); | 2411 typedef double (*SquareRootDoubleCode)(double d); |
2387 const double kDoubleConst = .7; | 2412 const double kDoubleConst = .7; |
2388 double res = | 2413 double res = |
2389 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); | 2414 reinterpret_cast<SquareRootDoubleCode>(test->entry())(kDoubleConst); |
2390 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); | 2415 EXPECT_FLOAT_EQ(sqrt(kDoubleConst), res, 0.0001); |
2391 } | 2416 } |
2392 | 2417 |
2393 | 2418 |
2394 // Called from assembler_test.cc. | 2419 // Called from assembler_test.cc. |
2395 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { | 2420 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
| 2421 __ EnterDartFrame(0); |
2396 __ pushq(CTX); | 2422 __ pushq(CTX); |
2397 __ movq(CTX, RDI); | 2423 __ movq(CTX, RDI); |
2398 __ StoreIntoObject(RDX, | 2424 __ StoreIntoObject(RDX, |
2399 FieldAddress(RDX, GrowableObjectArray::data_offset()), | 2425 FieldAddress(RDX, GrowableObjectArray::data_offset()), |
2400 RSI); | 2426 RSI); |
2401 __ popq(CTX); | 2427 __ popq(CTX); |
| 2428 __ LeaveFrameWithPP(); |
2402 __ ret(); | 2429 __ ret(); |
2403 } | 2430 } |
2404 | 2431 |
2405 | 2432 |
2406 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { | 2433 ASSEMBLER_TEST_GENERATE(DoubleFPUStackMoves, assembler) { |
2407 int64_t l = bit_cast<int64_t, double>(1024.67); | 2434 int64_t l = bit_cast<int64_t, double>(1024.67); |
2408 __ movq(RAX, Immediate(l)); | 2435 __ movq(RAX, Immediate(l)); |
2409 __ pushq(RAX); | 2436 __ pushq(RAX); |
2410 __ fldl(Address(RSP, 0)); | 2437 __ fldl(Address(RSP, 0)); |
2411 __ movq(Address(RSP, 0), Immediate(0)); | 2438 __ movq(Address(RSP, 0), Immediate(0)); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 EXPECT_EQ(1, res); // Greater equal. | 2636 EXPECT_EQ(1, res); // Greater equal. |
2610 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); | 2637 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(5, 5); |
2611 EXPECT_EQ(1, res); // Greater equal. | 2638 EXPECT_EQ(1, res); // Greater equal. |
2612 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); | 2639 res = reinterpret_cast<ConditionalMovesCompareCode>(test->entry())(2, 5); |
2613 EXPECT_EQ(-1, res); // Less. | 2640 EXPECT_EQ(-1, res); // Less. |
2614 } | 2641 } |
2615 | 2642 |
2616 } // namespace dart | 2643 } // namespace dart |
2617 | 2644 |
2618 #endif // defined TARGET_ARCH_X64 | 2645 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |