mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
66 lines
2.8 KiB
Diff
66 lines
2.8 KiB
Diff
From 4493524ec24afb946eba3942f48d9fc1ff3192c1 Mon Sep 17 00:00:00 2001
|
|
From: Erik Verbruggen <erik.verbruggen@digia.com>
|
|
Date: Tue, 9 Aug 2016 10:49:22 +0200
|
|
Subject: [PATCH] V4: Align stack on 16 byte boundaries in the YarrJIT
|
|
|
|
This is the required alignment for Aarch64, and a number of other ABIs
|
|
prefer this size too when calling into system libraries.
|
|
|
|
Change-Id: Ie38cabb77cf83543b915553e69c5c5728a67503b
|
|
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
|
|
---
|
|
src/3rdparty/masm/yarr/YarrJIT.cpp | 22 ++++++++++++++++++++--
|
|
1 file changed, 20 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
|
|
index 5664c58..d8211ec 100644
|
|
--- a/src/3rdparty/masm/yarr/YarrJIT.cpp
|
|
+++ b/src/3rdparty/masm/yarr/YarrJIT.cpp
|
|
@@ -338,17 +338,31 @@ class YarrGenerator : private MacroAssembler {
|
|
jump(Address(stackPointerRegister, frameLocation * sizeof(void*)));
|
|
}
|
|
|
|
+ unsigned alignCallFrameSizeInBytes(unsigned callFrameSize)
|
|
+ {
|
|
+ callFrameSize *= sizeof(void*);
|
|
+ if (callFrameSize / sizeof(void*) != m_pattern.m_body->m_callFrameSize)
|
|
+ CRASH();
|
|
+ // Originally, the code was:
|
|
+// callFrameSize = (callFrameSize + 0x3f) & ~0x3f;
|
|
+ // However, 64 bytes is a bit surprising. The biggest "alignment" requirement is on Aarch64, where:
|
|
+ // "SP mod 16 = 0. The stack must be quad-word aligned." (IHI0055B_aapcs64.pdf)
|
|
+ callFrameSize = (callFrameSize + 0xf) & ~0xf;
|
|
+ if (!callFrameSize)
|
|
+ CRASH();
|
|
+ return callFrameSize;
|
|
+ }
|
|
void initCallFrame()
|
|
{
|
|
unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
|
|
if (callFrameSize)
|
|
- subPtr(Imm32(callFrameSize * sizeof(void*)), stackPointerRegister);
|
|
+ subPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
|
|
}
|
|
void removeCallFrame()
|
|
{
|
|
unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
|
|
if (callFrameSize)
|
|
- addPtr(Imm32(callFrameSize * sizeof(void*)), stackPointerRegister);
|
|
+ addPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
|
|
}
|
|
|
|
// Used to record subpatters, should only be called if compileMode is IncludeSubpatterns.
|
|
@@ -2565,6 +2579,10 @@ class YarrGenerator : private MacroAssembler {
|
|
if (compileMode == IncludeSubpatterns)
|
|
loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), output);
|
|
#endif
|
|
+#elif CPU(ARM64)
|
|
+ // The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves.
|
|
+ zeroExtend32ToPtr(index, index);
|
|
+ zeroExtend32ToPtr(length, length);
|
|
#elif CPU(ARM)
|
|
push(ARMRegisters::r4);
|
|
push(ARMRegisters::r5);
|
|
--
|
|
2.10.2
|
|
|