| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 CPURegList register_list = kCallerSaved; | 297 CPURegList register_list = kCallerSaved; |
| 298 CPURegList fpregister_list = kCallerSavedFP; | 298 CPURegList fpregister_list = kCallerSavedFP; |
| 299 | 299 |
| 300 CorruptRegisters(®ister_list, kCallerSavedRegisterCorruptionValue); | 300 CorruptRegisters(®ister_list, kCallerSavedRegisterCorruptionValue); |
| 301 CorruptRegisters(&fpregister_list, kCallerSavedFPRegisterCorruptionValue); | 301 CorruptRegisters(&fpregister_list, kCallerSavedFPRegisterCorruptionValue); |
| 302 } | 302 } |
| 303 #endif | 303 #endif |
| 304 | 304 |
| 305 | 305 |
| 306 // Extending the stack by 2 * 64 bits is required for stack alignment purposes. | 306 // Extending the stack by 2 * 64 bits is required for stack alignment purposes. |
| 307 // TODO(all): Insert a marker in the extra space allocated on the stack. | |
| 308 uintptr_t Simulator::PushAddress(uintptr_t address) { | 307 uintptr_t Simulator::PushAddress(uintptr_t address) { |
| 309 ASSERT(sizeof(uintptr_t) < 2 * kXRegSize); | 308 ASSERT(sizeof(uintptr_t) < 2 * kXRegSize); |
| 310 intptr_t new_sp = sp() - 2 * kXRegSize; | 309 intptr_t new_sp = sp() - 2 * kXRegSize; |
| 310 uintptr_t* alignment_slot = |
| 311 reinterpret_cast<uintptr_t*>(new_sp + kXRegSize); |
| 312 memcpy(alignment_slot, &kSlotsZapValue, kPointerSize); |
| 311 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp); | 313 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(new_sp); |
| 312 *stack_slot = address; | 314 memcpy(stack_slot, &address, kPointerSize); |
| 313 set_sp(new_sp); | 315 set_sp(new_sp); |
| 314 return new_sp; | 316 return new_sp; |
| 315 } | 317 } |
| 316 | 318 |
| 317 | 319 |
| 318 uintptr_t Simulator::PopAddress() { | 320 uintptr_t Simulator::PopAddress() { |
| 319 intptr_t current_sp = sp(); | 321 intptr_t current_sp = sp(); |
| 320 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 322 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
| 321 uintptr_t address = *stack_slot; | 323 uintptr_t address = *stack_slot; |
| 322 ASSERT(sizeof(uintptr_t) < 2 * kXRegSize); | 324 ASSERT(sizeof(uintptr_t) < 2 * kXRegSize); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 437 } |
| 436 } | 438 } |
| 437 | 439 |
| 438 | 440 |
| 439 void Simulator::RunFrom(Instruction* start) { | 441 void Simulator::RunFrom(Instruction* start) { |
| 440 set_pc(start); | 442 set_pc(start); |
| 441 Run(); | 443 Run(); |
| 442 } | 444 } |
| 443 | 445 |
| 444 | 446 |
| 445 void Simulator::CheckStackAlignment() { | |
| 446 // TODO(aleram): The sp alignment check to perform depends on the processor | |
| 447 // state. Check the specifications for more details. | |
| 448 } | |
| 449 | |
| 450 | |
| 451 // When the generated code calls an external reference we need to catch that in | 447 // When the generated code calls an external reference we need to catch that in |
| 452 // the simulator. The external reference will be a function compiled for the | 448 // the simulator. The external reference will be a function compiled for the |
| 453 // host architecture. We need to call that function instead of trying to | 449 // host architecture. We need to call that function instead of trying to |
| 454 // execute it with the simulator. We do that by redirecting the external | 450 // execute it with the simulator. We do that by redirecting the external |
| 455 // reference to a svc (Supervisor Call) instruction that is handled by | 451 // reference to a svc (Supervisor Call) instruction that is handled by |
| 456 // the simulator. We write the original destination of the jump just at a known | 452 // the simulator. We write the original destination of the jump just at a known |
| 457 // offset from the svc instruction so the simulator knows what to call. | 453 // offset from the svc instruction so the simulator knows what to call. |
| 458 class Redirection { | 454 class Redirection { |
| 459 public: | 455 public: |
| 460 Redirection(void* external_function, ExternalReference::Type type) | 456 Redirection(void* external_function, ExternalReference::Type type) |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 uint64_t result = 0; | 1700 uint64_t result = 0; |
| 1705 for (int i = 0; i < 8; i++) { | 1701 for (int i = 0; i < 8; i++) { |
| 1706 result <<= 8; | 1702 result <<= 8; |
| 1707 result |= bytes[permute_table[mode][i]]; | 1703 result |= bytes[permute_table[mode][i]]; |
| 1708 } | 1704 } |
| 1709 return result; | 1705 return result; |
| 1710 } | 1706 } |
| 1711 | 1707 |
| 1712 | 1708 |
| 1713 void Simulator::VisitDataProcessing2Source(Instruction* instr) { | 1709 void Simulator::VisitDataProcessing2Source(Instruction* instr) { |
| 1714 // TODO(mcapewel) move these to a higher level file, as they are global | |
| 1715 // assumptions. | |
| 1716 ASSERT((static_cast<int32_t>(-1) >> 1) == -1); | |
| 1717 ASSERT((static_cast<uint32_t>(-1) >> 1) == 0x7FFFFFFF); | |
| 1718 | |
| 1719 Shift shift_op = NO_SHIFT; | 1710 Shift shift_op = NO_SHIFT; |
| 1720 int64_t result = 0; | 1711 int64_t result = 0; |
| 1721 switch (instr->Mask(DataProcessing2SourceMask)) { | 1712 switch (instr->Mask(DataProcessing2SourceMask)) { |
| 1722 case SDIV_w: { | 1713 case SDIV_w: { |
| 1723 int32_t rn = wreg(instr->Rn()); | 1714 int32_t rn = wreg(instr->Rn()); |
| 1724 int32_t rm = wreg(instr->Rm()); | 1715 int32_t rm = wreg(instr->Rm()); |
| 1725 if ((rn == kWMinInt) && (rm == -1)) { | 1716 if ((rn == kWMinInt) && (rm == -1)) { |
| 1726 result = kWMinInt; | 1717 result = kWMinInt; |
| 1727 } else if (rm == 0) { | 1718 } else if (rm == 0) { |
| 1728 // Division by zero can be trapped, but not on A-class processors. | 1719 // Division by zero can be trapped, but not on A-class processors. |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2910 | 2901 |
| 2911 // Disassemble. | 2902 // Disassemble. |
| 2912 PrintInstructionsAt(reinterpret_cast<Instruction*>(address), | 2903 PrintInstructionsAt(reinterpret_cast<Instruction*>(address), |
| 2913 n_of_instrs_to_disasm); | 2904 n_of_instrs_to_disasm); |
| 2914 PrintF("\n"); | 2905 PrintF("\n"); |
| 2915 | 2906 |
| 2916 // print / p ------------------------------------------------------------- | 2907 // print / p ------------------------------------------------------------- |
| 2917 } else if ((strcmp(cmd, "print") == 0) || (strcmp(cmd, "p") == 0)) { | 2908 } else if ((strcmp(cmd, "print") == 0) || (strcmp(cmd, "p") == 0)) { |
| 2918 if (argc == 2) { | 2909 if (argc == 2) { |
| 2919 if (strcmp(arg1, "all") == 0) { | 2910 if (strcmp(arg1, "all") == 0) { |
| 2920 // TODO(all): better support for printing in the debugger. | |
| 2921 PrintRegisters(true); | 2911 PrintRegisters(true); |
| 2922 PrintFPRegisters(true); | 2912 PrintFPRegisters(true); |
| 2923 } else { | 2913 } else { |
| 2924 if (!PrintValue(arg1)) { | 2914 if (!PrintValue(arg1)) { |
| 2925 PrintF("%s unrecognized\n", arg1); | 2915 PrintF("%s unrecognized\n", arg1); |
| 2926 } | 2916 } |
| 2927 } | 2917 } |
| 2928 } else { | 2918 } else { |
| 2929 PrintF( | 2919 PrintF( |
| 2930 "print <register>\n" | 2920 "print <register>\n" |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3450 default: | 3440 default: |
| 3451 UNIMPLEMENTED(); | 3441 UNIMPLEMENTED(); |
| 3452 } | 3442 } |
| 3453 } | 3443 } |
| 3454 | 3444 |
| 3455 #endif // USE_SIMULATOR | 3445 #endif // USE_SIMULATOR |
| 3456 | 3446 |
| 3457 } } // namespace v8::internal | 3447 } } // namespace v8::internal |
| 3458 | 3448 |
| 3459 #endif // V8_TARGET_ARCH_A64 | 3449 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |