diff options
author | Pedro Giffuni <pfg@apache.org> | 2011-10-09 01:07:51 +0000 |
---|---|---|
committer | Pedro Giffuni <pfg@apache.org> | 2011-10-09 01:07:51 +0000 |
commit | 353689d050bbd375292e2a524a5b2ceb1a38c920 (patch) | |
tree | 9725a68c2e930cc9ff9e07898e98e661714ebf3d /bridges | |
parent | 9e104e36689958b046f853f67782382d83d04c9b (diff) |
i85126 - FreeBSD port: newer bridge code for amd64.
Diffstat (limited to 'bridges')
7 files changed, 55 insertions, 57 deletions
diff --git a/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx b/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx index 434e0c6a0a28..e43d2c33eed3 100644 --- a/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx +++ b/bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx @@ -37,7 +37,7 @@ #include <hash_map> /*See: http://people.redhat.com/drepper/selinux-mem.html*/ -#ifdef LINUX +#if defined (LINUX) || defined (FREEBSD) #define USE_DOUBLE_MMAP #endif 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 937af0152d90..c0166b720f0b 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx @@ -226,6 +226,7 @@ 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 num = classify_argument( pTypeInStruct, subclasses, rByteOffset ); @@ -240,9 +241,6 @@ classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_c int pos = rByteOffset / 8; classes[i + pos] = merge_classes( subclasses[i], classes[i + pos] ); } - - if ( pTypeInStruct->eTypeClass != typelib_TypeClass_STRUCT ) - rByteOffset = pStruct->pMemberOffsets[ nMember ]; } TYPELIB_DANGER_RELEASE( pTypeDescr ); @@ -329,7 +327,7 @@ bool x86_64::return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef return examine_argument( pTypeRef, true, g, s ) == 0; } -void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ) +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; @@ -343,12 +341,14 @@ void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * con { case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: - *pStructAlign++ = *reinterpret_cast<sal_uInt64 *>( *pGPR++ ); + *pStructAlign++ = *pGPR++; break; case X86_64_SSE_CLASS: case X86_64_SSESF_CLASS: case X86_64_SSEDF_CLASS: - *pStructAlign++ = *reinterpret_cast<sal_uInt64 *>( *pSSE++ ); + *pStructAlign++ = *reinterpret_cast<const sal_uInt64 *>( pSSE++ ); + break; + default: break; } } diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx index 1e2bc64fff93..adb8acbb4771 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx @@ -60,7 +60,7 @@ bool examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInRetur */ bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ); -void fill_struct( typelib_TypeDescriptionReference *pTypeRef, void * const *pGPR, void * const *pSSE, void *pStruct ); +void fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64* pGPR, const double* pSSE, void *pStruct ); } // namespace x86_64 diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s index 736230705d5a..a0572ef61641 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s @@ -43,6 +43,9 @@ privateSnippetExecutor: je .Lfloat movq -144(%rbp), %rax # Return value (int case) + movq -136(%rbp), %rdx # Return value (int case) + movq -144(%rbp), %xmm0 # Return value (int case) + movq -136(%rbp), %xmm1 # Return value (int case) jmp .Lfinish .Lfloat: movlpd -144(%rbp), %xmm0 # Return value (float/double case) 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 d5c47f82a3f4..503ea07d01b5 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx @@ -74,8 +74,8 @@ static typelib_TypeClass cpp2uno_call( void ** gpreg, void ** fpreg, void ** ovrflw, sal_uInt64 * pRegisterReturn /* space for register return */ ) { - int nr_gpr = 0; //number of gpr registers used - int nr_fpr = 0; //number of fpr regsiters used + unsigned int nr_gpr = 0; //number of gpr registers used + unsigned int nr_fpr = 0; //number of fpr registers used // return typelib_TypeDescription * pReturnTypeDescr = 0; @@ -123,7 +123,10 @@ static typelib_TypeClass cpp2uno_call( int nUsedGPR = 0; int nUsedSSE = 0; - bool bFitsRegisters = x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); +#if OSL_DEBUG_LEVEL > 1 + bool bFitsRegisters = +#endif + x86_64::examine_argument( rParam.pTypeRef, false, nUsedGPR, nUsedSSE ); if ( !rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ) ) // value { // Simple types must fit exactly one register on x86_64 @@ -156,28 +159,7 @@ static typelib_TypeClass cpp2uno_call( else // struct <= 16 bytes || ptr to complex value || ref { void *pCppStack; - char pTmpStruct[16]; - - if ( bFitsRegisters && !rParam.bOut && - ( pParamTypeDescr->eTypeClass == typelib_TypeClass_STRUCT || - pParamTypeDescr->eTypeClass == typelib_TypeClass_EXCEPTION ) ) - { - if ( ( nr_gpr + nUsedGPR <= x86_64::MAX_GPR_REGS ) && ( nr_fpr + nUsedSSE <= x86_64::MAX_SSE_REGS ) ) - { - x86_64::fill_struct( rParam.pTypeRef, gpreg, fpreg, pTmpStruct ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "nUsedGPR == %d, nUsedSSE == %d, pTmpStruct[0] == 0x%x, pTmpStruct[1] == 0x%x, **gpreg == 0x%lx\n", - nUsedGPR, nUsedSSE, pTmpStruct[0], pTmpStruct[1], *(sal_uInt64*)*gpreg ); -#endif - - pCppArgs[nPos] = pCppStack = reinterpret_cast<void *>( pTmpStruct ); - gpreg += nUsedGPR; - fpreg += nUsedSSE; - } - else - pCppArgs[nPos] = pCppStack = *ovrflw++; - } - else if ( nr_gpr < x86_64::MAX_GPR_REGS ) + if ( nr_gpr < x86_64::MAX_GPR_REGS ) { pCppArgs[nPos] = pCppStack = *gpreg++; nr_gpr++; @@ -486,13 +468,12 @@ bridges::cpp_uno::shared::VtableFactory::initializeBlock( //================================================================================================== unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( - Slot ** slots, unsigned char * code, + Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff, typelib_InterfaceTypeDescription const * type, sal_Int32 nFunctionOffset, sal_Int32 functionCount, sal_Int32 nVtableOffset ) { (*slots) -= functionCount; Slot * s = *slots; - for ( sal_Int32 nPos = 0; nPos < type->nMembers; ++nPos ) { typelib_TypeDescription * pTD = 0; @@ -506,14 +487,14 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( reinterpret_cast<typelib_InterfaceAttributeTypeDescription *>( pTD ); // get method - (s++)->fn = code; + (s++)->fn = code + writetoexecdiff; code = codeSnippet( code, nFunctionOffset++, nVtableOffset, x86_64::return_in_hidden_param( pAttrTD->pAttributeTypeRef ) ); if ( ! pAttrTD->bReadOnly ) { // set method - (s++)->fn = code; + (s++)->fn = code + writetoexecdiff; code = codeSnippet( code, nFunctionOffset++, nVtableOffset, false ); } } @@ -522,7 +503,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( typelib_InterfaceMethodTypeDescription *pMethodTD = reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD ); - (s++)->fn = code; + (s++)->fn = code + writetoexecdiff; code = codeSnippet( code, nFunctionOffset++, nVtableOffset, x86_64::return_in_hidden_param( pMethodTD->pReturnTypeRef ) ); } diff --git a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx index a6ba69855a1c..4c53dcf333cd 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx @@ -29,6 +29,7 @@ #include "precompiled_bridges.hxx" #include <stdio.h> +#include <string.h> #include <dlfcn.h> #include <cxxabi.h> #include <hash_map> @@ -118,7 +119,7 @@ public: }; //__________________________________________________________________________________________________ RTTI::RTTI() SAL_THROW( () ) -#if __FreeBSD_version < 602103 +#if __FreeBSD_version < 702104 /* #i22253# */ : m_hApp( dlopen( 0, RTLD_NOW | RTLD_GLOBAL ) ) #else : m_hApp( dlopen( 0, RTLD_LAZY ) ) @@ -157,7 +158,7 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR buf.append( 'E' ); OString symName( buf.makeStringAndClear() ); -#if __FreeBSD_version < 602103 /* #i22253# */ +#if __FreeBSD_version < 702104 /* #i22253# */ rtti = (type_info *)dlsym( RTLD_DEFAULT, symName.getStr() ); #else rtti = (type_info *)dlsym( m_hApp, symName.getStr() ); @@ -172,8 +173,8 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR else { // try to lookup the symbol in the generated rtti map - t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) ); - if (iFind == m_generatedRttis.end()) + t_rtti_map::const_iterator iFind2( m_generatedRttis.find( unoName ) ); + if (iFind2 == m_generatedRttis.end()) { // we must generate it ! // symbol and rtti-name is nearly identical, @@ -202,7 +203,7 @@ type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THR } else // taking already generated rtti { - rtti = iFind->second; + rtti = iFind2->second; } } } 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 6da45f9fb8ce..6a9ab16845dc 100644 --- a/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx @@ -50,13 +50,13 @@ using namespace ::com::sun::star::uno; //================================================================================================== static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) __attribute__((noinline)); static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, - void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, + void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, sal_uInt32 nGPR, double *pFPR, sal_uInt32 nFPR) @@ -65,13 +65,13 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, // Let's figure out what is really going on here { fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR ); - for ( int i = 0; i < nGPR; ++i ) + for ( unsigned int i = 0; i < nGPR; ++i ) fprintf( stderr, "0x%lx, ", pGPR[i] ); fprintf( stderr, "\nFPR's (%d): ", nFPR ); - for ( int i = 0; i < nFPR; ++i ) + for ( unsigned int i = 0; i < nFPR; ++i ) fprintf( stderr, "%f, ", pFPR[i] ); fprintf( stderr, "\nStack (%d): ", nStack ); - for ( int i = 0; i < nStack; ++i ) + for ( unsigned int i = 0; i < nStack; ++i ) fprintf( stderr, "0x%lx, ", pStack[i] ); fprintf( stderr, "\n" ); } @@ -110,6 +110,7 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, sal_uInt64 rax; sal_uInt64 rdx; double xmm0; + double xmm1; asm volatile ( @@ -144,13 +145,14 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, "movq %%rax, %4\n\t" "movq %%rdx, %5\n\t" "movsd %%xmm0, %6\n\t" + "movsd %%xmm1, %7\n\t" : : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ), - "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ) + "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 ) : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11" ); - switch (pReturnTypeDescr->eTypeClass) + switch (pReturnTypeRef->eTypeClass) { case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: @@ -176,12 +178,17 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, break; default: { - sal_Int32 const nRetSize = pReturnTypeDescr->nSize; + sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize; if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) { - if (nRetSize > 8) - static_cast<sal_uInt64 *>(pRegisterReturn)[1] = rdx; - static_cast<sal_uInt64 *>(pRegisterReturn)[0] = rax; + sal_uInt64 longs[2]; + longs[0] = rax; + longs[1] = rdx; + + double doubles[2]; + doubles[0] = xmm0; + doubles[1] = xmm1; + x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); } break; } @@ -320,6 +327,8 @@ static void cpp_call( case typelib_TypeClass_DOUBLE: INSERT_FLOAT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack ); break; + default: + break; } // no longer needed @@ -362,7 +371,7 @@ static void cpp_call( { callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeDescr, bSimpleReturn, + pCppReturn, pReturnTypeRef, bSimpleReturn, pStackStart, ( pStack - pStackStart ), pGPR, nGPR, pFPR, nFPR ); @@ -432,16 +441,19 @@ void unoInterfaceProxyDispatch( // is my surrogate bridges::cpp_uno::shared::UnoInterfaceProxy * pThis = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); +#if OSL_DEBUG_LEVEL > 0 typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; +#endif switch (pMemberDescr->eTypeClass) { case typelib_TypeClass_INTERFACE_ATTRIBUTE: { +#if OSL_DEBUG_LEVEL > 0 // determine vtable call index sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); - +#endif VtableSlot aVtableSlot( getVtableSlot( reinterpret_cast< @@ -486,10 +498,11 @@ void unoInterfaceProxyDispatch( } case typelib_TypeClass_INTERFACE_METHOD: { +#if OSL_DEBUG_LEVEL > 0 // determine vtable call index sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); - +#endif VtableSlot aVtableSlot( getVtableSlot( reinterpret_cast< |