aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-08-09 10:49:22 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2016-08-09 12:44:55 +0000
commit4493524ec24afb946eba3942f48d9fc1ff3192c1 (patch)
tree3d368ac41e572a0b963e64752b2db68447b80564 /src
parent45f79dc7e572c1a1e4c40633d5055d0c6741cfbe (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
index 5664c585b9..d8211ec4b2 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);