mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 971897: Use xpct{stubs,invoke}_x86_64 from linux/unix on OpenBSD/amd64 for consistency r=bsmedberg
This fixes the download panel issue, and brings us revs 727721e5d8ac, 844b142d8111 and 236989b3a807 as a bonus. Remove the unmaintained OpenBSD/amd64 specific versions.
This commit is contained in:
parent
a05388252a
commit
fd74ccfd81
@ -19,14 +19,14 @@ if CONFIG['OS_ARCH'] == 'Darwin':
|
||||
if '86' in CONFIG['OS_TEST'] and CONFIG['OS_TEST'] != 'x86_64':
|
||||
DEFINES['MOZ_NEED_LEADING_UNDERSCORE'] = True
|
||||
|
||||
if CONFIG['OS_ARCH'] in ('NetBSD', 'OpenBSD', 'GNU'):
|
||||
if CONFIG['OS_ARCH'] in ('NetBSD', 'GNU'):
|
||||
if CONFIG['CPU_ARCH'] == 'x86':
|
||||
SOURCES += [
|
||||
'xptcinvoke_gcc_x86_unix.cpp',
|
||||
'xptcstubs_gcc_x86_unix.cpp'
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD') or \
|
||||
if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD', 'OpenBSD') or \
|
||||
CONFIG['OS_ARCH'].startswith('GNU_'):
|
||||
if CONFIG['OS_TEST'] == 'x86_64':
|
||||
SOURCES += [
|
||||
@ -48,12 +48,6 @@ if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'):
|
||||
'xptcstubs_ipf64.cpp'
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'OpenBSD' and CONFIG['OS_TEST'] == 'x86_64':
|
||||
SOURCES += [
|
||||
'xptcinvoke_amd64_openbsd.cpp',
|
||||
'xptcstubs_amd64_openbsd.cpp'
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'SunOS':
|
||||
if CONFIG['OS_TEST'] == 'x86_64':
|
||||
if CONFIG['GNU_CC']:
|
||||
|
@ -1,178 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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/. */
|
||||
|
||||
// Platform specific code to invoke XPCOM methods on native objects
|
||||
|
||||
#include "xptcprivate.h"
|
||||
|
||||
// 6 integral parameters are passed in registers
|
||||
const uint32_t GPR_COUNT = 6;
|
||||
|
||||
// 8 floating point parameters are passed in SSE registers
|
||||
const uint32_t FPR_COUNT = 8;
|
||||
|
||||
// Remember that these 'words' are 64-bit long
|
||||
static inline void
|
||||
invoke_count_words(uint32_t paramCount, nsXPTCVariant * s,
|
||||
uint32_t & nr_gpr, uint32_t & nr_fpr, uint32_t & nr_stack)
|
||||
{
|
||||
nr_gpr = 1; // skip one GP register for 'that'
|
||||
nr_fpr = 0;
|
||||
nr_stack = 0;
|
||||
|
||||
/* Compute number of eightbytes of class MEMORY. */
|
||||
for (uint32_t i = 0; i < paramCount; i++, s++) {
|
||||
if (!s->IsPtrData()
|
||||
&& (s->type == nsXPTType::T_FLOAT || s->type == nsXPTType::T_DOUBLE)) {
|
||||
if (nr_fpr < FPR_COUNT)
|
||||
nr_fpr++;
|
||||
else
|
||||
nr_stack++;
|
||||
}
|
||||
else {
|
||||
if (nr_gpr < GPR_COUNT)
|
||||
nr_gpr++;
|
||||
else
|
||||
nr_stack++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
invoke_copy_to_stack(uint64_t * d, uint32_t paramCount, nsXPTCVariant * s,
|
||||
uint64_t * gpregs, double * fpregs)
|
||||
{
|
||||
uint32_t nr_gpr = 1; // skip one GP register for 'that'
|
||||
uint32_t nr_fpr = 0;
|
||||
uint64_t value;
|
||||
|
||||
for (uint32_t i = 0; i < paramCount; i++, s++) {
|
||||
if (s->IsPtrData())
|
||||
value = (uint64_t) s->ptr;
|
||||
else {
|
||||
switch (s->type) {
|
||||
case nsXPTType::T_FLOAT: break;
|
||||
case nsXPTType::T_DOUBLE: break;
|
||||
case nsXPTType::T_I8: value = s->val.i8; break;
|
||||
case nsXPTType::T_I16: value = s->val.i16; break;
|
||||
case nsXPTType::T_I32: value = s->val.i32; break;
|
||||
case nsXPTType::T_I64: value = s->val.i64; break;
|
||||
case nsXPTType::T_U8: value = s->val.u8; break;
|
||||
case nsXPTType::T_U16: value = s->val.u16; break;
|
||||
case nsXPTType::T_U32: value = s->val.u32; break;
|
||||
case nsXPTType::T_U64: value = s->val.u64; break;
|
||||
case nsXPTType::T_BOOL: value = s->val.b; break;
|
||||
case nsXPTType::T_CHAR: value = s->val.c; break;
|
||||
case nsXPTType::T_WCHAR: value = s->val.wc; break;
|
||||
default: value = (uint64_t) s->val.p; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
|
||||
if (nr_fpr < FPR_COUNT)
|
||||
fpregs[nr_fpr++] = s->val.d;
|
||||
else {
|
||||
*((double *)d) = s->val.d;
|
||||
d++;
|
||||
}
|
||||
}
|
||||
else if (!s->IsPtrData() && s->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.
|
||||
fpregs[nr_fpr++] = s->val.d;
|
||||
else {
|
||||
*((float *)d) = s->val.f;
|
||||
d++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (nr_gpr < GPR_COUNT)
|
||||
gpregs[nr_gpr++] = value;
|
||||
else
|
||||
*d++ = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_InvokeByIndex(nsISupports * that, uint32_t methodIndex,
|
||||
uint32_t paramCount, nsXPTCVariant * params)
|
||||
{
|
||||
uint32_t nr_gpr, nr_fpr, nr_stack;
|
||||
invoke_count_words(paramCount, params, nr_gpr, nr_fpr, nr_stack);
|
||||
|
||||
// Stack, if used, must be 16-bytes aligned
|
||||
if (nr_stack)
|
||||
nr_stack = (nr_stack + 1) & ~1;
|
||||
|
||||
// Load parameters to stack, if necessary
|
||||
uint64_t *stack = (uint64_t *) __builtin_alloca(nr_stack * 8);
|
||||
uint64_t gpregs[GPR_COUNT];
|
||||
double fpregs[FPR_COUNT];
|
||||
invoke_copy_to_stack(stack, paramCount, params, gpregs, fpregs);
|
||||
|
||||
// Load FPR registers from fpregs[]
|
||||
register double d0 asm("xmm0");
|
||||
register double d1 asm("xmm1");
|
||||
register double d2 asm("xmm2");
|
||||
register double d3 asm("xmm3");
|
||||
register double d4 asm("xmm4");
|
||||
register double d5 asm("xmm5");
|
||||
register double d6 asm("xmm6");
|
||||
register double d7 asm("xmm7");
|
||||
|
||||
switch (nr_fpr) {
|
||||
#define ARG_FPR(N) \
|
||||
case N+1: d##N = fpregs[N];
|
||||
ARG_FPR(7);
|
||||
ARG_FPR(6);
|
||||
ARG_FPR(5);
|
||||
ARG_FPR(4);
|
||||
ARG_FPR(3);
|
||||
ARG_FPR(2);
|
||||
ARG_FPR(1);
|
||||
ARG_FPR(0);
|
||||
case 0:;
|
||||
#undef ARG_FPR
|
||||
}
|
||||
|
||||
// Load GPR registers from gpregs[]
|
||||
register uint64_t a0 asm("rdi");
|
||||
register uint64_t a1 asm("rsi");
|
||||
register uint64_t a2 asm("rdx");
|
||||
register uint64_t a3 asm("rcx");
|
||||
register uint64_t a4 asm("r8");
|
||||
register uint64_t a5 asm("r9");
|
||||
|
||||
switch (nr_gpr) {
|
||||
#define ARG_GPR(N) \
|
||||
case N+1: a##N = gpregs[N];
|
||||
ARG_GPR(5);
|
||||
ARG_GPR(4);
|
||||
ARG_GPR(3);
|
||||
ARG_GPR(2);
|
||||
ARG_GPR(1);
|
||||
case 1: a0 = (uint64_t) that;
|
||||
case 0:;
|
||||
#undef ARG_GPR
|
||||
}
|
||||
|
||||
// Ensure that assignments to SSE registers won't be optimized away
|
||||
asm("" ::
|
||||
"x" (d0), "x" (d1), "x" (d2), "x" (d3),
|
||||
"x" (d4), "x" (d5), "x" (d6), "x" (d7));
|
||||
|
||||
// Get pointer to method
|
||||
uint64_t methodAddress = *((uint64_t *)that);
|
||||
methodAddress += 8 * methodIndex;
|
||||
methodAddress = *((uint64_t *)methodAddress);
|
||||
|
||||
typedef nsresult (*Method)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
|
||||
nsresult result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5);
|
||||
return result;
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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/. */
|
||||
|
||||
// Implement shared vtbl methods.
|
||||
|
||||
#include "xptcprivate.h"
|
||||
#include "xptiprivate.h"
|
||||
|
||||
// The Linux/x86-64 ABI passes the first 6 integer parameters and the
|
||||
// first 8 floating point parameters in registers (rdi, rsi, rdx, rcx,
|
||||
// r8, r9 and xmm0-xmm7), no stack space is allocated for these by the
|
||||
// caller. The rest of the parameters are passed in the callers stack
|
||||
// area.
|
||||
|
||||
const uint32_t PARAM_BUFFER_COUNT = 16;
|
||||
const uint32_t GPR_COUNT = 6;
|
||||
const uint32_t FPR_COUNT = 8;
|
||||
|
||||
// PrepareAndDispatch() is called by SharedStub() and calls the actual method.
|
||||
//
|
||||
// - 'args[]' contains the arguments passed on stack
|
||||
// - 'gpregs[]' contains the arguments passed in integer registers
|
||||
// - 'fpregs[]' contains the arguments passed in floating point registers
|
||||
//
|
||||
// The parameters are mapped into an array of type 'nsXPTCMiniVariant'
|
||||
// and then the method gets called.
|
||||
|
||||
extern "C" nsresult ATTRIBUTE_USED
|
||||
PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
|
||||
uint64_t * args, uint64_t * gpregs, double *fpregs)
|
||||
{
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint32_t paramCount;
|
||||
uint32_t i;
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(self,"no self");
|
||||
|
||||
self->mEntry->GetMethodInfo(uint16_t(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;
|
||||
|
||||
uint64_t* ap = args;
|
||||
uint32_t nr_gpr = 1; // skip one GPR register for 'that'
|
||||
uint32_t nr_fpr = 0;
|
||||
uint64_t 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++];
|
||||
else
|
||||
dp->val.d = *(double*) ap++;
|
||||
continue;
|
||||
}
|
||||
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++;
|
||||
else
|
||||
dp->val.f = *(float*) ap++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (nr_gpr < GPR_COUNT)
|
||||
value = gpregs[nr_gpr++];
|
||||
else
|
||||
value = *ap++;
|
||||
}
|
||||
|
||||
if (param.IsOut() || !type.IsArithmetic()) {
|
||||
dp->val.p = (void*) value;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case nsXPTType::T_I8: dp->val.i8 = (int8_t) value; break;
|
||||
case nsXPTType::T_I16: dp->val.i16 = (int16_t) value; break;
|
||||
case nsXPTType::T_I32: dp->val.i32 = (int32_t) value; break;
|
||||
case nsXPTType::T_I64: dp->val.i64 = (int64_t) value; break;
|
||||
case nsXPTType::T_U8: dp->val.u8 = (uint8_t) value; break;
|
||||
case nsXPTType::T_U16: dp->val.u16 = (uint16_t) value; break;
|
||||
case nsXPTType::T_U32: dp->val.u32 = (uint32_t) value; break;
|
||||
case nsXPTType::T_U64: dp->val.u64 = (uint64_t) value; break;
|
||||
case nsXPTType::T_BOOL: dp->val.b = (bool) value; break;
|
||||
case nsXPTType::T_CHAR: dp->val.c = (char) value; break;
|
||||
case nsXPTType::T_WCHAR: dp->val.wc = (wchar_t) value; break;
|
||||
|
||||
default:
|
||||
NS_ERROR("bad type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams);
|
||||
|
||||
if (dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Linux/x86-64 uses gcc >= 3.1
|
||||
#define STUB_ENTRY(n) \
|
||||
asm(".section \".text\"\n\t" \
|
||||
".align 2\n\t" \
|
||||
".if " #n " < 10\n\t" \
|
||||
".globl _ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
|
||||
".hidden _ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
|
||||
".type _ZN14nsXPTCStubBase5Stub" #n "Ev,@function\n" \
|
||||
"_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
|
||||
".elseif " #n " < 100\n\t" \
|
||||
".globl _ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
|
||||
".hidden _ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
|
||||
".type _ZN14nsXPTCStubBase6Stub" #n "Ev,@function\n" \
|
||||
"_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
|
||||
".elseif " #n " < 1000\n\t" \
|
||||
".globl _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
|
||||
".hidden _ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
|
||||
".type _ZN14nsXPTCStubBase7Stub" #n "Ev,@function\n" \
|
||||
"_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
|
||||
".else\n\t" \
|
||||
".err \"stub number " #n " >= 1000 not yet supported\"\n\t" \
|
||||
".endif\n\t" \
|
||||
"movl $" #n ", %eax\n\t" \
|
||||
"jmp SharedStub\n\t" \
|
||||
".if " #n " < 10\n\t" \
|
||||
".size _ZN14nsXPTCStubBase5Stub" #n "Ev,.-_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
|
||||
".elseif " #n " < 100\n\t" \
|
||||
".size _ZN14nsXPTCStubBase6Stub" #n "Ev,.-_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
|
||||
".else\n\t" \
|
||||
".size _ZN14nsXPTCStubBase7Stub" #n "Ev,.-_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
|
||||
".endif");
|
||||
|
||||
// static nsresult SharedStub(uint32_t methodIndex)
|
||||
asm(".section \".text\"\n\t"
|
||||
".align 2\n\t"
|
||||
".type SharedStub,@function\n\t"
|
||||
"SharedStub:\n\t"
|
||||
// make room for gpregs (48), fpregs (64)
|
||||
"pushq %rbp\n\t"
|
||||
"movq %rsp,%rbp\n\t"
|
||||
"subq $112,%rsp\n\t"
|
||||
// save GP registers
|
||||
"movq %rdi,-112(%rbp)\n\t"
|
||||
"movq %rsi,-104(%rbp)\n\t"
|
||||
"movq %rdx, -96(%rbp)\n\t"
|
||||
"movq %rcx, -88(%rbp)\n\t"
|
||||
"movq %r8 , -80(%rbp)\n\t"
|
||||
"movq %r9 , -72(%rbp)\n\t"
|
||||
"leaq -112(%rbp),%rcx\n\t"
|
||||
// save FP registers
|
||||
"movsd %xmm0,-64(%rbp)\n\t"
|
||||
"movsd %xmm1,-56(%rbp)\n\t"
|
||||
"movsd %xmm2,-48(%rbp)\n\t"
|
||||
"movsd %xmm3,-40(%rbp)\n\t"
|
||||
"movsd %xmm4,-32(%rbp)\n\t"
|
||||
"movsd %xmm5,-24(%rbp)\n\t"
|
||||
"movsd %xmm6,-16(%rbp)\n\t"
|
||||
"movsd %xmm7, -8(%rbp)\n\t"
|
||||
"leaq -64(%rbp),%r8\n\t"
|
||||
// rdi has the 'self' pointer already
|
||||
"movl %eax,%esi\n\t"
|
||||
"leaq 16(%rbp),%rdx\n\t"
|
||||
"call PrepareAndDispatch@plt\n\t"
|
||||
"leave\n\t"
|
||||
"ret\n\t"
|
||||
".size SharedStub,.-SharedStub");
|
||||
|
||||
#define SENTINEL_ENTRY(n) \
|
||||
nsresult nsXPTCStubBase::Sentinel##n() \
|
||||
{ \
|
||||
NS_ERROR("nsXPTCStubBase::Sentinel called"); \
|
||||
return NS_ERROR_NOT_IMPLEMENTED; \
|
||||
}
|
||||
|
||||
#include "xptcstubsdef.inc"
|
Loading…
Reference in New Issue
Block a user