Commit 559a0034 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cpu-profiler] Fix stack iterability during deopt (arm port)

We didn't think this affected arm but it turns out it does.

This is a port of
https://chromium-review.googlesource.com/c/v8/v8/+/1688049

Bug: v8:9057
Change-Id: I671737107e589673fc32c5fa1760d887d1bcc240
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1826665Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64024}
parent fcff2437
......@@ -123,6 +123,17 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
__ vstr(d0, r1, dst_offset);
}
// Mark the stack as not iterable for the CPU profiler which won't be able to
// walk the stack without the return address.
{
UseScratchRegisterScope temps(masm);
Register is_iterable = temps.Acquire();
Register zero = r4;
__ Move(is_iterable, ExternalReference::stack_is_iterable_address(isolate));
__ mov(zero, Operand(0));
__ strb(zero, MemOperand(is_iterable));
}
// Remove the saved registers from the stack.
__ add(sp, sp, Operand(kSavedRegistersAreaSize));
......@@ -209,6 +220,15 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
// Restore the registers from the stack.
__ ldm(ia_w, sp, restored_regs); // all but pc registers.
{
UseScratchRegisterScope temps(masm);
Register is_iterable = temps.Acquire();
Register one = r4;
__ Move(is_iterable, ExternalReference::stack_is_iterable_address(isolate));
__ mov(one, Operand(1));
__ strb(one, MemOperand(is_iterable));
}
// Remove sp, lr and pc.
__ Drop(3);
{
......@@ -218,6 +238,7 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
__ pop(lr);
__ Jump(scratch);
}
__ stop();
}
......
......@@ -189,6 +189,15 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
CopyRegListToFrame(masm, x1, FrameDescription::double_registers_offset(),
saved_double_registers, x2, x3, kDoubleRegistersOffset);
// Mark the stack as not iterable for the CPU profiler which won't be able to
// walk the stack without the return address.
{
UseScratchRegisterScope temps(masm);
Register is_iterable = temps.AcquireX();
__ Mov(is_iterable, ExternalReference::stack_is_iterable_address(isolate));
__ strb(xzr, MemOperand(is_iterable));
}
// Remove the saved registers from the stack.
DCHECK_EQ(kSavedRegistersAreaSize % kXRegSize, 0);
__ Drop(kSavedRegistersAreaSize / kXRegSize);
......@@ -251,6 +260,15 @@ void Deoptimizer::GenerateDeoptimizationEntries(MacroAssembler* masm,
RestoreRegList(masm, saved_double_registers, x1,
FrameDescription::double_registers_offset());
{
UseScratchRegisterScope temps(masm);
Register is_iterable = temps.AcquireX();
Register one = x4;
__ Mov(is_iterable, ExternalReference::stack_is_iterable_address(isolate));
__ Mov(one, Operand(1));
__ strb(one, MemOperand(is_iterable));
}
// TODO(all): ARM copies a lot (if not all) of the last output frame onto the
// stack, then pops it all into registers. Here, we try to load it directly
// into the relevant registers. Is this correct? If so, we should improve the
......
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