michael@0: /* -*- Mode: asm -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: .text michael@0: .globl _SharedStub michael@0: dnl michael@0: define(STUB_MANGLED_ENTRY, michael@0: ` .globl '$2` michael@0: .align 2 michael@0: '$2`: michael@0: addi r12, 0,'$1` michael@0: b _SharedStub') michael@0: dnl michael@0: define(STUB_ENTRY, michael@0: ` .if '$1` < 10 michael@0: STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase5Stub'$1`Ev') michael@0: .elseif '$1` < 100 michael@0: STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase6Stub'$1`Ev') michael@0: .elseif '$1` < 1000 michael@0: STUB_MANGLED_ENTRY('$1`, `__ZN14nsXPTCStubBase7Stub'$1`Ev') michael@0: .else michael@0: .err "Stub'$1` >= 1000 not yet supported." michael@0: .endif michael@0: ') michael@0: dnl michael@0: define(SENTINEL_ENTRY, `') michael@0: dnl michael@0: include(xptcstubsdef.inc) michael@0: dnl michael@0: // See also xptcstubs_ppc_rhapsody.cpp:PrepareAndDispatch. michael@0: _SharedStub: michael@0: // Prolog(ue) michael@0: mflr r0 // Save the link register in the caller's michael@0: stw r0, 8(r1) // stack frame michael@0: stwu r1,-176(r1) // Allocate stack space for our own frame and michael@0: // adjust stack pointer michael@0: michael@0: // Linkage area, 0(r1) to 24(r1) michael@0: // Original sp saved at 0(r1) michael@0: michael@0: // Parameter area, 20 bytes from 24(r1) to michael@0: // 44(r1) to accomodate 5 arguments passed michael@0: // to PrepareAndDispatch michael@0: michael@0: // Local variables, 132 bytes from 44(r1) michael@0: // to 176(r1), to accomodate 5 words and michael@0: // 13 doubles michael@0: michael@0: stw r4, 44(r1) // Save parameters passed in GPRs r4-r10; michael@0: stw r5, 48(r1) // a pointer to here will be passed to michael@0: stw r6, 52(r1) // PrepareAndDispatch for access to michael@0: stw r7, 56(r1) // arguments passed in registers. r3, michael@0: stw r8, 60(r1) // the self pointer, is used for the michael@0: stw r9, 64(r1) // call but isn't otherwise needed in michael@0: stw r10, 68(r1) // PrepareAndDispatch, so it is not saved. michael@0: michael@0: stfd f1, 72(r1) // Do the same for floating-point parameters michael@0: stfd f2, 80(r1) // passed in FPRs f1-f13 michael@0: stfd f3, 88(r1) michael@0: stfd f4, 96(r1) michael@0: stfd f5, 104(r1) michael@0: stfd f6, 112(r1) michael@0: stfd f7, 120(r1) michael@0: stfd f8, 128(r1) michael@0: stfd f9, 136(r1) michael@0: stfd f10, 144(r1) michael@0: stfd f11, 152(r1) michael@0: stfd f12, 160(r1) michael@0: stfd f13, 168(r1) michael@0: michael@0: // Set up parameters for call to michael@0: // PrepareAndDispatch. argument= michael@0: // 0, pointer to self, already in r3 michael@0: mr r4,r12 // 1, stub number michael@0: addi r5, r1, 204 // 2, pointer to the parameter area in our michael@0: // caller's stack, for access to michael@0: // parameters beyond those passed in michael@0: // registers. Skip past the first parameter michael@0: // (corresponding to r3) for the same reason michael@0: // as above. 176 (size of our frame) + 24 michael@0: // (size of caller's linkage) + 4 (skipped michael@0: // parameter) michael@0: addi r6, r1, 44 // 3, pointer to saved GPRs michael@0: addi r7, r1, 72 // 4, pointer to saved FPRs michael@0: michael@0: bl L_PrepareAndDispatch$stub michael@0: // Do it michael@0: nop // Leave room for linker magic michael@0: michael@0: // Epilog(ue) michael@0: lwz r0, 184(r1) // Retrieve old link register value michael@0: addi r1, r1, 176 // Restore stack pointer michael@0: mtlr r0 // Restore link register michael@0: blr // Return michael@0: michael@0: .picsymbol_stub michael@0: L_PrepareAndDispatch$stub: // Standard PIC symbol stub michael@0: .indirect_symbol _PrepareAndDispatch michael@0: mflr r0 michael@0: bcl 20,31,L1$pb michael@0: L1$pb: michael@0: mflr r11 michael@0: addis r11,r11,ha16(L1$lz-L1$pb) michael@0: mtlr r0 michael@0: lwz r12,lo16(L1$lz-L1$pb)(r11) michael@0: mtctr r12 michael@0: addi r11,r11,lo16(L1$lz-L1$pb) michael@0: bctr michael@0: .lazy_symbol_pointer michael@0: L1$lz: michael@0: .indirect_symbol _PrepareAndDispatch michael@0: .long dyld_stub_binding_helper