2003-01-28 00:52:52 +03:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-01-28 00:52:52 +03:00
|
|
|
|
|
|
|
/* Implement shared vtbl methods. */
|
|
|
|
|
|
|
|
#include "xptcprivate.h"
|
|
|
|
|
2014-01-18 01:17:20 +04:00
|
|
|
static nsresult ATTRIBUTE_USED
|
2017-07-06 15:00:35 +03:00
|
|
|
PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t* a_gpr, uint64_t *a_fpr, uint64_t *a_ov)
|
2003-01-28 00:52:52 +03:00
|
|
|
{
|
|
|
|
#define PARAM_BUFFER_COUNT 16
|
|
|
|
|
|
|
|
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
2013-10-11 00:42:16 +04:00
|
|
|
nsXPTCMiniVariant* dispatchParams = nullptr;
|
2003-01-28 00:52:52 +03:00
|
|
|
const nsXPTMethodInfo* info;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t paramCount;
|
|
|
|
uint8_t i;
|
2003-01-28 00:52:52 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(self,"no self");
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
|
2008-01-20 00:09:25 +03:00
|
|
|
NS_ASSERTION(info,"no info");
|
2003-01-28 00:52:52 +03:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2018-07-17 19:11:03 +03:00
|
|
|
const uint8_t indexOfJSContext = info->IndexOfJSContext();
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t gpr = 1, fpr = 0;
|
2003-01-28 00:52:52 +03:00
|
|
|
|
|
|
|
for(i = 0; i < paramCount; i++)
|
|
|
|
{
|
|
|
|
const nsXPTParamInfo& param = info->GetParam(i);
|
|
|
|
const nsXPTType& type = param.GetType();
|
|
|
|
nsXPTCMiniVariant* dp = &dispatchParams[i];
|
|
|
|
|
2018-07-17 19:11:03 +03:00
|
|
|
if (i == indexOfJSContext) {
|
|
|
|
if (gpr < 5)
|
|
|
|
a_gpr++, gpr++;
|
|
|
|
else
|
|
|
|
a_ov++;
|
|
|
|
}
|
|
|
|
|
2003-01-28 00:52:52 +03:00
|
|
|
if(param.IsOut() || !type.IsArithmetic())
|
|
|
|
{
|
|
|
|
if (gpr < 5)
|
|
|
|
dp->val.p = (void*) *a_gpr++, gpr++;
|
|
|
|
else
|
|
|
|
dp->val.p = (void*) *a_ov++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// else
|
|
|
|
switch(type)
|
|
|
|
{
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_I8 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i8 = *((int64_t*) a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i8 = *((int64_t*) a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_I16 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i16 = *((int64_t*) a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i16 = *((int64_t*) a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_I32 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i32 = *((int64_t*) a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i32 = *((int64_t*) a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_I64 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i64 = *((int64_t*) a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.i64 = *((int64_t*) a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_U8 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u8 = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u8 = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_U16 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u16 = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u16 = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_U32 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u32 = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u32 = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_U64 :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u64 = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.u64 = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_FLOAT :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (fpr < 4)
|
|
|
|
dp->val.f = *((float*) a_fpr), a_fpr++, fpr++;
|
|
|
|
else
|
|
|
|
dp->val.f = *(((float*) a_ov )+1), a_ov++;
|
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_DOUBLE :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (fpr < 4)
|
|
|
|
dp->val.d = *((double*) a_fpr), a_fpr++, fpr++;
|
|
|
|
else
|
|
|
|
dp->val.d = *((double*) a_ov ), a_ov++;
|
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_BOOL :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.b = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.b = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_CHAR :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.c = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.c = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
2017-07-06 15:00:35 +03:00
|
|
|
case nsXPTType::T_WCHAR :
|
2003-01-28 00:52:52 +03:00
|
|
|
if (gpr < 5)
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.wc = *((uint64_t*)a_gpr), a_gpr++, gpr++;
|
2003-01-28 00:52:52 +03:00
|
|
|
else
|
2012-08-22 19:56:38 +04:00
|
|
|
dp->val.wc = *((uint64_t*)a_ov ), a_ov++;
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
|
|
|
default:
|
2009-08-14 18:09:00 +04:00
|
|
|
NS_ERROR("bad type");
|
2003-01-28 00:52:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-19 13:36:42 +03:00
|
|
|
nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info,
|
|
|
|
dispatchParams);
|
2003-01-28 00:52:52 +03:00
|
|
|
|
|
|
|
if(dispatchParams != paramBuffer)
|
|
|
|
delete [] dispatchParams;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define STUB_ENTRY(n) \
|
|
|
|
nsresult nsXPTCStubBase::Stub##n() \
|
|
|
|
{ \
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t a_gpr[4]; \
|
|
|
|
uint64_t a_fpr[4]; \
|
|
|
|
uint64_t *a_ov; \
|
2003-01-28 00:52:52 +03:00
|
|
|
\
|
|
|
|
__asm__ __volatile__ \
|
|
|
|
( \
|
2005-01-14 02:13:49 +03:00
|
|
|
"lg %0,0(15)\n\t" \
|
2003-01-28 00:52:52 +03:00
|
|
|
"aghi %0,160\n\t" \
|
|
|
|
"stmg 3,6,0(%5)\n\t"\
|
|
|
|
"std 0,%1\n\t" \
|
|
|
|
"std 2,%2\n\t" \
|
|
|
|
"std 4,%3\n\t" \
|
|
|
|
"std 6,%4\n\t" \
|
|
|
|
: "=&a" (a_ov), \
|
|
|
|
"=m" (a_fpr[0]), \
|
|
|
|
"=m" (a_fpr[1]), \
|
|
|
|
"=m" (a_fpr[2]), \
|
|
|
|
"=m" (a_fpr[3]) \
|
|
|
|
: "a" (a_gpr) \
|
|
|
|
: "memory", "cc", \
|
|
|
|
"3", "4", "5", "6" \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
return PrepareAndDispatch(this, n, a_gpr, a_fpr, a_ov); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SENTINEL_ENTRY(n) \
|
|
|
|
nsresult nsXPTCStubBase::Sentinel##n() \
|
|
|
|
{ \
|
2009-08-14 18:09:00 +04:00
|
|
|
NS_ERROR("nsXPTCStubBase::Sentinel called"); \
|
2003-01-28 00:52:52 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "xptcstubsdef.inc"
|