michael@0: /* -*- Mode: asm; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 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: /* michael@0: Platform specific code to invoke XPCOM methods on native objects michael@0: for sparcv9 Solaris. michael@0: michael@0: See the SPARC Compliance Definition (SCD) Chapter 3 michael@0: for more information about what is going on here, including michael@0: the use of BIAS (0x7ff). michael@0: The SCD is available from http://www.sparc.com/. michael@0: */ michael@0: michael@0: .global NS_InvokeByIndex michael@0: .type NS_InvokeByIndex, #function michael@0: michael@0: /* michael@0: NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, michael@0: uint32_t paramCount, nsXPTCVariant* params); michael@0: michael@0: */ michael@0: NS_InvokeByIndex: michael@0: save %sp,-(128 + 64),%sp ! room for the register window and michael@0: ! struct pointer, rounded up to 0 % 64 michael@0: sll %i2,4,%l0 ! assume the worst case michael@0: ! paramCount * 2 * 8 bytes michael@0: cmp %l0, 0 ! are there any args? If not, michael@0: be .invoke ! no need to copy args to stack michael@0: nop michael@0: michael@0: sub %sp,%l0,%sp ! create the additional stack space michael@0: add %sp,0x7ff+136,%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: ! michael@0: ! load arguments from stack into the outgoing registers michael@0: ! BIAS is 0x7ff (2047) michael@0: ! michael@0: michael@0: ! load the %o1..5 64bit (extended word) output registers registers michael@0: ldx [%sp + 0x7ff + 136],%o1 ! %i1 michael@0: ldx [%sp + 0x7ff + 144],%o2 ! %i2 michael@0: ldx [%sp + 0x7ff + 152],%o3 ! %i3 michael@0: ldx [%sp + 0x7ff + 160],%o4 ! %i4 michael@0: ldx [%sp + 0x7ff + 168],%o5 ! %i5 michael@0: michael@0: ! load the even number double registers starting with %f2 michael@0: ldd [%sp + 0x7ff + 136],%f2 michael@0: ldd [%sp + 0x7ff + 144],%f4 michael@0: ldd [%sp + 0x7ff + 152],%f6 michael@0: ldd [%sp + 0x7ff + 160],%f8 michael@0: ldd [%sp + 0x7ff + 168],%f10 michael@0: ldd [%sp + 0x7ff + 176],%f12 michael@0: ldd [%sp + 0x7ff + 184],%f14 michael@0: ldd [%sp + 0x7ff + 192],%f16 michael@0: ldd [%sp + 0x7ff + 200],%f18 michael@0: ldd [%sp + 0x7ff + 208],%f20 michael@0: ldd [%sp + 0x7ff + 216],%f22 michael@0: ldd [%sp + 0x7ff + 224],%f24 michael@0: ldd [%sp + 0x7ff + 232],%f26 michael@0: ldd [%sp + 0x7ff + 240],%f28 michael@0: ldd [%sp + 0x7ff + 248],%f30 michael@0: michael@0: ! michael@0: ! calculate the target address from the vtable michael@0: ! michael@0: .invoke: michael@0: sll %i1,3,%l0 ! index *= 8 michael@0: ! add %l0,16,%l0 ! there are 2 extra entries in the vTable (16bytes) michael@0: ldx [%i0],%l1 ! *that --> address of vtable michael@0: ldx [%l0 + %l1],%l0 ! that->vtable[index * 8 + 16] --> address michael@0: michael@0: jmpl %l0,%o7 ! call the routine michael@0: mov %i0,%o0 ! move 'this' pointer to out register michael@0: michael@0: mov %o0,%i0 ! propagate return value michael@0: ret michael@0: restore michael@0: michael@0: .size NS_InvokeByIndex, .-NS_InvokeByIndex