/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// Implement shared vtbl methods.
#include "xptcprivate.h"
// 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.
// Solaris does the same, just the assembler may differ.
// 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
{
PRUint32 i;
if (!iface_info)
return NS_ERROR_UNEXPECTED;
if (!info)
return NS_ERROR_UNEXPECTED;
// setup variant array pointer
if (paramCount > PARAM_BUFFER_COUNT)
else
if (!dispatchParams)
return NS_ERROR_OUT_OF_MEMORY;
for (i = 0; i < paramCount; i++) {
else
continue;
}
// 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.
else
continue;
}
else {
else
}
continue;
}
switch (type) {
default:
NS_ASSERTION(0, "bad type");
break;
}
}
if (dispatchParams != paramBuffer)
delete [] dispatchParams;
return result;
}
#define STUB_ENTRY(n,m) \
asm(".section .text\n\t" \
".align 2\n\t" \
".globl _ZN14nsXPTCStubBase" #m "Stub" #n "Ev\n\t" \
".type _ZN14nsXPTCStubBase" #m "Stub" #n "Ev,@function\n" \
"_ZN14nsXPTCStubBase" #m "Stub" #n "Ev:\n\t" \
"movl $" #n ", %eax\n\t" \
"jmp SharedStub\n\t" \
".size _ZN14nsXPTCStubBase" #m "Stub" #n "Ev,.-_ZN14nsXPTCStubBase" #m "Stub" #n "Ev\n\t" \
)
STUB_ENTRY(n10##0,m); \
STUB_ENTRY_10(,5);
// static nsresult SharedStub(PRUint32 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) \
{ \
NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
return NS_ERROR_NOT_IMPLEMENTED; \
}
#else
#endif /* __GNUC__ */