Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 664058 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-23 / +69 lines)
Line  Link Here
0
-- a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.hxx
0
++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.hxx
Lines 24-32 Link Here
24
24
25
#include <sal/types.h>
25
#include <sal/types.h>
26
26
27
namespace x86_64
28
{
29
    union funArg
30
    {
31
        sal_uInt64 val;
32
        void * p;
33
34
        operator sal_uInt64() const noexcept { return val; }
35
        template <typename T>
36
        operator T *() const noexcept { return static_cast<T *>( p ); }
37
    };
38
} // namespace x86_64
39
27
extern "C" typelib_TypeClass cpp_vtable_call(
40
extern "C" typelib_TypeClass cpp_vtable_call(
28
    sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
41
    sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
29
    void ** gpreg, void ** fpreg, void ** ovrflw,
42
    x86_64::funArg * gpreg, x86_64::funArg * fpreg, x86_64::funArg * ovrflw,
30
    sal_uInt64 * pRegisterReturn /* space for register return */ );
43
    sal_uInt64 * pRegisterReturn /* space for register return */ );
31
44
32
#endif
45
#endif
33
-- a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx
46
++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx
Lines 54-78 Link Here
54
    // registers than available" error:
54
    // registers than available" error:
55
    struct Data {
55
    struct Data {
56
        sal_uInt64 pMethod;
56
        sal_uInt64 pMethod;
57
        sal_uInt64 * pStack;
57
        sal_uInt64 pStack;
58
        sal_uInt32 nStack;
58
        sal_uInt64 nStack;
59
        sal_uInt64 * pGPR;
59
        sal_uInt64 pGPR;
60
        double * pFPR;
60
        sal_uInt64 pFPR;
61
        // Return values:
61
        // Return values:
62
        sal_uInt64 rax;
62
        sal_uInt64 rax;
63
        sal_uInt64 rdx;
63
        sal_uInt64 rdx;
64
        double xmm0;
64
        double xmm0;
65
        double xmm1;
65
        double xmm1;
66
    } data;
66
    } data;
67
    data.pStack = pStack;
67
    data.pStack = reinterpret_cast<sal_uIntPtr>(pStack);
68
    data.nStack = nStack;
68
    data.nStack = nStack;
69
    data.pGPR = pGPR;
69
    data.pGPR = reinterpret_cast<sal_uIntPtr>(pGPR);
70
    data.pFPR = pFPR;
70
    data.pFPR = reinterpret_cast<sal_uIntPtr>(pFPR);
71
71
72
    // Get pointer to method
72
    // Get pointer to method
73
    sal_uInt64 pMethod = *static_cast<sal_uInt64 *>(pThis);
73
    sal_uIntPtr pMethod = *static_cast<sal_uIntPtr *>(pThis);
74
    pMethod += 8 * nVtableIndex;
74
    pMethod += sizeof(void *) * nVtableIndex;
75
    data.pMethod = *reinterpret_cast<sal_uInt64 *>(pMethod);
75
    data.pMethod = *reinterpret_cast<sal_uIntPtr *>(pMethod);
76
76
77
    asm volatile (
77
    asm volatile (
78
        // Push arguments to stack
78
        // Push arguments to stack
79
-- a/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx
79
++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/cpp2uno.cxx
Lines 59-65 Link Here
59
    const typelib_TypeDescription * pMemberTypeDescr,
59
    const typelib_TypeDescription * pMemberTypeDescr,
60
    typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
60
    typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
61
    sal_Int32 nParams, typelib_MethodParameter * pParams,
61
    sal_Int32 nParams, typelib_MethodParameter * pParams,
62
    void ** gpreg, void ** fpreg, void ** ovrflw,
62
    x86_64::funArg * gpreg, x86_64::funArg * fpreg, x86_64::funArg * ovrflw,
63
    sal_uInt64 * pRegisterReturn /* space for register return */ )
63
    sal_uInt64 * pRegisterReturn /* space for register return */ )
64
{
64
{
65
    unsigned int nr_gpr = 0; //number of gpr registers used
65
    unsigned int nr_gpr = 0; //number of gpr registers used
Lines 233-239 Link Here
233
                uno_destructData( pUnoReturn, pReturnTypeDescr, nullptr );
233
                uno_destructData( pUnoReturn, pReturnTypeDescr, nullptr );
234
            }
234
            }
235
            // complex return ptr is set to return reg
235
            // complex return ptr is set to return reg
236
            *reinterpret_cast<void **>(pRegisterReturn) = pCppReturn;
236
            *pRegisterReturn = reinterpret_cast<sal_uIntPtr>( pCppReturn );
237
        }
237
        }
238
        if ( pReturnTypeDescr )
238
        if ( pReturnTypeDescr )
239
        {
239
        {
Lines 249-255 Link Here
249
249
250
typelib_TypeClass cpp_vtable_call(
250
typelib_TypeClass cpp_vtable_call(
251
    sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
251
    sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
252
    void ** gpreg, void ** fpreg, void ** ovrflw,
252
    x86_64::funArg * gpreg, x86_64::funArg * fpreg, x86_64::funArg * ovrflw,
253
    sal_uInt64 * pRegisterReturn /* space for register return */ )
253
    sal_uInt64 * pRegisterReturn /* space for register return */ )
254
{
254
{
255
    // gpreg:  [ret *], this, [other gpr params]
255
    // gpreg:  [ret *], this, [other gpr params]
Lines 356-362 Link Here
356
                            pInterface->release();
356
                            pInterface->release();
357
                            TYPELIB_DANGER_RELEASE( pTD );
357
                            TYPELIB_DANGER_RELEASE( pTD );
358
358
359
                            reinterpret_cast<void **>( pRegisterReturn )[0] = gpreg[0];
359
                            *pRegisterReturn = gpreg[0];
360
                            eRet = typelib_TypeClass_ANY;
360
                            eRet = typelib_TypeClass_ANY;
361
                            break;
361
                            break;
362
                        }
362
                        }
Lines 388-394 Link Here
388
    return eRet;
388
    return eRet;
389
}
389
}
390
390
391
const int codeSnippetSize = 24;
391
const int codeSnippetSize = sizeof(void *) == 8 ? 24 : 16;
392
392
393
// Generate a trampoline that redirects method calls to
393
// Generate a trampoline that redirects method calls to
394
// privateSnippetExecutor().
394
// privateSnippetExecutor().
Lines 400-406 Link Here
400
// Note: The code snippet we build here must not create a stack frame,
400
// Note: The code snippet we build here must not create a stack frame,
401
// otherwise the UNO exceptions stop working thanks to non-existing
401
// otherwise the UNO exceptions stop working thanks to non-existing
402
// unwinding info.
402
// unwinding info.
403
#ifdef __ILP32__
404
unsigned char * codeSnippet( unsigned char * code, sal_PtrDiff writetoexecdiff,
405
#else
403
unsigned char * codeSnippet( unsigned char * code,
406
unsigned char * codeSnippet( unsigned char * code,
407
#endif
404
        sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
408
        sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
405
        bool bHasHiddenParam )
409
        bool bHasHiddenParam )
406
{
410
{
Lines 415-420 Link Here
415
    *reinterpret_cast<sal_uInt32 *>( code + 4 ) = nOffsetAndIndex >> 16;
419
    *reinterpret_cast<sal_uInt32 *>( code + 4 ) = nOffsetAndIndex >> 16;
416
    *reinterpret_cast<sal_uInt16 *>( code + 8 ) = nOffsetAndIndex >> 48;
420
    *reinterpret_cast<sal_uInt16 *>( code + 8 ) = nOffsetAndIndex >> 48;
417
421
422
#ifdef __ILP32__
423
    // addr32 jmp privateSnippetExecutor(%rip)
424
    *reinterpret_cast<sal_uInt16 *>( code + 10 ) = 0xe967;
425
    *reinterpret_cast<sal_uInt32 *>( code + 12 )
426
        = reinterpret_cast<sal_uInt32>( privateSnippetExecutor )
427
        - reinterpret_cast<sal_uInt32>( code ) - 16ul - writetoexecdiff;
428
#else
418
    // movq $<address of the privateSnippetExecutor>, %r11
429
    // movq $<address of the privateSnippetExecutor>, %r11
419
    *reinterpret_cast<sal_uInt16 *>( code + 10 ) = 0xbb49;
430
    *reinterpret_cast<sal_uInt16 *>( code + 10 ) = 0xbb49;
420
    *reinterpret_cast<sal_uInt32 *>( code + 12 )
431
    *reinterpret_cast<sal_uInt32 *>( code + 12 )
Lines 424-429 Link Here
424
435
425
    // jmpq *%r11
436
    // jmpq *%r11
426
    *reinterpret_cast<sal_uInt32 *>( code + 20 ) = 0x00e3ff49;
437
    *reinterpret_cast<sal_uInt32 *>( code + 20 ) = 0x00e3ff49;
438
#endif
427
439
428
#if OSL_DEBUG_LEVEL > 1
440
#if OSL_DEBUG_LEVEL > 1
429
    fprintf(stderr,
441
    fprintf(stderr,
Lines 486-499 Link Here
486
498
487
            // get method
499
            // get method
488
            (s++)->fn = code + writetoexecdiff;
500
            (s++)->fn = code + writetoexecdiff;
501
#ifdef __ILP32__
502
            code = codeSnippet( code, writetoexecdiff, nFunctionOffset++, nVtableOffset,
503
#else
489
            code = codeSnippet( code, nFunctionOffset++, nVtableOffset,
504
            code = codeSnippet( code, nFunctionOffset++, nVtableOffset,
505
#endif
490
                                x86_64::return_in_hidden_param( pAttrTD->pAttributeTypeRef ) );
506
                                x86_64::return_in_hidden_param( pAttrTD->pAttributeTypeRef ) );
491
507
492
            if ( ! pAttrTD->bReadOnly )
508
            if ( ! pAttrTD->bReadOnly )
493
            {
509
            {
494
                // set method
510
                // set method
495
                (s++)->fn = code + writetoexecdiff;
511
                (s++)->fn = code + writetoexecdiff;
512
#ifdef __ILP32__
513
                code = codeSnippet( code, writetoexecdiff, nFunctionOffset++, nVtableOffset, false );
514
#else
496
                code = codeSnippet( code, nFunctionOffset++, nVtableOffset, false );
515
                code = codeSnippet( code, nFunctionOffset++, nVtableOffset, false );
516
#endif
497
            }
517
            }
498
        }
518
        }
499
        else if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_METHOD )
519
        else if ( pTD->eTypeClass == typelib_TypeClass_INTERFACE_METHOD )
Lines 502-508 Link Here
502
                reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD );
522
                reinterpret_cast<typelib_InterfaceMethodTypeDescription *>( pTD );
503
523
504
            (s++)->fn = code + writetoexecdiff;
524
            (s++)->fn = code + writetoexecdiff;
525
#ifdef __ILP32__
526
            code = codeSnippet( code, writetoexecdiff, nFunctionOffset++, nVtableOffset,
527
#else
505
            code = codeSnippet( code, nFunctionOffset++, nVtableOffset,
528
            code = codeSnippet( code, nFunctionOffset++, nVtableOffset,
529
#endif
506
                                x86_64::return_in_hidden_param( pMethodTD->pReturnTypeRef ) );
530
                                x86_64::return_in_hidden_param( pMethodTD->pReturnTypeRef ) );
507
        }
531
        }
508
        else
532
        else
509
-- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
533
++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
Lines 68-73 Link Here
68
        *pDS++ = *static_cast<sal_uInt64 const *>( pSV );
68
        *pDS++ = *static_cast<sal_uInt64 const *>( pSV );
69
}
69
}
70
70
71
void INSERT_PTR(
72
    void const * pSV, sal_uInt32 & nr, sal_uInt64 * pGPR, sal_uInt64 *& pDS)
