michael@0: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * 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: /* Platform specific code to invoke XPCOM methods on native objects */ michael@0: .global XPTC_InvokeByIndex michael@0: /* michael@0: XPTC_InvokeByIndex(nsISupports* that, uint32_t methodIndex, michael@0: uint32_t paramCount, nsXPTCVariant* params); michael@0: michael@0: */ michael@0: XPTC_InvokeByIndex: michael@0: save %sp,-(64 + 16),%sp ! room for the register window and michael@0: ! struct pointer, rounded up to 0 % 16 michael@0: mov %i2,%o0 ! paramCount michael@0: call invoke_count_words ! returns the required stack size in %o0 michael@0: mov %i3,%o1 ! params michael@0: michael@0: sll %o0,2,%l0 ! number of bytes michael@0: sub %sp,%l0,%sp ! create the additional stack space michael@0: michael@0: mov %sp,%o0 ! pointer for copied args michael@0: add %o0,72,%o0 ! step past the register window, the michael@0: ! struct result pointer and the 'this' slot michael@0: mov %i2,%o1 ! paramCount michael@0: call invoke_copy_to_stack michael@0: mov %i3,%o2 ! params michael@0: ! michael@0: ! calculate the target address from the vtable michael@0: ! michael@0: add %i1,1,%i1 ! vTable is zero-based, index is 1 based (?) michael@0: ld [%i0],%l1 ! *that --> vTable michael@0: sll %i1,3,%i1 michael@0: add %i1,%l1,%l1 ! vTable[index * 8], l1 now points to vTable entry michael@0: lduh [%l1],%l0 ! this adjustor michael@0: sll %l0,16,%l0 ! sign extend to 32 bits michael@0: sra %l0,16,%l0 michael@0: add %l0,%i0,%i0 ! adjust this michael@0: ld [%l1 + 4],%l0 ! target address michael@0: michael@0: .L5: ld [%sp + 88],%o5 michael@0: .L4: ld [%sp + 84],%o4 michael@0: .L3: ld [%sp + 80],%o3 michael@0: .L2: ld [%sp + 76],%o2 michael@0: .L1: ld [%sp + 72],%o1 michael@0: .L0: michael@0: jmpl %l0,%o7 ! call the routine michael@0: ! always have a 'this', from the incoming 'that' michael@0: mov %i0,%o0 michael@0: michael@0: mov %o0,%i0 ! propagate return value michael@0: ret michael@0: restore