Author: hdu
Date: Tue Apr 30 12:24:12 2013
New Revision: 1477588

URL: http://svn.apache.org/r1477588
Log:
#i122195# fix OSX64 UNO bridge's callVirtualMethod() for high optimization 
levels

if the pCallStack variable is optimized out then any assumptions of the
method's inlined assembler about stack layout collapse. Adding a pseudo
dependency to the pCallStack variable solves that problem.

Modified:
    openoffice/trunk/main/bridges/source/cpp_uno/cxx_macosx_x86-64/uno2cpp.cxx

Modified: 
openoffice/trunk/main/bridges/source/cpp_uno/cxx_macosx_x86-64/uno2cpp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/bridges/source/cpp_uno/cxx_macosx_x86-64/uno2cpp.cxx?rev=1477588&r1=1477587&r2=1477588&view=diff
==============================================================================
--- openoffice/trunk/main/bridges/source/cpp_uno/cxx_macosx_x86-64/uno2cpp.cxx 
(original)
+++ openoffice/trunk/main/bridges/source/cpp_uno/cxx_macosx_x86-64/uno2cpp.cxx 
Tue Apr 30 12:24:12 2013
@@ -98,11 +98,12 @@ static void callVirtualMethod(void * pTh
     pMethod = *((sal_uInt64 *)pMethod);
 
     // Load parameters to stack, if necessary
+    sal_uInt64* pCallStack = NULL;
     if ( nStack )
     {
         // 16-bytes aligned
         sal_uInt32 nStackBytes = ( ( nStack + 1 ) >> 1 ) * 16;
-        sal_uInt64 *pCallStack = (sal_uInt64 *) __builtin_alloca( nStackBytes 
);
+        pCallStack = (sal_uInt64*) __builtin_alloca( nStackBytes );
         memcpy( pCallStack, pStack, nStackBytes );
     }
 
@@ -113,7 +114,6 @@ static void callVirtualMethod(void * pTh
     double xmm1;
 
     asm volatile (
-        
         // Fill the xmm registers
         "movq %2, %%rax\n\t"
 
@@ -148,8 +148,11 @@ static void callVirtualMethod(void * pTh
         "movsd %%xmm1, %7\n\t"
         :
         : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ),
-          "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 )
-        : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11"
+          "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 ),
+          "m" (pCallStack) // dummy input to prevent the compiler from 
optimizing it out
+        : "rax", "rbx", "rcx", "rdx", "rdi", "rsi", "r8", "r9",
+          "r10", "r11", "r10", "r12", "r13", "r14", "r15", "rbx",
+          "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
     );
 
     switch (pReturnTypeRef->eTypeClass)


Reply via email to