xref: /AOO41X/main/bridges/source/cpp_uno/cc50_solaris_sparc/call.s (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1.global privateSnippetExecutor
2.type privateSnippetExecutor,2
3privateSnippetExecutor:
4		! save %sp, -96, %sp  already done in code snippet
5		st %i0, [%fp+68]
6		st %i1, [%fp+72]
7		st %i2, [%fp+76]
8		st %i3, [%fp+80]
9		st %i4, [%fp+84]
10		st %i5, [%fp+88]
11		! %o0: functionIndex, stored by code snippet
12		! %o1: vtableOffset, stored by code snippet
13		call cpp_vtable_call
14		add %fp, 68, %o2
15.privateSnippetExecutorExceptionPosition:
16		subcc %o0, 11, %g0
17		be .double
18		subcc %o0, 10, %g0
19		be .float
20		ld [%fp+72], %i0
21		ld [%fp+76], %i1
22		ret
23		restore
24.double:
25		ldd [%fp+72], %f0
26		ret
27		restore
28.float:
29		ld [%fp+72], %f0
30		ret
31		restore
32.size privateSnippetExecutor,(.-privateSnippetExecutor)
33.align 8
34
35
36.global callVirtualMethod
37.type callVirtualMethod,2
38callVirtualMethod:
39		! allocate FIRST stack to have own local registers
40		sethi		 %hi(-96), %g1
41		or		 %g1, %lo(-96), %g1
42		subcc		 %g1, %o5, %g1
43		subcc		 %g1, %o5, %g1
44		subcc		 %g1, %o5, %g1
45		subcc		 %g1, %o5, %g1
46		save		%sp, %g1, %sp
47		! copy stack longs if necessary
48		subcc		%i5, 6, %l5
49		ble		.copyRegisters
50		nop
51
52		! prepare source location
53		add		%i4, 24, %l4
54
55		! prepare real stack
56		add		%sp, 92, %l3
57
58.copyLong:
59		ld		[%l4+0], %l0
60		st		%l0, [%l3]
61		add		%l4, 4, %l4
62		add		%l3, 4, %l3
63		deccc		%l5
64		bne		.copyLong
65		nop
66.copyRegisters:
67		mov		%i5, %l5
68		mov		%i4, %l4
69
70		ld		[%l4], %o0
71		add		%l4, 4, %l4
72		deccc		%l5
73		ble		.doCall
74
75		ld		[%l4], %o1
76		add		%l4, 4, %l4
77		deccc		%l5
78		ble		.doCall
79
80		ld		[%l4], %o2
81		add		%l4, 4, %l4
82		deccc		%l5
83		ble		.doCall
84
85		ld			[%l4], %o3
86		add		%l4, 4, %l4
87		deccc		%l5
88		ble		.doCall
89
90		ld			[%l4], %o4
91		add		%l4, 4, %l4
92		deccc		%l5
93		ble		.doCall
94
95		ld			[%l4], %o5
96		add		%l4, 4, %l4
97
98		! prepare complex return pointer
99		st			%i2, [%sp+64]
100.doCall:
101		! get virtual table entry
102		mov		%i1, %l1
103		add		%l1, 2, %l1
104		sll		%l1, 2, %l1
105		ld			[%i0], %l3
106		add		%l3, %l1, %l1
107		ld			[%l1], %l0
108		jmpl		%l0,%o7
109		nop
110.callVirtualMethodExceptionPosition:
111		! handle returns
112
113		!byte types
114		subcc %i3, 2, %l3		! typelib_TypeClass_BOOLEAN
115		be .handleByte
116		subcc %i3, 3, %l3		! typelib_TypeClass_BYTE
117		be .handleByte
118
119		! half word types
120		subcc %i3, 4, %l3		! typelib_TypeClass_SHORT
121		be .handleShort
122		subcc %i3, 5, %l3		! typelib_TypeClass_UNSIGNED_SHORT
123		be .handleShort
124		subcc %i3, 1, %l3		! typelib_TypeClass_CHAR (sal_Unicode==sal_uInt16)
125		be .handleShort
126
127		! word types
128		subcc %i3, 6, %l3		! typelib_TypeClass_LONG
129		be .handleWord
130		subcc %i3, 7, %l3		! typelib_TypeClass_UNSIGNED_LONG
131		be .handleWord
132		subcc %i3, 15, %l3	! typelib_TypeClass_ENUM
133		be .handleWord
134
135		! double word types
136		subcc %i3, 8, %l3		! typelib_TypeClass_HYPER
137		be .handleDoubleWord
138		subcc %i3, 9, %l3		! typelib_TypeClass_UNSIGNED_HYPER
139		be .handleDoubleWord
140
141		! float
142		subcc %i3, 10, %l3	! typelib_TypeClass_FLOAT
143		be .handleFloat
144
145		! double
146		subcc %i3, 11, %l3	! typelib_TypeClass_DOUBLE
147		be .handleDouble
148
149		! default: return void
150		nop					! empty prefetch
151		ba .doRestore
152		nop
153.handleByte:
154		stb %o0, [%i2]
155		ba .doRestore
156		nop
157.handleShort:
158		sth %o0, [%i2]
159		ba .doRestore
160		nop
161.handleWord:
162		st %o0, [%i2]
163		ba .doRestore
164		nop
165.handleDoubleWord:
166		st %o0, [%i2]
167		st %o1, [%i2+4]
168		ba .doRestore
169		nop
170.handleFloat:
171		st %f0, [%i2]
172		ba .doRestore
173		nop
174.handleDouble:
175		std %f0, [%fp-8]
176		ldd [%fp-8], %o0
177		st %o0, [%i2]
178		st %o1, [%i2+4]
179		ba .doRestore
180		nop
181.doRestore:
182		ret
183		restore	! stack frame for own locals
184.size callVirtualMethod,(.-callVirtualMethod)
185.align 8
186
187.rethrow_handler:
188		call	__1cG__CrunMex_rethrow_q6F_v_
189		nop
190
191.section	".exception_ranges",#alloc
192.word		%r_disp32(.privateSnippetExecutorExceptionPosition)
193.word		0
194.word		.rethrow_handler-.privateSnippetExecutorExceptionPosition
195.word		0,0
196.word		%r_disp32(.callVirtualMethodExceptionPosition)
197.word		0
198.word		.rethrow_handler-.callVirtualMethodExceptionPosition
199.word		0,0
200