| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_ARM64) | 10 #if defined(TARGET_ARCH_ARM64) |
| (...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 } else if (imm == kImmExceptionIsRedirectedCall) { | 1305 } else if (imm == kImmExceptionIsRedirectedCall) { |
| 1306 DoRedirectedCall(instr); | 1306 DoRedirectedCall(instr); |
| 1307 } else { | 1307 } else { |
| 1308 UnimplementedInstruction(instr); | 1308 UnimplementedInstruction(instr); |
| 1309 } | 1309 } |
| 1310 } | 1310 } |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 | 1313 |
| 1314 void Simulator::DecodeSystem(Instr* instr) { | 1314 void Simulator::DecodeSystem(Instr* instr) { |
| 1315 if ((instr->Bits(0, 8) == 0x5f) && (instr->Bits(12, 4) == 2) && | 1315 if ((instr->Bits(0, 8) == 0x1f) && (instr->Bits(12, 4) == 2) && |
| 1316 (instr->Bits(16, 3) == 3) && (instr->Bits(19, 2) == 0) && | 1316 (instr->Bits(16, 3) == 3) && (instr->Bits(19, 2) == 0) && |
| 1317 (instr->Bit(21) == 0)) { | 1317 (instr->Bit(21) == 0)) { |
| 1318 if (instr->Bits(8, 4) == 0) { | 1318 if (instr->Bits(8, 4) == 0) { |
| 1319 // Format(instr, "nop"); | 1319 // Format(instr, "nop"); |
| 1320 } else { | 1320 } else { |
| 1321 UnimplementedInstruction(instr); | 1321 UnimplementedInstruction(instr); |
| 1322 } | 1322 } |
| 1323 } else { | 1323 } else { |
| 1324 UnimplementedInstruction(instr); | 1324 UnimplementedInstruction(instr); |
| 1325 } | 1325 } |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 | 2355 |
| 2356 | 2356 |
| 2357 int64_t Simulator::Call(int64_t entry, | 2357 int64_t Simulator::Call(int64_t entry, |
| 2358 int64_t parameter0, | 2358 int64_t parameter0, |
| 2359 int64_t parameter1, | 2359 int64_t parameter1, |
| 2360 int64_t parameter2, | 2360 int64_t parameter2, |
| 2361 int64_t parameter3, | 2361 int64_t parameter3, |
| 2362 bool fp_return, | 2362 bool fp_return, |
| 2363 bool fp_args) { | 2363 bool fp_args) { |
| 2364 // Save the SP register before the call so we can restore it. | 2364 // Save the SP register before the call so we can restore it. |
| 2365 intptr_t sp_before_call = get_register(R31, R31IsSP); | 2365 const intptr_t sp_before_call = get_register(R31, R31IsSP); |
| 2366 | 2366 |
| 2367 // Setup parameters. | 2367 // Setup parameters. |
| 2368 if (fp_args) { | 2368 if (fp_args) { |
| 2369 set_vregisterd(V0, parameter0); | 2369 set_vregisterd(V0, parameter0); |
| 2370 set_vregisterd(V1, parameter1); | 2370 set_vregisterd(V1, parameter1); |
| 2371 set_vregisterd(V2, parameter2); | 2371 set_vregisterd(V2, parameter2); |
| 2372 set_vregisterd(V3, parameter3); | 2372 set_vregisterd(V3, parameter3); |
| 2373 } else { | 2373 } else { |
| 2374 set_register(R0, parameter0); | 2374 set_register(R0, parameter0); |
| 2375 set_register(R1, parameter1); | 2375 set_register(R1, parameter1); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2389 set_pc(entry); | 2389 set_pc(entry); |
| 2390 // Put down marker for end of simulation. The simulator will stop simulation | 2390 // Put down marker for end of simulation. The simulator will stop simulation |
| 2391 // when the PC reaches this value. By saving the "end simulation" value into | 2391 // when the PC reaches this value. By saving the "end simulation" value into |
| 2392 // the LR the simulation stops when returning to this call point. | 2392 // the LR the simulation stops when returning to this call point. |
| 2393 set_register(LR, kEndSimulatingPC); | 2393 set_register(LR, kEndSimulatingPC); |
| 2394 | 2394 |
| 2395 // Remember the values of callee-saved registers, and set them up with a | 2395 // Remember the values of callee-saved registers, and set them up with a |
| 2396 // known value so that we are able to check that they are preserved | 2396 // known value so that we are able to check that they are preserved |
| 2397 // properly across Dart execution. | 2397 // properly across Dart execution. |
| 2398 int64_t preserved_vals[kAbiPreservedCpuRegCount]; | 2398 int64_t preserved_vals[kAbiPreservedCpuRegCount]; |
| 2399 int64_t callee_saved_value = icount_; | 2399 const double dicount = static_cast<double>(icount_); |
| 2400 const int64_t callee_saved_value = bit_cast<int64_t, double>(dicount); |
| 2400 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { | 2401 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { |
| 2401 const Register r = static_cast<Register>(i); | 2402 const Register r = static_cast<Register>(i); |
| 2402 preserved_vals[i - kAbiFirstPreservedCpuReg] = get_register(r); | 2403 preserved_vals[i - kAbiFirstPreservedCpuReg] = get_register(r); |
| 2403 set_register(r, callee_saved_value); | 2404 set_register(r, callee_saved_value); |
| 2404 } | 2405 } |
| 2405 | 2406 |
| 2406 // Only the bottom half of the V registers must be preserved. | 2407 // Only the bottom half of the V registers must be preserved. |
| 2407 int64_t preserved_dvals[kAbiPreservedFpuRegCount]; | 2408 int64_t preserved_dvals[kAbiPreservedFpuRegCount]; |
| 2408 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { | 2409 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { |
| 2409 const VRegister r = static_cast<VRegister>(i); | 2410 const VRegister r = static_cast<VRegister>(i); |
| 2410 preserved_dvals[i - kAbiFirstPreservedFpuReg] = get_vregisterd(r); | 2411 preserved_dvals[i - kAbiFirstPreservedFpuReg] = get_vregisterd(r); |
| 2411 set_vregisterd(r, callee_saved_value); | 2412 set_vregisterd(r, callee_saved_value); |
| 2412 } | 2413 } |
| 2413 | 2414 |
| 2414 // Start the simulation | 2415 // Start the simulation. |
| 2415 Execute(); | 2416 Execute(); |
| 2416 | 2417 |
| 2417 // Check that the callee-saved registers have been preserved, | 2418 // Check that the callee-saved registers have been preserved, |
| 2418 // and restore them with the original value | 2419 // and restore them with the original value. |
| 2419 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { | 2420 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { |
| 2420 const Register r = static_cast<Register>(i); | 2421 const Register r = static_cast<Register>(i); |
| 2421 ASSERT(callee_saved_value == get_register(r)); | 2422 ASSERT(callee_saved_value == get_register(r)); |
| 2422 set_register(r, preserved_vals[i - kAbiFirstPreservedCpuReg]); | 2423 set_register(r, preserved_vals[i - kAbiFirstPreservedCpuReg]); |
| 2423 } | 2424 } |
| 2424 | 2425 |
| 2425 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { | 2426 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { |
| 2426 const VRegister r = static_cast<VRegister>(i); | 2427 const VRegister r = static_cast<VRegister>(i); |
| 2427 ASSERT(callee_saved_value == get_vregisterd(r)); | 2428 ASSERT(callee_saved_value == get_vregisterd(r)); |
| 2428 set_vregisterd(r, preserved_dvals[i - kAbiFirstPreservedFpuReg]); | 2429 set_vregisterd(r, preserved_dvals[i - kAbiFirstPreservedFpuReg]); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2472 set_register(kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 2473 set_register(kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
| 2473 set_register(kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 2474 set_register(kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
| 2474 buf->Longjmp(); | 2475 buf->Longjmp(); |
| 2475 } | 2476 } |
| 2476 | 2477 |
| 2477 } // namespace dart | 2478 } // namespace dart |
| 2478 | 2479 |
| 2479 #endif // !defined(HOST_ARCH_ARM64) | 2480 #endif // !defined(HOST_ARCH_ARM64) |
| 2480 | 2481 |
| 2481 #endif // defined TARGET_ARCH_ARM64 | 2482 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |