xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.S

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: asm; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* This code is for MIPS using the O32 ABI. */
michael@0 7
michael@0 8 #ifdef ANDROID
michael@0 9 #include <asm/regdef.h>
michael@0 10 #include <asm/asm.h>
michael@0 11 #include <machine/asm.h>
michael@0 12 #else
michael@0 13 #include <sys/regdef.h>
michael@0 14 #include <sys/asm.h>
michael@0 15 #endif
michael@0 16
michael@0 17 # NARGSAVE is the argument space in the callers frame, including extra
michael@0 18 # 'shadowed' space for the argument registers. The minimum of 4
michael@0 19 # argument slots is sometimes predefined in the header files.
michael@0 20 #ifndef NARGSAVE
michael@0 21 #define NARGSAVE 4
michael@0 22 #endif
michael@0 23
michael@0 24 #define LOCALSZ 2 /* gp, ra */
michael@0 25 #define FRAMESZ ((((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK)
michael@0 26
michael@0 27 #define RAOFF (FRAMESZ - (1*SZREG))
michael@0 28 #define GPOFF (FRAMESZ - (2*SZREG))
michael@0 29
michael@0 30 #define A0OFF (FRAMESZ + (0*SZREG))
michael@0 31 #define A1OFF (FRAMESZ + (1*SZREG))
michael@0 32 #define A2OFF (FRAMESZ + (2*SZREG))
michael@0 33 #define A3OFF (FRAMESZ + (3*SZREG))
michael@0 34
michael@0 35 .text
michael@0 36
michael@0 37 #define STUB_ENTRY(x) \
michael@0 38 .if x < 10; \
michael@0 39 .globl _ZN14nsXPTCStubBase5Stub ##x ##Ev; \
michael@0 40 .type _ZN14nsXPTCStubBase5Stub ##x ##Ev,@function; \
michael@0 41 .aent _ZN14nsXPTCStubBase5Stub ##x ##Ev,0; \
michael@0 42 _ZN14nsXPTCStubBase5Stub ##x ##Ev:; \
michael@0 43 SETUP_GP; \
michael@0 44 li t0,x; \
michael@0 45 b sharedstub; \
michael@0 46 .elseif x < 100; \
michael@0 47 .globl _ZN14nsXPTCStubBase6Stub ##x ##Ev; \
michael@0 48 .type _ZN14nsXPTCStubBase6Stub ##x ##Ev,@function; \
michael@0 49 .aent _ZN14nsXPTCStubBase6Stub ##x ##Ev,0; \
michael@0 50 _ZN14nsXPTCStubBase6Stub ##x ##Ev:; \
michael@0 51 SETUP_GP; \
michael@0 52 li t0,x; \
michael@0 53 b sharedstub; \
michael@0 54 .elseif x < 1000; \
michael@0 55 .globl _ZN14nsXPTCStubBase7Stub ##x ##Ev; \
michael@0 56 .type _ZN14nsXPTCStubBase7Stub ##x ##Ev,@function; \
michael@0 57 .aent _ZN14nsXPTCStubBase7Stub ##x ##Ev,0; \
michael@0 58 _ZN14nsXPTCStubBase7Stub ##x ##Ev:; \
michael@0 59 SETUP_GP; \
michael@0 60 li t0,x; \
michael@0 61 b sharedstub; \
michael@0 62 .else; \
michael@0 63 .err; \
michael@0 64 .endif
michael@0 65
michael@0 66 # SENTINEL_ENTRY is handled in the cpp file.
michael@0 67 #define SENTINEL_ENTRY(x)
michael@0 68
michael@0 69 #
michael@0 70 # open a dummy frame for the function entries
michael@0 71 #
michael@0 72 .align 2
michael@0 73 .type dummy,@function
michael@0 74 .ent dummy, 0
michael@0 75 .frame sp, FRAMESZ, ra
michael@0 76 dummy:
michael@0 77 SETUP_GP
michael@0 78
michael@0 79 #include "xptcstubsdef.inc"
michael@0 80
michael@0 81 sharedstub:
michael@0 82 subu sp, FRAMESZ
michael@0 83
michael@0 84 # specify the save register mask for gp, ra, a0-a3
michael@0 85 .mask 0x900000F0, RAOFF-FRAMESZ
michael@0 86
michael@0 87 sw ra, RAOFF(sp)
michael@0 88 SAVE_GP(GPOFF)
michael@0 89
michael@0 90 # Micro-optimization: a0 is already loaded, and its slot gets
michael@0 91 # ignored by PrepareAndDispatch, so no need to save it here.
michael@0 92 # sw a0, A0OFF(sp)
michael@0 93 sw a1, A1OFF(sp)
michael@0 94 sw a2, A2OFF(sp)
michael@0 95 sw a3, A3OFF(sp)
michael@0 96
michael@0 97 la t9, PrepareAndDispatch
michael@0 98
michael@0 99 # t0 is methodIndex
michael@0 100 move a1, t0
michael@0 101 # have a2 point to the begin of the argument space on stack
michael@0 102 addiu a2, sp, FRAMESZ
michael@0 103
michael@0 104 # PrepareAndDispatch(that, methodIndex, args)
michael@0 105 jalr t9
michael@0 106
michael@0 107 # Micro-optimization: Using jalr explicitly has the side-effect
michael@0 108 # of not triggering .cprestore. This is ok because we have no
michael@0 109 # gp reference below this point. It also allows better
michael@0 110 # instruction sscheduling.
michael@0 111 # lw gp, GPOFF(fp)
michael@0 112
michael@0 113 lw ra, RAOFF(sp)
michael@0 114 addiu sp, FRAMESZ
michael@0 115 j ra
michael@0 116 END(dummy)

mercurial