1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent 571f8d1f1501d31bd7c0d0affdc7cdc8b21203a0 |
2 # Parent 571f8d1f1501d31bd7c0d0affdc7cdc8b21203a0 |
3 # User Ulrich Weigand <uweigand@de.ibm.com> |
3 # User Ulrich Weigand <uweigand@de.ibm.com> |
4 Bug 976648 - powerpc64le-linux support - xptcall port |
4 Bug 976648 - powerpc64le-linux support - xptcall port |
5 |
5 |
6 diff --git a/xpcom/reflect/xptcall/src/md/unix/moz.build b/xpcom/reflect/xptcall/src/md/unix/moz.build |
6 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/moz.build |
7 --- a/xpcom/reflect/xptcall/src/md/unix/moz.build |
7 =================================================================== |
8 +++ b/xpcom/reflect/xptcall/src/md/unix/moz.build |
8 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/moz.build |
9 @@ -228,16 +228,23 @@ if CONFIG['OS_TEST'] == 'powerpc64': |
9 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/moz.build |
|
10 @@ -224,12 +224,12 @@ if CONFIG['OS_TEST'] == 'powerpc': |
|
11 'xptcstubs_ppc_linux.cpp', |
|
12 ] |
|
13 |
|
14 -if CONFIG['OS_TEST'] == 'powerpc64': |
|
15 +if CONFIG['OS_TEST'] in ('powerpc64', 'powerpc64le'): |
10 if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'): |
16 if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'): |
11 SOURCES += [ |
17 SOURCES += [ |
12 'xptcinvoke_asm_ppc64_linux.s', |
18 - 'xptcinvoke_asm_ppc64_linux.s', |
|
19 + 'xptcinvoke_asm_ppc64_linux.S', |
13 'xptcinvoke_ppc64_linux.cpp', |
20 'xptcinvoke_ppc64_linux.cpp', |
14 'xptcstubs_asm_ppc64_linux.s', |
21 - 'xptcstubs_asm_ppc64_linux.s', |
|
22 + 'xptcstubs_asm_ppc64_linux.S', |
15 'xptcstubs_ppc64_linux.cpp', |
23 'xptcstubs_ppc64_linux.cpp', |
16 ] |
24 ] |
17 |
25 |
18 +if CONFIG['OS_TEST'] == 'powerpc64le': |
26 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.S |
19 + if CONFIG['OS_ARCH'] == 'Linux': |
27 rename from xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s |
20 + CPP_SOURCES += [ |
28 rename to xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.S |
21 + 'xptcinvoke_ppc64_linux.cpp', |
|
22 + 'xptcstubs_ppc64_linux.cpp', |
|
23 + ] |
|
24 + |
|
25 if CONFIG['OS_TEST'] in ('macppc', 'bebox', 'ofppc', 'prep', 'amigappc'): |
|
26 if CONFIG['OS_ARCH'] == 'NetBSD': |
|
27 SOURCES += [ |
|
28 'xptcinvoke_asm_ppc_netbsd.s', |
|
29 'xptcinvoke_ppc_netbsd.cpp', |
|
30 'xptcstubs_asm_ppc_netbsd.s', |
|
31 'xptcstubs_ppc_netbsd.cpp', |
|
32 ] |
|
33 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s |
|
34 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s |
29 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s |
35 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.s |
30 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc64_linux.S |
36 @@ -12,90 +12,121 @@ |
31 @@ -17,12 +17,38 @@ |
37 .set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4 |
|
38 .set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9 |
|
39 .set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14 |
|
40 .set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19 |
|
41 .set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24 |
|
42 .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
32 .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
43 .set f30,30; .set f31,31 |
33 .set f30,30; .set f31,31 |
44 |
34 |
45 +# The ABI defines a fixed stack frame area of 4 doublewords (ELFv2) |
35 +# The ABI defines a fixed stack frame area of 4 doublewords (ELFv2) |
46 +# or 6 doublewords (ELFv1); the last of these doublewords is used |
36 +# or 6 doublewords (ELFv1); the last of these doublewords is used |
75 + .localentry NS_InvokeByIndex,.-NS_InvokeByIndex |
65 + .localentry NS_InvokeByIndex,.-NS_InvokeByIndex |
76 +#else |
66 +#else |
77 .section ".toc","aw" |
67 .section ".toc","aw" |
78 .section ".text" |
68 .section ".text" |
79 .align 2 |
69 .align 2 |
80 .globl NS_InvokeByIndex |
70 @@ -34,6 +60,7 @@ NS_InvokeByIndex: |
81 .section ".opd","aw" |
|
82 .align 3 |
|
83 NS_InvokeByIndex: |
|
84 .quad .NS_InvokeByIndex,.TOC.@tocbase |
|
85 .previous |
71 .previous |
86 .type NS_InvokeByIndex,@function |
72 .type NS_InvokeByIndex,@function |
87 .NS_InvokeByIndex: |
73 .NS_InvokeByIndex: |
88 +#endif |
74 +#endif |
89 mflr 0 |
75 mflr 0 |
90 std 0,16(r1) |
76 std 0,16(r1) |
91 |
77 |
92 std r29,-24(r1) |
78 @@ -50,13 +77,12 @@ NS_InvokeByIndex: |
93 std r30,-16(r1) |
|
94 std r31,-8(r1) |
|
95 |
|
96 mr r29,r3 # Save 'that' in r29 |
|
97 mr r30,r4 # Save 'methodIndex' in r30 |
|
98 mr r31,r1 # Save old frame |
|
99 |
|
100 # Allocate stack frame with space for params. Since at least the |
|
101 # first 7 parameters (not including 'that') will be in registers, |
|
102 # we don't actually need stack space for those. We must ensure |
79 # we don't actually need stack space for those. We must ensure |
103 # that the stack remains 16-byte aligned. |
80 # that the stack remains 16-byte aligned. |
104 # |
81 # |
105 - # | ..128-byte stack frame.. | | 7 GP | 13 FP | 3 NV | |
82 - # | ..128-byte stack frame.. | | 7 GP | 13 FP | 3 NV | |
106 - # | |(params)........| regs | regs | regs | |
83 - # | |(params)........| regs | regs | regs | |
114 - addi r7,r5,((112/8)-7+7+13+3+1) |
91 - addi r7,r5,((112/8)-7+7+13+3+1) |
115 + addi r7,r5,((STACK_PARAMS/8)-7+7+13+3+1) |
92 + addi r7,r5,((STACK_PARAMS/8)-7+7+13+3+1) |
116 rldicr r7,r7,3,59 # multiply by 8 and mask with ~15 |
93 rldicr r7,r7,3,59 # multiply by 8 and mask with ~15 |
117 neg r7,r7 |
94 neg r7,r7 |
118 stdux r1,r1,r7 |
95 stdux r1,r1,r7 |
119 |
96 @@ -67,12 +93,13 @@ NS_InvokeByIndex: |
120 |
|
121 # Call invoke_copy_to_stack(uint64_t* gpregs, double* fpregs, |
|
122 # uint32_t paramCount, nsXPTCVariant* s, |
|
123 # uint64_t* d)) |
97 # uint64_t* d)) |
124 |
98 |
125 # r5, r6 are passed through intact (paramCount, params) |
99 # r5, r6 are passed through intact (paramCount, params) |
126 - # r7 (d) has to be r1+112 -- where parameters are passed on the stack. |
100 - # r7 (d) has to be r1+112 -- where parameters are passed on the stack. |
127 + # r7 (d) has to be r1+STACK_PARAMS |
101 + # r7 (d) has to be r1+STACK_PARAMS |
160 + ld r2,8(r12) # TOC pointer from fd. |
131 + ld r2,8(r12) # TOC pointer from fd. |
161 +#endif |
132 +#endif |
162 |
133 |
163 # Load FP and GP registers as required |
134 # Load FP and GP registers as required |
164 ld r4, -(23*8)(r31) |
135 ld r4, -(23*8)(r31) |
165 ld r5, -(22*8)(r31) |
136 @@ -117,7 +148,7 @@ NS_InvokeByIndex: |
166 ld r6, -(21*8)(r31) |
|
167 ld r7, -(20*8)(r31) |
|
168 ld r8, -(19*8)(r31) |
|
169 ld r9, -(18*8)(r31) |
|
170 @@ -112,21 +143,25 @@ NS_InvokeByIndex: |
|
171 lfd f9, -(8*8)(r31) |
|
172 lfd f10, -(7*8)(r31) |
|
173 lfd f11, -(6*8)(r31) |
|
174 lfd f12, -(5*8)(r31) |
|
175 lfd f13, -(4*8)(r31) |
|
176 |
137 |
177 bctrl # Do it |
138 bctrl # Do it |
178 |
139 |
179 - ld r2,40(r1) # Load our own TOC pointer |
140 - ld r2,40(r1) # Load our own TOC pointer |
180 + ld r2,STACK_TOC(r1) # Load our own TOC pointer |
141 + ld r2,STACK_TOC(r1) # Load our own TOC pointer |
181 ld r1,0(r1) # Revert stack frame |
142 ld r1,0(r1) # Revert stack frame |
182 ld 0,16(r1) # Reload lr |
143 ld 0,16(r1) # Reload lr |
183 ld 29,-24(r1) # Restore NVGPRS |
144 ld 29,-24(r1) # Restore NVGPRS |
184 ld 30,-16(r1) |
145 @@ -126,7 +157,11 @@ NS_InvokeByIndex: |
185 ld 31,-8(r1) |
|
186 mtlr 0 |
146 mtlr 0 |
187 blr |
147 blr |
188 |
148 |
189 +#if _CALL_ELF == 2 |
149 +#if _CALL_ELF == 2 |
190 + .size NS_InvokeByIndex,.-NS_InvokeByIndex |
150 + .size NS_InvokeByIndex,.-NS_InvokeByIndex |
192 .size NS_InvokeByIndex,.-.NS_InvokeByIndex |
152 .size NS_InvokeByIndex,.-.NS_InvokeByIndex |
193 +#endif |
153 +#endif |
194 |
154 |
195 # Magic indicating no need for an executable stack |
155 # Magic indicating no need for an executable stack |
196 .section .note.GNU-stack, "", @progbits ; .previous |
156 .section .note.GNU-stack, "", @progbits ; .previous |
197 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
157 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
198 --- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
158 =================================================================== |
199 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
159 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
200 @@ -69,17 +69,19 @@ invoke_copy_to_stack(uint64_t* gpregs, |
160 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.cpp |
201 else |
161 @@ -74,7 +74,9 @@ invoke_copy_to_stack(uint64_t* gpregs, |
202 *(double *)d = s->val.d; |
|
203 } |
|
204 else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) { |
|
205 if (i < FPR_COUNT) { |
|
206 fpregs[i] = s->val.f; // if passed in registers, floats are promoted to doubles |
162 fpregs[i] = s->val.f; // if passed in registers, floats are promoted to doubles |
207 } else { |
163 } else { |
208 float *p = (float *)d; |
164 float *p = (float *)d; |
209 +#ifndef __LITTLE_ENDIAN__ |
165 +#ifndef __LITTLE_ENDIAN__ |
210 p++; |
166 p++; |
211 +#endif |
167 +#endif |
212 *p = s->val.f; |
168 *p = s->val.f; |
213 } |
169 } |
214 } |
170 } |
215 else { |
171 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.S |
216 if (i < GPR_COUNT) |
172 rename from xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s |
217 gpregs[i] = tempu64; |
173 rename to xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.S |
218 else |
|
219 *d = tempu64; |
|
220 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s |
|
221 --- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s |
174 --- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s |
222 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.s |
175 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc64_linux.S |
223 @@ -12,28 +12,50 @@ |
176 @@ -17,6 +17,27 @@ |
224 .set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4 |
|
225 .set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9 |
|
226 .set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14 |
|
227 .set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19 |
|
228 .set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24 |
|
229 .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
177 .set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29 |
230 .set f30,30; .set f31,31 |
178 .set f30,30; .set f31,31 |
231 |
179 |
232 +#if _CALL_ELF == 2 |
180 +#if _CALL_ELF == 2 |
233 +#define STACK_PARAMS 96 |
181 +#define STACK_PARAMS 96 |
251 + .localentry SharedStub,.-SharedStub |
199 + .localentry SharedStub,.-SharedStub |
252 +#else |
200 +#else |
253 .section ".text" |
201 .section ".text" |
254 .align 2 |
202 .align 2 |
255 .globl SharedStub |
203 .globl SharedStub |
256 .section ".opd","aw" |
204 @@ -29,6 +50,7 @@ SharedStub: |
257 .align 3 |
|
258 |
|
259 SharedStub: |
|
260 .quad .SharedStub,.TOC.@tocbase |
|
261 .previous |
|
262 .type SharedStub,@function |
205 .type SharedStub,@function |
263 |
206 |
264 .SharedStub: |
207 .SharedStub: |
265 +#endif |
208 +#endif |
266 mflr r0 |
209 mflr r0 |
267 |
210 |
268 std r4, -56(r1) # Save all GPRS |
211 std r4, -56(r1) # Save all GPRS |
269 std r5, -48(r1) |
212 @@ -55,7 +77,7 @@ SharedStub: |
270 std r6, -40(r1) |
|
271 std r7, -32(r1) |
|
272 std r8, -24(r1) |
|
273 std r9, -16(r1) |
|
274 @@ -50,17 +72,17 @@ SharedStub: |
|
275 stfd f5, -128(r1) |
|
276 stfd f4, -136(r1) |
|
277 stfd f3, -144(r1) |
|
278 stfd f2, -152(r1) |
|
279 stfd f1, -160(r1) |
|
280 |
213 |
281 subi r6,r1,56 # r6 --> gprData |
214 subi r6,r1,56 # r6 --> gprData |
282 subi r7,r1,160 # r7 --> fprData |
215 subi r7,r1,160 # r7 --> fprData |
283 - addi r5,r1,112 # r5 --> extra stack args |
216 - addi r5,r1,112 # r5 --> extra stack args |
284 + addi r5,r1,STACK_PARAMS # r5 --> extra stack args |
217 + addi r5,r1,STACK_PARAMS # r5 --> extra stack args |
285 |
218 |
286 std r0, 16(r1) |
219 std r0, 16(r1) |
287 |
220 |
288 stdu r1,-288(r1) |
221 @@ -75,7 +97,11 @@ SharedStub: |
289 # r3 has the 'self' pointer |
|
290 # already |
|
291 |
|
292 mr r4,r11 # r4 is methodIndex selector, |
|
293 @@ -70,12 +92,16 @@ SharedStub: |
|
294 bl PrepareAndDispatch |
|
295 nop |
|
296 |
|
297 ld 1,0(r1) # restore stack |
|
298 ld r0,16(r1) # restore LR |
|
299 mtlr r0 |
222 mtlr r0 |
300 blr |
223 blr |
301 |
224 |
302 +#if _CALL_ELF == 2 |
225 +#if _CALL_ELF == 2 |
303 + .size SharedStub,.-SharedStub |
226 + .size SharedStub,.-SharedStub |
305 .size SharedStub,.-.SharedStub |
228 .size SharedStub,.-.SharedStub |
306 +#endif |
229 +#endif |
307 |
230 |
308 # Magic indicating no need for an executable stack |
231 # Magic indicating no need for an executable stack |
309 .section .note.GNU-stack, "", @progbits ; .previous |
232 .section .note.GNU-stack, "", @progbits ; .previous |
310 diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
233 Index: mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
311 --- a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
234 =================================================================== |
312 +++ b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
235 --- mozilla.orig/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
313 @@ -78,17 +78,19 @@ PrepareAndDispatch(nsXPTCStubBase* self, |
236 +++ mozilla/xpcom/reflect/xptcall/src/md/unix/xptcstubs_ppc64_linux.cpp |
314 dp->val.d = fprData[i]; |
237 @@ -83,7 +83,9 @@ PrepareAndDispatch(nsXPTCStubBase* self, |
315 else |
|
316 dp->val.d = *(double*) ap; |
|
317 } else if (!param.IsOut() && type == nsXPTType::T_FLOAT) { |
|
318 if (i < FPR_COUNT) |
|
319 dp->val.f = (float) fprData[i]; // in registers floats are passed as doubles |
238 dp->val.f = (float) fprData[i]; // in registers floats are passed as doubles |
320 else { |
239 else { |
321 float *p = (float *)ap; |
240 float *p = (float *)ap; |
322 +#ifndef __LITTLE_ENDIAN__ |
241 +#ifndef __LITTLE_ENDIAN__ |
323 p++; |
242 p++; |
324 +#endif |
243 +#endif |
325 dp->val.f = *p; |
244 dp->val.f = *p; |
326 } |
245 } |
327 } else { /* integer type or pointer */ |
246 } else { /* integer type or pointer */ |
328 if (i < GPR_COUNT) |
247 @@ -153,6 +155,43 @@ PrepareAndDispatch(nsXPTCStubBase* self, |
329 tempu64 = gprData[i]; |
|
330 else |
|
331 tempu64 = *ap; |
|
332 |
|
333 @@ -148,16 +150,53 @@ PrepareAndDispatch(nsXPTCStubBase* self, |
|
334 // Create names would be like: |
|
335 // _ZN14nsXPTCStubBase5Stub1Ev |
|
336 // _ZN14nsXPTCStubBase6Stub12Ev |
|
337 // _ZN14nsXPTCStubBase7Stub123Ev |
|
338 // _ZN14nsXPTCStubBase8Stub1234Ev |
|
339 // etc. |
248 // etc. |
340 // Use assembler directives to get the names right... |
249 // Use assembler directives to get the names right... |
341 |
250 |
342 +#if _CALL_ELF == 2 |
251 +#if _CALL_ELF == 2 |
343 +# define STUB_ENTRY(n) \ |
252 +# define STUB_ENTRY(n) \ |
377 +); |
286 +); |
378 +#else |
287 +#else |
379 # define STUB_ENTRY(n) \ |
288 # define STUB_ENTRY(n) \ |
380 __asm__ ( \ |
289 __asm__ ( \ |
381 ".section \".toc\",\"aw\" \n\t" \ |
290 ".section \".toc\",\"aw\" \n\t" \ |
382 ".section \".text\" \n\t" \ |
291 @@ -195,6 +234,7 @@ __asm__ ( |
383 ".align 2 \n\t" \ |
|
384 ".if "#n" < 10 \n\t" \ |
|
385 ".globl _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ |
|
386 ".section \".opd\",\"aw\" \n\t" \ |
|
387 @@ -190,16 +229,17 @@ PrepareAndDispatch(nsXPTCStubBase* self, |
|
388 \ |
|
389 ".else \n\t" \ |
|
390 ".err \"stub number "#n" >= 1000 not yet supported\"\n" \ |
|
391 ".endif \n\t" \ |
|
392 \ |
|
393 "li 11,"#n" \n\t" \ |
292 "li 11,"#n" \n\t" \ |
394 "b SharedStub \n" \ |
293 "b SharedStub \n" \ |
395 ); |
294 ); |
396 +#endif |
295 +#endif |
397 |
296 |
398 #define SENTINEL_ENTRY(n) \ |
297 #define SENTINEL_ENTRY(n) \ |
399 nsresult nsXPTCStubBase::Sentinel##n() \ |
298 nsresult nsXPTCStubBase::Sentinel##n() \ |
400 { \ |
|
401 NS_ERROR("nsXPTCStubBase::Sentinel called"); \ |
|
402 return NS_ERROR_NOT_IMPLEMENTED; \ |
|
403 } |
|
404 |
|