1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
5
6#ifdef __APPLE__
7#define SYM(x) _ ## x
8#else
9#define SYM(x) x
10#endif
11
12            .text
13            .align 2
14            .globl SYM(_NS_InvokeByIndex)
15#ifndef __APPLE__
16            .type  _NS_InvokeByIndex,@function
17#endif
18
19/*
20 * _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
21 *                   uint32_t paramCount, nsXPTCVariant* params)
22 */
23
24SYM(_NS_InvokeByIndex):
25            .cfi_startproc
26            # set up frame
27            stp         x29, x30, [sp,#-32]!
28            .cfi_adjust_cfa_offset 32
29            .cfi_rel_offset x29, 0
30            .cfi_rel_offset x30, 8
31            mov         x29, sp
32            .cfi_def_cfa_register x29
33            stp         x19, x20, [sp,#16]
34            .cfi_rel_offset x19, 16
35            .cfi_rel_offset x20, 24
36
37            # save methodIndex across function calls
38            mov         w20, w1
39
40            # end of stack area passed to invoke_copy_to_stack
41            mov         x1, sp
42
43            # assume 8 bytes of stack for each argument with 16-byte alignment
44            add         w19, w2, #1
45            and         w19, w19, #0xfffffffe
46            sub         sp, sp, w19, uxth #3
47
48            # temporary place to store args passed in r0-r7,v0-v7
49            sub         sp, sp, #128
50
51            # save 'that' on stack
52            str         x0, [sp]
53
54            # start of stack area passed to invoke_copy_to_stack
55            mov         x0, sp
56            bl          SYM(invoke_copy_to_stack)
57
58            # load arguments passed in r0-r7
59            ldp         x6, x7, [sp, #48]
60            ldp         x4, x5, [sp, #32]
61            ldp         x2, x3, [sp, #16]
62            ldp         x0, x1, [sp],#64
63
64            # load arguments passed in v0-v7
65            ldp         d6, d7, [sp, #48]
66            ldp         d4, d5, [sp, #32]
67            ldp         d2, d3, [sp, #16]
68            ldp         d0, d1, [sp],#64
69
70            # call the method
71            ldr         x16, [x0]
72            add         x16, x16, w20, uxth #3
73            ldr         x16, [x16]
74            blr         x16
75
76            add         sp, sp, w19, uxth #3
77            .cfi_def_cfa_register sp
78            ldp         x19, x20, [sp,#16]
79            .cfi_restore x19
80            .cfi_restore x20
81            ldp         x29, x30, [sp],#32
82            .cfi_adjust_cfa_offset -32
83            .cfi_restore x29
84            .cfi_restore x30
85            ret
86            .cfi_endproc
87
88#ifndef __APPLE__
89            .size _NS_InvokeByIndex, . - _NS_InvokeByIndex
90
91            .section .note.GNU-stack, "", @progbits
92#endif
93