]> gitweb @ CieloNegro.org - pkgsrc-firefox3.git/blob - files/xptcinvoke_asm_sparc64_netbsd.s
Initial revision of the upstream www/firefox3
[pkgsrc-firefox3.git] / files / xptcinvoke_asm_sparc64_netbsd.s
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * The contents of this file are subject to the Netscape Public
4  * License Version 1.1 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of
6  * the License at http://www.mozilla.org/NPL/
7  *
8  * Software distributed under the License is distributed on an "AS
9  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10  * implied. See the License for the specific language governing
11  * rights and limitations under the License.
12  *
13  * The Original Code is mozilla.org code.
14  *
15  * The Initial Developer of the Original Code is Netscape
16  * Communications Corporation.  Portions created by Netscape are
17  * Copyright (C) 1998 Netscape Communications Corporation. All
18  * Rights Reserved.
19  *
20  * Contributor(s): 
21  */
22
23 /* Platform specific code to invoke XPCOM methods on native objects */
24         .global NS_InvokeByIndex_P
25         .type   NS_InvokeByIndex_P, #function
26 /*
27     NS_InvokeByIndex_P(nsISupports* that, PRUint32 methodIndex,
28                    PRUint32 paramCount, nsXPTCVariant* params);
29     
30 */
31 /*
32  * Note:  To simplify stack handling we allocate an extra stack
33  *      frame here.  In principle invoke_copy_to_stack() could
34  *      save the parameters our caller's frame and we could
35  *      reclaim the stackframe and do a tail call to the
36  *      function.  However, this gets complicated....
37  *
38  * The vtable consist of be:
39  *
40  *  struct { 
41  *    short __delta;
42  *    short __index;
43  *    union {
44  *      P __pfn;
45  *      short __delta2; 
46  *    } __pfn_or_delta2;
47  *  };
48  *
49  * See gcc/cp/cp-tree.h
50  */
51         
52 NS_InvokeByIndex_P:
53         save    %sp,-(128 + 64),%sp ! room for the register window and
54                                     ! struct pointer, rounded up to 0 % 64
55         sll     %i2,4,%l0           ! assume the worst case
56                                     ! paramCount * 2 * 8 bytes
57         cmp     %l0, 0              ! are there any args? If not,
58         be      .invoke             ! no need to copy args to stack
59          nop
60
61         sub     %sp,%l0,%sp         ! create the additional stack space
62         add     %sp,0x7ff+136,%o0   ! step past the register window, the
63                                     ! struct result pointer and the 'this' slot
64         mov     %i2,%o1             ! paramCount
65         call    invoke_copy_to_stack
66          mov    %i3,%o2             ! params
67
68 !
69 !   load arguments from stack into the outgoing registers
70 !   BIAS is 0x7ff (2047)
71 !
72
73 !   load the %o1..5 64bit (extended word) output registers registers 
74         ldx     [%sp + 0x7ff + 136],%o1    ! %i1
75         ldx     [%sp + 0x7ff + 144],%o2    ! %i2
76         ldx     [%sp + 0x7ff + 152],%o3    ! %i3
77         ldx     [%sp + 0x7ff + 160],%o4    ! %i4
78         ldx     [%sp + 0x7ff + 168],%o5    ! %i5
79
80 !   load the even number double registers starting with %f2
81         ldd     [%sp + 0x7ff + 136],%f2
82         ldd     [%sp + 0x7ff + 144],%f4
83         ldd     [%sp + 0x7ff + 152],%f6
84         ldd     [%sp + 0x7ff + 160],%f8
85         ldd     [%sp + 0x7ff + 168],%f10
86         ldd     [%sp + 0x7ff + 176],%f12
87         ldd     [%sp + 0x7ff + 184],%f14
88         ldd     [%sp + 0x7ff + 192],%f16
89         ldd     [%sp + 0x7ff + 200],%f18
90         ldd     [%sp + 0x7ff + 208],%f20
91         ldd     [%sp + 0x7ff + 216],%f22
92         ldd     [%sp + 0x7ff + 224],%f24
93         ldd     [%sp + 0x7ff + 232],%f26
94         ldd     [%sp + 0x7ff + 240],%f28
95         ldd     [%sp + 0x7ff + 248],%f30
96
97 !
98 !   calculate the target address from the vtable
99 !
100 .invoke:
101         sll     %i1,3,%l0           ! index *= 8
102         ldx     [%i0],%l1           ! *this --> address of vtable
103         ldx     [%l0 + %l1],%l0     ! this->vtable[index] --> address
104
105         jmpl    %l0,%o7             ! call the routine
106          mov    %i0,%o0             ! move 'this' pointer to out register
107
108         mov     %o0,%i0             ! propagate return value
109         ret
110          restore
111
112         .size    NS_InvokeByIndex_P, .-NS_InvokeByIndex_P