Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C; tab-width: 8; 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 | #include <sys/regdef.h> |
michael@0 | 6 | #include <sys/asm.h> |
michael@0 | 7 | |
michael@0 | 8 | .text |
michael@0 | 9 | .globl invoke_count_words |
michael@0 | 10 | .globl invoke_copy_to_stack |
michael@0 | 11 | |
michael@0 | 12 | LOCALSZ=7 # a0, a1, a2, a3, s0, ra, gp |
michael@0 | 13 | FRAMESZ=(((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK |
michael@0 | 14 | |
michael@0 | 15 | RAOFF=FRAMESZ-(1*SZREG) |
michael@0 | 16 | A0OFF=FRAMESZ-(2*SZREG) |
michael@0 | 17 | A1OFF=FRAMESZ-(3*SZREG) |
michael@0 | 18 | A2OFF=FRAMESZ-(4*SZREG) |
michael@0 | 19 | A3OFF=FRAMESZ-(5*SZREG) |
michael@0 | 20 | S0OFF=FRAMESZ-(6*SZREG) |
michael@0 | 21 | GPOFF=FRAMESZ-(7*SZREG) |
michael@0 | 22 | |
michael@0 | 23 | # |
michael@0 | 24 | # _NS_InvokeByIndex(that, methodIndex, paramCount, params) |
michael@0 | 25 | # a0 a1 a2 a3 |
michael@0 | 26 | |
michael@0 | 27 | NESTED(_NS_InvokeByIndex, FRAMESZ, ra) |
michael@0 | 28 | PTR_SUBU sp, FRAMESZ |
michael@0 | 29 | SETUP_GP64(GPOFF, _NS_InvokeByIndex) |
michael@0 | 30 | |
michael@0 | 31 | REG_S ra, RAOFF(sp) |
michael@0 | 32 | REG_S a0, A0OFF(sp) |
michael@0 | 33 | REG_S a1, A1OFF(sp) |
michael@0 | 34 | REG_S a2, A2OFF(sp) |
michael@0 | 35 | REG_S a3, A3OFF(sp) |
michael@0 | 36 | REG_S s0, S0OFF(sp) |
michael@0 | 37 | |
michael@0 | 38 | # invoke_count_words(paramCount, params) |
michael@0 | 39 | move a0, a2 |
michael@0 | 40 | move a1, a3 |
michael@0 | 41 | jal invoke_count_words |
michael@0 | 42 | |
michael@0 | 43 | # invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, |
michael@0 | 44 | # nsXPTCVariant* s, uint32_t *reg) |
michael@0 | 45 | |
michael@0 | 46 | REG_L a1, A2OFF(sp) # a1 - paramCount |
michael@0 | 47 | REG_L a2, A3OFF(sp) # a2 - params |
michael@0 | 48 | |
michael@0 | 49 | # save sp before we copy the params to the stack |
michael@0 | 50 | move t0, sp |
michael@0 | 51 | |
michael@0 | 52 | # assume full size of 16 bytes per param to be safe |
michael@0 | 53 | sll v0, 4 # 16 bytes * num params |
michael@0 | 54 | subu sp, sp, v0 # make room |
michael@0 | 55 | move a0, sp # a0 - param stack address |
michael@0 | 56 | |
michael@0 | 57 | # create temporary stack space to write int and fp regs |
michael@0 | 58 | subu sp, 64 # 64 = 8 regs of 8 bytes |
michael@0 | 59 | move a3, sp |
michael@0 | 60 | |
michael@0 | 61 | # save the old sp and save the arg stack |
michael@0 | 62 | subu sp, sp, 16 |
michael@0 | 63 | REG_S t0, 0(sp) |
michael@0 | 64 | REG_S a0, 8(sp) |
michael@0 | 65 | |
michael@0 | 66 | # copy the param into the stack areas |
michael@0 | 67 | jal invoke_copy_to_stack |
michael@0 | 68 | |
michael@0 | 69 | REG_L t3, 8(sp) # get previous a0 |
michael@0 | 70 | REG_L sp, 0(sp) # get orig sp back |
michael@0 | 71 | |
michael@0 | 72 | REG_L a0, A0OFF(sp) # a0 - that |
michael@0 | 73 | REG_L a1, A1OFF(sp) # a1 - methodIndex |
michael@0 | 74 | |
michael@0 | 75 | # t1 = methodIndex * pow(2, PTRLOG) |
michael@0 | 76 | # (use shift instead of mult) |
michael@0 | 77 | sll t1, a1, PTRLOG |
michael@0 | 78 | |
michael@0 | 79 | # calculate the function we need to jump to, |
michael@0 | 80 | # which must then be saved in t9 |
michael@0 | 81 | lw t9, 0(a0) |
michael@0 | 82 | addu t9, t9, t1 |
michael@0 | 83 | lw t9, (t9) |
michael@0 | 84 | |
michael@0 | 85 | # get register save area from invoke_copy_to_stack |
michael@0 | 86 | subu t1, t3, 64 |
michael@0 | 87 | |
michael@0 | 88 | # a1..a7 and f13..f19 should now be set to what |
michael@0 | 89 | # invoke_copy_to_stack told us. skip a0 and f12 |
michael@0 | 90 | # because that's the "this" pointer |
michael@0 | 91 | |
michael@0 | 92 | REG_L a1, 0(t1) |
michael@0 | 93 | REG_L a2, 8(t1) |
michael@0 | 94 | REG_L a3, 16(t1) |
michael@0 | 95 | REG_L a4, 24(t1) |
michael@0 | 96 | REG_L a5, 32(t1) |
michael@0 | 97 | REG_L a6, 40(t1) |
michael@0 | 98 | REG_L a7, 48(t1) |
michael@0 | 99 | |
michael@0 | 100 | l.d $f13, 0(t1) |
michael@0 | 101 | l.d $f14, 8(t1) |
michael@0 | 102 | l.d $f15, 16(t1) |
michael@0 | 103 | l.d $f16, 24(t1) |
michael@0 | 104 | l.d $f17, 32(t1) |
michael@0 | 105 | l.d $f18, 40(t1) |
michael@0 | 106 | l.d $f19, 48(t1) |
michael@0 | 107 | |
michael@0 | 108 | # save away our stack pointer and create |
michael@0 | 109 | # the stack pointer for the function |
michael@0 | 110 | move s0, sp |
michael@0 | 111 | move sp, t3 |
michael@0 | 112 | |
michael@0 | 113 | jalr t9 |
michael@0 | 114 | |
michael@0 | 115 | move sp, s0 |
michael@0 | 116 | |
michael@0 | 117 | RESTORE_GP64 |
michael@0 | 118 | REG_L ra, RAOFF(sp) |
michael@0 | 119 | REG_L s0, S0OFF(sp) |
michael@0 | 120 | PTR_ADDU sp, FRAMESZ |
michael@0 | 121 | j ra |
michael@0 | 122 | .end _NS_InvokeByIndex |