| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 "src/profiler/sampler.h" | 5 #include "src/profiler/sampler.h" |
| 6 | 6 |
| 7 #if V8_OS_POSIX && !V8_OS_CYGWIN | 7 #if V8_OS_POSIX && !V8_OS_CYGWIN |
| 8 | 8 |
| 9 #define USE_SIGNALS | 9 #define USE_SIGNALS |
| 10 | 10 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 state->fp = reinterpret_cast<Address>(simulator_->get_register( | 329 state->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 330 Simulator::fp)); | 330 Simulator::fp)); |
| 331 #elif V8_TARGET_ARCH_PPC | 331 #elif V8_TARGET_ARCH_PPC |
| 332 if (!simulator_->has_bad_pc()) { | 332 if (!simulator_->has_bad_pc()) { |
| 333 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 333 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 334 } | 334 } |
| 335 state->sp = | 335 state->sp = |
| 336 reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); | 336 reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); |
| 337 state->fp = | 337 state->fp = |
| 338 reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); | 338 reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); |
| 339 #elif V8_TARGET_ARCH_S390 |
| 340 if (!simulator_->has_bad_pc()) { |
| 341 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 342 } |
| 343 state->sp = |
| 344 reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); |
| 345 state->fp = |
| 346 reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); |
| 339 #endif | 347 #endif |
| 340 } | 348 } |
| 341 | 349 |
| 342 private: | 350 private: |
| 343 Simulator* simulator_; | 351 Simulator* simulator_; |
| 344 }; | 352 }; |
| 345 #endif // USE_SIMULATOR | 353 #endif // USE_SIMULATOR |
| 346 | 354 |
| 347 | 355 |
| 348 #if defined(USE_SIGNALS) | 356 #if defined(USE_SIGNALS) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!helper.Init(isolate)) return; | 442 if (!helper.Init(isolate)) return; |
| 435 helper.FillRegisters(&state); | 443 helper.FillRegisters(&state); |
| 436 // It possible that the simulator is interrupted while it is updating | 444 // It possible that the simulator is interrupted while it is updating |
| 437 // the sp or fp register. ARM64 simulator does this in two steps: | 445 // the sp or fp register. ARM64 simulator does this in two steps: |
| 438 // first setting it to zero and then setting it to the new value. | 446 // first setting it to zero and then setting it to the new value. |
| 439 // Bailout if sp/fp doesn't contain the new value. | 447 // Bailout if sp/fp doesn't contain the new value. |
| 440 if (state.sp == 0 || state.fp == 0) return; | 448 if (state.sp == 0 || state.fp == 0) return; |
| 441 #else | 449 #else |
| 442 // Extracting the sample from the context is extremely machine dependent. | 450 // Extracting the sample from the context is extremely machine dependent. |
| 443 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 451 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 444 #if !(V8_OS_OPENBSD || (V8_OS_LINUX && V8_HOST_ARCH_PPC)) | 452 #if !(V8_OS_OPENBSD || (V8_OS_LINUX && (V8_HOST_ARCH_PPC || V8_HOST_ARCH_S390))) |
| 445 mcontext_t& mcontext = ucontext->uc_mcontext; | 453 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 446 #endif | 454 #endif |
| 447 #if V8_OS_LINUX | 455 #if V8_OS_LINUX |
| 448 #if V8_HOST_ARCH_IA32 | 456 #if V8_HOST_ARCH_IA32 |
| 449 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 457 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
| 450 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 458 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
| 451 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 459 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
| 452 #elif V8_HOST_ARCH_X64 | 460 #elif V8_HOST_ARCH_X64 |
| 453 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 461 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
| 454 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); | 462 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 475 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 483 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 476 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 484 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 477 #elif V8_HOST_ARCH_MIPS64 | 485 #elif V8_HOST_ARCH_MIPS64 |
| 478 state.pc = reinterpret_cast<Address>(mcontext.pc); | 486 state.pc = reinterpret_cast<Address>(mcontext.pc); |
| 479 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 487 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 480 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 488 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 481 #elif V8_HOST_ARCH_PPC | 489 #elif V8_HOST_ARCH_PPC |
| 482 state.pc = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->nip); | 490 state.pc = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->nip); |
| 483 state.sp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R1]); | 491 state.sp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R1]); |
| 484 state.fp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R31]); | 492 state.fp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R31]); |
| 493 #elif V8_HOST_ARCH_S390 |
| 494 #if V8_TARGET_ARCH_32_BIT |
| 495 // 31-bit target will have bit 0 (MSB) of the PSW set to denote addressing |
| 496 // mode. This bit needs to be masked out to resolve actual address. |
| 497 state.pc = |
| 498 reinterpret_cast<Address>(ucontext->uc_mcontext.psw.addr & 0x7FFFFFFF); |
| 499 #else |
| 500 state.pc = reinterpret_cast<Address>(ucontext->uc_mcontext.psw.addr); |
| 501 #endif // V8_TARGET_ARCH_32_BIT |
| 502 state.sp = reinterpret_cast<Address>(ucontext->uc_mcontext.gregs[15]); |
| 503 state.fp = reinterpret_cast<Address>(ucontext->uc_mcontext.gregs[11]); |
| 485 #endif // V8_HOST_ARCH_* | 504 #endif // V8_HOST_ARCH_* |
| 486 #elif V8_OS_MACOSX | 505 #elif V8_OS_MACOSX |
| 487 #if V8_HOST_ARCH_X64 | 506 #if V8_HOST_ARCH_X64 |
| 488 #if __DARWIN_UNIX03 | 507 #if __DARWIN_UNIX03 |
| 489 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); | 508 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); |
| 490 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); | 509 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); |
| 491 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); | 510 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); |
| 492 #else // !__DARWIN_UNIX03 | 511 #else // !__DARWIN_UNIX03 |
| 493 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); | 512 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); |
| 494 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); | 513 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 SampleStack(state); | 889 SampleStack(state); |
| 871 } | 890 } |
| 872 ResumeThread(profiled_thread); | 891 ResumeThread(profiled_thread); |
| 873 } | 892 } |
| 874 | 893 |
| 875 #endif // USE_SIGNALS | 894 #endif // USE_SIGNALS |
| 876 | 895 |
| 877 | 896 |
| 878 } // namespace internal | 897 } // namespace internal |
| 879 } // namespace v8 | 898 } // namespace v8 |
| OLD | NEW |