[quake3-commits] r1785 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jun 2 10:46:16 EDT 2010


Author: ludwig
Date: 2010-06-02 10:46:16 -0400 (Wed, 02 Jun 2010)
New Revision: 1785

Modified:
   trunk/code/qcommon/vm_x86_64.c
Log:
fix stack alignment dynamically for OP_BLOCK_COPY

Modified: trunk/code/qcommon/vm_x86_64.c
===================================================================
--- trunk/code/qcommon/vm_x86_64.c	2010-05-17 08:59:53 UTC (rev 1784)
+++ trunk/code/qcommon/vm_x86_64.c	2010-06-02 14:46:16 UTC (rev 1785)
@@ -757,14 +757,19 @@
 				emit("push %%r8");
 				emit("push %%r9");
 				emit("push %%r10");
-				emit("push %%r10");
+				emit("movq %%rsp, %%rbx"); // we need to align the stack pointer
+				emit("subq $8, %%rbx");    //   |
+				emit("andq $127, %%rbx");  //   |
+				emit("subq %%rbx, %%rsp"); // <-+
+				emit("push %%rbx");
 				emit("movl 4(%%rsi), %%edi");  // 1st argument dest
 				emit("movl 8(%%rsi), %%esi");  // 2nd argument src
 				emit("movl $%d, %%edx", iarg); // 3rd argument count
 				emit("movq $%"PRIu64", %%rax", (uint64_t)block_copy_vm);
 				emit("callq *%%rax");
+				emit("pop %%rbx");
+				emit("addq %%rbx, %%rsp");
 				emit("pop %%r10");
-				emit("pop %%r10");
 				emit("pop %%r9");
 				emit("pop %%r8");
 				emit("pop %%rdi");



More information about the quake3-commits mailing list