Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: asm -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 .text
7 .globl _SharedStub
8 dnl
9 define(STUB_MANGLED_ENTRY,
10 ` .globl '$2`
11 .align 2
12 '$2`:
13 addi r12, 0,'$1`
14 b _SharedStub')
15 dnl
16 define(STUB_ENTRY,
17 ` .if '$1` < 10
18 STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase5Stub'$1`Ev')
19 .elseif '$1` < 100
20 STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase6Stub'$1`Ev')
21 .elseif '$1` < 1000
22 STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase7Stub'$1`Ev')
23 .else
24 .err "Stub'$1` >= 1000 not yet supported."
25 .endif
26 ')
27 dnl
28 define(SENTINEL_ENTRY, `')
29 dnl
30 include(xptcstubsdef.inc)
31 dnl
32 // See also xptcstubs_ppc_rhapsody.cpp:PrepareAndDispatch.
33 _SharedStub:
34 // Prolog(ue)
35 mflr r0 // Save the link register in the caller's
36 stw r0, 8(r1) // stack frame
37 stwu r1,-176(r1) // Allocate stack space for our own frame and
38 // adjust stack pointer
40 // Linkage area, 0(r1) to 24(r1)
41 // Original sp saved at 0(r1)
43 // Parameter area, 20 bytes from 24(r1) to
44 // 44(r1) to accomodate 5 arguments passed
45 // to PrepareAndDispatch
47 // Local variables, 132 bytes from 44(r1)
48 // to 176(r1), to accomodate 5 words and
49 // 13 doubles
51 stw r4, 44(r1) // Save parameters passed in GPRs r4-r10;
52 stw r5, 48(r1) // a pointer to here will be passed to
53 stw r6, 52(r1) // PrepareAndDispatch for access to
54 stw r7, 56(r1) // arguments passed in registers. r3,
55 stw r8, 60(r1) // the self pointer, is used for the
56 stw r9, 64(r1) // call but isn't otherwise needed in
57 stw r10, 68(r1) // PrepareAndDispatch, so it is not saved.
59 stfd f1, 72(r1) // Do the same for floating-point parameters
60 stfd f2, 80(r1) // passed in FPRs f1-f13
61 stfd f3, 88(r1)
62 stfd f4, 96(r1)
63 stfd f5, 104(r1)
64 stfd f6, 112(r1)
65 stfd f7, 120(r1)
66 stfd f8, 128(r1)
67 stfd f9, 136(r1)
68 stfd f10, 144(r1)
69 stfd f11, 152(r1)
70 stfd f12, 160(r1)
71 stfd f13, 168(r1)
73 // Set up parameters for call to
74 // PrepareAndDispatch. argument=
75 // 0, pointer to self, already in r3
76 mr r4,r12 // 1, stub number
77 addi r5, r1, 204 // 2, pointer to the parameter area in our
78 // caller's stack, for access to
79 // parameters beyond those passed in
80 // registers. Skip past the first parameter
81 // (corresponding to r3) for the same reason
82 // as above. 176 (size of our frame) + 24
83 // (size of caller's linkage) + 4 (skipped
84 // parameter)
85 addi r6, r1, 44 // 3, pointer to saved GPRs
86 addi r7, r1, 72 // 4, pointer to saved FPRs
88 bl L_PrepareAndDispatch$stub
89 // Do it
90 nop // Leave room for linker magic
92 // Epilog(ue)
93 lwz r0, 184(r1) // Retrieve old link register value
94 addi r1, r1, 176 // Restore stack pointer
95 mtlr r0 // Restore link register
96 blr // Return
98 .picsymbol_stub
99 L_PrepareAndDispatch$stub: // Standard PIC symbol stub
100 .indirect_symbol _PrepareAndDispatch
101 mflr r0
102 bcl 20,31,L1$pb
103 L1$pb:
104 mflr r11
105 addis r11,r11,ha16(L1$lz-L1$pb)
106 mtlr r0
107 lwz r12,lo16(L1$lz-L1$pb)(r11)
108 mtctr r12
109 addi r11,r11,lo16(L1$lz-L1$pb)
110 bctr
111 .lazy_symbol_pointer
112 L1$lz:
113 .indirect_symbol _PrepareAndDispatch
114 .long dyld_stub_binding_helper