| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_PPC | 9 #if V8_TARGET_ARCH_PPC |
| 10 | 10 |
| 11 #include "src/assembler.h" | 11 #include "src/assembler.h" |
| 12 #include "src/base/bits.h" | 12 #include "src/base/bits.h" |
| 13 #include "src/codegen.h" | 13 #include "src/codegen.h" |
| 14 #include "src/disasm.h" | 14 #include "src/disasm.h" |
| 15 #include "src/ppc/constants-ppc.h" | 15 #include "src/ppc/constants-ppc.h" |
| 16 #include "src/ppc/frames-ppc.h" | 16 #include "src/ppc/frames-ppc.h" |
| 17 #include "src/ppc/simulator-ppc.h" | 17 #include "src/ppc/simulator-ppc.h" |
| 18 #include "src/runtime/runtime-utils.h" | 18 #include "src/runtime/runtime-utils.h" |
| 19 | 19 |
| 20 #if defined(USE_SIMULATOR) | 20 #if defined(USE_SIMULATOR) |
| 21 | 21 |
| 22 // Only build the simulator if not compiling for real PPC hardware. | 22 // Only build the simulator if not compiling for real PPC hardware. |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 const auto GetRegConfig = RegisterConfiguration::Crankshaft; |
| 27 |
| 26 // This macro provides a platform independent use of sscanf. The reason for | 28 // This macro provides a platform independent use of sscanf. The reason for |
| 27 // SScanF not being implemented in a platform independent way through | 29 // SScanF not being implemented in a platform independent way through |
| 28 // ::v8::internal::OS in the same way as SNPrintF is that the | 30 // ::v8::internal::OS in the same way as SNPrintF is that the |
| 29 // Windows C Run-Time Library does not provide vsscanf. | 31 // Windows C Run-Time Library does not provide vsscanf. |
| 30 #define SScanF sscanf // NOLINT | 32 #define SScanF sscanf // NOLINT |
| 31 | 33 |
| 32 // The PPCDebugger class is used by the simulator while debugging simulated | 34 // The PPCDebugger class is used by the simulator while debugging simulated |
| 33 // PowerPC code. | 35 // PowerPC code. |
| 34 class PPCDebugger { | 36 class PPCDebugger { |
| 35 public: | 37 public: |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // Leave the debugger shell. | 310 // Leave the debugger shell. |
| 309 done = true; | 311 done = true; |
| 310 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { | 312 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { |
| 311 if (argc == 2 || (argc == 3 && strcmp(arg2, "fp") == 0)) { | 313 if (argc == 2 || (argc == 3 && strcmp(arg2, "fp") == 0)) { |
| 312 intptr_t value; | 314 intptr_t value; |
| 313 double dvalue; | 315 double dvalue; |
| 314 if (strcmp(arg1, "all") == 0) { | 316 if (strcmp(arg1, "all") == 0) { |
| 315 for (int i = 0; i < kNumRegisters; i++) { | 317 for (int i = 0; i < kNumRegisters; i++) { |
| 316 value = GetRegisterValue(i); | 318 value = GetRegisterValue(i); |
| 317 PrintF(" %3s: %08" V8PRIxPTR, | 319 PrintF(" %3s: %08" V8PRIxPTR, |
| 318 Register::from_code(i).ToString(), value); | 320 GetRegConfig()->GetGeneralRegisterName(i), value); |
| 319 if ((argc == 3 && strcmp(arg2, "fp") == 0) && i < 8 && | 321 if ((argc == 3 && strcmp(arg2, "fp") == 0) && i < 8 && |
| 320 (i % 2) == 0) { | 322 (i % 2) == 0) { |
| 321 dvalue = GetRegisterPairDoubleValue(i); | 323 dvalue = GetRegisterPairDoubleValue(i); |
| 322 PrintF(" (%f)\n", dvalue); | 324 PrintF(" (%f)\n", dvalue); |
| 323 } else if (i != 0 && !((i + 1) & 3)) { | 325 } else if (i != 0 && !((i + 1) & 3)) { |
| 324 PrintF("\n"); | 326 PrintF("\n"); |
| 325 } | 327 } |
| 326 } | 328 } |
| 327 PrintF(" pc: %08" V8PRIxPTR " lr: %08" V8PRIxPTR | 329 PrintF(" pc: %08" V8PRIxPTR " lr: %08" V8PRIxPTR |
| 328 " " | 330 " " |
| 329 "ctr: %08" V8PRIxPTR " xer: %08x cr: %08x\n", | 331 "ctr: %08" V8PRIxPTR " xer: %08x cr: %08x\n", |
| 330 sim_->special_reg_pc_, sim_->special_reg_lr_, | 332 sim_->special_reg_pc_, sim_->special_reg_lr_, |
| 331 sim_->special_reg_ctr_, sim_->special_reg_xer_, | 333 sim_->special_reg_ctr_, sim_->special_reg_xer_, |
| 332 sim_->condition_reg_); | 334 sim_->condition_reg_); |
| 333 } else if (strcmp(arg1, "alld") == 0) { | 335 } else if (strcmp(arg1, "alld") == 0) { |
| 334 for (int i = 0; i < kNumRegisters; i++) { | 336 for (int i = 0; i < kNumRegisters; i++) { |
| 335 value = GetRegisterValue(i); | 337 value = GetRegisterValue(i); |
| 336 PrintF(" %3s: %08" V8PRIxPTR " %11" V8PRIdPTR, | 338 PrintF(" %3s: %08" V8PRIxPTR " %11" V8PRIdPTR, |
| 337 Register::from_code(i).ToString(), value, value); | 339 GetRegConfig()->GetGeneralRegisterName(i), value, value); |
| 338 if ((argc == 3 && strcmp(arg2, "fp") == 0) && i < 8 && | 340 if ((argc == 3 && strcmp(arg2, "fp") == 0) && i < 8 && |
| 339 (i % 2) == 0) { | 341 (i % 2) == 0) { |
| 340 dvalue = GetRegisterPairDoubleValue(i); | 342 dvalue = GetRegisterPairDoubleValue(i); |
| 341 PrintF(" (%f)\n", dvalue); | 343 PrintF(" (%f)\n", dvalue); |
| 342 } else if (!((i + 1) % 2)) { | 344 } else if (!((i + 1) % 2)) { |
| 343 PrintF("\n"); | 345 PrintF("\n"); |
| 344 } | 346 } |
| 345 } | 347 } |
| 346 PrintF(" pc: %08" V8PRIxPTR " lr: %08" V8PRIxPTR | 348 PrintF(" pc: %08" V8PRIxPTR " lr: %08" V8PRIxPTR |
| 347 " " | 349 " " |
| 348 "ctr: %08" V8PRIxPTR " xer: %08x cr: %08x\n", | 350 "ctr: %08" V8PRIxPTR " xer: %08x cr: %08x\n", |
| 349 sim_->special_reg_pc_, sim_->special_reg_lr_, | 351 sim_->special_reg_pc_, sim_->special_reg_lr_, |
| 350 sim_->special_reg_ctr_, sim_->special_reg_xer_, | 352 sim_->special_reg_ctr_, sim_->special_reg_xer_, |
| 351 sim_->condition_reg_); | 353 sim_->condition_reg_); |
| 352 } else if (strcmp(arg1, "allf") == 0) { | 354 } else if (strcmp(arg1, "allf") == 0) { |
| 353 for (int i = 0; i < DoubleRegister::kNumRegisters; i++) { | 355 for (int i = 0; i < DoubleRegister::kNumRegisters; i++) { |
| 354 dvalue = GetFPDoubleRegisterValue(i); | 356 dvalue = GetFPDoubleRegisterValue(i); |
| 355 uint64_t as_words = bit_cast<uint64_t>(dvalue); | 357 uint64_t as_words = bit_cast<uint64_t>(dvalue); |
| 356 PrintF("%3s: %f 0x%08x %08x\n", | 358 PrintF("%3s: %f 0x%08x %08x\n", |
| 357 DoubleRegister::from_code(i).ToString(), dvalue, | 359 GetRegConfig()->GetDoubleRegisterName(i), dvalue, |
| 358 static_cast<uint32_t>(as_words >> 32), | 360 static_cast<uint32_t>(as_words >> 32), |
| 359 static_cast<uint32_t>(as_words & 0xffffffff)); | 361 static_cast<uint32_t>(as_words & 0xffffffff)); |
| 360 } | 362 } |
| 361 } else if (arg1[0] == 'r' && | 363 } else if (arg1[0] == 'r' && |
| 362 (arg1[1] >= '0' && arg1[1] <= '9' && | 364 (arg1[1] >= '0' && arg1[1] <= '9' && |
| 363 (arg1[2] == '\0' || (arg1[2] >= '0' && arg1[2] <= '9' && | 365 (arg1[2] == '\0' || (arg1[2] >= '0' && arg1[2] <= '9' && |
| 364 arg1[3] == '\0')))) { | 366 arg1[3] == '\0')))) { |
| 365 int regnum = strtoul(&arg1[1], 0, 10); | 367 int regnum = strtoul(&arg1[1], 0, 10); |
| 366 if (regnum != kNoRegister) { | 368 if (regnum != kNoRegister) { |
| 367 value = GetRegisterValue(regnum); | 369 value = GetRegisterValue(regnum); |
| (...skipping 3760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4128 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); | 4130 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); |
| 4129 uintptr_t address = *stack_slot; | 4131 uintptr_t address = *stack_slot; |
| 4130 set_register(sp, current_sp + sizeof(uintptr_t)); | 4132 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 4131 return address; | 4133 return address; |
| 4132 } | 4134 } |
| 4133 } // namespace internal | 4135 } // namespace internal |
| 4134 } // namespace v8 | 4136 } // namespace v8 |
| 4135 | 4137 |
| 4136 #endif // USE_SIMULATOR | 4138 #endif // USE_SIMULATOR |
| 4137 #endif // V8_TARGET_ARCH_PPC | 4139 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |