Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
xptcstubs_ppc_linux.cpp File Reference
#include "xptcprivate.h"
#include "xptcstubsdef.inc"

Go to the source code of this file.

Defines

#define PARAM_BUFFER_COUNT   16
#define GPR_COUNT   8
#define FPR_COUNT   8
#define STUB_ENTRY(n)
#define SENTINEL_ENTRY(n)

Functions

nsresult PrepareAndDispatch (nsXPTCStubBase *self, PRUint32 methodIndex, PRUint32 *args, PRUint32 *gprData, double *fprData)

Define Documentation

#define FPR_COUNT   8

Definition at line 54 of file xptcstubs_ppc_linux.cpp.

#define GPR_COUNT   8

Definition at line 53 of file xptcstubs_ppc_linux.cpp.

Definition at line 52 of file xptcstubs_ppc_linux.cpp.

Value:
nsresult nsXPTCStubBase::Sentinel##n()               \
{                                                    \
  NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
  return NS_ERROR_NOT_IMPLEMENTED;                   \
}

Definition at line 246 of file xptcstubs_ppc_linux.cpp.

Value:
__asm__ (                                                   \
        ".section \".text\" \n\t"                           \
        ".align 2 \n\t"                                     \
       ".globl  Stub"#n"__14nsXPTCStubBase \n\t"           \
       ".type   Stub"#n"__14nsXPTCStubBase,@function \n\n" \
                                                            \
"Stub"#n"__14nsXPTCStubBase: \n\t"                          \
       "li     11,"#n" \n\t"                               \
       "b      SharedStub@local \n"                        \
);

Definition at line 194 of file xptcstubs_ppc_linux.cpp.


Function Documentation

nsresult PrepareAndDispatch ( nsXPTCStubBase *  self,
PRUint32  methodIndex,
PRUint32 args,
PRUint32 gprData,
double *  fprData 
)

Definition at line 66 of file xptcstubs_ppc_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");

    self->GetInterfaceInfo(&iface_info);
    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];
    else
        dispatchParams = paramBuffer;

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

    PRUint32* ap = args;
    PRUint32 gpr = 1;    // skip one GPR register
    PRUint32 fpr = 0;
    PRUint32 tempu32;
    PRUint64 tempu64;

    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 (fpr < FPR_COUNT)
                dp->val.d = fprData[fpr++];
            else {
                if ((PRUint32) ap & 4) ap++; // doubles are 8-byte aligned on stack
                dp->val.d = *(double*) ap;
                ap += 2;
            }
            continue;
        }
        else if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
            if (fpr < FPR_COUNT)
                dp->val.f = (float) fprData[fpr++]; // in registers floats are passed as doubles
            else
                dp->val.f = *(float*) ap++;
            continue;
        }
        else if (!param.IsOut() && (type == nsXPTType::T_I64
                                    || type == nsXPTType::T_U64)) {
            if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
            if ((gpr + 1) < GPR_COUNT) {
                tempu64 = *(PRUint64*) &gprData[gpr];
                gpr += 2;
            }
            else {
                if ((PRUint32) ap & 4) ap++; // longlongs are 8-byte aligned on stack
                tempu64 = *(PRUint64*) ap;
                ap += 2;
            }
        }
        else {
            if (gpr < GPR_COUNT)
                tempu32 = gprData[gpr++];
            else
                tempu32 = *ap++;
        }

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

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

        default:
            NS_ASSERTION(0, "bad type");
            break;
        }
    }

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

    NS_RELEASE(iface_info);

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

    return result;
}

Here is the call graph for this function: