[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - bridges/Library_cpp_uno.mk bridges/source
Gabriele Bulfon
gabriele.bulfon at sonicle.com
Thu Feb 19 13:08:19 PST 2015
bridges/Library_cpp_uno.mk | 1
bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.cxx | 117 ++++++++++
bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.hxx | 50 ++++
bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx | 88 -------
4 files changed, 171 insertions(+), 85 deletions(-)
New commits:
commit 4801b29677462f7206fa281f06646e5cd8d81bfa
Author: Gabriele Bulfon <gabriele.bulfon at sonicle.com>
Date: Thu Feb 19 14:36:39 2015 +0100
Adapt gcc3_solaris_intel bridge to GCC 4.7
...similarly to 0fdbb5b0eabbaa571f3747fda12a56c938cba474 "Make
cpp_uno/gcc3_linux_x86-64 bridge work with GCC 4.7"
Change-Id: Idcafcb07678d02446172d7fde30631a342f6437e
(cherry picked from commit 834afd885bd74ff80b59898d3f63ba940a58c1d8)
Signed-off-by: Michael Stahl <mstahl at redhat.com>
diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk
index 5b7377a..61ffa29 100644
--- a/bridges/Library_cpp_uno.mk
+++ b/bridges/Library_cpp_uno.mk
@@ -74,6 +74,7 @@ bridge_noncallexception_objects := callvirtualmethod
else ifeq ($(OS),SOLARIS)
bridges_SELECTED_BRIDGE := gcc3_solaris_intel
bridge_exception_objects := cpp2uno except uno2cpp
+bridge_noncallexception_objects := callvirtualmethod
else ifeq ($(COM),MSC)
bridges_SELECTED_BRIDGE := msvc_win32_intel
bridge_exception_objects := cpp2uno dllinit uno2cpp
diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.cxx
new file mode 100644
index 0000000..00f9bdc
--- /dev/null
+++ b/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <com/sun/star/uno/genfunc.hxx>
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include <uno/data.h>
+
+#include "bridges/cpp_uno/shared/bridge.hxx"
+#include "bridges/cpp_uno/shared/types.hxx"
+#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
+#include "bridges/cpp_uno/shared/vtables.hxx"
+
+#include "share.hxx"
+
+#include "callvirtualmethod.hxx"
+
+void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
+ void * pAdjustedThisPtr,
+ sal_Int32 nVtableIndex,
+ void * pRegisterReturn,
+ typelib_TypeClass eReturnType,
+ sal_Int32 * pStackLongs,
+ sal_Int32 nStackLongs )
+{
+ // parameter list is mixed list of * and values
+ // reference parameters are pointers
+
+ assert(pStackLongs && pAdjustedThisPtr);
+ static_assert((sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!");
+ assert(nStackLongs && pStackLongs && "### no stack in callVirtualMethod !");
+
+ // never called
+ if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
+
+ long edx, eax; // for register returns
+ void * stackptr;
+ asm volatile (
+ "mov %%esp, %2\n\t"
+ // preserve potential 128bit stack alignment
+ "and $0xfffffff0, %%esp\n\t"
+ "mov %3, %%eax\n\t"
+ "lea -4(,%%eax,4), %%eax\n\t"
+ "and $0xf, %%eax\n\t"
+ "sub $0xc, %%eax\n\t"
+ "add %%eax, %%esp\n\t"
+ // copy values
+ "mov %3, %%eax\n\t"
+ "mov %%eax, %%edx\n\t"
+ "dec %%edx\n\t"
+ "shl $2, %%edx\n\t"
+ "add %4, %%edx\n"
+ "Lcopy:\n\t"
+ "pushl 0(%%edx)\n\t"
+ "sub $4, %%edx\n\t"
+ "dec %%eax\n\t"
+ "jne Lcopy\n\t"
+ // do the actual call
+ "mov %5, %%edx\n\t"
+ "mov 0(%%edx), %%edx\n\t"
+ "mov %6, %%eax\n\t"
+ "shl $2, %%eax\n\t"
+ "add %%eax, %%edx\n\t"
+ "mov 0(%%edx), %%edx\n\t"
+ "call *%%edx\n\t"
+ // save return registers
+ "mov %%eax, %0\n\t"
+ "mov %%edx, %1\n\t"
+ // cleanup stack
+ "mov %2, %%esp\n\t"
+ : "=m"(eax), "=m"(edx), "=m"(stackptr)
+ : "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr), "m"(nVtableIndex)
+ : "eax", "ecx", "edx" );
+ switch( eReturnType )
+ {
+ case typelib_TypeClass_HYPER:
+ case typelib_TypeClass_UNSIGNED_HYPER:
+ ((long*)pRegisterReturn)[1] = edx;
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_ENUM:
+ ((long*)pRegisterReturn)[0] = eax;
+ break;
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ *(unsigned short*)pRegisterReturn = eax;
+ break;
+ case typelib_TypeClass_BOOLEAN:
+ case typelib_TypeClass_BYTE:
+ *(unsigned char*)pRegisterReturn = eax;
+ break;
+ case typelib_TypeClass_FLOAT:
+ asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn) );
+ break;
+ case typelib_TypeClass_DOUBLE:
+ asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn) );
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.hxx b/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.hxx
new file mode 100644
index 0000000..783a4c1
--- /dev/null
+++ b/bridges/source/cpp_uno/gcc3_solaris_intel/callvirtualmethod.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_SOLARIS_INTEL_CALLVIRTUALMETHOD_HXX
+#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_SOLARIS_INTEL_CALLVIRTUALMETHOD_HXX
+
+
+#include <malloc.h>
+#include "sal/alloca.h"
+
+#include "sal/config.h"
+
+#include <cstring>
+
+
+#include "sal/types.h"
+#include "typelib/typeclass.h"
+#include "typelib/typedescription.h"
+
+namespace CPPU_CURRENT_NAMESPACE {
+
+void callVirtualMethod(
+ void * pAdjustedThisPtr,
+ sal_Int32 nVtableIndex,
+ void * pRegisterReturn,
+ typelib_TypeClass eReturnType,
+ sal_Int32 * pStackLongs,
+ sal_Int32 nStackLongs );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
index 51c4eec..4f829ad 100644
--- a/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_solaris_intel/uno2cpp.cxx
@@ -32,95 +32,13 @@
#include "share.hxx"
+#include "callvirtualmethod.hxx"
+
using namespace ::com::sun::star::uno;
namespace
{
-static void __attribute__((noinline)) callVirtualMethod(
- void * pAdjustedThisPtr,
- sal_Int32 nVtableIndex,
- void * pRegisterReturn,
- typelib_TypeClass eReturnType,
- sal_Int32 * pStackLongs,
- sal_Int32 nStackLongs )
-{
- // parameter list is mixed list of * and values
- // reference parameters are pointers
-
- assert(pStackLongs && pAdjustedThisPtr);
- static_assert((sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!");
- assert(nStackLongs && pStackLongs && "### no stack in callVirtualMethod !");
-
- // never called
- if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
-
- long edx, eax; // for register returns
- void * stackptr;
- asm volatile (
- "mov %%esp, %2\n\t"
- // preserve potential 128bit stack alignment
- "and $0xfffffff0, %%esp\n\t"
- "mov %3, %%eax\n\t"
- "lea -4(,%%eax,4), %%eax\n\t"
- "and $0xf, %%eax\n\t"
- "sub $0xc, %%eax\n\t"
- "add %%eax, %%esp\n\t"
- // copy values
- "mov %3, %%eax\n\t"
- "mov %%eax, %%edx\n\t"
- "dec %%edx\n\t"
- "shl $2, %%edx\n\t"
- "add %4, %%edx\n"
- "Lcopy:\n\t"
- "pushl 0(%%edx)\n\t"
- "sub $4, %%edx\n\t"
- "dec %%eax\n\t"
- "jne Lcopy\n\t"
- // do the actual call
- "mov %5, %%edx\n\t"
- "mov 0(%%edx), %%edx\n\t"
- "mov %6, %%eax\n\t"
- "shl $2, %%eax\n\t"
- "add %%eax, %%edx\n\t"
- "mov 0(%%edx), %%edx\n\t"
- "call *%%edx\n\t"
- // save return registers
- "mov %%eax, %0\n\t"
- "mov %%edx, %1\n\t"
- // cleanup stack
- "mov %2, %%esp\n\t"
- : "=m"(eax), "=m"(edx), "=m"(stackptr)
- : "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr), "m"(nVtableIndex)
- : "eax", "ecx", "edx" );
- switch( eReturnType )
- {
- case typelib_TypeClass_HYPER:
- case typelib_TypeClass_UNSIGNED_HYPER:
- ((long*)pRegisterReturn)[1] = edx;
- case typelib_TypeClass_LONG:
- case typelib_TypeClass_UNSIGNED_LONG:
- case typelib_TypeClass_CHAR:
- case typelib_TypeClass_ENUM:
- ((long*)pRegisterReturn)[0] = eax;
- break;
- case typelib_TypeClass_SHORT:
- case typelib_TypeClass_UNSIGNED_SHORT:
- *(unsigned short*)pRegisterReturn = eax;
- break;
- case typelib_TypeClass_BOOLEAN:
- case typelib_TypeClass_BYTE:
- *(unsigned char*)pRegisterReturn = eax;
- break;
- case typelib_TypeClass_FLOAT:
- asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn) );
- break;
- case typelib_TypeClass_DOUBLE:
- asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn) );
- break;
- }
-}
-
static void cpp_call(
bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
bridges::cpp_uno::shared::VtableSlot aVtableSlot,
@@ -234,7 +152,7 @@ static void cpp_call(
try
{
assert( !( (pCppStack - pCppStackStart ) & 3) && "UNALIGNED STACK !!! (Please DO panic)");
- callVirtualMethod(
+ CPPU_CURRENT_NAMESPACE::callVirtualMethod(
pAdjustedThisPtr, aVtableSlot.index,
pCppReturn, pReturnTypeDescr->eTypeClass,
(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
More information about the Libreoffice-commits
mailing list