1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this
3# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5.set r0,0; .set r1,1; .set RTOC,2; .set r3,3; .set r4,4
6.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
7.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
8.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
9.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
10.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
11.set r30,30; .set r31,31
12.set f0,0; .set f1,1; .set f2,2; .set f3,3; .set f4,4
13.set f5,5; .set f6,6; .set f7,7; .set f8,8; .set f9,9
14.set f10,10; .set f11,11; .set f12,12; .set f13,13; .set f14,14
15.set f15,15; .set f16,16; .set f17,17; .set f18,18; .set f19,19
16.set f20,20; .set f21,21; .set f22,22; .set f23,23; .set f24,24
17.set f25,25; .set f26,26; .set f27,27; .set f28,28; .set f29,29
18.set f30,30; .set f31,31
19
20#if _CALL_ELF == 2
21#define STACK_PARAMS   96
22#else
23#define STACK_PARAMS   112
24#endif
25
26#if _CALL_ELF == 2
27        .section ".text"
28        .type   SharedStub,@function
29        .globl  SharedStub
30        # Make the symbol hidden so that the branch from the stub does
31        # not go via a PLT.  This is not only better for performance,
32        # but may be necessary to avoid linker errors since there is
33        # no place to restore the TOC register in a sibling call.
34        .hidden SharedStub
35        .align 2
36SharedStub:
370:      addis 2,12,(.TOC.-0b)@ha
38        addi 2,2,(.TOC.-0b)@l
39        .localentry SharedStub,.-SharedStub
40#else
41        .section ".text"
42        .align 2
43        .globl SharedStub
44        # Make the symbol hidden so that the branch from the stub does
45        # not go via a PLT.  This is not only better for performance,
46        # but may be necessary to avoid linker errors since there is
47        # no place to restore the TOC register in a sibling call.
48        .hidden SharedStub
49        .section ".opd","aw"
50        .align 3
51
52SharedStub:
53        .quad   .SharedStub,.TOC.@tocbase
54        .previous
55        .type   SharedStub,@function
56
57.SharedStub:
58#endif
59        mflr    r0
60
61        std     r4, -56(r1)                     # Save all GPRS
62        std     r5, -48(r1)
63        std     r6, -40(r1)
64        std     r7, -32(r1)
65        std     r8, -24(r1)
66        std     r9, -16(r1)
67        std     r10, -8(r1)
68
69        stfd    f13, -64(r1)                    # ... and FPRS
70        stfd    f12, -72(r1)
71        stfd    f11, -80(r1)
72        stfd    f10, -88(r1)
73        stfd    f9, -96(r1)
74        stfd    f8, -104(r1)
75        stfd    f7, -112(r1)
76        stfd    f6, -120(r1)
77        stfd    f5, -128(r1)
78        stfd    f4, -136(r1)
79        stfd    f3, -144(r1)
80        stfd    f2, -152(r1)
81        stfd    f1, -160(r1)
82
83        subi    r6,r1,56                        # r6 --> gprData
84        subi    r7,r1,160                       # r7 --> fprData
85        addi    r5,r1,STACK_PARAMS              # r5 --> extra stack args
86
87        std     r0, 16(r1)
88
89        stdu    r1,-288(r1)
90                                                # r3 has the 'self' pointer
91                                                # already
92
93        mr      r4,r11                          # r4 is methodIndex selector,
94                                                # passed via r11 in the
95                                                # nsNSStubBase::StubXX() call
96
97        bl      PrepareAndDispatch
98        nop
99
100        ld      1,0(r1)                         # restore stack
101        ld      r0,16(r1)                       # restore LR
102        mtlr    r0
103        blr
104
105#if _CALL_ELF == 2
106        .size   SharedStub,.-SharedStub
107#else
108        .size   SharedStub,.-.SharedStub
109#endif
110
111        # Magic indicating no need for an executable stack
112        .section .note.GNU-stack, "", @progbits ; .previous
113