Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
xptcstubs_x86_64_linux.cpp File Reference
#include "xptcprivate.h"

Go to the source code of this file.


nsresult PrepareAndDispatch (nsXPTCStubBase *self, PRUint32 methodIndex, PRUint64 *args, PRUint64 *gpregs, double *fpregs)


const PRUint32 PARAM_BUFFER_COUNT = 16
const PRUint32 GPR_COUNT = 6
const PRUint32 FPR_COUNT = 8

Function Documentation

nsresult PrepareAndDispatch ( nsXPTCStubBase *  self,
PRUint32  methodIndex,
PRUint64 args,
PRUint64 gpregs,
double *  fpregs 

Definition at line 63 of file xptcstubs_x86_64_linux.cpp.

    nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    nsXPTCMiniVariant* dispatchParams = NULL;
    nsIInterfaceInfo* iface_info = NULL;
    const nsXPTMethodInfo* info;
    PRUint32 paramCount;
    PRUint32 i;
    nsresult result = NS_ERROR_FAILURE;

    NS_ASSERTION(self,"no self");

    NS_ASSERTION(iface_info,"no interface info");
    if (!iface_info)
        return NS_ERROR_UNEXPECTED;

    iface_info->GetMethodInfo(PRUint16(methodIndex), &info);
    NS_ASSERTION(info,"no method info");
    if (!info)
        return NS_ERROR_UNEXPECTED;

    paramCount = info->GetParamCount();

    // setup variant array pointer
    if (paramCount > PARAM_BUFFER_COUNT)
        dispatchParams = new nsXPTCMiniVariant[paramCount];
        dispatchParams = paramBuffer;

    NS_ASSERTION(dispatchParams,"no place for params");
    if (!dispatchParams)
        return NS_ERROR_OUT_OF_MEMORY;

    PRUint64* ap = args;
    PRUint32 nr_gpr = 1;    // skip one GPR register for 'that'
    PRUint32 nr_fpr = 0;
    PRUint64 value;

    for (i = 0; i < paramCount; i++) {
        const nsXPTParamInfo& param = info->GetParam(i);
        const nsXPTType& type = param.GetType();
        nsXPTCMiniVariant* dp = &dispatchParams[i];
        if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
            if (nr_fpr < FPR_COUNT)
                dp->val.d = fpregs[nr_fpr++];
                dp->val.d = *(double*) ap++;
        else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
            if (nr_fpr < FPR_COUNT)
                // The value in %xmm register is already prepared to
                // be retrieved as a float. Therefore, we pass the
                // value verbatim, as a double without conversion.
                dp->val.d = *(double*) ap++;
                dp->val.f = *(float*) ap++;
        else {
            if (nr_gpr < GPR_COUNT)
                value = gpregs[nr_gpr++];
                value = *ap++;

        if (param.IsOut() || !type.IsArithmetic()) {
            dp->val.p = (void*) value;

        switch (type) {
        case nsXPTType::T_I8:      dp->val.i8  = (PRInt8)   value; break;
        case nsXPTType::T_I16:     dp->val.i16 = (PRInt16)  value; break;
        case nsXPTType::T_I32:     dp->val.i32 = (PRInt32)  value; break;
        case nsXPTType::T_I64:     dp->val.i64 = (PRInt64)  value; break;
        case nsXPTType::T_U8:      dp->val.u8  = (PRUint8)  value; break;
        case nsXPTType::T_U16:     dp->val.u16 = (PRUint16) value; break;
        case nsXPTType::T_U32:     dp->val.u32 = (PRUint32) value; break;
        case nsXPTType::T_U64:     dp->val.u64 = (PRUint64) value; break;
        case nsXPTType::T_BOOL:    dp->val.b   = (PRBool)   value; break;
        case nsXPTType::T_CHAR:    dp->val.c   = (char)     value; break;
        case nsXPTType::T_WCHAR:   dp->val.wc  = (wchar_t)  value; break;

            NS_ASSERTION(0, "bad type");

    result = self->CallMethod((PRUint16) methodIndex, info, dispatchParams);


    if (dispatchParams != paramBuffer)
        delete [] dispatchParams;

    return result;

Here is the call graph for this function:

Variable Documentation

Definition at line 51 of file xptcstubs_x86_64_linux.cpp.

Definition at line 50 of file xptcstubs_x86_64_linux.cpp.

Definition at line 49 of file xptcstubs_x86_64_linux.cpp.