1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 .global privateSnippetExecutor
23 .type privateSnippetExecutor,2
24 privateSnippetExecutor:
25 		! save %sp, -96, %sp  already done in code snippet
26 		st %i0, [%fp+68]
27 		st %i1, [%fp+72]
28 		st %i2, [%fp+76]
29 		st %i3, [%fp+80]
30 		st %i4, [%fp+84]
31 		st %i5, [%fp+88]
32 		! %o0: functionIndex, stored by code snippet
33 		! %o1: vtableOffset, stored by code snippet
34 		call cpp_vtable_call
35 		add %fp, 68, %o2
36 .privateSnippetExecutorExceptionPosition:
37 		subcc %o0, 11, %g0
38 		be .double
39 		subcc %o0, 10, %g0
40 		be .float
41 		ld [%fp+72], %i0
42 		ld [%fp+76], %i1
43 		ret
44 		restore
45 .double:
46 		ldd [%fp+72], %f0
47 		ret
48 		restore
49 .float:
50 		ld [%fp+72], %f0
51 		ret
52 		restore
53 .size privateSnippetExecutor,(.-privateSnippetExecutor)
54 .align 8
55 
56 
57 .global callVirtualMethod
58 .type callVirtualMethod,2
59 callVirtualMethod:
60 		! allocate FIRST stack to have own local registers
61 		sethi		 %hi(-96), %g1
62 		or		 %g1, %lo(-96), %g1
63 		subcc		 %g1, %o5, %g1
64 		subcc		 %g1, %o5, %g1
65 		subcc		 %g1, %o5, %g1
66 		subcc		 %g1, %o5, %g1
67 		save		%sp, %g1, %sp
68 		! copy stack longs if necessary
69 		subcc		%i5, 6, %l5
70 		ble		.copyRegisters
71 		nop
72 
73 		! prepare source location
74 		add		%i4, 24, %l4
75 
76 		! prepare real stack
77 		add		%sp, 92, %l3
78 
79 .copyLong:
80 		ld		[%l4+0], %l0
81 		st		%l0, [%l3]
82 		add		%l4, 4, %l4
83 		add		%l3, 4, %l3
84 		deccc		%l5
85 		bne		.copyLong
86 		nop
87 .copyRegisters:
88 		mov		%i5, %l5
89 		mov		%i4, %l4
90 
91 		ld		[%l4], %o0
92 		add		%l4, 4, %l4
93 		deccc		%l5
94 		ble		.doCall
95 
96 		ld		[%l4], %o1
97 		add		%l4, 4, %l4
98 		deccc		%l5
99 		ble		.doCall
100 
101 		ld		[%l4], %o2
102 		add		%l4, 4, %l4
103 		deccc		%l5
104 		ble		.doCall
105 
106 		ld			[%l4], %o3
107 		add		%l4, 4, %l4
108 		deccc		%l5
109 		ble		.doCall
110 
111 		ld			[%l4], %o4
112 		add		%l4, 4, %l4
113 		deccc		%l5
114 		ble		.doCall
115 
116 		ld			[%l4], %o5
117 		add		%l4, 4, %l4
118 
119 		! prepare complex return pointer
120 		st			%i2, [%sp+64]
121 .doCall:
122 		! get virtual table entry
123 		mov		%i1, %l1
124 		add		%l1, 2, %l1
125 		sll		%l1, 2, %l1
126 		ld			[%i0], %l3
127 		add		%l3, %l1, %l1
128 		ld			[%l1], %l0
129 		jmpl		%l0,%o7
130 		nop
131 .callVirtualMethodExceptionPosition:
132 		! handle returns
133 
134 		!byte types
135 		subcc %i3, 2, %l3		! typelib_TypeClass_BOOLEAN
136 		be .handleByte
137 		subcc %i3, 3, %l3		! typelib_TypeClass_BYTE
138 		be .handleByte
139 
140 		! half word types
141 		subcc %i3, 4, %l3		! typelib_TypeClass_SHORT
142 		be .handleShort
143 		subcc %i3, 5, %l3		! typelib_TypeClass_UNSIGNED_SHORT
144 		be .handleShort
145 		subcc %i3, 1, %l3		! typelib_TypeClass_CHAR (sal_Unicode==sal_uInt16)
146 		be .handleShort
147 
148 		! word types
149 		subcc %i3, 6, %l3		! typelib_TypeClass_LONG
150 		be .handleWord
151 		subcc %i3, 7, %l3		! typelib_TypeClass_UNSIGNED_LONG
152 		be .handleWord
153 		subcc %i3, 15, %l3	! typelib_TypeClass_ENUM
154 		be .handleWord
155 
156 		! double word types
157 		subcc %i3, 8, %l3		! typelib_TypeClass_HYPER
158 		be .handleDoubleWord
159 		subcc %i3, 9, %l3		! typelib_TypeClass_UNSIGNED_HYPER
160 		be .handleDoubleWord
161 
162 		! float
163 		subcc %i3, 10, %l3	! typelib_TypeClass_FLOAT
164 		be .handleFloat
165 
166 		! double
167 		subcc %i3, 11, %l3	! typelib_TypeClass_DOUBLE
168 		be .handleDouble
169 
170 		! default: return void
171 		nop					! empty prefetch
172 		ba .doRestore
173 		nop
174 .handleByte:
175 		stb %o0, [%i2]
176 		ba .doRestore
177 		nop
178 .handleShort:
179 		sth %o0, [%i2]
180 		ba .doRestore
181 		nop
182 .handleWord:
183 		st %o0, [%i2]
184 		ba .doRestore
185 		nop
186 .handleDoubleWord:
187 		st %o0, [%i2]
188 		st %o1, [%i2+4]
189 		ba .doRestore
190 		nop
191 .handleFloat:
192 		st %f0, [%i2]
193 		ba .doRestore
194 		nop
195 .handleDouble:
196 		std %f0, [%fp-8]
197 		ldd [%fp-8], %o0
198 		st %o0, [%i2]
199 		st %o1, [%i2+4]
200 		ba .doRestore
201 		nop
202 .doRestore:
203 		ret
204 		restore	! stack frame for own locals
205 .size callVirtualMethod,(.-callVirtualMethod)
206 .align 8
207 
208 .rethrow_handler:
209 		call	__1cG__CrunMex_rethrow_q6F_v_
210 		nop
211 
212 .section	".exception_ranges",#alloc
213 .word		%r_disp32(.privateSnippetExecutorExceptionPosition)
214 .word		0
215 .word		.rethrow_handler-.privateSnippetExecutorExceptionPosition
216 .word		0,0
217 .word		%r_disp32(.callVirtualMethodExceptionPosition)
218 .word		0
219 .word		.rethrow_handler-.callVirtualMethodExceptionPosition
220 .word		0,0
221