Commit 8e7945a6 authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

PPC/s390: [Profiler] Ensure ticks in frameless bytecode handlers are interpreted frames.

Port 381a7f9e

Original Commit Message:

    On Arm/64 the last return address is stored in a link register instead of
    being pushed to the top-of-stack like on x64/ia32. Extend the support in the
    tick sampler to check for samples in a frameless bytecode handler with support
    for checking the link register if it exists instead of top-of-stack. In addition,
    make the x64/ia32 check more robust by ensuring we only apply the change if the
    pc is a bytecode handler and the top frame isn't a bytecode handler (stub) frame.

R=rmcilroy@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:9162
LOG=N

Change-Id: I893b45af40a48415fbbc2c9f5e9e5cd72ed8d9e7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1588888Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61173}
parent 18100666
......@@ -420,11 +420,13 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R1]);
state->fp =
reinterpret_cast<void*>(ucontext->uc_mcontext.regs->gpr[PT_R31]);
state->lr = reinterpret_cast<void*>(ucontext->uc_mcontext.regs->link);
#else
// Some C libraries, notably Musl, define the regs member as a void pointer
state->pc = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[32]);
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[1]);
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[31]);
state->lr = reinterpret_cast<void*>(ucontext->uc_mcontext.gp_regs[36]);
#endif
#elif V8_HOST_ARCH_S390
#if V8_TARGET_ARCH_32_BIT
......@@ -437,6 +439,7 @@ void SignalHandler::FillRegisterState(void* context, RegisterState* state) {
#endif // V8_TARGET_ARCH_32_BIT
state->sp = reinterpret_cast<void*>(ucontext->uc_mcontext.gregs[15]);
state->fp = reinterpret_cast<void*>(ucontext->uc_mcontext.gregs[11]);
state->lr = reinterpret_cast<void*>(ucontext->uc_mcontext.gregs[14]);
#endif // V8_HOST_ARCH_*
#elif V8_OS_IOS
......
......@@ -838,6 +838,8 @@ bool Simulator::has_bad_pc() const {
// Raw access to the PC register without the special adjustment when reading.
intptr_t Simulator::get_pc() const { return special_reg_pc_; }
// Accessor to the internal Link Register
intptr_t Simulator::get_lr() const { return special_reg_lr_; }
// Runtime FP routines take:
// - two double arguments
......
......@@ -163,6 +163,9 @@ class Simulator : public SimulatorBase {
Address get_sp() const { return static_cast<Address>(get_register(sp)); }
// Accessor to the internal Link Register
intptr_t get_lr() const;
// Accessor to the internal simulator stack area.
uintptr_t StackLimit(uintptr_t c_limit) const;
......
......@@ -118,12 +118,14 @@ bool SimulatorHelper::FillRegisters(Isolate* isolate,
}
state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp));
state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::fp));
state->lr = reinterpret_cast<void*>(simulator->get_lr());
#elif V8_TARGET_ARCH_S390
if (!simulator->has_bad_pc()) {
state->pc = reinterpret_cast<void*>(simulator->get_pc());
}
state->sp = reinterpret_cast<void*>(simulator->get_register(Simulator::sp));
state->fp = reinterpret_cast<void*>(simulator->get_register(Simulator::fp));
state->lr = reinterpret_cast<void*>(simulator->get_register(Simulator::ra));
#endif
if (state->sp == 0 || state->fp == 0) {
// It possible that the simulator is interrupted while it is updating
......
......@@ -75,12 +75,15 @@ class SimulatorHelper {
simulator_->get_register(v8::internal::Simulator::sp));
state->fp = reinterpret_cast<void*>(
simulator_->get_register(v8::internal::Simulator::fp));
state->lr = reinterpret_cast<void*>(simulator_->get_lr());
#elif V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
state->pc = reinterpret_cast<void*>(simulator_->get_pc());
state->sp = reinterpret_cast<void*>(
simulator_->get_register(v8::internal::Simulator::sp));
state->fp = reinterpret_cast<void*>(
simulator_->get_register(v8::internal::Simulator::fp));
state->lr = reinterpret_cast<void*>(
simulator_->get_register(v8::internal::Simulator::ra));
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment