summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/ABI.cpp
diff options
context:
space:
mode:
authorMaarten ter Huurne <maarten@treewalker.org>2008-09-05 01:48:16 +0000
committerMaarten ter Huurne <maarten@treewalker.org>2008-09-05 01:48:16 +0000
commitcf36d4ba58ed12987107fe44e810f148dca48801 (patch)
treedfdbcac49fd4159e11a406bb7e2895eea09bf043 /Source/Core/Common/Src/ABI.cpp
parent6d53aaed21970604a706f06ec154eae4a5031c55 (diff)
Fixed ProtectFunction(): it should copy parameters using the padded size. Actually, I am not sure this function is correct, but at least its implementation is now equivalent to the original (before rev 439).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@441 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/ABI.cpp')
-rw-r--r--Source/Core/Common/Src/ABI.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/Source/Core/Common/Src/ABI.cpp b/Source/Core/Common/Src/ABI.cpp
index d41225a964..097d6fc45b 100644
--- a/Source/Core/Common/Src/ABI.cpp
+++ b/Source/Core/Common/Src/ABI.cpp
@@ -65,6 +65,17 @@ void ABI_PopAllCalleeSavedRegsAndAdjustStack() {
POP(EBP);
}
+unsigned int ABI_GetAlignedFrameSize(unsigned int frameSize) {
+ frameSize += 4; // reserve space for return address
+ unsigned int alignedSize =
+#ifdef __GNUC__
+ (frameSize + 15) & -16;
+#else
+ frameSize;
+#endif
+ return alignedSize;
+}
+
void ABI_AlignStack(unsigned int frameSize) {
// Mac OS X requires the stack to be 16-byte aligned before every call.
// Linux requires the stack to be 16-byte aligned before calls that put SSE
@@ -74,9 +85,8 @@ void ABI_AlignStack(unsigned int frameSize) {
// expect that GCC on Windows acts the same as GCC on Linux in this respect.
// It would be nice if someone could verify this.
#ifdef __GNUC__
- frameSize += 4; // reserve space for return address
- unsigned int paddedSize = (frameSize + 15) & -16;
- unsigned int fillSize = paddedSize - frameSize;
+ unsigned int fillSize =
+ ABI_GetAlignedFrameSize(frameSize) - (frameSize + 4);
if (fillSize != 0) {
SUB(32, R(ESP), Imm8(fillSize));
}
@@ -84,16 +94,10 @@ void ABI_AlignStack(unsigned int frameSize) {
}
void ABI_RestoreStack(unsigned int frameSize) {
- frameSize += 4; // reserve space for return address
- unsigned int paddedSize =
-#ifdef __GNUC__
- (frameSize + 15) & -16;
-#else
- frameSize;
-#endif
- paddedSize -= 4; // return address is already consumed
- if (paddedSize != 0) {
- ADD(32, R(ESP), Imm8(paddedSize));
+ unsigned int alignedSize = ABI_GetAlignedFrameSize(frameSize);
+ alignedSize -= 4; // return address is POPped at end of call
+ if (alignedSize != 0) {
+ ADD(32, R(ESP), Imm8(alignedSize));
}
}
@@ -137,6 +141,10 @@ void ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2)
CALL(func);
}
+unsigned int ABI_GetAlignedFrameSize(unsigned int frameSize) {
+ return frameSize;
+}
+
void ABI_AlignStack(unsigned int /*frameSize*/) {
}