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/sampler.h" | 5 #include "src/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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 state->sp = reinterpret_cast<Address>(simulator_->get_register( | 255 state->sp = reinterpret_cast<Address>(simulator_->get_register( |
256 Simulator::sp)); | 256 Simulator::sp)); |
257 state->fp = reinterpret_cast<Address>(simulator_->get_register( | 257 state->fp = reinterpret_cast<Address>(simulator_->get_register( |
258 Simulator::fp)); | 258 Simulator::fp)); |
259 #elif V8_TARGET_ARCH_MIPS64 | 259 #elif V8_TARGET_ARCH_MIPS64 |
260 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 260 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
261 state->sp = reinterpret_cast<Address>(simulator_->get_register( | 261 state->sp = reinterpret_cast<Address>(simulator_->get_register( |
262 Simulator::sp)); | 262 Simulator::sp)); |
263 state->fp = reinterpret_cast<Address>(simulator_->get_register( | 263 state->fp = reinterpret_cast<Address>(simulator_->get_register( |
264 Simulator::fp)); | 264 Simulator::fp)); |
| 265 #elif V8_TARGET_ARCH_PPC |
| 266 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 267 state->sp = reinterpret_cast<Address>(simulator_->get_register( |
| 268 Simulator::sp)); |
| 269 state->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 270 Simulator::fp)); |
265 #endif | 271 #endif |
266 } | 272 } |
267 | 273 |
268 private: | 274 private: |
269 Simulator* simulator_; | 275 Simulator* simulator_; |
270 }; | 276 }; |
271 #endif // USE_SIMULATOR | 277 #endif // USE_SIMULATOR |
272 | 278 |
273 | 279 |
274 #if defined(USE_SIGNALS) | 280 #if defined(USE_SIGNALS) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 if (!helper.Init(sampler, isolate)) return; | 363 if (!helper.Init(sampler, isolate)) return; |
358 helper.FillRegisters(&state); | 364 helper.FillRegisters(&state); |
359 // It possible that the simulator is interrupted while it is updating | 365 // It possible that the simulator is interrupted while it is updating |
360 // the sp or fp register. ARM64 simulator does this in two steps: | 366 // the sp or fp register. ARM64 simulator does this in two steps: |
361 // first setting it to zero and then setting it to the new value. | 367 // first setting it to zero and then setting it to the new value. |
362 // Bailout if sp/fp doesn't contain the new value. | 368 // Bailout if sp/fp doesn't contain the new value. |
363 if (state.sp == 0 || state.fp == 0) return; | 369 if (state.sp == 0 || state.fp == 0) return; |
364 #else | 370 #else |
365 // Extracting the sample from the context is extremely machine dependent. | 371 // Extracting the sample from the context is extremely machine dependent. |
366 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 372 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
367 #if !V8_OS_OPENBSD | 373 #if !(V8_OS_OPENBSD || (V8_OS_LINUX && V8_HOST_ARCH_PPC)) |
368 mcontext_t& mcontext = ucontext->uc_mcontext; | 374 mcontext_t& mcontext = ucontext->uc_mcontext; |
369 #endif | 375 #endif |
370 #if V8_OS_LINUX | 376 #if V8_OS_LINUX |
371 #if V8_HOST_ARCH_IA32 | 377 #if V8_HOST_ARCH_IA32 |
372 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 378 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
373 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 379 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
374 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 380 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
375 #elif V8_HOST_ARCH_X64 | 381 #elif V8_HOST_ARCH_X64 |
376 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 382 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
377 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); | 383 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
(...skipping 18 matching lines...) Expand all Loading... |
396 // FP is an alias for x29. | 402 // FP is an alias for x29. |
397 state.fp = reinterpret_cast<Address>(mcontext.regs[29]); | 403 state.fp = reinterpret_cast<Address>(mcontext.regs[29]); |
398 #elif V8_HOST_ARCH_MIPS | 404 #elif V8_HOST_ARCH_MIPS |
399 state.pc = reinterpret_cast<Address>(mcontext.pc); | 405 state.pc = reinterpret_cast<Address>(mcontext.pc); |
400 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 406 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
401 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 407 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
402 #elif V8_HOST_ARCH_MIPS64 | 408 #elif V8_HOST_ARCH_MIPS64 |
403 state.pc = reinterpret_cast<Address>(mcontext.pc); | 409 state.pc = reinterpret_cast<Address>(mcontext.pc); |
404 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 410 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
405 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 411 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 412 #elif V8_HOST_ARCH_PPC |
| 413 state.pc = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->nip); |
| 414 state.sp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R1]); |
| 415 state.fp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R31]); |
406 #endif // V8_HOST_ARCH_* | 416 #endif // V8_HOST_ARCH_* |
407 #elif V8_OS_MACOSX | 417 #elif V8_OS_MACOSX |
408 #if V8_HOST_ARCH_X64 | 418 #if V8_HOST_ARCH_X64 |
409 #if __DARWIN_UNIX03 | 419 #if __DARWIN_UNIX03 |
410 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); | 420 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); |
411 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); | 421 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); |
412 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); | 422 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); |
413 #else // !__DARWIN_UNIX03 | 423 #else // !__DARWIN_UNIX03 |
414 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); | 424 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); |
415 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); | 425 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 #endif // USE_SIMULATOR | 748 #endif // USE_SIMULATOR |
739 SampleStack(state); | 749 SampleStack(state); |
740 } | 750 } |
741 ResumeThread(profiled_thread); | 751 ResumeThread(profiled_thread); |
742 } | 752 } |
743 | 753 |
744 #endif // USE_SIGNALS | 754 #endif // USE_SIGNALS |
745 | 755 |
746 | 756 |
747 } } // namespace v8::internal | 757 } } // namespace v8::internal |
OLD | NEW |