blob: 8cc7e587db26925793f481387adce980a7710af9 [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:
264 DELIVER_PENDING_EXCEPTION
Elliott Hughes787ec202012-03-29 17:14:15 -0700265END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700266
267INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline
268INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck
269
270INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck
271INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck
272INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck
273INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck
274
Ian Rogersd36c52e2012-04-09 16:29:25 -0700275MACRO3(NO_ARG_DOWNCALL, c_name, cxx_name, return_macro)
276 .globl VAR(c_name, 0)
277 ALIGN_FUNCTION_ENTRY
278VAR(c_name, 0):
279 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
280 mov %esp, %edx // remember SP
281 // Outgoing argument set up
282 subl MACRO_LITERAL(8), %esp // push padding
283 pushl %edx // pass SP
284 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
285 call VAR(cxx_name, 1) // cxx_name(Thread*, SP)
286 addl MACRO_LITERAL(16), %esp // pop arguments
287 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700288 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700289END_MACRO
290
291MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro)
292 .globl VAR(c_name, 0)
293 ALIGN_FUNCTION_ENTRY
294VAR(c_name, 0):
295 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
296 mov %esp, %edx // remember SP
297 // Outgoing argument set up
298 pushl %eax // push padding
299 pushl %edx // pass SP
300 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
301 pushl %eax // pass arg1
302 call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP)
303 addl MACRO_LITERAL(16), %esp // pop arguments
304 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700305 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700306END_MACRO
307
308MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro)
Ian Rogers7caad772012-03-30 01:07:54 -0700309 .globl VAR(c_name, 0)
310 ALIGN_FUNCTION_ENTRY
311VAR(c_name, 0):
312 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
313 mov %esp, %edx // remember SP
314 // Outgoing argument set up
315 pushl %edx // pass SP
316 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
317 pushl %ecx // pass arg2
318 pushl %eax // pass arg1
Ian Rogersd36c52e2012-04-09 16:29:25 -0700319 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP)
Elliott Hughesea944212012-04-05 13:11:53 -0700320 addl MACRO_LITERAL(16), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700321 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700322 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogers7caad772012-03-30 01:07:54 -0700323END_MACRO
324
Ian Rogersd36c52e2012-04-09 16:29:25 -0700325MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro)
Ian Rogers7caad772012-03-30 01:07:54 -0700326 .globl VAR(c_name, 0)
327 ALIGN_FUNCTION_ENTRY
328VAR(c_name, 0):
329 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
330 mov %esp, %ebx // remember SP
331 // Outgoing argument set up
Elliott Hughesea944212012-04-05 13:11:53 -0700332 subl MACRO_LITERAL(12), %esp // alignment padding
Ian Rogers7caad772012-03-30 01:07:54 -0700333 pushl %ebx // pass SP
334 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
335 pushl %edx // pass arg3
336 pushl %ecx // pass arg2
337 pushl %eax // pass arg1
Ian Rogersd36c52e2012-04-09 16:29:25 -0700338 call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP)
Elliott Hughesea944212012-04-05 13:11:53 -0700339 addl MACRO_LITERAL(32), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700340 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
Elliott Hughes754caaa2012-04-10 10:57:36 -0700341 CALL_MACRO(return_macro, 2) // return or deliver exception
Ian Rogersd36c52e2012-04-09 16:29:25 -0700342END_MACRO
343
344MACRO0(RETURN_IF_EAX_NOT_ZERO)
Ian Rogers7caad772012-03-30 01:07:54 -0700345 testl %eax, %eax // eax == 0 ?
Ian Rogersd36c52e2012-04-09 16:29:25 -0700346 jz 1f // if eax == 0 goto 1
347 ret // return
3481: // deliver exception on current thread
Ian Rogers7caad772012-03-30 01:07:54 -0700349 DELIVER_PENDING_EXCEPTION
350END_MACRO
351
Ian Rogersd36c52e2012-04-09 16:29:25 -0700352MACRO0(RETURN_IF_EAX_ZERO)
353 testl %eax, %eax // eax == 0 ?
354 jnz 1f // if eax != 0 goto 1
355 ret // return
3561: // deliver exception on current thread
Ian Rogers7caad772012-03-30 01:07:54 -0700357 DELIVER_PENDING_EXCEPTION
Ian Rogersd36c52e2012-04-09 16:29:25 -0700358END_MACRO
Ian Rogers7caad772012-03-30 01:07:54 -0700359
Ian Rogersd36c52e2012-04-09 16:29:25 -0700360TWO_ARG_DOWNCALL art_alloc_object_from_code, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO
361TWO_ARG_DOWNCALL art_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
362THREE_ARG_DOWNCALL art_alloc_array_from_code, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO
363THREE_ARG_DOWNCALL art_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
364THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO
365THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO
366
367TWO_ARG_DOWNCALL art_resolve_string_from_code, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO
368TWO_ARG_DOWNCALL art_initialize_static_storage_from_code, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO
Elliott Hughese87c7bc2012-04-16 20:42:34 -0700369TWO_ARG_DOWNCALL art_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO
370TWO_ARG_DOWNCALL art_initialize_type_and_verify_access_from_code, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO
Ian Rogersd36c52e2012-04-09 16:29:25 -0700371
372ONE_ARG_DOWNCALL art_lock_object_from_code, artLockObjectFromCode, ret
373ONE_ARG_DOWNCALL art_unlock_object_from_code, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO
374
375TWO_ARG_DOWNCALL art_handle_fill_data_from_code, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO
Ian Rogers7caad772012-03-30 01:07:54 -0700376
Elliott Hughes5e284222012-04-04 13:38:03 -0700377DEFINE_FUNCTION art_is_assignable_from_code
Ian Rogers7caad772012-03-30 01:07:54 -0700378 pushl %eax // alignment padding
379 pushl %ecx // pass arg2
380 pushl %eax // pass arg1
Elliott Hughesadc078a2012-04-04 11:39:05 -0700381 call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b, Thread*, SP)
Ian Rogers55bd45f2012-04-04 17:31:20 -0700382 addl LITERAL(12), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700383 ret
384
Elliott Hughes5e284222012-04-04 13:38:03 -0700385DEFINE_FUNCTION art_memcpy
Ian Rogers7caad772012-03-30 01:07:54 -0700386 pushl %edx // pass arg3
387 pushl %ecx // pass arg2
388 pushl %eax // pass arg1
Elliott Hughesadc078a2012-04-04 11:39:05 -0700389 call SYMBOL(memcpy) // (void*, const void*, size_t)
Ian Rogers55bd45f2012-04-04 17:31:20 -0700390 addl LITERAL(12), %esp // pop arguments
Ian Rogers7caad772012-03-30 01:07:54 -0700391 ret
392
Ian Rogersd36c52e2012-04-09 16:29:25 -0700393TWO_ARG_DOWNCALL art_check_cast_from_code, artCheckCastFromCode, RETURN_IF_EAX_ZERO
394TWO_ARG_DOWNCALL art_can_put_array_element_from_code, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO
395
396NO_ARG_DOWNCALL art_test_suspend, artTestSuspendFromCode, ret
Ian Rogers7caad772012-03-30 01:07:54 -0700397
jeffhao292188d2012-05-17 15:45:04 -0700398DEFINE_FUNCTION art_fmod_from_code
399 movl %ebx, -4(%esp) // put hi arg2 into memory
400 movl %edx, -8(%esp) // put lo arg2 into memory
401 fldl -8(%esp) // push arg2 onto fp stack
402 movl %ecx, -4(%esp) // put hi arg1 into memory
403 movl %eax, -8(%esp) // put lo arg1 into memory
404 fldl -8(%esp) // push arg1 onto fp stack
405 fprem1 // calculate IEEE remainder
406 fstpl -8(%esp) // pop return value off fp stack
407 movsd -8(%esp), %xmm0 // place into %xmm0
408 ret
409
410DEFINE_FUNCTION art_fmodf_from_code
411 movl %ecx, -4(%esp) // put arg2 into memory
412 fld -4(%esp) // push arg2 onto fp stack
413 movl %eax, -4(%esp) // put arg1 into memory
414 fld -4(%esp) // push arg1 onto fp stack
415 fprem1 // calculate IEEE remainder
416 fstp -4(%esp) // pop return value off fp stack
417 movss -4(%esp), %xmm0 // place into %xmm0
418 ret
419
jeffhao41005dd2012-05-09 17:58:52 -0700420DEFINE_FUNCTION art_l2d_from_code
421 pushl %eax // alignment padding
422 pushl %ecx // pass arg2
423 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700424 call SYMBOL(art_l2d) // (jlong a, Thread*, SP)
425 fstpl (%esp) // pop return value off fp stack
jeffhao41005dd2012-05-09 17:58:52 -0700426 movsd (%esp), %xmm0 // place into %xmm0
427 addl LITERAL(12), %esp // pop arguments
428 ret
429
430DEFINE_FUNCTION art_l2f_from_code
431 pushl %eax // alignment padding
432 pushl %ecx // pass arg2
433 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700434 call SYMBOL(art_l2f) // (jlong a, Thread*, SP)
435 fstp (%esp) // pop return value off fp stack
jeffhao41005dd2012-05-09 17:58:52 -0700436 movss (%esp), %xmm0 // place into %xmm0
437 addl LITERAL(12), %esp // pop arguments
438 ret
439
440DEFINE_FUNCTION art_d2l_from_code
441 pushl %eax // alignment padding
442 pushl %ecx // pass arg2
443 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700444 call SYMBOL(art_d2l) // (jdouble a, Thread*, SP)
jeffhao41005dd2012-05-09 17:58:52 -0700445 addl LITERAL(12), %esp // pop arguments
446 ret
447
448DEFINE_FUNCTION art_f2l_from_code
449 subl LITERAL(8), %esp // alignment padding
450 pushl %eax // pass arg1
jeffhao292188d2012-05-17 15:45:04 -0700451 call SYMBOL(art_f2l) // (jfloat a, Thread*, SP)
jeffhao41005dd2012-05-09 17:58:52 -0700452 addl LITERAL(12), %esp // pop arguments
453 ret
454
Elliott Hughes5e284222012-04-04 13:38:03 -0700455DEFINE_FUNCTION art_idivmod_from_code
jeffhao174651d2012-04-19 15:27:22 -0700456 cmpl LITERAL(0x80000000), %eax
457 je check_arg2 // special case
458args_ok:
Ian Rogers7caad772012-03-30 01:07:54 -0700459 cdq // edx:eax = sign extend eax
460 idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx)
Ian Rogers7caad772012-03-30 01:07:54 -0700461 ret
jeffhao174651d2012-04-19 15:27:22 -0700462check_arg2:
463 cmpl LITERAL(-1), %ecx
464 jne args_ok
465 xorl %edx, %edx
466 ret // eax already holds min int
Ian Rogers7caad772012-03-30 01:07:54 -0700467
Ian Rogers55bd45f2012-04-04 17:31:20 -0700468DEFINE_FUNCTION art_ldiv_from_code
Ian Rogers141d6222012-04-05 12:23:06 -0700469 subl LITERAL(12), %esp // alignment padding
Ian Rogers55bd45f2012-04-04 17:31:20 -0700470 pushl %ebx // pass arg4
471 pushl %edx // pass arg3
472 pushl %ecx // pass arg2
473 pushl %eax // pass arg1
474 call SYMBOL(artLdivFromCode) // (jlong a, jlong b, Thread*, SP)
475 addl LITERAL(28), %esp // pop arguments
476 ret
477
478DEFINE_FUNCTION art_ldivmod_from_code
Ian Rogers141d6222012-04-05 12:23:06 -0700479 subl LITERAL(12), %esp // alignment padding
Ian Rogers55bd45f2012-04-04 17:31:20 -0700480 pushl %ebx // pass arg4
481 pushl %edx // pass arg3
482 pushl %ecx // pass arg2
483 pushl %eax // pass arg1
484 call SYMBOL(artLdivmodFromCode) // (jlong a, jlong b, Thread*, SP)
485 addl LITERAL(28), %esp // pop arguments
486 ret
487
jeffhao644d5312012-05-03 19:04:49 -0700488DEFINE_FUNCTION art_lmul_from_code
489 subl LITERAL(12), %esp // alignment padding
490 pushl %ebx // pass arg4
491 pushl %edx // pass arg3
492 pushl %ecx // pass arg2
493 pushl %eax // pass arg1
494 call SYMBOL(artLmulFromCode) // (jlong a, jlong b, Thread*, SP)
495 addl LITERAL(28), %esp // pop arguments
496 ret
497
Ian Rogers141d6222012-04-05 12:23:06 -0700498DEFINE_FUNCTION art_lshl_from_code
jeffhao644d5312012-05-03 19:04:49 -0700499 // ecx:eax << edx
Ian Rogers141d6222012-04-05 12:23:06 -0700500 xchg %edx, %ecx
501 shld %cl,%eax,%edx
502 shl %cl,%eax
503 test LITERAL(32), %cl
504 jz 1f
505 mov %eax, %edx
506 xor %eax, %eax
5071:
508 ret
509
510DEFINE_FUNCTION art_lshr_from_code
jeffhao644d5312012-05-03 19:04:49 -0700511 // ecx:eax >> edx
Ian Rogers141d6222012-04-05 12:23:06 -0700512 xchg %edx, %ecx
jeffhao644d5312012-05-03 19:04:49 -0700513 shrd %cl,%edx,%eax
514 sar %cl,%edx
Ian Rogers141d6222012-04-05 12:23:06 -0700515 test LITERAL(32),%cl
516 jz 1f
jeffhao5121e0b2012-05-08 18:23:38 -0700517 mov %edx, %eax
518 sar LITERAL(31), %edx
Ian Rogers141d6222012-04-05 12:23:06 -07005191:
520 ret
521
522DEFINE_FUNCTION art_lushr_from_code
jeffhao644d5312012-05-03 19:04:49 -0700523 // ecx:eax >>> edx
Ian Rogers141d6222012-04-05 12:23:06 -0700524 xchg %edx, %ecx
jeffhao644d5312012-05-03 19:04:49 -0700525 shrd %cl,%edx,%eax
526 shr %cl,%edx
527 test LITERAL(32),%cl
Ian Rogers141d6222012-04-05 12:23:06 -0700528 jz 1f
jeffhao5121e0b2012-05-08 18:23:38 -0700529 mov %edx, %eax
530 xor %edx, %edx
Ian Rogers141d6222012-04-05 12:23:06 -07005311:
532 ret
533
jeffhao9dbb23e2012-05-18 17:03:57 -0700534DEFINE_FUNCTION art_set32_instance_from_code
535 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
536 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700537 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700538 pushl %ebx // pass SP
539 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
540 mov 32(%ebx), %ebx // get referrer
541 pushl %ebx // pass referrer
542 pushl %edx // pass new_val
543 pushl %ecx // pass object
544 pushl %eax // pass field_idx
545 call SYMBOL(artSet32InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700546 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700547 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
548 RETURN_IF_EAX_ZERO // return or deliver exception
549
550DEFINE_FUNCTION art_set64_instance_from_code
551 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
jeffhao1ff4cd72012-05-21 11:17:48 -0700552 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700553 pushl %esp // pass SP-8
jeffhao1ff4cd72012-05-21 11:17:48 -0700554 addl LITERAL(8), (%esp) // fix SP on stack by adding 8
jeffhao9dbb23e2012-05-18 17:03:57 -0700555 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
556 pushl %ebx // pass high half of new_val
557 pushl %edx // pass low half of new_val
558 pushl %ecx // pass object
559 pushl %eax // pass field_idx
560 call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700561 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700562 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
563 RETURN_IF_EAX_ZERO // return or deliver exception
564
565DEFINE_FUNCTION art_set_obj_instance_from_code
566 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
567 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700568 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700569 pushl %ebx // pass SP
570 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
571 mov 32(%ebx), %ebx // get referrer
572 pushl %ebx // pass referrer
573 pushl %edx // pass new_val
574 pushl %ecx // pass object
575 pushl %eax // pass field_idx
576 call SYMBOL(artSetObjInstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700577 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700578 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
579 RETURN_IF_EAX_ZERO // return or deliver exception
580
581DEFINE_FUNCTION art_get32_instance_from_code
582 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
583 mov %esp, %ebx // remember SP
584 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700585 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700586 pushl %ebx // pass SP
587 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
588 pushl %edx // pass referrer
589 pushl %ecx // pass object
590 pushl %eax // pass field_idx
591 call SYMBOL(artGet32InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700592 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700593 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
594 RETURN_IF_EAX_ZERO // return or deliver exception
595
596DEFINE_FUNCTION art_get64_instance_from_code
597 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
598 mov %esp, %ebx // remember SP
599 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700600 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700601 pushl %ebx // pass SP
602 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
603 pushl %edx // pass referrer
604 pushl %ecx // pass object
605 pushl %eax // pass field_idx
606 call SYMBOL(artGet64InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700607 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700608 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
609 RETURN_IF_EAX_ZERO // return or deliver exception
610
611DEFINE_FUNCTION art_get_obj_instance_from_code
612 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
613 mov %esp, %ebx // remember SP
614 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700615 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700616 pushl %ebx // pass SP
617 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
618 pushl %edx // pass referrer
619 pushl %ecx // pass object
620 pushl %eax // pass field_idx
621 call SYMBOL(artGetObjInstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700622 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700623 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
624 RETURN_IF_EAX_ZERO // return or deliver exception
625
626DEFINE_FUNCTION art_set32_static_from_code
627 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
628 mov %esp, %ebx // remember SP
629 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700630 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700631 pushl %ebx // pass SP
632 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
633 pushl %edx // pass referrer
634 pushl %ecx // pass new_val
635 pushl %eax // pass field_idx
636 call SYMBOL(artSet32StaticFromCode) // (field_idx, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700637 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700638 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
639 RETURN_IF_EAX_ZERO // return or deliver exception
640
641DEFINE_FUNCTION art_set64_static_from_code
642 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
643 mov %esp, %ebx // remember SP
jeffhao1ff4cd72012-05-21 11:17:48 -0700644 subl LITERAL(8), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700645 pushl %ebx // pass SP
646 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
647 mov 32(%ebx), %ebx // get referrer
648 pushl %edx // pass high half of new_val
649 pushl %ecx // pass low half of new_val
650 pushl %ebx // pass referrer
651 pushl %eax // pass field_idx
652 call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700653 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700654 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
655 RETURN_IF_EAX_ZERO // return or deliver exception
656
657DEFINE_FUNCTION art_set_obj_static_from_code
658 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
659 mov %esp, %ebx // remember SP
660 mov 32(%esp), %edx // get referrer
jeffhao1ff4cd72012-05-21 11:17:48 -0700661 subl LITERAL(12), %esp // alignment padding
jeffhao9dbb23e2012-05-18 17:03:57 -0700662 pushl %ebx // pass SP
663 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
664 pushl %edx // pass referrer
665 pushl %ecx // pass new_val
666 pushl %eax // pass field_idx
667 call SYMBOL(artSetObjStaticFromCode) // (field_idx, new_val, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700668 addl LITERAL(32), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700669 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
670 RETURN_IF_EAX_ZERO // return or deliver exception
671
672DEFINE_FUNCTION art_get32_static_from_code
673 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
674 mov %esp, %edx // remember SP
675 mov 32(%esp), %ecx // get referrer
676 pushl %edx // pass SP
677 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
678 pushl %ecx // pass referrer
679 pushl %eax // pass field_idx
680 call SYMBOL(artGet32StaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700681 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700682 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
683 RETURN_IF_EAX_ZERO // return or deliver exception
684
685DEFINE_FUNCTION art_get64_static_from_code
686 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
687 mov %esp, %edx // remember SP
688 mov 32(%esp), %ecx // get referrer
689 pushl %edx // pass SP
690 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
691 pushl %ecx // pass referrer
692 pushl %eax // pass field_idx
693 call SYMBOL(artGet64StaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700694 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700695 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
696 RETURN_IF_EAX_ZERO // return or deliver exception
697
698DEFINE_FUNCTION art_get_obj_static_from_code
699 SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC
700 mov %esp, %edx // remember SP
701 mov 32(%esp), %ecx // get referrer
702 pushl %edx // pass SP
703 pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current()
704 pushl %ecx // pass referrer
705 pushl %eax // pass field_idx
706 call SYMBOL(artGetObjStaticFromCode) // (field_idx, referrer, Thread*, SP)
jeffhao1ff4cd72012-05-21 11:17:48 -0700707 addl LITERAL(16), %esp // pop arguments
jeffhao9dbb23e2012-05-18 17:03:57 -0700708 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address
709 RETURN_IF_EAX_ZERO // return or deliver exception
710
Elliott Hughes787ec202012-03-29 17:14:15 -0700711MACRO1(UNIMPLEMENTED,name)
712 .globl VAR(name, 0)
713 ALIGN_FUNCTION_ENTRY
714VAR(name, 0):
Ian Rogers57b86d42012-03-27 16:05:41 -0700715 int3
Elliott Hughes787ec202012-03-29 17:14:15 -0700716END_MACRO
Ian Rogers57b86d42012-03-27 16:05:41 -0700717
Elliott Hughes787ec202012-03-29 17:14:15 -0700718 // TODO: implement these!
719UNIMPLEMENTED art_proxy_invoke_handler
720UNIMPLEMENTED art_update_debugger
Elliott Hughes787ec202012-03-29 17:14:15 -0700721UNIMPLEMENTED art_indexof
Ian Rogers7caad772012-03-30 01:07:54 -0700722UNIMPLEMENTED art_memcmp16
Elliott Hughes787ec202012-03-29 17:14:15 -0700723UNIMPLEMENTED art_string_compareto