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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial