[Libreoffice-commits] core.git: 3 commits - bridges/source

Stephan Bergmann sbergman at redhat.com
Mon Nov 7 07:55:25 UTC 2016


 bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx |   57 +++++-----
 bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx |    3 
 bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx           |    3 
 3 files changed, 32 insertions(+), 31 deletions(-)

New commits:
commit 9ec4c4ab052c66e9e25c9893bba33b8dee258484
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Nov 4 23:06:45 2016 +0100

    Don't rely on __builtin_alloca when creating a call stack
    
    same as 3f7c8ce1dca7eacb511def7799691be2e3d9a4a6 for gcc_linux_x86-64 (see there
    for a more detailed commit message; plus trivial follow-up
    5e04886917abad0541eb3ef6d51cd5dc0395af21 "Remove spurious vertical whitespace").
    Except use labels 'Lpush', 'Lpushed' not starting with a dot ('.Lpush',
    '.Lpushed'), as otherwise at least macOS 10.12.1 linker (ld64-274.1), when
    building libgcc3_uno.dylib's __TEXT,__unwind_info section, would use
    callvirtualmethod.o's __LD,__compact_unwind entry---covering the complete
    callVirtualMethod function---only for the first part of the function up to the
    .Lpush label, and would mark the remainder as having no unwind information (a
    compact_unwind_encoding_t value of 0; see the inline comments in the
    libunwind-35.3 source code,
    <http://opensource.apple.com/source/libunwind/libunwind-35.3/>).  So if an
    exception shall pass through that latter part it would lead to std::terminate.
    
    Change-Id: Ib1e8a5e4534b11ebe96c3ce774f8e5e8d45476cf

diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
index d4d5160..47f383a 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
@@ -54,6 +54,8 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
     // than available" error:
     struct Data {
         sal_uInt64 pMethod;
+        sal_uInt64 * pStack;
+        sal_uInt32 nStack;
         sal_uInt64 * pGPR;
         double * pFPR;
         // Return values:
@@ -62,6 +64,8 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
         double xmm0;
         double xmm1;
     } data;
+    data.pStack = pStack;
+    data.nStack = nStack;
     data.pGPR = pGPR;
     data.pFPR = pFPR;
 
@@ -70,19 +74,25 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
     pMethod += 8 * nVtableIndex;
     data.pMethod = *reinterpret_cast<sal_uInt64 *>(pMethod);
 
-    // Load parameters to stack, if necessary
-    if ( nStack )
-    {
-        // 16-bytes aligned
-        sal_uInt32 nStackBytes = ( ( nStack + 1 ) >> 1 ) * 16;
-        sal_uInt64 *pCallStack = static_cast<sal_uInt64 *>(__builtin_alloca( nStackBytes ));
-        std::memcpy( pCallStack, pStack, nStackBytes );
-    }
-
     asm volatile (
+        // Push arguments to stack
+        "movq %%rsp, %%r12\n\t"
+        "movl 16%0, %%ecx\n\t"
+        "jrcxz Lpushed\n\t"
+        "xor %%rax, %%rax\n\t"
+        "leaq (%%rax, %%rcx, 8), %%rax\n\t"
+        "subq %%rax, %%rsp\n\t"
+        "andq $-9, %%rsp\n\t" // 16-bytes aligned
+        "movq 8%0, %%rsi\n\t"
+        "\nLpush:\n\t"
+        "decq %%rcx\n\t"
+        "movq (%%rsi, %%rcx, 8), %%rax\n\t"
+        "movq %%rax, (%%rsp, %%rcx, 8)\n\t"
+        "jnz Lpush\n\t"
+        "\nLpushed:\n\t"
 
         // Fill the xmm registers
-        "movq 16%0, %%rax\n\t"
+        "movq 32%0, %%rax\n\t"
 
         "movsd   (%%rax), %%xmm0\n\t"
         "movsd  8(%%rax), %%xmm1\n\t"
@@ -94,7 +104,7 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
         "movsd 56(%%rax), %%xmm7\n\t"
 
         // Fill the general purpose registers
-        "movq 8%0, %%rax\n\t"
+        "movq 24%0, %%rax\n\t"
 
         "movq    (%%rax), %%rdi\n\t"
         "movq   8(%%rax), %%rsi\n\t"
@@ -108,12 +118,15 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
         "call *%%r11\n\t"
 
         // Fill the return values
-        "movq   %%rax, 24%0\n\t"
-        "movq   %%rdx, 32%0\n\t"
-        "movsd %%xmm0, 40%0\n\t"
-        "movsd %%xmm1, 48%0\n\t"
+        "movq   %%rax, 40%0\n\t"
+        "movq   %%rdx, 48%0\n\t"
+        "movsd %%xmm0, 56%0\n\t"
+        "movsd %%xmm1, 64%0\n\t"
+
+        // Reset %rsp
+        "movq %%r12, %%rsp\n\t"
         :: "o" (data)
-        : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11",
+        : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", "r12",
           "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
           "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15",
           "memory"
commit c01e02425e3ce7a14f06cfc505cf375a82a7c980
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Nov 2 21:44:30 2016 +0100

    Drop unnecessary nFPR parameter
    
    same as 8a85f9f29f13805af449943990af8af8399ab7b5 for gcc_linux_x86-64 (see there
    for a more detailed commit message)
    
    Change-Id: Ic2765c21834aabf8f7690c0bdab4d6efe6d34585

diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
index 513018c..d4d5160 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
@@ -48,20 +48,14 @@
 void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
     void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn,
     typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn,
-    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR,
-    sal_uInt32 nFPR)
+    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR)
 {
-    // Should not happen, but...
-    if ( nFPR > x86_64::MAX_SSE_REGS )
-        nFPR = x86_64::MAX_SSE_REGS;
-
     // Work around -fsanitize=address "inline assembly requires more registers
     // than available" error:
     struct Data {
         sal_uInt64 pMethod;
         sal_uInt64 * pGPR;
         double * pFPR;
-        sal_uInt64 nFPR;
         // Return values:
         sal_uInt64 rax;
         sal_uInt64 rdx;
@@ -70,7 +64,6 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
     } data;
     data.pGPR = pGPR;
     data.pFPR = pFPR;
-    data.nFPR = nFPR;
 
     // Get pointer to method
     sal_uInt64 pMethod = *static_cast<sal_uInt64 *>(pThis);
@@ -112,14 +105,13 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
 
         // Perform the call
         "movq 0%0, %%r11\n\t"
-        "movq 24%0, %%rax\n\t"
         "call *%%r11\n\t"
 
         // Fill the return values
-        "movq   %%rax, 32%0\n\t"
-        "movq   %%rdx, 40%0\n\t"
-        "movsd %%xmm0, 48%0\n\t"
-        "movsd %%xmm1, 56%0\n\t"
+        "movq   %%rax, 24%0\n\t"
+        "movq   %%rdx, 32%0\n\t"
+        "movsd %%xmm0, 40%0\n\t"
+        "movsd %%xmm1, 48%0\n\t"
         :: "o" (data)
         : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11",
           "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
index c94333e..53c5ac0 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
@@ -31,8 +31,7 @@ namespace CPPU_CURRENT_NAMESPACE {
 void callVirtualMethod(
     void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn,
     typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn,
-    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR,
-    sal_uInt32 nFPR);
+    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR);
 
 }
 
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
index 5179918..f606f72 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
@@ -242,8 +242,7 @@ static void cpp_call(
                 pAdjustedThisPtr, aVtableSlot.index,
                 pCppReturn, pReturnTypeRef, bSimpleReturn,
                 pStackStart, ( pStack - pStackStart ),
-                pGPR,
-                pFPR, nFPR );
+                pGPR, pFPR );
         } catch (const Exception &) {
             throw;
         } catch (const std::exception & e) {
commit 6daac9adb4e367f1830a2eaa72913dd367523f88
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Nov 2 21:27:20 2016 +0100

    Drop unused nGPR parameter
    
    same as aa04177e7c43d75bc87875a9d8ce2393d7263822 for gcc_linux_x86-64
    
    Change-Id: I2c1e203271aa0038b83c3c55a37eab59411a6857

diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
index edae16e..513018c 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.cxx
@@ -48,14 +48,12 @@
 void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
     void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn,
     typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn,
-    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR,
-    double * pFPR, sal_uInt32 nFPR)
+    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR,
+    sal_uInt32 nFPR)
 {
     // Should not happen, but...
     if ( nFPR > x86_64::MAX_SSE_REGS )
         nFPR = x86_64::MAX_SSE_REGS;
-    if ( nGPR > x86_64::MAX_GPR_REGS )
-        nGPR = x86_64::MAX_GPR_REGS;
 
     // Work around -fsanitize=address "inline assembly requires more registers
     // than available" error:
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
index ddd0493..c94333e 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/callvirtualmethod.hxx
@@ -31,8 +31,8 @@ namespace CPPU_CURRENT_NAMESPACE {
 void callVirtualMethod(
     void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn,
     typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn,
-    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR,
-    double * pFPR, sal_uInt32 nFPR);
+    sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR,
+    sal_uInt32 nFPR);
 
 }
 
diff --git a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
index ecf9066..5179918 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_x86-64/uno2cpp.cxx
@@ -242,7 +242,7 @@ static void cpp_call(
                 pAdjustedThisPtr, aVtableSlot.index,
                 pCppReturn, pReturnTypeRef, bSimpleReturn,
                 pStackStart, ( pStack - pStackStart ),
-                pGPR, nGPR,
+                pGPR,
                 pFPR, nFPR );
         } catch (const Exception &) {
             throw;


More information about the Libreoffice-commits mailing list