blob: 8b904b8ea45aab40871ac7a922749dbb3f1fcf2e [file] [log] [blame]
buzbee54330722011-08-23 16:46:55 -07001#if defined(__arm__)
2
3 .balign 4
buzbee4a3164f2011-09-03 11:25:10 -07004
Ian Rogers67375ac2011-09-14 00:55:44 -07005 .global art_deliver_exception
6 .extern artDeliverExceptionHelper
Ian Rogersbdb03912011-09-14 00:55:44 -07007 /*
Ian Rogers67375ac2011-09-14 00:55:44 -07008 * Called by managed code, saves mosts registers (forms basis of long jump context).
Ian Rogersbdb03912011-09-14 00:55:44 -07009 * artThrowExceptionHelper will place a mock Method* at the bottom of the thread.
10 * r0 holds Throwable
11 */
Ian Rogers67375ac2011-09-14 00:55:44 -070012art_deliver_exception:
Ian Rogersbdb03912011-09-14 00:55:44 -070013 stmdb sp!, {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
Ian Rogers67375ac2011-09-14 00:55:44 -070014 sub sp, #16 @ 4 words of space, bottom word will hold Method*
Ian Rogersbdb03912011-09-14 00:55:44 -070015 mov r1, r9
16 mov r2, sp
Ian Rogers67375ac2011-09-14 00:55:44 -070017 b artDeliverExceptionHelper @ artThrowExceptionHelper(Throwable*, SP)
Ian Rogersbdb03912011-09-14 00:55:44 -070018
buzbee4a3164f2011-09-03 11:25:10 -070019 .global art_invoke_interface_trampoline
20 .extern artFindInterfaceMethodInCache
21 .extern artFailedInvokeInterface
22art_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
buzbee54330722011-08-23 16:46:55 -070056 .global art_shl_long
57art_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
80art_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
103art_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 Rogers67375ac2011-09-14 00:55:44 -0700125
126#if defined(__i386__)
127
128 .global art_deliver_exception
129 .extern artDeliverExceptionHelper
130 .extern _ZN3art6Thread5self_E
131 /*
132 * Called by managed code, saves callee saves and then calls artThrowExceptionHelper
133 * that will place a mock Method* at the bottom of the stack.
134 * EAX holds the exception.
135 */
136art_deliver_exception:
137 // Create frame
138 pushl %edi // Save callee saves
139 pushl %esi
140 pushl %ebp
141 pushl %ebx
142 pushl $0
143 pushl $0
144 pushl $0 // Will be clobbered to be Method*
145 mov %esp, %ecx
146 // Outgoing argument set up
147 pushl $0 // Alignment padding
148 pushl %ecx
149 pushl $0 // TODO: pass fs:offsetof(Thread,self_) - for now this is computed in the helper
150 pushl %eax
151 call artDeliverExceptionHelper // artThrowExceptionHelper(Throwable*, Thread*, SP)
152 int3
153
154#endif