Commit 577b4c80 authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

Update JSEntryStub for arm64 stack alignment.

This includes adding a padding slot to the stack handler, which is done for all
architectures for consistency.

Bug: v8:6644
Change-Id: I8a6379a82e2a9d1819069850b6734489bd6071a6
Reviewed-on: https://chromium-review.googlesource.com/822477Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com>
Cr-Commit-Position: refs/heads/master@{#50070}
parent 6630a1f1
......@@ -1539,15 +1539,15 @@ void MacroAssembler::MaybeDropFrames() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
Push(Smi::kZero); // Padding.
// Link the current handler as the next handler.
mov(r6,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
ldr(r5, MemOperand(r6));
push(r5);
// Set this new handler as the current one.
str(sp, MemOperand(r6));
}
......@@ -1560,8 +1560,8 @@ void MacroAssembler::PopStackHandler() {
pop(r1);
mov(scratch,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize));
str(r1, MemOperand(scratch));
add(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize));
}
......
......@@ -553,14 +553,15 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ Str(fp, MemOperand(x10));
__ Bind(&done);
__ Push(x12);
__ Push(x12, padreg);
// The frame set up looks like this:
// jssp[0] : JS entry frame marker.
// jssp[1] : C entry FP.
// jssp[2] : stack frame marker.
// jssp[0] : padding.
// jssp[1] : JS entry frame marker.
// jssp[2] : C entry FP.
// jssp[3] : stack frame marker.
// jssp[4] : bad frame pointer 0xFFF...FF <- fp points here.
// jssp[4] : stack frame marker.
// jssp[5] : bad frame pointer 0xFFF...FF <- fp points here.
// Jump to a faked try block that does the invoke, with a faked catch
// block that sets the pending exception.
......@@ -591,7 +592,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Push new stack handler.
DCHECK(jssp.Is(__ StackPointer()));
static_assert(StackHandlerConstants::kSize == 1 * kPointerSize,
static_assert(StackHandlerConstants::kSize == 2 * kPointerSize,
"Unexpected offset for StackHandlerConstants::kSize");
static_assert(StackHandlerConstants::kNextOffset == 0 * kPointerSize,
"Unexpected offset for StackHandlerConstants::kNextOffset");
......@@ -599,7 +600,7 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Link the current handler as the next handler.
__ Mov(x11, ExternalReference(IsolateAddressId::kHandlerAddress, isolate()));
__ Ldr(x10, MemOperand(x11));
__ Push(x10);
__ Push(padreg, x10);
// Set this new handler as the current one.
__ Str(jssp, MemOperand(x11));
......@@ -624,26 +625,27 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Pop the stack handler and unlink this frame from the handler chain.
static_assert(StackHandlerConstants::kNextOffset == 0 * kPointerSize,
"Unexpected offset for StackHandlerConstants::kNextOffset");
__ Pop(x10);
__ Pop(x10, padreg);
__ Mov(x11, ExternalReference(IsolateAddressId::kHandlerAddress, isolate()));
__ Drop(StackHandlerConstants::kSize - kXRegSize, kByteSizeInBytes);
__ Drop(StackHandlerConstants::kSlotCount - 2);
__ Str(x10, MemOperand(x11));
__ Bind(&exit);
// x0 holds the result.
// The stack pointer points to the top of the entry frame pushed on entry from
// C++ (at the beginning of this stub):
// jssp[0] : JS entry frame marker.
// jssp[1] : C entry FP.
// jssp[2] : stack frame marker.
// jssp[3] : stack frmae marker.
// jssp[4] : bad frame pointer 0xFFF...FF <- fp points here.
// jssp[0] : padding.
// jssp[1] : JS entry frame marker.
// jssp[2] : C entry FP.
// jssp[3] : stack frame marker.
// jssp[4] : stack frame marker.
// jssp[5] : bad frame pointer 0xFFF...FF <- fp points here.
// Check if the current stack frame is marked as the outermost JS frame.
Label non_outermost_js_2;
{
Register c_entry_fp = x11;
__ Pop(x10, c_entry_fp);
__ PeekPair(x10, c_entry_fp, 1 * kPointerSize);
__ Cmp(x10, StackFrame::OUTERMOST_JSENTRY_FRAME);
__ B(ne, &non_outermost_js_2);
__ Mov(x12, ExternalReference(js_entry_sp));
......@@ -657,7 +659,9 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
}
// Reset the stack to the callee saved registers.
__ Drop(-EntryFrameConstants::kCallerFPOffset, kByteSizeInBytes);
static_assert(EntryFrameConstants::kFixedFrameSize % (2 * kPointerSize) == 0,
"Size of entry frame is not a multiple of 16 bytes");
__ Drop(EntryFrameConstants::kFixedFrameSize / kPointerSize);
// Restore the callee-saved registers and return.
DCHECK(jssp.Is(__ StackPointer()));
__ Mov(csp, jssp);
......
......@@ -8,10 +8,31 @@
namespace v8 {
namespace internal {
// The layout of an EntryFrame is as follows:
//
// slot Entry frame
// +---------------------+-----------------------
// 0 | bad frame pointer | <-- frame ptr
// | (0xFFF.. FF) |
// |- - - - - - - - - - -|
// 1 | stack frame marker |
// | (ENTRY) |
// |- - - - - - - - - - -|
// 2 | stack frame marker |
// | (0) |
// |- - - - - - - - - - -|
// 3 | C entry FP |
// |- - - - - - - - - - -|
// 4 | JS entry frame |
// | marker |
// |- - - - - - - - - - -|
// 5 | padding | <-- stack ptr
// -----+---------------------+-----------------------
//
class EntryFrameConstants : public AllStatic {
public:
static const int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
static const int kCallerFPOffset = -3 * kPointerSize;
static const int kFixedFrameSize = 6 * kPointerSize;
};
class ExitFrameConstants : public TypedFrameConstants {
......
......@@ -64,8 +64,9 @@ class InnerPointerToCodeCache {
class StackHandlerConstants : public AllStatic {
public:
static const int kNextOffset = 0 * kPointerSize;
static const int kPaddingOffset = 1 * kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
static const int kSize = kPaddingOffset + kPointerSize;
static const int kSlotCount = kSize >> kPointerSizeLog2;
};
......
......@@ -758,9 +758,11 @@ void MacroAssembler::LeaveApiExitFrame() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
push(Immediate(0)); // Padding.
// Link the current handler as the next handler.
ExternalReference handler_address(IsolateAddressId::kHandlerAddress,
isolate());
......
......@@ -3763,9 +3763,11 @@ void MacroAssembler::MaybeDropFrames() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
Push(Smi::kZero); // Padding.
// Link the current handler as the next handler.
li(t2,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
......
......@@ -4037,9 +4037,11 @@ void MacroAssembler::MaybeDropFrames() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
Push(Smi::kZero); // Padding.
// Link the current handler as the next handler.
li(a6,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
......
......@@ -1327,9 +1327,11 @@ void MacroAssembler::MaybeDropFrames() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
Push(Smi::kZero); // Padding.
// Link the current handler as the next handler.
// Preserve r3-r7.
mov(r8,
......@@ -1343,13 +1345,15 @@ void MacroAssembler::PushStackHandler() {
void MacroAssembler::PopStackHandler() {
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
pop(r4);
mov(ip,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
StoreP(r4, MemOperand(ip));
Drop(1); // Drop padding.
}
......
......@@ -1352,7 +1352,7 @@ void MacroAssembler::MaybeDropFrames() {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize);
// Link the current handler as the next handler.
......@@ -1362,6 +1362,10 @@ void MacroAssembler::PushStackHandler() {
// Buy the full stack frame for 5 slots.
lay(sp, MemOperand(sp, -StackHandlerConstants::kSize));
// Store padding.
mov(r0, Operand(Smi::kZero));
StoreP(r0, MemOperand(sp)); // Padding.
// Copy the old handler into the next handler slot.
mvc(MemOperand(sp, StackHandlerConstants::kNextOffset), MemOperand(r7),
kPointerSize);
......@@ -1370,15 +1374,16 @@ void MacroAssembler::PushStackHandler() {
}
void MacroAssembler::PopStackHandler() {
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
// Pop the Next Handler into r3 and store it into Handler Address reference.
Pop(r3);
mov(ip,
Operand(ExternalReference(IsolateAddressId::kHandlerAddress, isolate())));
StoreP(r3, MemOperand(ip));
Drop(1); // Drop padding.
}
void MacroAssembler::CompareObjectType(Register object, Register map,
......
......@@ -1919,9 +1919,11 @@ MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = {
void MacroAssembler::PushStackHandler() {
// Adjust this code if not the case.
STATIC_ASSERT(StackHandlerConstants::kSize == 1 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kPointerSize);
STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0);
Push(Immediate(0)); // Padding.
// Link the current handler as the next handler.
ExternalReference handler_address(IsolateAddressId::kHandlerAddress,
isolate());
......
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