From c759d349f235d74508c2f8af4e85cc313897a361 Mon Sep 17 00:00:00 2001 From: Herbert Dürr Date: Tue, 30 Apr 2013 11:57:36 +0000 Subject: optimization fix to UNO bridge's callVirtualMethod() for generic x86_64 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 (cherry picked from commit 254359b9ed96152091b8f7a74a3442cf6c553e04) Conflicts: bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx Change-Id: I5ba7713c2630bb3ecc4343632e796c38541bcd0e --- bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx index 3b6cd4a000e9..47b8f13a9c29 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx @@ -63,11 +63,12 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( 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 ); std::memcpy( pCallStack, pStack, nStackBytes ); } @@ -112,7 +113,8 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( "movsd %%xmm0, %2\n\t" "movsd %%xmm1, %3\n\t" : "=m" ( rax ), "=m" ( rdx ), "=m" ( xmm0 ), "=m" ( xmm1 ) - : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ) + : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ), + "m" ( pCallStack ) // dummy input to prevent the compiler from optimizing the alloca out : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" -- cgit