summaryrefslogtreecommitdiffstats
path: root/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_riscv64.S
blob: 46065232962cd20620667c3805aca99603b26e6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

    .set NGPREGS, 8
    .set NFPREGS, 8

    .text
    .globl  _NS_InvokeByIndex
    .type   _NS_InvokeByIndex, @function
/*
 * _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
 *                   uint32_t paramCount, nsXPTCVariant* params)
 */
_NS_InvokeByIndex:
    .cfi_startproc
    addi    sp, sp, -32
    .cfi_adjust_cfa_offset 32
    sd      s0, 16(sp)
    .cfi_rel_offset s0, 16
    sd      s1, 8(sp)
    .cfi_rel_offset s1, 8
    sd      s2, 0(sp)
    .cfi_rel_offset s2, 0
    sd      ra, 24(sp)
    .cfi_rel_offset ra, 24

    mv      s2, a0
    mv      s1, a1
    mv      s0, sp
    .cfi_def_cfa_register s0

    /* 16-bytes alignment */
    addiw   a0, a2, 1
    andi    a0, a0, -2
    slli    a0, a0, 3
    sub     sp, sp, a0
    mv      a4, sp

    addi    sp, sp, -8*(NGPREGS+NFPREGS)
    mv      a0, sp
    addi    a1, sp, 8*NGPREGS

    call    invoke_copy_to_stack

    /* 1st argument is this */
    mv      a0, s2

    ld      a1, 8(sp)
    ld      a2, 16(sp)
    ld      a3, 24(sp)
    ld      a4, 32(sp)
    ld      a5, 40(sp)
    ld      a6, 48(sp)
    ld      a7, 56(sp)

    fld     fa0, 64(sp)
    fld     fa1, 72(sp)
    fld     fa2, 80(sp)
    fld     fa3, 88(sp)
    fld     fa4, 96(sp)
    fld     fa5, 104(sp)
    fld     fa6, 112(sp)
    fld     fa7, 120(sp)

    addi    sp, sp, 8*(NGPREGS+NFPREGS)

    ld      s2, 0(s2)
    slliw   s1, s1, 3
    add     s2, s2, s1
    ld      t0, 0(s2)
    jalr    t0

    mv      sp, s0
    .cfi_def_cfa_register sp
    ld      s0, 16(sp)
    .cfi_restore s0
    ld      s1, 8(sp)
    .cfi_restore s1
    ld      s2, 0(sp)
    .cfi_restore s2
    ld      ra, 24(sp)
    .cfi_restore ra
    addi    sp, sp, 32
    .cfi_adjust_cfa_offset -32
    ret
    .cfi_endproc
    .size   _NS_InvokeByIndex, . - _NS_InvokeByIndex
    .section .note.GNU-stack, "", @progbits