summaryrefslogtreecommitdiff
path: root/bridges/source/cpp_uno/cc50_solaris_sparc/call.s
blob: be4027fda0704b504af7db9bf3e7513bf4c727ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
.global privateSnippetExecutor
.type privateSnippetExecutor,2
privateSnippetExecutor:
		! save %sp, -96, %sp  already done in code snippet
		st %i0, [%fp+68]
		st %i1, [%fp+72]
		st %i2, [%fp+76]
		st %i3, [%fp+80]
		st %i4, [%fp+84]
		st %i5, [%fp+88]
		! %o0: functionIndex, stored by code snippet
		! %o1: vtableOffset, stored by code snippet
		call cpp_vtable_call
		add %fp, 68, %o2
.privateSnippetExecutorExceptionPosition:
		subcc %o0, 11, %g0
		be .double
		subcc %o0, 10, %g0
		be .float
		ld [%fp+72], %i0
		ld [%fp+76], %i1
		ret
		restore
.double:
		ldd [%fp+72], %f0
		ret
		restore
.float:
		ld [%fp+72], %f0
		ret
		restore
.size privateSnippetExecutor,(.-privateSnippetExecutor)
.align 8

	
.global callVirtualMethod
.type callVirtualMethod,2
callVirtualMethod:
		! allocate FIRST stack to have own local registers
		sethi		 %hi(-96), %g1
		or		 %g1, %lo(-96), %g1
		subcc		 %g1, %o5, %g1
		subcc		 %g1, %o5, %g1
		subcc		 %g1, %o5, %g1
		subcc		 %g1, %o5, %g1
		save		%sp, %g1, %sp
		! copy stack longs if necessary
		subcc		%i5, 6, %l5
		ble		.copyRegisters
		nop

		! prepare source location
		add		%i4, 24, %l4
		
		! prepare real stack
		add		%sp, 92, %l3
		
.copyLong:
		ld		[%l4+0], %l0
		st		%l0, [%l3]
		add		%l4, 4, %l4
		add		%l3, 4, %l3
		deccc		%l5
		bne		.copyLong
		nop
.copyRegisters:
		mov		%i5, %l5
		mov		%i4, %l4

		ld		[%l4], %o0
		add		%l4, 4, %l4
		deccc		%l5
		ble		.doCall

		ld		[%l4], %o1
		add		%l4, 4, %l4
		deccc		%l5
		ble		.doCall

		ld		[%l4], %o2
		add		%l4, 4, %l4
		deccc		%l5
		ble		.doCall

		ld			[%l4], %o3
		add		%l4, 4, %l4
		deccc		%l5
		ble		.doCall

		ld			[%l4], %o4
		add		%l4, 4, %l4
		deccc		%l5
		ble		.doCall

		ld			[%l4], %o5
		add		%l4, 4, %l4

		! prepare complex return pointer
		st			%i2, [%sp+64]
.doCall:
		! get virtual table entry
		mov		%i1, %l1
		add		%l1, 2, %l1
		sll		%l1, 2, %l1
		ld			[%i0], %l3
		add		%l3, %l1, %l1
		ld			[%l1], %l0
		jmpl		%l0,%o7
		nop
.callVirtualMethodExceptionPosition:
		! handle returns

		!byte types
		subcc %i3, 2, %l3		! typelib_TypeClass_BOOLEAN
		be .handleByte
		subcc %i3, 3, %l3		! typelib_TypeClass_BYTE
		be .handleByte

		! half word types
		subcc %i3, 4, %l3		! typelib_TypeClass_SHORT
		be .handleShort
		subcc %i3, 5, %l3		! typelib_TypeClass_UNSIGNED_SHORT
		be .handleShort
		subcc %i3, 1, %l3		! typelib_TypeClass_CHAR (sal_Unicode==sal_uInt16)
		be .handleShort

		! word types
		subcc %i3, 6, %l3		! typelib_TypeClass_LONG
		be .handleWord
		subcc %i3, 7, %l3		! typelib_TypeClass_UNSIGNED_LONG
		be .handleWord
		subcc %i3, 15, %l3	! typelib_TypeClass_ENUM
		be .handleWord

		! double word types
		subcc %i3, 8, %l3		! typelib_TypeClass_HYPER
		be .handleDoubleWord
		subcc %i3, 9, %l3		! typelib_TypeClass_UNSIGNED_HYPER
		be .handleDoubleWord

		! float
		subcc %i3, 10, %l3	! typelib_TypeClass_FLOAT
		be .handleFloat

		! double
		subcc %i3, 11, %l3	! typelib_TypeClass_DOUBLE
		be .handleDouble

		! default: return void
		nop					! empty prefetch
		ba .doRestore
		nop
.handleByte:
		stb %o0, [%i2]
		ba .doRestore
		nop
.handleShort:
		sth %o0, [%i2]
		ba .doRestore
		nop
.handleWord:
		st %o0, [%i2]
		ba .doRestore
		nop
.handleDoubleWord:
		st %o0, [%i2]
		st %o1, [%i2+4]
		ba .doRestore
		nop
.handleFloat:
		st %f0, [%i2]
		ba .doRestore
		nop
.handleDouble:
		std %f0, [%fp-8]
		ldd [%fp-8], %o0
		st %o0, [%i2]
		st %o1, [%i2+4]
		ba .doRestore
		nop
.doRestore:
		ret
		restore	! stack frame for own locals
.size callVirtualMethod,(.-callVirtualMethod)
.align 8

.rethrow_handler:
		call	__1cG__CrunMex_rethrow_q6F_v_
		nop

.section	".exception_ranges",#alloc
.word		%r_disp32(.privateSnippetExecutorExceptionPosition)
.word		0
.word		.rethrow_handler-.privateSnippetExecutorExceptionPosition
.word		0,0
.word		%r_disp32(.callVirtualMethodExceptionPosition)
.word		0
.word		.rethrow_handler-.callVirtualMethodExceptionPosition
.word		0,0