incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r1226336 - in /incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64: abi.cxx cpp2uno.cxx uno2cpp.cxx
Date Mon, 02 Jan 2012 03:51:22 GMT
Author: pfg
Date: Mon Jan  2 03:51:21 2012
New Revision: 1226336

URL: http://svn.apache.org/viewvc?rev=1226336&view=rev
Log:
Update FreeBSD amd64 bridge code: #i114635# #i109415#

Modified:
    incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx
    incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
    incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx

Modified: incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx?rev=1226336&r1=1226335&r2=1226336&view=diff
==============================================================================
--- incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx (original)
+++ incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx Mon Jan  2
03:51:21 2012
@@ -96,8 +96,6 @@ enum x86_64_reg_class
 
 #define MAX_CLASSES 4
 
-#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
-
 /* x86-64 register passing implementation.  See x86-64 ABI for details.  Goal
    of this code is to classify each 8bytes of incoming argument by the register
    class and assign registers accordingly.  */
@@ -149,11 +147,8 @@ merge_classes (enum x86_64_reg_class cla
    See the x86-64 PS ABI for details.
 */
 static int
-classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_class classes[],
int &rByteOffset )
+classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_class classes[],
int byteOffset )
 {
-    /* First, align to the right place.  */
-    rByteOffset = ALIGN( rByteOffset, pTypeRef->pType->nAlignment );
-
     switch ( pTypeRef->eTypeClass )
     {
         case typelib_TypeClass_VOID:
@@ -169,13 +164,13 @@ classify_argument( typelib_TypeDescripti
         case typelib_TypeClass_HYPER:
         case typelib_TypeClass_UNSIGNED_HYPER:
         case typelib_TypeClass_ENUM:
-            if ( ( rByteOffset % 8 + pTypeRef->pType->nSize ) <= 4 )
+            if ( ( byteOffset % 8 + pTypeRef->pType->nSize ) <= 4 )
                 classes[0] = X86_64_INTEGERSI_CLASS;
             else
                 classes[0] = X86_64_INTEGER_CLASS;
             return 1;
         case typelib_TypeClass_FLOAT:
-            if ( ( rByteOffset % 8 ) == 0 )
+            if ( ( byteOffset % 8 ) == 0 )
                 classes[0] = X86_64_SSESF_CLASS;
             else
                 classes[0] = X86_64_SSE_CLASS;
@@ -222,9 +217,9 @@ classify_argument( typelib_TypeDescripti
                 for ( sal_Int32 nMember = 0; nMember < pStruct->nMembers; ++nMember
)
                 {
                     typelib_TypeDescriptionReference *pTypeInStruct = pStruct->ppTypeRefs[
nMember ];
-                    rByteOffset = pStruct->pMemberOffsets[ nMember ];
+                    int offset = byteOffset + pStruct->pMemberOffsets[ nMember ];
 
-                    int num = classify_argument( pTypeInStruct, subclasses, rByteOffset );
+                    int num = classify_argument( pTypeInStruct, subclasses, offset );
 
                     if ( num == 0 )
                     {
@@ -234,7 +229,7 @@ classify_argument( typelib_TypeDescripti
 
                     for ( int i = 0; i < num; i++ )
                     {
-                        int pos = rByteOffset / 8;
+                        int pos = offset / 8;
                         classes[i + pos] = merge_classes( subclasses[i], classes[i + pos]
);
                     }
                 }
@@ -277,10 +272,9 @@ classify_argument( typelib_TypeDescripti
 bool x86_64::examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInReturn,
int &nUsedGPR, int &nUsedSSE )
 {
     enum x86_64_reg_class classes[MAX_CLASSES];
-    int offset = 0;
     int n;
 
-    n = classify_argument( pTypeRef, classes, offset );
+    n = classify_argument( pTypeRef, classes, 0 );
 
     if ( n == 0 )
         return false;
@@ -326,10 +320,9 @@ bool x86_64::return_in_hidden_param( typ
 void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64 *pGPR,
const double *pSSE, void *pStruct )
 {
     enum x86_64_reg_class classes[MAX_CLASSES];
-    int offset = 0;
     int n;
 
-    n = classify_argument( pTypeRef, classes, offset );
+    n = classify_argument( pTypeRef, classes, 0 );
 
     sal_uInt64 *pStructAlign = reinterpret_cast<sal_uInt64 *>( pStruct );
     for ( n--; n >= 0; n-- )
@@ -437,10 +430,10 @@ ffi_prep_args (stackLayout *stack, exten
 	  /* All easy cases are eliminated. Now fire the big guns.  */
 
 	  enum x86_64_reg_class classes[MAX_CLASSES];
-	  int offset = 0, j, num;
+	  int j, num;
 	  void *a;
 
-	  num = classify_argument (*p_arg, classes, &offset);
+	  num = classify_argument (*p_arg, classes, 0);
 	  for (j=0, a=*p_argv; j<num; j++, a+=8)
 	    {
 	      switch (classes[j])
@@ -567,7 +560,7 @@ ffi_fill_return_value (return_value *rv,
             ;
     }
 
-    num = classify_argument (ecif->cif->rtype, classes, &i);
+    num = classify_argument (ecif->cif->rtype, classes, 0);
 
     if (num == 0)
         /* Return in memory.  */

Modified: incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx?rev=1226336&r1=1226335&r2=1226336&view=diff
==============================================================================
--- incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx (original)
+++ incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx Mon Jan
 2 03:51:21 2012
@@ -114,16 +114,14 @@ static typelib_TypeClass cpp2uno_call(
 	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
 	{
 		const typelib_MethodParameter & rParam = pParams[nPos];
-		typelib_TypeDescription * pParamTypeDescr = 0;
-		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
 
 		int nUsedGPR = 0;
 		int nUsedSSE = 0;
-#if OSL_DEBUG_LEVEL > 1
+#if OSL_DEBUG_LEVEL > 0
 		bool bFitsRegisters =
 #endif
 			x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE );
-		if ( !rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )
) // value
+		if ( !rParam.bOut && bridges::cpp_uno::shared::isSimpleType( rParam.pTypeRef )
) // value
 		{
 			// Simple types must fit exactly one register on x86_64
 			OSL_ASSERT( bFitsRegisters && ( ( nUsedSSE == 1 && nUsedGPR == 0 ) ||
( nUsedSSE == 0 && nUsedGPR == 1 ) ) );
@@ -148,12 +146,12 @@ static typelib_TypeClass cpp2uno_call(
 				else
 					pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw++;
 			}
-
-			// no longer needed
-			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
 		}
 		else // struct <= 16 bytes || ptr to complex value || ref
 		{
+			typelib_TypeDescription * pParamTypeDescr = 0;
+			TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
+
 			void *pCppStack;
 			if ( nr_gpr < x86_64::MAX_GPR_REGS )
 			{ 

Modified: incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx?rev=1226336&r1=1226335&r2=1226336&view=diff
==============================================================================
--- incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx (original)
+++ incubator/ooo/trunk/main/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx Mon Jan
 2 03:51:21 2012
@@ -24,10 +24,14 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_bridges.hxx"
 
+#include <exception>
+#include <typeinfo>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <rtl/alloc.h>
+
+#include "rtl/alloc.h"
+#include "rtl/ustrbuf.hxx"
 
 #include <com/sun/star/uno/genfunc.hxx>
 #include "com/sun/star/uno/RuntimeException.hpp"
@@ -233,6 +237,18 @@ static void callVirtualMethod(void * pTh
 
 //==================================================================================================

 
+namespace {
+
+void appendCString(OUStringBuffer & buffer, char const * text) {
+    if (text != 0) {
+        buffer.append(
+            OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1));
+            // use 8859-1 to avoid conversion failure
+    }
+}
+
+}
+
 static void cpp_call(
 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
 	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
@@ -365,12 +381,31 @@ static void cpp_call(
 	
 	try
 	{
-		callVirtualMethod(
-			pAdjustedThisPtr, aVtableSlot.index,
-			pCppReturn, pReturnTypeRef, bSimpleReturn,
-			pStackStart, ( pStack - pStackStart ),
-			pGPR, nGPR,
-			pFPR, nFPR );
+        try {
+            callVirtualMethod(
+                pAdjustedThisPtr, aVtableSlot.index,
+                pCppReturn, pReturnTypeRef, bSimpleReturn,
+                pStackStart, ( pStack - pStackStart ),
+                pGPR, nGPR,
+                pFPR, nFPR );
+        } catch (Exception &) {
+            throw;
+        } catch (std::exception & e) {
+            OUStringBuffer buf;
+            buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw "));
+            appendCString(buf, typeid(e).name());
+            buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": "));
+            appendCString(buf, e.what());
+            throw RuntimeException(
+                buf.makeStringAndClear(), Reference< XInterface >());
+        } catch (...) {
+            throw RuntimeException(
+                OUString(
+                    RTL_CONSTASCII_USTRINGPARAM(
+                        "C++ code threw unknown exception")),
+                Reference< XInterface >());
+        }
+
 		// NO exception occured...
 		*ppUnoExc = 0;
 		



Mime
View raw message