73
{
74
    if ( nr < x86_64::MAX_GPR_REGS )
75
        pGPR[nr++] = *static_cast<sal_uIntPtr const *>( pSV );
76
    else
77
        *pDS++ = *static_cast<sal_uIntPtr const *>( pSV );
78
}
79
71
void INSERT_INT32(
80
void INSERT_INT32(
72
    void const * pSV, sal_uInt32 & nr, sal_uInt64 * pGPR, sal_uInt64 *& pDS)
81
    void const * pSV, sal_uInt32 & nr, sal_uInt64 * pGPR, sal_uInt64 *& pDS)
73
{
82
{
Lines 135-147 Link Here
135
            // complex return via ptr
144
            // complex return via ptr
136
            pCppReturn = bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )?
145
            pCppReturn = bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )?
137
                         __builtin_alloca( pReturnTypeDescr->nSize ) : pUnoReturn;
146
                         __builtin_alloca( pReturnTypeDescr->nSize ) : pUnoReturn;
138
            INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack );
147
            INSERT_PTR( &pCppReturn, nGPR, pGPR, pStack );
139
        }
148
        }
140
    }
149
    }
141
150
142
    // Push "this" pointer
151
    // Push "this" pointer
143
    void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
152
    void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
144
    INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack );
153
    INSERT_PTR( &pAdjustedThisPtr, nGPR, pGPR, pStack );
145
154
146
    // Args
155
    // Args
147
    void ** pCppArgs = static_cast<void **>(alloca( 3 * sizeof(void *) * nParams ));
156
    void ** pCppArgs = static_cast<void **>(alloca( 3 * sizeof(void *) * nParams ));
Lines 223-229 Link Here
223
                // no longer needed
232
                // no longer needed
224
                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
233
                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
225
            }
234
            }
226
            INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack );
235
            INSERT_PTR( &(pCppArgs[nPos]), nGPR, pGPR, pStack );
227
        }
236
        }
228
    }
237
    }
229
238

Return to bug 664058