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