catch up to recent bridge also fixes following issues for amd64 http://www.openoffice.org/issues/show_bug.cgi?id=98781 http://www.openoffice.org/issues/show_bug.cgi?id=82690 http://www.freebsd.org/cgi/query-pr.cgi?pr=127946 We also need #define USE_DOUBLE_MMAP for FreeBSD as well. It's very hard to maintain without it, and performance loss is negligible. See also http://www.openoffice.org/issues/show_bug.cgi?id=97320 . Note that i386 also requires the patch for "bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx" . --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.cxx 2009-12-06 13:19:58.000000000 +0900 @@ -229,6 +229,7 @@ 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 ); @@ -243,9 +244,6 @@ 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 ); @@ -332,7 +330,7 @@ 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; @@ -346,12 +344,14 @@ { case X86_64_INTEGER_CLASS: case X86_64_INTEGERSI_CLASS: - *pStructAlign++ = *reinterpret_cast( *pGPR++ ); + *pStructAlign++ = *pGPR++; break; case X86_64_SSE_CLASS: case X86_64_SSESF_CLASS: case X86_64_SSEDF_CLASS: - *pStructAlign++ = *reinterpret_cast( *pSSE++ ); + *pStructAlign++ = *reinterpret_cast( pSSE++ ); + break; + default: break; } } --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/abi.hxx 2009-12-06 13:19:58.000000000 +0900 @@ -63,7 +63,7 @@ */ 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 --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/call.s 2009-12-06 13:19:58.000000000 +0900 @@ -43,6 +43,9 @@ 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) --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/cpp2uno.cxx 2009-12-06 13:19:58.000000000 +0900 @@ -77,8 +77,8 @@ 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; @@ -126,7 +126,10 @@ 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 @@ -159,28 +162,7 @@ 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( 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++; @@ -489,13 +471,12 @@ //================================================================================================== 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; @@ -509,14 +490,14 @@ reinterpret_cast( 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 ); } } @@ -525,7 +506,7 @@ typelib_InterfaceMethodTypeDescription *pMethodTD = reinterpret_cast( pTD ); - (s++)->fn = code; + (s++)->fn = code + writetoexecdiff; code = codeSnippet( code, nFunctionOffset++, nVtableOffset, x86_64::return_in_hidden_param( pMethodTD->pReturnTypeRef ) ); } --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/except.cxx 2009-12-06 13:19:58.000000000 +0900 @@ -32,6 +32,7 @@ #include "precompiled_bridges.hxx" #include +#include #include #include #include @@ -121,7 +121,7 @@ }; //__________________________________________________________________________________________________ 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 ) ) @@ -160,7 +160,7 @@ 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() ); @@ -175,8 +167,8 @@ 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, @@ -205,7 +197,7 @@ } else // taking already generated rtti { - rtti = iFind->second; + rtti = iFind2->second; } } } --- bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx 2009-12-12 18:15:33.000000000 +0900 +++ bridges/source/cpp_uno/gcc3_freebsd_x86-64/uno2cpp.cxx 2009-12-06 13:19:58.000000000 +0900 @@ -53,13 +53,13 @@ //================================================================================================== 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) @@ -68,13 +68,13 @@ // 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" ); } @@ -113,6 +113,7 @@ sal_uInt64 rax; sal_uInt64 rdx; double xmm0; + double xmm1; asm volatile ( @@ -147,13 +148,14 @@ "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: @@ -179,12 +181,17 @@ 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(pRegisterReturn)[1] = rdx; - static_cast(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; } @@ -323,6 +330,8 @@ case typelib_TypeClass_DOUBLE: INSERT_FLOAT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack ); break; + default: + break; } // no longer needed @@ -365,7 +374,7 @@ { callVirtualMethod( pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeDescr, bSimpleReturn, + pCppReturn, pReturnTypeRef, bSimpleReturn, pStackStart, ( pStack - pStackStart ), pGPR, nGPR, pFPR, nFPR ); @@ -435,16 +444,19 @@ // 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< @@ -489,10 +501,11 @@ } 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< --- bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx~ 2009-06-13 16:41:45.000000000 +0900 +++ bridges/inc/bridges/cpp_uno/shared/vtablefactory.hxx 2009-06-13 16:42:24.000000000 +0900 @@ -40,7 +40,7 @@ #include /*See: http://people.redhat.com/drepper/selinux-mem.html*/ -#ifdef LINUX +#if defined (LINUX) || defined (FREEBSD) #define USE_DOUBLE_MMAP #endif