summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Giffuni <pfg@apache.org>2012-01-02 02:51:21 +0000
committerPedro Giffuni <pfg@apache.org>2012-01-02 02:51:21 +0000
commita5526353c08eb417540a5085d903984a5d7c3943 (patch)
tree2740306e1b136eecef649d1c70e7d55a28c908df
parent393d7bf027019955439ddbb4d53932395a3e4450 (diff)
Update FreeBSD amd64 bridge code: #i114635# #i109415#
-rw-r--r--bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx29
-rw-r--r--bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx12
-rw-r--r--bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx49
3 files changed, 58 insertions, 32 deletions
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx
index 6fbf2fc4699b..765d9a05cd97 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx
@@ -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 class1, enum x86_64_reg_class class2)
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_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c
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_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c
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_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c
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_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c
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( typelib_TypeDescriptionReference *pTypeRef
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, extended_cif *ecif)
/* 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, extended_cif *ecif)
;
}
- num = classify_argument (ecif->cif->rtype, classes, &i);
+ num = classify_argument (ecif->cif->rtype, classes, 0);
if (num == 0)
/* Return in memory. */
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
index 318092634b82..f027a41e5bac 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx
@@ -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 )
{
diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
index b3548c4e37af..aab74331527e 100644
--- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx
@@ -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 * pThis, sal_uInt32 nVtableIndex,
//==================================================================================================
+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;