blob: 74ae8fcc78361fecd1c21adb594f491ac65ac37a [file] [log] [blame]
Elliott Hughes0f3c5532012-03-30 14:51:51 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ian Rogers57b86d42012-03-27 16:05:41 -070017#include "asm_support.h"
18
19#if defined(__APPLE__)
Elliott Hughes787ec202012-03-29 17:14:15 -070020 // Mac OS' as(1) doesn't let you name macro parameters.
21 #define MACRO0(macro_name) .macro macro_name
22 #define MACRO1(macro_name, macro_arg1) .macro macro_name
23 #define MACRO2(macro_name, macro_arg1, macro_args2) .macro macro_name
Ian Rogersd36c52e2012-04-09 16:29:25 -070024 #define MACRO3(macro_name, macro_arg1, macro_args2, macro_args3) .macro macro_name
Elliott Hughes787ec202012-03-29 17:14:15 -070025 #define END_MACRO .endmacro
26
27 // Mac OS' as(1) uses $0, $1, and so on for macro arguments, and function names
28 // are mangled with an extra underscore prefix. The use of $x for arguments
29 // mean that literals need to be represented with $$x in macros.
Elliott Hughes20a7a072012-04-04 12:54:00 -070030 #define SYMBOL(name) _ ## name
Elliott Hughesadc078a2012-04-04 11:39:05 -070031 #define VAR(name,index) SYMBOL($index)
Elliott Hughes754caaa2012-04-10 10:57:36 -070032 #define CALL_MACRO(name,index) $index
Elliott Hughesea944212012-04-05 13:11:53 -070033 #define LITERAL(value) $value
34 #define MACRO_LITERAL(value) $$value
Elliott Hughes787ec202012-03-29 17:14:15 -070035#else
36 // Regular gas(1) lets you name macro parameters.
37 #define MACRO0(macro_name) .macro macro_name
38 #define MACRO1(macro_name, macro_arg1) .macro macro_name macro_arg1
39 #define MACRO2(macro_name, macro_arg1, macro_arg2) .macro macro_name macro_arg1, macro_arg2
Ian Rogersd36c52e2012-04-09 16:29:25 -070040 #define MACRO3(macro_name, macro_arg1, macro_arg2, macro_arg3) .macro macro_name macro_arg1, macro_arg2, macro_arg3
Elliott Hughes787ec202012-03-29 17:14:15 -070041 #define END_MACRO .endm
42
43 // Regular gas(1) uses \argument_name for macro arguments.
44 // We need to turn on alternate macro syntax so we can use & instead or the preprocessor
45 // will screw us by inserting a space between the \ and the name. Even in this mode there's
46 // no special meaning to $, so literals are still just $x.
47 .altmacro
Elliott Hughesadc078a2012-04-04 11:39:05 -070048 #define SYMBOL(name) name
Elliott Hughes787ec202012-03-29 17:14:15 -070049 #define VAR(name,index) name&
Elliott Hughes754caaa2012-04-10 10:57:36 -070050 #define CALL_MACRO(name,index) name&
Elliott Hughes787ec202012-03-29 17:14:15 -070051 #define LITERAL(value) $value
Elliott Hughesea944212012-04-05 13:11:53 -070052 #define MACRO_LITERAL(value) $value
Ian Rogers57b86d42012-03-27 16:05:41 -070053#endif
54
Ian Rogers57b86d42012-03-27 16:05:41 -070055 /* Cache alignment for function entry */
Elliott Hughes787ec202012-03-29 17:14:15 -070056MACRO0(ALIGN_FUNCTION_ENTRY)
Ian Rogers57b86d42012-03-27 16:05:41 -070057 .balign 16
Elliott Hughes787ec202012-03-29 17:14:15 -070058END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -070059
Elliott Hughes5e284222012-04-04 13:38:03 -070060MACRO1(DEFINE_FUNCTION,c_name)
61 .globl VAR(c_name, 0)
62 ALIGN_FUNCTION_ENTRY
63VAR(c_name, 0):
64END_MACRO
65
Ian Rogers57b86d42012-03-27 16:05:41 -070066 /*
67 * Macro that sets up the callee save frame to conform with
Ian Rogers7caad772012-03-30 01:07:54 -070068 * Runtime::CreateCalleeSaveMethod(kSaveAll)
Ian Rogers57b86d42012-03-27 16:05:41 -070069 */
Elliott Hughes787ec202012-03-29 17:14:15 -070070MACRO0(SETUP_SAVE_ALL_CALLEE_SAVE_FRAME)
Ian Rogers57b86d42012-03-27 16:05:41 -070071 pushl %edi // Save callee saves (ebx is saved/restored by the upcall)
72 pushl %esi
73 pushl %ebp
Elliott Hughesea944212012-04-05 13:11:53 -070074 subl MACRO_LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method*
Elliott Hughes787ec202012-03-29 17:14:15 -070075END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -070076
Ian Rogers7caad772012-03-30 01:07:54 -070077 /*
78 * Macro that sets up the callee save frame to conform with
79 * Runtime::CreateCalleeSaveMethod(kRefsOnly)
80 */
81MACRO0(SETUP_REF_ONLY_CALLEE_SAVE_FRAME)
82 pushl %edi // Save callee saves (ebx is saved/restored by the upcall)
83 pushl %esi
84 pushl %ebp
Elliott Hughesea944212012-04-05 13:11:53 -070085 subl MACRO_LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method*
Ian Rogers7caad772012-03-30 01:07:54 -070086END_MACRO
87
88MACRO0(RESTORE_REF_ONLY_CALLEE_SAVE_FRAME)
Elliott Hughesea944212012-04-05 13:11:53 -070089 addl MACRO_LITERAL(28), %esp // Unwind stack up to return address
Elliott Hughes787ec202012-03-29 17:14:15 -070090END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -070091
92 /*
93 * Macro that sets up the callee save frame to conform with
Ian Rogers7caad772012-03-30 01:07:54 -070094 * Runtime::CreateCalleeSaveMethod(kRefsAndArgs)
Ian Rogers57b86d42012-03-27 16:05:41 -070095 */
jeffhao9dbb23e2012-05-18 17:03:57 -070096MACRO0(SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME)
Ian Rogers57b86d42012-03-27 16:05:41 -070097 pushl %edi // Save callee saves
98 pushl %esi
99 pushl %ebp
100 pushl %ebx // Save args
101 pushl %edx
102 pushl %ecx
103 pushl %eax // Align stack, eax will be clobbered by Method*
Elliott Hughes787ec202012-03-29 17:14:15 -0700104END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700105
jeffhao9dbb23e2012-05-18 17:03:57 -0700106MACRO0(RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME)
Elliott Hughesea944212012-04-05 13:11:53 -0700107 addl MACRO_LITERAL(4), %esp // Remove padding
Ian Rogers7caad772012-03-30 01:07:54 -0700108 popl %ecx // Restore args except eax
109 popl %edx
110 popl %ebx
Ian Rogers57b86d42012-03-27 16:05:41 -0700111 popl %ebp // Restore callee saves
112 popl %esi
113 popl %edi
Elliott Hughes787ec202012-03-29 17:14:15 -0700114END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700115
116 /*
117 * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending
118 * exception is Thread::Current()->exception_.
119 */
Elliott Hughes787ec202012-03-29 17:14:15 -0700120MACRO0(DELIVER_PENDING_EXCEPTION)
Ian Rogers57b86d42012-03-27 16:05:41 -0700121 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save callee saves for throw
122 mov %esp, %ecx
123 // Outgoing argument set up
Elliott Hughesea944212012-04-05 13:11:53 -0700124 subl MACRO_LITERAL(8), %esp // Alignment padding
Ian Rogers57b86d42012-03-27 16:05:41 -0700125 pushl %ecx // pass SP
126 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
jeffhao9dbb23e2012-05-18 17:03:57 -0700127 call SYMBOL(artDeliverPendingExceptionFromCode) // artDeliverPendingExceptionFromCode(Thread*, SP)
128 int3 // unreached
Elliott Hughes787ec202012-03-29 17:14:15 -0700129END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700130
Elliott Hughes787ec202012-03-29 17:14:15 -0700131MACRO2(NO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name)
132 .globl VAR(c_name, 0)
Ian Rogers57b86d42012-03-27 16:05:41 -0700133 ALIGN_FUNCTION_ENTRY
Elliott Hughes787ec202012-03-29 17:14:15 -0700134VAR(c_name, 0):
Ian Rogers57b86d42012-03-27 16:05:41 -0700135 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
136 mov %esp, %ecx
137 // Outgoing argument set up
Elliott Hughesea944212012-04-05 13:11:53 -0700138 subl MACRO_LITERAL(8), %esp // alignment padding
Ian Rogers57b86d42012-03-27 16:05:41 -0700139 pushl %ecx // pass SP
Ian Rogers55bd45f2012-04-04 17:31:20 -0700140 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
Elliott Hughes787ec202012-03-29 17:14:15 -0700141 call VAR(cxx_name, 1) // cxx_name(Thread*, SP)
Ian Rogers57b86d42012-03-27 16:05:41 -0700142 int3 // unreached
Elliott Hughes787ec202012-03-29 17:14:15 -0700143END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700144
Elliott Hughes787ec202012-03-29 17:14:15 -0700145MACRO2(ONE_ARG_RUNTIME_EXCEPTION, c_name, cxx_name)
146 .globl VAR(c_name, 0)
Ian Rogers57b86d42012-03-27 16:05:41 -0700147 ALIGN_FUNCTION_ENTRY
Elliott Hughes787ec202012-03-29 17:14:15 -0700148VAR(c_name, 0):
Ian Rogers57b86d42012-03-27 16:05:41 -0700149 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
150 mov %esp, %ecx
151 // Outgoing argument set up
Ian Rogers55bd45f2012-04-04 17:31:20 -0700152 pushl %eax // alignment padding
Ian Rogers57b86d42012-03-27 16:05:41 -0700153 pushl %ecx // pass SP
154 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
155 pushl %eax // pass arg1
Elliott Hughes787ec202012-03-29 17:14:15 -0700156 call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP)
Ian Rogers57b86d42012-03-27 16:05:41 -0700157 int3 // unreached
Elliott Hughes787ec202012-03-29 17:14:15 -0700158END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700159
Elliott Hughes787ec202012-03-29 17:14:15 -0700160MACRO2(TWO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name)
161 .globl VAR(c_name, 0)
Ian Rogers57b86d42012-03-27 16:05:41 -0700162 ALIGN_FUNCTION_ENTRY
Elliott Hughes787ec202012-03-29 17:14:15 -0700163VAR(c_name, 0):
Ian Rogers57b86d42012-03-27 16:05:41 -0700164 SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context
165 mov %esp, %edx
166 // Outgoing argument set up
167 pushl %edx // pass SP
168 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
Ian Rogers57b86d42012-03-27 16:05:41 -0700169 pushl %ecx // pass arg2
Ian Rogers7caad772012-03-30 01:07:54 -0700170 pushl %eax // pass arg1
171 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP)
Ian Rogers57b86d42012-03-27 16:05:41 -0700172 int3 // unreached
Elliott Hughes787ec202012-03-29 17:14:15 -0700173END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700174
175 /*
176 * Called by managed code to create and deliver a NullPointerException.
177 */
178NO_ARG_RUNTIME_EXCEPTION art_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode
179
180 /*
181 * Called by managed code to create and deliver an ArithmeticException.
182 */
183NO_ARG_RUNTIME_EXCEPTION art_throw_div_zero_from_code, artThrowDivZeroFromCode
184
185 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700186 * Called by managed code to create and deliver a StackOverflowError.
187 */
188NO_ARG_RUNTIME_EXCEPTION art_throw_stack_overflow_from_code, artThrowStackOverflowFromCode
189
190 /*
Elliott Hughes787ec202012-03-29 17:14:15 -0700191 * Called by managed code, saves callee saves and then calls artThrowException
192 * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception.
193 */
194ONE_ARG_RUNTIME_EXCEPTION art_deliver_exception_from_code, artDeliverExceptionFromCode
195
196 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700197 * Called by managed code to create and deliver a NoSuchMethodError.
198 */
199ONE_ARG_RUNTIME_EXCEPTION art_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode
200
201 /*
Elliott Hughes787ec202012-03-29 17:14:15 -0700202 * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds
203 * index, arg2 holds limit.
204 */
205TWO_ARG_RUNTIME_EXCEPTION art_throw_array_bounds_from_code, artThrowArrayBoundsFromCode
206
207 /*
Ian Rogers57b86d42012-03-27 16:05:41 -0700208 * Called by managed code to create and deliver verification errors. Arg1 is kind, arg2 is ref.
209 */
210TWO_ARG_RUNTIME_EXCEPTION art_throw_verification_error_from_code, artThrowVerificationErrorFromCode
211
212 /*
213 * All generated callsites for interface invokes and invocation slow paths will load arguments
214 * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain
215 * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the
216 * stack and call the appropriate C helper.
217 * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1.
218 *
219 * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting
220 * of the target Method* in r0 and method->code_ in r1.
221 *
222 * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the
223 * thread and we branch to another stub to deliver it.
224 *
225 * On success this wrapper will restore arguments and *jump* to the target, leaving the lr
226 * pointing back to the original caller.
227 */
Elliott Hughes787ec202012-03-29 17:14:15 -0700228MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name)
229 .globl VAR(c_name, 0)
Ian Rogers57b86d42012-03-27 16:05:41 -0700230 ALIGN_FUNCTION_ENTRY
Elliott Hughes787ec202012-03-29 17:14:15 -0700231VAR(c_name, 0):
Ian Rogers7caad772012-03-30 01:07:54 -0700232 // Set up the callee save frame to conform with Runtime::CreateCalleeSaveMethod(kRefsAndArgs)
233 // return address
234 pushl %edi
235 pushl %esi
236 pushl %ebp
237 pushl %ebx
238 pushl %edx
239 pushl %ecx
240 pushl %eax // <-- callee save Method* to go here
241 movl %esp, %edx // remember SP
242 // Outgoing argument set up
Elliott Hughesea944212012-04-05 13:11:53 -0700243 subl MACRO_LITERAL(12), %esp // alignment padding
Ian Rogers7caad772012-03-30 01:07:54 -0700244 pushl %edx // pass SP
245 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
246 pushl 32(%edx) // pass caller Method*
247 pushl %ecx // pass arg2
248 pushl %eax // pass arg1
249 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP)
250 movl %edx, %edi // save code pointer in EDI
Elliott Hughesea944212012-04-05 13:11:53 -0700251 addl MACRO_LITERAL(36), %esp // Pop arguments skip eax
Ian Rogers7caad772012-03-30 01:07:54 -0700252 popl %ecx // Restore args
253 popl %edx
254 popl %ebx
255 popl %ebp // Restore callee saves.
256 popl %esi
257 // Swap EDI callee save with code pointer.
258 xchgl %edi, (%esp)
259 testl %eax, %eax // Branch forward if exception pending.
260 jz 1f
261 // Tail call to intended method.
262 ret
2631:
jeffhao20b5c6c2012-05-21 14:15:18 -0700264 addl MACRO_LITERAL(4), %esp // Pop code pointer off stack
Ian Rogers7caad772012-03-30 01:07:54 -0700265 DELIVER_PENDING_EXCEPTION
Elliott Hughes787ec202012-03-29 17:14:15 -0700266END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700267
268INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline
269INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
270
271INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
272INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
273INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
274INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
275
Ian Rogersd36c52e2012-04-09 16:29:25 -0700276MACRO3(NO_ARG_DOWNCALL, c_name, cxx_name, return_macro)
277 .globl VAR(c_name, 0)
278 ALIGN_FUNCTION_ENTRY
279VAR(c_name, 0):
280 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
281 mov %esp, %edx // remember SP
282 // Outgoing argument set up
283 subl MACRO_LITERAL(8), %esp // push padding
284 pushl %edx // pass SP
285 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
286 call VAR(cxx_name, 1) // cxx_name(Thread*, SP)
287 addl MACRO_LITERAL(16), %esp // pop arguments
288 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700289 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700290END_MACRO
291
292MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro)
293 .globl VAR(c_name, 0)
294 ALIGN_FUNCTION_ENTRY
295VAR(c_name, 0):
296 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
297 mov %esp, %edx // remember SP
298 // Outgoing argument set up
299 pushl %eax // push padding
300 pushl %edx // pass SP
301 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
302 pushl %eax // pass arg1
303 call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP)
304 addl MACRO_LITERAL(16), %esp // pop arguments
305 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700306 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700307END_MACRO
308
309MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro)
Ian Rogers7caad772012-03-30 01:07:54 -0700310 .globl VAR(c_name, 0)
311 ALIGN_FUNCTION_ENTRY
312VAR(c_name, 0):
313 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
314 mov %esp, %edx // remember SP
315 // Outgoing argument set up
316 pushl %edx // pass SP
317 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
318 pushl %ecx // pass arg2
319 pushl %eax // pass arg1
Ian Rogersd36c52e2012-04-09 16:29:25 -0700320 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP)
Elliott Hughesea944212012-04-05 13:11:53 -0700321 addl MACRO_LITERAL(16), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700322 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700323 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogers7caad772012-03-30 01:07:54 -0700324END_MACRO
325
Ian Rogersd36c52e2012-04-09 16:29:25 -0700326MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro)
Ian Rogers7caad772012-03-30 01:07:54 -0700327 .globl VAR(c_name, 0)
328 ALIGN_FUNCTION_ENTRY
329VAR(c_name, 0):
330 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
331 mov %esp, %ebx // remember SP
332 // Outgoing argument set up
Elliott Hughesea944212012-04-05 13:11:53 -0700333 subl MACRO_LITERAL(12), %esp // alignment padding
Ian Rogers7caad772012-03-30 01:07:54 -0700334 pushl %ebx // pass SP
335 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
336 pushl %edx // pass arg3
337 pushl %ecx // pass arg2
338 pushl %eax // pass arg1
Ian Rogersd36c52e2012-04-09 16:29:25 -0700339 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP)
Elliott Hughesea944212012-04-05 13:11:53 -0700340 addl MACRO_LITERAL(32), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700341 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700342 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700343END_MACRO
344
345MACRO0(RETURN_IF_EAX_NOT_ZERO)
Ian Rogers7caad772012-03-30 01:07:54 -0700346 testl %eax, %eax // eax == 0 ?
Ian Rogersd36c52e2012-04-09 16:29:25 -0700347 jz 1f // if eax == 0 goto 1
348 ret // return
3491: // deliver exception on current thread
Ian Rogers7caad772012-03-30 01:07:54 -0700350 DELIVER_PENDING_EXCEPTION
351END_MACRO
352
Ian Rogersd36c52e2012-04-09 16:29:25 -0700353MACRO0(RETURN_IF_EAX_ZERO)
354 testl %eax, %eax // eax == 0 ?
355 jnz 1f // if eax != 0 goto 1
356 ret // return
3571: // deliver exception on current thread
Ian Rogers7caad772012-03-30 01:07:54 -0700358 DELIVER_PENDING_EXCEPTION
Ian Rogersd36c52e2012-04-09 16:29:25 -0700359END_MACRO
Ian Rogers7caad772012-03-30 01:07:54 -0700360
Ian Rogersd36c52e2012-04-09 16:29:25 -0700361TWO_ARG_DOWNCALL art_alloc_object_from_code, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO
362TWO_ARG_DOWNCALL art_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
363THREE_ARG_DOWNCALL art_alloc_array_from_code, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO
364THREE_ARG_DOWNCALL art_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
365THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO
366THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
367
368TWO_ARG_DOWNCALL art_resolve_string_from_code, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO
369TWO_ARG_DOWNCALL art_initialize_static_storage_from_code, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO
Elliott Hughese87c7bc2012-04-16 20:42:34 -0700370TWO_ARG_DOWNCALL art_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO
371TWO_ARG_DOWNCALL art_initialize_type_and_verify_access_from_code, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO
Ian Rogersd36c52e2012-04-09 16:29:25 -0700372
373ONE_ARG_DOWNCALL art_lock_object_from_code, artLockObjectFromCode, ret
374ONE_ARG_DOWNCALL art_unlock_object_from_code, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO
375
376TWO_ARG_DOWNCALL art_handle_fill_data_from_code, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO
Ian Rogers7caad772012-03-30 01:07:54 -0700377
Elliott Hughes5e284222012-04-04 13:38:03 -0700378DEFINE_FUNCTION art_is_assignable_from_code
Ian Rogers7caad772012-03-30 01:07:54 -0700379 pushl %eax // alignment padding
380 pushl %ecx // pass arg2
381 pushl %eax // pass arg1
Elliott Hughesadc078a2012-04-04 11:39:05 -0700382 call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b, Thread*, SP)
Ian Rogers55bd45f2012-04-04 17:31:20 -0700383 addl LITERAL(12), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700384 ret
385
Elliott Hughes5e284222012-04-04 13:38:03 -0700386DEFINE_FUNCTION art_memcpy
Ian Rogers7caad772012-03-30 01:07:54 -0700387 pushl %edx // pass arg3
388 pushl %ecx // pass arg2
389 pushl %eax // pass arg1
Elliott Hughesadc078a2012-04-04 11:39:05 -0700390 call SYMBOL(memcpy) // (void*, const void*, size_t)
Ian Rogers55bd45f2012-04-04 17:31:20 -0700391 addl LITERAL(12), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700392 ret
393
Ian Rogersd36c52e2012-04-09 16:29:25 -0700394TWO_ARG_DOWNCALL art_check_cast_from_code, artCheckCastFromCode, RETURN_IF_EAX_ZERO
395TWO_ARG_DOWNCALL art_can_put_array_element_from_code, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO
396
397NO_ARG_DOWNCALL art_test_suspend, artTestSuspendFromCode, ret
Ian Rogers7caad772012-03-30 01:07:54 -0700398
jeffhao292188d2012-05-17 15:45:04 -0700399DEFINE_FUNCTION art_fmod_from_code
400 movl %ebx, -4(%esp) // put hi arg2 into memory
401 movl %edx, -8(%esp) // put lo arg2 into memory
402 fldl -8(%esp) // push arg2 onto fp stack
403 movl %ecx, -4(%esp) // put hi arg1 into memory
404 movl %eax, -8(%esp) // put lo arg1 into memory
405 fldl -8(%esp) // push arg1 onto fp stack
406 fprem1 // calculate IEEE remainder
407 fstpl -8(%esp) // pop return value off fp stack
408 movsd -8(%esp), %xmm0 // place into %xmm0
409 ret
410
411DEFINE_FUNCTION art_fmodf_from_code
412 movl %ecx, -4(%esp) // put arg2 into memory
413 fld -4(%esp) // push arg2 onto fp stack
414 movl %eax, -4(%esp) // put arg1 into memory
415 fld -4(%esp) // push arg1 onto fp stack
416 fprem1 // calculate IEEE remainder
417 fstp -4(%esp) // pop return value off fp stack
418 movss -4(%esp), %xmm0 // place into %xmm0
419 ret
420
jeffhao41005dd2012-05-09 17:58:52 -0700421DEFINE_FUNCTION art_l2d_from_code
422 pushl %eax // alignment padding
423 pushl %ecx // pass arg2
424 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700425 call SYMBOL(art_l2d) // (jlong a, Thread*, SP)
426 fstpl (%esp) // pop return value off fp stack
jeffhao41005dd2012-05-09 17:58:52 -0700427 movsd (%esp), %xmm0 // place into %xmm0
428 addl LITERAL(12), %esp // pop arguments
429 ret
430
431DEFINE_FUNCTION art_l2f_from_code
432 pushl %eax // alignment padding
433 pushl %ecx // pass arg2
434 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700435 call SYMBOL(art_l2f) // (jlong a, Thread*, SP)
436 fstp (%esp) // pop return value off fp stack
jeffhao41005dd2012-05-09 17:58:52 -0700437 movss (%esp), %xmm0 // place into %xmm0
438 addl LITERAL(12), %esp // pop arguments
439 ret
440
441DEFINE_FUNCTION art_d2l_from_code
442 pushl %eax // alignment padding
443 pushl %ecx // pass arg2
444 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700445 call SYMBOL(art_d2l) // (jdouble a, Thread*, SP)
jeffhao41005dd2012-05-09 17:58:52 -0700446 addl LITERAL(12), %esp // pop arguments
447 ret
448
449DEFINE_FUNCTION art_f2l_from_code
450 subl LITERAL(8), %esp // alignment padding
451 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700452 call SYMBOL(art_f2l) // (jfloat a, Thread*, SP)
jeffhao41005dd2012-05-09 17:58:52 -0700453 addl LITERAL(12), %esp // pop arguments
454 ret
455
Elliott Hughes5e284222012-04-04 13:38:03 -0700456DEFINE_FUNCTION art_idivmod_from_code
jeffhao174651d2012-04-19 15:27:22 -0700457 cmpl LITERAL(0x80000000), %eax
458 je check_arg2 // special case
459args_ok:
Ian Rogers7caad772012-03-30 01:07:54 -0700460 cdq // edx:eax = sign extend eax
461 idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx)
Ian Rogers7caad772012-03-30 01:07:54 -0700462 ret
jeffhao174651d2012-04-19 15:27:22 -0700463check_arg2:
464 cmpl LITERAL(-1), %ecx
465 jne args_ok
466 xorl %edx, %edx
467 ret // eax already holds min int
Ian Rogers7caad772012-03-30 01:07:54 -0700468
Ian Rogers55bd45f2012-04-04 17:31:20 -0700469DEFINE_FUNCTION art_ldiv_from_code
Ian Rogers141d6222012-04-05 12:23:06 -0700470 subl LITERAL(12), %esp // alignment padding
Ian Rogers55bd45f2012-04-04 17:31:20 -0700471 pushl %ebx // pass arg4
472 pushl %edx // pass arg3
473 pushl %ecx // pass arg2
474 pushl %eax // pass arg1
475 call SYMBOL(artLdivFromCode) // (jlong a, jlong b, Thread*, SP)
476 addl LITERAL(28), %esp // pop arguments
477 ret
478
479DEFINE_FUNCTION art_ldivmod_from_code
Ian Rogers141d6222012-04-05 12:23:06 -0700480 subl LITERAL(12), %esp // alignment padding
Ian Rogers55bd45f2012-04-04 17:31:20 -0700481 pushl %ebx // pass arg4
482 pushl %edx // pass arg3
483 pushl %ecx // pass arg2
484 pushl %eax // pass arg1
485 call SYMBOL(artLdivmodFromCode) // (jlong a, jlong b, Thread*, SP)
486 addl LITERAL(28), %esp // pop arguments
487 ret
488
jeffhao644d5312012-05-03 19:04:49 -0700489DEFINE_FUNCTION art_lmul_from_code
490 subl LITERAL(12), %esp // alignment padding
491 pushl %ebx // pass arg4
492 pushl %edx // pass arg3
493 pushl %ecx // pass arg2
494 pushl %eax // pass arg1
495 call SYMBOL(artLmulFromCode) // (jlong a, jlong b, Thread*, SP)
496 addl LITERAL(28), %esp // pop arguments
497 ret
498
Ian Rogers141d6222012-04-05 12:23:06 -0700499DEFINE_FUNCTION art_lshl_from_code
jeffhao644d5312012-05-03 19:04:49 -0700500 // ecx:eax << edx
Ian Rogers141d6222012-04-05 12:23:06 -0700501 xchg %edx, %ecx
502 shld %cl,%eax,%edx
503 shl %cl,%eax
504 test LITERAL(32), %cl
505 jz 1f
506 mov %eax, %edx
507 xor %eax, %eax
5081:
509 ret
510
511DEFINE_FUNCTION art_lshr_from_code
jeffhao644d5312012-05-03 19:04:49 -0700512 // ecx:eax >> edx
Ian Rogers141d6222012-04-05 12:23:06 -0700513 xchg %edx, %ecx
jeffhao644d5312012-05-03 19:04:49 -0700514 shrd %cl,%edx,%eax
515 sar %cl,%edx
Ian Rogers141d6222012-04-05 12:23:06 -0700516 test LITERAL(32),%cl
517 jz 1f
jeffhao5121e0b2012-05-08 18:23:38 -0700518 mov %edx, %eax
519 sar LITERAL(31), %edx
Ian Rogers141d6222012-04-05 12:23:06 -07005201:
521 ret
522
523DEFINE_FUNCTION art_lushr_from_code
jeffhao644d5312012-05-03 19:04:49 -0700524 // ecx:eax >>> edx
Ian Rogers141d6222012-04-05 12:23:06 -0700525 xchg %edx, %ecx
jeffhao644d5312012-05-03 19:04:49 -0700526 shrd %cl,%edx,%eax
527 shr %cl,%edx
528 test LITERAL(32),%cl
Ian Rogers141d6222012-04-05 12:23:06 -0700529 jz 1f
jeffhao5121e0b2012-05-08 18:23:38 -0700530 mov %edx, %eax
531 xor %edx, %edx
Ian Rogers141d6222012-04-05 12:23:06 -07005321:
533 ret
534
jeffhao9dbb23e2012-05-18 17:03:57 -0700535DEFINE_FUNCTION art_set32_instance_from_code
536 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
537 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700538 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700539 pushl %ebx // pass SP
540 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
541 mov 32(%ebx), %ebx // get referrer
542 pushl %ebx // pass referrer
543 pushl %edx // pass new_val
544 pushl %ecx // pass object
545 pushl %eax // pass field_idx
546 call SYMBOL(artSet32InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700547 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700548 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
549 RETURN_IF_EAX_ZERO // return or deliver exception
550
551DEFINE_FUNCTION art_set64_instance_from_code
552 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
jeffhao1ff4cd72012-05-21 11:17:48 -0700553 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700554 pushl %esp // pass SP-8
jeffhao1ff4cd72012-05-21 11:17:48 -0700555 addl LITERAL(8), (%esp) // fix SP on stack by adding 8
jeffhao9dbb23e2012-05-18 17:03:57 -0700556 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
557 pushl %ebx // pass high half of new_val
558 pushl %edx // pass low half of new_val
559 pushl %ecx // pass object
560 pushl %eax // pass field_idx
561 call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700562 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700563 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
564 RETURN_IF_EAX_ZERO // return or deliver exception
565
566DEFINE_FUNCTION art_set_obj_instance_from_code
567 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
568 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700569 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700570 pushl %ebx // pass SP
571 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
572 mov 32(%ebx), %ebx // get referrer
573 pushl %ebx // pass referrer
574 pushl %edx // pass new_val
575 pushl %ecx // pass object
576 pushl %eax // pass field_idx
577 call SYMBOL(artSetObjInstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700578 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700579 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
580 RETURN_IF_EAX_ZERO // return or deliver exception
581
582DEFINE_FUNCTION art_get32_instance_from_code
583 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
584 mov %esp, %ebx // remember SP
585 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700586 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700587 pushl %ebx // pass SP
588 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
589 pushl %edx // pass referrer
590 pushl %ecx // pass object
591 pushl %eax // pass field_idx
592 call SYMBOL(artGet32InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700593 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700594 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
595 RETURN_IF_EAX_ZERO // return or deliver exception
596
597DEFINE_FUNCTION art_get64_instance_from_code
598 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
599 mov %esp, %ebx // remember SP
600 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700601 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700602 pushl %ebx // pass SP
603 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
604 pushl %edx // pass referrer
605 pushl %ecx // pass object
606 pushl %eax // pass field_idx
607 call SYMBOL(artGet64InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700608 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700609 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
610 RETURN_IF_EAX_ZERO // return or deliver exception
611
612DEFINE_FUNCTION art_get_obj_instance_from_code
613 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
614 mov %esp, %ebx // remember SP
615 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700616 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700617 pushl %ebx // pass SP
618 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
619 pushl %edx // pass referrer
620 pushl %ecx // pass object
621 pushl %eax // pass field_idx
622 call SYMBOL(artGetObjInstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700623 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700624 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
625 RETURN_IF_EAX_ZERO // return or deliver exception
626
627DEFINE_FUNCTION art_set32_static_from_code
628 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
629 mov %esp, %ebx // remember SP
630 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700631 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700632 pushl %ebx // pass SP
633 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
634 pushl %edx // pass referrer
635 pushl %ecx // pass new_val
636 pushl %eax // pass field_idx
637 call SYMBOL(artSet32StaticFromCode) // (field_idx, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700638 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700639 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
640 RETURN_IF_EAX_ZERO // return or deliver exception
641
642DEFINE_FUNCTION art_set64_static_from_code
643 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
644 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700645 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700646 pushl %ebx // pass SP
647 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
648 mov 32(%ebx), %ebx // get referrer
649 pushl %edx // pass high half of new_val
650 pushl %ecx // pass low half of new_val
651 pushl %ebx // pass referrer
652 pushl %eax // pass field_idx
653 call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700654 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700655 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
656 RETURN_IF_EAX_ZERO // return or deliver exception
657
658DEFINE_FUNCTION art_set_obj_static_from_code
659 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
660 mov %esp, %ebx // remember SP
661 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700662 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700663 pushl %ebx // pass SP
664 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
665 pushl %edx // pass referrer
666 pushl %ecx // pass new_val
667 pushl %eax // pass field_idx
668 call SYMBOL(artSetObjStaticFromCode) // (field_idx, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700669 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700670 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
671 RETURN_IF_EAX_ZERO // return or deliver exception
672
673DEFINE_FUNCTION art_get32_static_from_code
674 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
675 mov %esp, %edx // remember SP
676 mov 32(%esp), %ecx // get referrer
677 pushl %edx // pass SP
678 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
679 pushl %ecx // pass referrer
680 pushl %eax // pass field_idx
681 call SYMBOL(artGet32StaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700682 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700683 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
684 RETURN_IF_EAX_ZERO // return or deliver exception
685
686DEFINE_FUNCTION art_get64_static_from_code
687 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
688 mov %esp, %edx // remember SP
689 mov 32(%esp), %ecx // get referrer
690 pushl %edx // pass SP
691 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
692 pushl %ecx // pass referrer
693 pushl %eax // pass field_idx
694 call SYMBOL(artGet64StaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700695 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700696 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
697 RETURN_IF_EAX_ZERO // return or deliver exception
698
699DEFINE_FUNCTION art_get_obj_static_from_code
700 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
701 mov %esp, %edx // remember SP
702 mov 32(%esp), %ecx // get referrer
703 pushl %edx // pass SP
704 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
705 pushl %ecx // pass referrer
706 pushl %eax // pass field_idx
707 call SYMBOL(artGetObjStaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700708 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700709 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
710 RETURN_IF_EAX_ZERO // return or deliver exception
711
Elliott Hughes787ec202012-03-29 17:14:15 -0700712MACRO1(UNIMPLEMENTED,name)
713 .globl VAR(name, 0)
714 ALIGN_FUNCTION_ENTRY
715VAR(name, 0):
Ian Rogers57b86d42012-03-27 16:05:41 -0700716 int3
Elliott Hughes787ec202012-03-29 17:14:15 -0700717END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700718
Elliott Hughes787ec202012-03-29 17:14:15 -0700719 // TODO: implement these!
720UNIMPLEMENTED art_proxy_invoke_handler
721UNIMPLEMENTED art_update_debugger
Elliott Hughes787ec202012-03-29 17:14:15 -0700722UNIMPLEMENTED art_indexof
Ian Rogers7caad772012-03-30 01:07:54 -0700723UNIMPLEMENTED art_memcmp16
Elliott Hughes787ec202012-03-29 17:14:15 -0700724UNIMPLEMENTED art_string_compareto