xref: /trunk/main/bridges/source/cpp_uno/cc50_solaris_intel/call.s (revision d2748020ce41a64ef548fe1dae7ba98cbf99a183)
1*d2748020SPedro Giffuni//**************************************************************
2*d2748020SPedro Giffuni/ *
3*d2748020SPedro Giffuni/ * Licensed to the Apache Software Foundation (ASF) under one
4*d2748020SPedro Giffuni/ * or more contributor license agreements.  See the NOTICE file
5*d2748020SPedro Giffuni/ * distributed with this work for additional information
6*d2748020SPedro Giffuni/ * regarding copyright ownership.  The ASF licenses this file
7*d2748020SPedro Giffuni/ * to you under the Apache License, Version 2.0 (the
8*d2748020SPedro Giffuni/ * "License"); you may not use this file except in compliance
9*d2748020SPedro Giffuni/ * with the License.  You may obtain a copy of the License at
10*d2748020SPedro Giffuni/ *
11*d2748020SPedro Giffuni/ *   http://www.apache.org/licenses/LICENSE-2.0
12*d2748020SPedro Giffuni/ *
13*d2748020SPedro Giffuni/ * Unless required by applicable law or agreed to in writing,
14*d2748020SPedro Giffuni/ * software distributed under the License is distributed on an
15*d2748020SPedro Giffuni/ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d2748020SPedro Giffuni/ * KIND, either express or implied.  See the License for the
17*d2748020SPedro Giffuni/ * specific language governing permissions and limitations
18*d2748020SPedro Giffuni/ * under the License.
19*d2748020SPedro Giffuni/ *
20*d2748020SPedro Giffuni/ *************************************************************/
21b5da552cSAndrew Rist
22cdf0e10cSrcweir    .align 4
23cdf0e10cSrcweir    .globl privateSnippetExecutorGeneral
24cdf0e10cSrcweirprivateSnippetExecutorGeneral:
25cdf0e10cSrcweir    movl    %esp,%ecx
26cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
27cdf0e10cSrcweir    movl    %esp,%ebp
28cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
29cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
30cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
31cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
32cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
33cdf0e10cSrcweir    call    cpp_vtable_call
34cdf0e10cSrcweir    movl    12(%esp),%eax     / 64 bit nRegReturn, lower half
35cdf0e10cSrcweir    leave
36cdf0e10cSrcweir    ret
37cdf0e10cSrcweir    .type privateSnippetExecutorGeneral, @function
38cdf0e10cSrcweir    .size privateSnippetExecutorGeneral, .-privateSnippetExecutorGeneral
39cdf0e10cSrcweir
40cdf0e10cSrcweir    .align 4
41cdf0e10cSrcweir    .globl privateSnippetExecutorVoid
42cdf0e10cSrcweirprivateSnippetExecutorVoid:
43cdf0e10cSrcweir    movl    %esp,%ecx
44cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
45cdf0e10cSrcweir    movl    %esp,%ebp
46cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
47cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
48cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
49cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
50cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
51cdf0e10cSrcweir    call    cpp_vtable_call
52cdf0e10cSrcweir    leave
53cdf0e10cSrcweir    ret
54cdf0e10cSrcweir    .type privateSnippetExecutorVoid, @function
55cdf0e10cSrcweir    .size privateSnippetExecutorVoid, .-privateSnippetExecutorVoid
56cdf0e10cSrcweir
57cdf0e10cSrcweir    .align 4
58cdf0e10cSrcweir    .globl privateSnippetExecutorHyper
59cdf0e10cSrcweirprivateSnippetExecutorHyper:
60cdf0e10cSrcweir    movl    %esp,%ecx
61cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
62cdf0e10cSrcweir    movl    %esp,%ebp
63cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
64cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
65cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
66cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
67cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
68cdf0e10cSrcweir    call    cpp_vtable_call
69cdf0e10cSrcweir    movl    12(%esp),%eax     / 64 bit nRegReturn, lower half
70cdf0e10cSrcweir    movl    16(%esp),%edx     / 64 bit nRegReturn, upper half
71cdf0e10cSrcweir    leave
72cdf0e10cSrcweir    ret
73cdf0e10cSrcweir    .type privateSnippetExecutorHyper, @function
74cdf0e10cSrcweir    .size privateSnippetExecutorHyper, .-privateSnippetExecutorHyper
75cdf0e10cSrcweir
76cdf0e10cSrcweir    .align 4
77cdf0e10cSrcweir    .globl privateSnippetExecutorFloat
78cdf0e10cSrcweirprivateSnippetExecutorFloat:
79cdf0e10cSrcweir    movl    %esp,%ecx
80cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
81cdf0e10cSrcweir    movl    %esp,%ebp
82cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
83cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
84cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
85cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
86cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
87cdf0e10cSrcweir    call    cpp_vtable_call
88cdf0e10cSrcweir    flds    12(%esp)          / 64 bit nRegReturn, lower half
89cdf0e10cSrcweir    leave
90cdf0e10cSrcweir    ret
91cdf0e10cSrcweir    .type privateSnippetExecutorFloat, @function
92cdf0e10cSrcweir    .size privateSnippetExecutorFloat, .-privateSnippetExecutorFloat
93cdf0e10cSrcweir
94cdf0e10cSrcweir    .align 4
95cdf0e10cSrcweir    .globl privateSnippetExecutorDouble
96cdf0e10cSrcweirprivateSnippetExecutorDouble:
97cdf0e10cSrcweir    movl    %esp,%ecx
98cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
99cdf0e10cSrcweir    movl    %esp,%ebp
100cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
101cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
102cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
103cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
104cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
105cdf0e10cSrcweir    call    cpp_vtable_call
106cdf0e10cSrcweir    fldl    12(%esp)          / 64 bit nRegReturn
107cdf0e10cSrcweir    leave
108cdf0e10cSrcweir    ret
109cdf0e10cSrcweir    .type privateSnippetExecutorDouble, @function
110cdf0e10cSrcweir    .size privateSnippetExecutorDouble, .-privateSnippetExecutorDouble
111cdf0e10cSrcweir
112cdf0e10cSrcweir    .align 4
113cdf0e10cSrcweir    .globl privateSnippetExecutorStruct
114cdf0e10cSrcweirprivateSnippetExecutorStruct:
115cdf0e10cSrcweir    movl    %esp,%ecx
116cdf0e10cSrcweir    pushl   %ebp              / proper stack frame needed for exception handling
117cdf0e10cSrcweir    movl    %esp,%ebp
118cdf0e10cSrcweir    andl    $0xFFFFFFF8,%esp  / align following 64bit arg
119cdf0e10cSrcweir    subl    $0x8,%esp         / 64bit nRegReturn
120cdf0e10cSrcweir    pushl   %ecx              / 32bit pCallStack
121cdf0e10cSrcweir    pushl   %edx              / 32bit nVtableOffset
122cdf0e10cSrcweir    pushl   %eax              / 32bit nFunctionIndex
123cdf0e10cSrcweir    call    cpp_vtable_call
124cdf0e10cSrcweir    movl    12(%esp),%eax     / 64 bit nRegReturn, lower half
125cdf0e10cSrcweir    leave
126cdf0e10cSrcweir    ret     $4
127cdf0e10cSrcweir    .type privateSnippetExecutorStruct, @function
128cdf0e10cSrcweir    .size privateSnippetExecutorStruct, .-privateSnippetExecutorStruct
129cdf0e10cSrcweir
130cdf0e10cSrcweir    .align 4
131cdf0e10cSrcweir    .globl callVirtualMethod
132cdf0e10cSrcweircallVirtualMethod:
133cdf0e10cSrcweir    pushl   %ebp
134cdf0e10cSrcweir    movl    %esp, %ebp
135cdf0e10cSrcweir    subl    $24, %esp
136cdf0e10cSrcweir    movl    %edx, -4(%ebp)
137cdf0e10cSrcweir    movl    %ecx, -8(%ebp)
138cdf0e10cSrcweir    movl    %eax, -12(%ebp)
139cdf0e10cSrcweir    movl    %esp, -16(%ebp)
140cdf0e10cSrcweir    movl    %ebx, -20(%ebp)
141cdf0e10cSrcweir
142cdf0e10cSrcweir    / set ebx to GOT
143cdf0e10cSrcweir.L_GOT_BEGIN_2:
144cdf0e10cSrcweir    call    .L_GOT_END_2
145cdf0e10cSrcweir.L_GOT_END_2:
146cdf0e10cSrcweir    popl    %ebx
147cdf0e10cSrcweir    addl    $_GLOBAL_OFFSET_TABLE_+[.-.L_GOT_END_2],%ebx
148cdf0e10cSrcweir.callBeginPosition:
149cdf0e10cSrcweir    movl    28(%ebp), %eax
150cdf0e10cSrcweir    movl    %eax, %edx
151cdf0e10cSrcweir    dec     %edx
152cdf0e10cSrcweir    shl     $2, %edx
153cdf0e10cSrcweir    add     24(%ebp), %edx
154cdf0e10cSrcweir.copyLong:
155cdf0e10cSrcweir    movl    0(%edx), %ecx
156cdf0e10cSrcweir    sub     $4, %edx
157cdf0e10cSrcweir    push    %ecx
158cdf0e10cSrcweir    dec     %eax
159cdf0e10cSrcweir    jne     .copyLong
160cdf0e10cSrcweir.doCall:
161cdf0e10cSrcweir    movl    8(%ebp), %edx
162cdf0e10cSrcweir    movl    0(%edx), %edx
163cdf0e10cSrcweir    movl    12(%ebp), %eax
164cdf0e10cSrcweir    add     $2, %eax
165cdf0e10cSrcweir    shl     $2, %eax
166cdf0e10cSrcweir    add     %eax, %edx
167cdf0e10cSrcweir    movl    0(%edx), %edx
168cdf0e10cSrcweir
169cdf0e10cSrcweir    call    *%edx
170cdf0e10cSrcweir
171cdf0e10cSrcweir.callVirtualMethodExceptionPosition:
172cdf0e10cSrcweir    / handle returns
173cdf0e10cSrcweir    movl    20(%ebp), %ecx
174cdf0e10cSrcweir
175cdf0e10cSrcweir    / byte types
176cdf0e10cSrcweir    cmp     $2, %ecx    / typelib_TypeClass_BOOLEAN
177cdf0e10cSrcweir    je      .handleByte
178cdf0e10cSrcweir    cmp     $3, %ecx
179cdf0e10cSrcweir    je      .handleByte / typelib_TypeClass_BYTE
180cdf0e10cSrcweir
181cdf0e10cSrcweir    / half word types
182cdf0e10cSrcweir    cmp    $4, %ecx     / typelib_TypeClass_SHORT
183cdf0e10cSrcweir    je     .handleShort
184cdf0e10cSrcweir    cmp    $5, %ecx     / typelib_TypeClass_UNSIGNED_SHORT
185cdf0e10cSrcweir    je     .handleShort
186cdf0e10cSrcweir
187cdf0e10cSrcweir    / word types
188cdf0e10cSrcweir    cmp    $6, %ecx     / typelib_TypeClass_LONG
189cdf0e10cSrcweir    je     .handleWord
190cdf0e10cSrcweir    cmp    $7, %ecx     / typelib_TypeClass_UNSIGNED_LONG
191cdf0e10cSrcweir    je     .handleWord
192cdf0e10cSrcweir    cmp    $1, %ecx     / typelib_TypeClass_CHAR (wchar_t)
193cdf0e10cSrcweir    je     .handleWord
194cdf0e10cSrcweir    cmp    $15, %ecx    / typelib_TypeClass_ENUM
195cdf0e10cSrcweir    je     .handleWord
196cdf0e10cSrcweir
197cdf0e10cSrcweir    / double word types
198cdf0e10cSrcweir    cmp    $8, %ecx     / typelib_TypeClass_HYPER
199cdf0e10cSrcweir    je     .handleDoubleWord
200cdf0e10cSrcweir    cmp    $9, %ecx     / typelib_TypeClass_UNSIGNED_HYPER
201cdf0e10cSrcweir    je     .handleDoubleWord
202cdf0e10cSrcweir
203cdf0e10cSrcweir    / float
204cdf0e10cSrcweir    cmp    $10, %ecx    / typelib_TypeClass_FLOAT
205cdf0e10cSrcweir    je     .handleFloat
206cdf0e10cSrcweir
207cdf0e10cSrcweir    / double
208cdf0e10cSrcweir    cmp    $11, %ecx    / typelib_TypeClass_DOUBLE
209cdf0e10cSrcweir    je     .handleDouble
210cdf0e10cSrcweir
211cdf0e10cSrcweir    / default: return void
212cdf0e10cSrcweir    jmp    .doRestore
213cdf0e10cSrcweir.handleByte:
214cdf0e10cSrcweir    movl    16(%ebp), %ecx
215cdf0e10cSrcweir    movb    %al, 0(%ecx)
216cdf0e10cSrcweir    jmp     .doRestore
217cdf0e10cSrcweir.handleShort:
218cdf0e10cSrcweir    movl    16(%ebp), %ecx
219cdf0e10cSrcweir    movw    %ax, 0(%ecx)
220cdf0e10cSrcweir    jmp     .doRestore
221cdf0e10cSrcweir.handleWord:
222cdf0e10cSrcweir    movl    16(%ebp), %ecx
223cdf0e10cSrcweir    movl    %eax, 0(%ecx)
224cdf0e10cSrcweir    jmp     .doRestore
225cdf0e10cSrcweir.handleDoubleWord:
226cdf0e10cSrcweir    movl    16(%ebp), %ecx
227cdf0e10cSrcweir    movl    %eax, 0(%ecx)
228cdf0e10cSrcweir    movl    %edx, 4(%ecx)
229cdf0e10cSrcweir    jmp     .doRestore
230cdf0e10cSrcweir.handleFloat:
231cdf0e10cSrcweir    movl    16(%ebp), %ecx
232cdf0e10cSrcweir    fstps   0(%ecx)
233cdf0e10cSrcweir    jmp     .doRestore
234cdf0e10cSrcweir.handleDouble:
235cdf0e10cSrcweir    movl    16(%ebp), %ecx
236cdf0e10cSrcweir    fstpl   0(%ecx)
237cdf0e10cSrcweir    jmp     .doRestore
238cdf0e10cSrcweir.doRestore:
239cdf0e10cSrcweir    movl    -4(%ebp), %edx
240cdf0e10cSrcweir    movl    -8(%ebp), %ecx
241cdf0e10cSrcweir    movl    -12(%ebp), %eax
242cdf0e10cSrcweir    movl    -20(%ebp), %ebx
243cdf0e10cSrcweir    movl    %ebp, %esp
244cdf0e10cSrcweir    popl    %ebp
245cdf0e10cSrcweir    ret
246cdf0e10cSrcweir    .type callVirtualMethod, @function
247cdf0e10cSrcweir    .size callVirtualMethod, .-callVirtualMethod
248cdf0e10cSrcweir
249cdf0e10cSrcweir    .globl callVirtualMethodExceptionHandler
250cdf0e10cSrcweircallVirtualMethodExceptionHandler:
251cdf0e10cSrcweir    movl    -4(%ebp), %edx
252cdf0e10cSrcweir    movl    -8(%ebp), %ecx
253cdf0e10cSrcweir    movl    -12(%ebp), %eax
254cdf0e10cSrcweir    movl    -16(%ebp), %esp
255cdf0e10cSrcweir    movl    -20(%ebp), %ebx
256cdf0e10cSrcweir    call    __1cG__CrunMex_rethrow_q6F_v_@PLT
257cdf0e10cSrcweir    ret
258cdf0e10cSrcweir
259cdf0e10cSrcweir    .type callVirtualMethodExceptionHandler, @function
260cdf0e10cSrcweir    .size callVirtualMethodExceptionHandler, .-callVirtualMethodExceptionHandler
261cdf0e10cSrcweir
262cdf0e10cSrcweir
263cdf0e10cSrcweir    .section    .exception_ranges,"aw"
264cdf0e10cSrcweir    .align      4
265cdf0e10cSrcweir
266cdf0e10cSrcweir    .4byte      .callBeginPosition@rel
267cdf0e10cSrcweir    .4byte      .callVirtualMethodExceptionPosition-.callBeginPosition
268cdf0e10cSrcweir    .4byte      callVirtualMethodExceptionHandler-.callBeginPosition
269cdf0e10cSrcweir    .zero       8
270