buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 1 | #if defined(__arm__) |
| 2 | |
| 3 | .balign 4 |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 4 | |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 5 | .global art_deliver_exception |
| 6 | .extern artDeliverExceptionHelper |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 7 | /* |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 8 | * Called by managed code, saves mosts registers (forms basis of long jump context). |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 9 | * artThrowExceptionHelper will place a mock Method* at the bottom of the thread. |
| 10 | * r0 holds Throwable |
| 11 | */ |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 12 | art_deliver_exception: |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 13 | stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr} |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 14 | sub sp, #16 @ 4 words of space, bottom word will hold Method* |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 15 | mov r1, r9 |
| 16 | mov r2, sp |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 17 | b artDeliverExceptionHelper @ artThrowExceptionHelper(Throwable*, SP) |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 18 | |
buzbee | 4a3164f | 2011-09-03 11:25:10 -0700 | [diff] [blame] | 19 | .global art_invoke_interface_trampoline |
| 20 | .extern artFindInterfaceMethodInCache |
| 21 | .extern artFailedInvokeInterface |
| 22 | art_invoke_interface_trampoline: |
| 23 | /* |
| 24 | * All generated callsites for interface invokes will load arguments |
| 25 | * as usual - except instead of loading arg0/r0 with the target |
| 26 | * Method*, arg0/r0 will contain the method_idx. This wrapper will |
| 27 | * save arg1-arg3, load the caller's Method*, align the stack and |
| 28 | * call the helper artFindInterfaceMethodInCache(idx, this, method); |
| 29 | * NOTE: "this" is first visable argument of the target, and so can be |
| 30 | * found in arg1/r1. |
| 31 | * |
| 32 | * artFindInterfaceMethodInCache will attempt to locate the target |
| 33 | * and return a 64-bit result in r0/r1 consisting of the target |
| 34 | * Method* in r0 and method->code_ in r1. |
| 35 | * |
| 36 | * If unsuccessful, artFindInterfaceMethodInCache will return |
| 37 | * NULL/NULL. This is somewhat different than the usual |
| 38 | * mechanism of helper routines performing the unwind & throw. |
| 39 | * The reason is that this trampoline is not unwindable. In the |
| 40 | * event artFindInterfaceMethodInCache fails to resolve, the wrapper |
| 41 | * will prepare an unwindable environment and jump to another helper |
| 42 | * to do unwind/throw. |
| 43 | * |
| 44 | * On success this wrapper will restore arguments and *jump* to the |
| 45 | * target, leaving the lr pointing back to the original caller. |
| 46 | */ |
| 47 | stmdb sp!, {r1, r2, r3, lr} |
| 48 | ldr r2, [sp, #16] @ load caller's Method* |
| 49 | bl artFindInterfaceMethodInCache @ (method_idx, this, callerMethod) |
| 50 | mov r12, r1 @ save r0->code_ |
| 51 | ldmia sp!, {r1, r2, r3, lr} @ restore arguments |
| 52 | cmp r0, #0 @ did we find the target? |
| 53 | bxne r12 @ tail call to target if so |
| 54 | b artFailedInvokeInterface @ Will appear as if called directly |
| 55 | |
buzbee | 5433072 | 2011-08-23 16:46:55 -0700 | [diff] [blame] | 56 | .global art_shl_long |
| 57 | art_shl_long: |
| 58 | /* |
| 59 | * Long integer shift. This is different from the generic 32/64-bit |
| 60 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 61 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 62 | * 6 bits. |
| 63 | * On entry: |
| 64 | * r0: low word |
| 65 | * r1: high word |
| 66 | * r2: shift count |
| 67 | */ |
| 68 | /* shl-long vAA, vBB, vCC */ |
| 69 | and r2, r2, #63 @ r2<- r2 & 0x3f |
| 70 | mov r1, r1, asl r2 @ r1<- r1 << r2 |
| 71 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 72 | orr r1, r1, r0, lsr r3 @ r1<- r1 | (r0 << (32-r2)) |
| 73 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 74 | movpl r1, r0, asl ip @ if r2 >= 32, r1<- r0 << (r2-32) |
| 75 | mov r0, r0, asl r2 @ r0<- r0 << r2 |
| 76 | bx lr |
| 77 | |
| 78 | .balign 4 |
| 79 | .global art_shr_long |
| 80 | art_shr_long: |
| 81 | /* |
| 82 | * Long integer shift. This is different from the generic 32/64-bit |
| 83 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 84 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 85 | * 6 bits. |
| 86 | * On entry: |
| 87 | * r0: low word |
| 88 | * r1: high word |
| 89 | * r2: shift count |
| 90 | */ |
| 91 | /* shr-long vAA, vBB, vCC */ |
| 92 | and r2, r2, #63 @ r0<- r0 & 0x3f |
| 93 | mov r0, r0, lsr r2 @ r0<- r2 >> r2 |
| 94 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 95 | orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) |
| 96 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 97 | movpl r0, r1, asr ip @ if r2 >= 32, r0<-r1 >> (r2-32) |
| 98 | mov r1, r1, asr r2 @ r1<- r1 >> r2 |
| 99 | bx lr |
| 100 | |
| 101 | .balign 4 |
| 102 | .global art_ushr_long |
| 103 | art_ushr_long: |
| 104 | /* |
| 105 | * Long integer shift. This is different from the generic 32/64-bit |
| 106 | * binary operations because vAA/vBB are 64-bit but vCC (the shift |
| 107 | * distance) is 32-bit. Also, Dalvik requires us to ignore all but the low |
| 108 | * 6 bits. |
| 109 | * On entry: |
| 110 | * r0: low word |
| 111 | * r1: high word |
| 112 | * r2: shift count |
| 113 | */ |
| 114 | /* ushr-long vAA, vBB, vCC */ |
| 115 | and r2, r2, #63 @ r0<- r0 & 0x3f |
| 116 | mov r0, r0, lsr r2 @ r0<- r2 >> r2 |
| 117 | rsb r3, r2, #32 @ r3<- 32 - r2 |
| 118 | orr r0, r0, r1, asl r3 @ r0<- r0 | (r1 << (32-r2)) |
| 119 | subs ip, r2, #32 @ ip<- r2 - 32 |
| 120 | movpl r0, r1, lsr ip @ if r2 >= 32, r0<-r1 >>> (r2-32) |
| 121 | mov r1, r1, lsr r2 @ r1<- r1 >>> r2 |
| 122 | bx lr |
| 123 | |
| 124 | #endif |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 125 | |
| 126 | #if defined(__i386__) |
| 127 | |
| 128 | .global art_deliver_exception |
| 129 | .extern artDeliverExceptionHelper |
Ian Rogers | 67375ac | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 130 | /* |
| 131 | * Called by managed code, saves callee saves and then calls artThrowExceptionHelper |
| 132 | * that will place a mock Method* at the bottom of the stack. |
| 133 | * EAX holds the exception. |
| 134 | */ |
| 135 | art_deliver_exception: |
| 136 | // Create frame |
| 137 | pushl %edi // Save callee saves |
| 138 | pushl %esi |
| 139 | pushl %ebp |
| 140 | pushl %ebx |
| 141 | pushl $0 |
| 142 | pushl $0 |
| 143 | pushl $0 // Will be clobbered to be Method* |
| 144 | mov %esp, %ecx |
| 145 | // Outgoing argument set up |
| 146 | pushl $0 // Alignment padding |
| 147 | pushl %ecx |
| 148 | pushl $0 // TODO: pass fs:offsetof(Thread,self_) - for now this is computed in the helper |
| 149 | pushl %eax |
| 150 | call artDeliverExceptionHelper // artThrowExceptionHelper(Throwable*, Thread*, SP) |
| 151 | int3 |
| 152 | |
| 153 | #endif |