[Libreoffice-commits] core.git: 2 commits - bridges/source include/comphelper

Herbert Dürr hdu at apache.org
Wed May 29 02:03:49 PDT 2013


 bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx |    6 ++--
 include/comphelper/namedvaluecollection.hxx                    |   14 +++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit c759d349f235d74508c2f8af4e85cc313897a361
Author: Herbert Dürr <hdu at apache.org>
Date:   Tue Apr 30 11:57:36 2013 +0000

    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

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 3b6cd4a..47b8f13 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"
commit 6526fda99f9133736906f326dde5cf48f967fcee
Author: Herbert Dürr <hdu at apache.org>
Date:   Tue May 28 09:52:00 2013 +0000

    Related: #i122378# avoid non-iterator bound std::transform()
    
    in some build environments the use of std::transform() with plain pointers as
    input iterators results in many warnings about how unsafe such a construct is.
    The warnings could be suppressed e.g. on MSVC with the SCL_SECURE_NO_WARNINGS
    define. Open coding the construct makes it cleaner and more debugable though.
    (cherry picked from commit a599e5242751057537c3de6eb58ceff2a173580e)
    
    Conflicts:
    	comphelper/inc/comphelper/namedvaluecollection.hxx
    
    Change-Id: I3233116bfb862f6cda038541ffecac492623611c

diff --git a/include/comphelper/namedvaluecollection.hxx b/include/comphelper/namedvaluecollection.hxx
index 93b53dd..26b2760 100644
--- a/include/comphelper/namedvaluecollection.hxx
+++ b/include/comphelper/namedvaluecollection.hxx
@@ -356,13 +356,13 @@ namespace comphelper
             ::com::sun::star::uno::Sequence< VALUE_TYPE > aValues;
             *this >>= aValues;
             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aWrappedValues( aValues.getLength() );
-            ::com::sun::star::uno::Any (* const makeAny)(const VALUE_TYPE&) = ::com::sun::star::uno::makeAny< VALUE_TYPE >;
-            ::std::transform(
-                aValues.getConstArray(),
-                aValues.getConstArray() + aValues.getLength(),
-                aWrappedValues.getArray(),
-                makeAny
-            );
+
+            ::com::sun::star::uno::Any* pO = aWrappedValues.getArray();
+            const VALUE_TYPE* pV = aValues.getConstArray();
+            const sal_Int32 nLen = aValues.getLength();
+            for( sal_Int32 i = 0; i < nLen; ++i )
+                *(pO++) = ::com::sun::star::uno::makeAny<VALUE_TYPE>( *(pV++) );
+
             return aWrappedValues;
         }
     };


More information about the Libreoffice-commits mailing list