xpcom/reflect/xptcall/src/md/unix/xptcinvoke_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

     1 /* -*- Mode: asm; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * Version: MPL 1.1
     3  *
     4  * This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 /* This code is for MIPS using the O32 ABI. */
    10 #ifdef ANDROID
    11 #include <asm/regdef.h>
    12 #include <asm/asm.h>
    13 #include <machine/asm.h>
    14 #else
    15 #include <sys/regdef.h>
    16 #include <sys/asm.h>
    17 #endif
    19 # NARGSAVE is the argument space in the callers frame, including extra
    20 # 'shadowed' space for the argument registers. The minimum of 4
    21 # argument slots is sometimes predefined in the header files.
    22 #ifndef NARGSAVE
    23 #define NARGSAVE 4
    24 #endif
    26 #define LOCALSZ 3	/* gp, fp, ra */
    27 #define FRAMESZ ((((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK)
    29 #define RAOFF (FRAMESZ - (1*SZREG))
    30 #define FPOFF (FRAMESZ - (2*SZREG))
    31 #define GPOFF (FRAMESZ - (3*SZREG))
    33 #define A0OFF (FRAMESZ + (0*SZREG))
    34 #define A1OFF (FRAMESZ + (1*SZREG))
    35 #define A2OFF (FRAMESZ + (2*SZREG))
    36 #define A3OFF (FRAMESZ + (3*SZREG))
    38 	.text
    40 #	
    41 # _NS_InvokeByIndex(that, methodIndex, paramCount, params)
    42 #                      a0       a1          a2         a3
    44 	.globl	_NS_InvokeByIndex
    45 	.align	2
    46 	.type	_NS_InvokeByIndex,@function
    47 	.ent	_NS_InvokeByIndex,0
    48 	.frame	fp, FRAMESZ, ra
    49 _NS_InvokeByIndex:
    50 	SETUP_GP
    51 	subu	sp, FRAMESZ
    53 	# specify the save register mask for gp, fp, ra, a3 - a0
    54 	.mask 0xD00000F0, RAOFF-FRAMESZ
    56 	sw	ra, RAOFF(sp)
    57 	sw	fp, FPOFF(sp)
    59 	# we can't use .cprestore in a variable stack frame
    60 	sw	gp, GPOFF(sp)
    62 	sw	a0, A0OFF(sp)
    63 	sw	a1, A1OFF(sp)
    64 	sw	a2, A2OFF(sp)
    65 	sw	a3, A3OFF(sp)
    67 	# save bottom of fixed frame
    68 	move	fp, sp
    70 	# extern "C" uint32
    71 	# invoke_count_words(uint32_t paramCount, nsXPTCVariant* s);
    72 	la	t9, invoke_count_words
    73 	move	a0, a2
    74 	move	a1, a3
    75 	jalr	t9
    76 	lw  	gp, GPOFF(fp)
    78 	# allocate variable stack, with a size of:
    79 	# wordsize (of 4 bytes) * result (already aligned to dword)
    80 	# but a minimum of 16 byte
    81 	sll	v0, 2
    82 	slt	t0, v0, 16
    83 	beqz	t0, 1f
    84 	li	v0, 16
    85 1:	subu	sp, v0
    87 	# let a0 point to the bottom of the variable stack, allocate
    88 	# another fixed stack for:
    89 	# extern "C" void
    90 	# invoke_copy_to_stack(uint32_t* d, uint32_t paramCount,
    91 	#		       nsXPTCVariant* s);
    92 	la	t9, invoke_copy_to_stack
    93 	move	a0, sp
    94 	lw	a1, A2OFF(fp)
    95 	lw	a2, A3OFF(fp)
    96 	subu	sp, 16
    97 	jalr	t9
    98 	lw  	gp, GPOFF(fp)
   100 	# back to the variable stack frame
   101 	addu	sp, 16
   103 	# calculate the function we need to jump to, which must then be
   104 	# stored in t9
   105 	lw	a0, A0OFF(fp)	# a0 = set "that" to be "this"
   106 	lw	t0, A1OFF(fp)	# a1 = methodIndex
   107 	lw	t9, 0(a0)
   108 	# t0 = methodIndex << PTRLOG
   109 	sll	t0, t0, PTRLOG
   110 	addu	t9, t0
   111 	lw	t9, (t9)
   113 	# Set a1-a3 to what invoke_copy_to_stack told us. a0 is already
   114 	# the "this" pointer. We don't have to care about floating
   115 	# point arguments, the non-FP "this" pointer as first argument
   116 	# means they'll never be used.
   117 	lw	a1, 1*SZREG(sp)
   118 	lw	a2, 2*SZREG(sp)
   119 	lw	a3, 3*SZREG(sp)
   121 	jalr	t9
   122 	# Micro-optimization: There's no gp usage below this point, so
   123 	# we don't reload.
   124 	# lw	gp, GPOFF(fp)
   126 	# leave variable stack frame
   127 	move	sp, fp
   129 	lw	ra, RAOFF(sp)
   130 	lw	fp, FPOFF(sp)
   132 	addiu	sp, FRAMESZ
   133 	j	ra
   134 END(_NS_InvokeByIndex)

mercurial