michael@0: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* Implement shared vtbl methods. */ michael@0: michael@0: #include "xptcprivate.h" michael@0: #include "xptiprivate.h" michael@0: michael@0: static nsresult ATTRIBUTE_USED michael@0: PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, michael@0: uint32_t* a_gpr, uint64_t *a_fpr, uint32_t *a_ov) michael@0: { michael@0: #define PARAM_BUFFER_COUNT 16 michael@0: michael@0: nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; michael@0: nsXPTCMiniVariant* dispatchParams = nullptr; michael@0: const nsXPTMethodInfo* info; michael@0: uint8_t paramCount; michael@0: uint8_t i; michael@0: nsresult result = NS_ERROR_FAILURE; michael@0: michael@0: NS_ASSERTION(self,"no self"); michael@0: michael@0: self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info); michael@0: NS_ASSERTION(info,"no info"); michael@0: michael@0: paramCount = info->GetParamCount(); michael@0: michael@0: // setup variant array pointer michael@0: if(paramCount > PARAM_BUFFER_COUNT) michael@0: dispatchParams = new nsXPTCMiniVariant[paramCount]; michael@0: else michael@0: dispatchParams = paramBuffer; michael@0: NS_ASSERTION(dispatchParams,"no place for params"); michael@0: michael@0: uint32_t gpr = 1, fpr = 0; michael@0: michael@0: for(i = 0; i < paramCount; i++) michael@0: { michael@0: const nsXPTParamInfo& param = info->GetParam(i); michael@0: const nsXPTType& type = param.GetType(); michael@0: nsXPTCMiniVariant* dp = &dispatchParams[i]; michael@0: michael@0: if(param.IsOut() || !type.IsArithmetic()) michael@0: { michael@0: if (gpr < 5) michael@0: dp->val.p = (void*) *a_gpr++, gpr++; michael@0: else michael@0: dp->val.p = (void*) *a_ov++; michael@0: continue; michael@0: } michael@0: // else michael@0: switch(type) michael@0: { michael@0: case nsXPTType::T_I8 : michael@0: if (gpr < 5) michael@0: dp->val.i8 = *((int32_t*) a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.i8 = *((int32_t*) a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_I16 : michael@0: if (gpr < 5) michael@0: dp->val.i16 = *((int32_t*) a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.i16 = *((int32_t*) a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_I32 : michael@0: if (gpr < 5) michael@0: dp->val.i32 = *((int32_t*) a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.i32 = *((int32_t*) a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_I64 : michael@0: if (gpr < 4) michael@0: dp->val.i64 = *((int64_t*) a_gpr), a_gpr+=2, gpr+=2; michael@0: else michael@0: dp->val.i64 = *((int64_t*) a_ov ), a_ov+=2, gpr=5; michael@0: break; michael@0: case nsXPTType::T_U8 : michael@0: if (gpr < 5) michael@0: dp->val.u8 = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.u8 = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_U16 : michael@0: if (gpr < 5) michael@0: dp->val.u16 = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.u16 = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_U32 : michael@0: if (gpr < 5) michael@0: dp->val.u32 = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.u32 = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_U64 : michael@0: if (gpr < 4) michael@0: dp->val.u64 = *((uint64_t*)a_gpr), a_gpr+=2, gpr+=2; michael@0: else michael@0: dp->val.u64 = *((uint64_t*)a_ov ), a_ov+=2, gpr=5; michael@0: break; michael@0: case nsXPTType::T_FLOAT : michael@0: if (fpr < 2) michael@0: dp->val.f = *((float*) a_fpr), a_fpr++, fpr++; michael@0: else michael@0: dp->val.f = *((float*) a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_DOUBLE : michael@0: if (fpr < 2) michael@0: dp->val.d = *((double*) a_fpr), a_fpr++, fpr++; michael@0: else michael@0: dp->val.d = *((double*) a_ov ), a_ov+=2; michael@0: break; michael@0: case nsXPTType::T_BOOL : michael@0: if (gpr < 5) michael@0: dp->val.b = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.b = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_CHAR : michael@0: if (gpr < 5) michael@0: dp->val.c = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.c = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: case nsXPTType::T_WCHAR : michael@0: if (gpr < 5) michael@0: dp->val.wc = *((uint32_t*)a_gpr), a_gpr++, gpr++; michael@0: else michael@0: dp->val.wc = *((uint32_t*)a_ov ), a_ov++; michael@0: break; michael@0: default: michael@0: NS_ERROR("bad type"); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); michael@0: michael@0: if(dispatchParams != paramBuffer) michael@0: delete [] dispatchParams; michael@0: michael@0: return result; michael@0: } michael@0: michael@0: #define STUB_ENTRY(n) \ michael@0: nsresult nsXPTCStubBase::Stub##n() \ michael@0: { \ michael@0: uint32_t a_gpr[4]; \ michael@0: uint64_t a_fpr[2]; \ michael@0: uint32_t *a_ov; \ michael@0: \ michael@0: __asm__ __volatile__ \ michael@0: ( \ michael@0: "l %0,0(15)\n\t" \ michael@0: "ahi %0,96\n\t" \ michael@0: "stm 3,6,0(%3)\n\t" \ michael@0: "std 0,%1\n\t" \ michael@0: "std 2,%2\n\t" \ michael@0: : "=&a" (a_ov), \ michael@0: "=m" (a_fpr[0]), \ michael@0: "=m" (a_fpr[1]) \ michael@0: : "a" (a_gpr) \ michael@0: : "memory", "cc", \ michael@0: "3", "4", "5", "6" \ michael@0: ); \ michael@0: \ michael@0: return PrepareAndDispatch(this, n, a_gpr, a_fpr, a_ov); \ michael@0: } michael@0: michael@0: #define SENTINEL_ENTRY(n) \ michael@0: nsresult nsXPTCStubBase::Sentinel##n() \ michael@0: { \ michael@0: NS_ERROR("nsXPTCStubBase::Sentinel called"); \ michael@0: return NS_ERROR_NOT_IMPLEMENTED; \ michael@0: } michael@0: michael@0: #include "xptcstubsdef.inc" michael@0: