Elliott Hughes | 0f3c553 | 2012-03-30 14:51:51 -0700 | [diff] [blame] | 1 | /* |
| 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 Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 17 | #include "asm_support.h" |
| 18 | |
| 19 | #if defined(__APPLE__) |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 20 | // 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 |
| 24 | #define END_MACRO .endmacro |
| 25 | |
| 26 | // Mac OS' as(1) uses $0, $1, and so on for macro arguments, and function names |
| 27 | // are mangled with an extra underscore prefix. The use of $x for arguments |
| 28 | // mean that literals need to be represented with $$x in macros. |
| 29 | #define VAR(name,index) _$index |
| 30 | #define LITERAL(value) $$value |
| 31 | #else |
| 32 | // Regular gas(1) lets you name macro parameters. |
| 33 | #define MACRO0(macro_name) .macro macro_name |
| 34 | #define MACRO1(macro_name, macro_arg1) .macro macro_name macro_arg1 |
| 35 | #define MACRO2(macro_name, macro_arg1, macro_arg2) .macro macro_name macro_arg1, macro_arg2 |
| 36 | #define END_MACRO .endm |
| 37 | |
| 38 | // Regular gas(1) uses \argument_name for macro arguments. |
| 39 | // We need to turn on alternate macro syntax so we can use & instead or the preprocessor |
| 40 | // will screw us by inserting a space between the \ and the name. Even in this mode there's |
| 41 | // no special meaning to $, so literals are still just $x. |
| 42 | .altmacro |
| 43 | #define VAR(name,index) name& |
| 44 | #define LITERAL(value) $value |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 45 | #endif |
| 46 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 47 | /* Cache alignment for function entry */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 48 | MACRO0(ALIGN_FUNCTION_ENTRY) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 49 | .balign 16 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 50 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 54 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 55 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 56 | MACRO0(SETUP_SAVE_ALL_CALLEE_SAVE_FRAME) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 57 | pushl %edi // Save callee saves (ebx is saved/restored by the upcall) |
| 58 | pushl %esi |
| 59 | pushl %ebp |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 60 | subl LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method* |
| 61 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 62 | |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 63 | /* |
| 64 | * Macro that sets up the callee save frame to conform with |
| 65 | * Runtime::CreateCalleeSaveMethod(kRefsOnly) |
| 66 | */ |
| 67 | MACRO0(SETUP_REF_ONLY_CALLEE_SAVE_FRAME) |
| 68 | pushl %edi // Save callee saves (ebx is saved/restored by the upcall) |
| 69 | pushl %esi |
| 70 | pushl %ebp |
| 71 | subl LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method* |
| 72 | END_MACRO |
| 73 | |
| 74 | MACRO0(RESTORE_REF_ONLY_CALLEE_SAVE_FRAME) |
| 75 | addl LITERAL(28), %esp // Unwind stack up to return address |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 76 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 80 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 81 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 82 | MACRO0(SETUP_REF_AND_ARG_CALLEE_SAVE_FRAME) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 83 | pushl %edi // Save callee saves |
| 84 | pushl %esi |
| 85 | pushl %ebp |
| 86 | pushl %ebx // Save args |
| 87 | pushl %edx |
| 88 | pushl %ecx |
| 89 | pushl %eax // Align stack, eax will be clobbered by Method* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 90 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 91 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 92 | MACRO0(RESTORE_REF_AND_ARG_CALLEE_SAVE_FRAME) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 93 | addl LITERAL(4), %esp // Remove padding |
| 94 | popl %ecx // Restore args except eax |
| 95 | popl %edx |
| 96 | popl %ebx |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 97 | popl %ebp // Restore callee saves |
| 98 | popl %esi |
| 99 | popl %edi |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 100 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 101 | |
| 102 | /* |
| 103 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 104 | * exception is Thread::Current()->exception_. |
| 105 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 106 | MACRO0(DELIVER_PENDING_EXCEPTION) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 107 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save callee saves for throw |
| 108 | mov %esp, %ecx |
| 109 | // Outgoing argument set up |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 110 | subl LITERAL(8), %esp // Alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 111 | pushl %ecx // pass SP |
| 112 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 113 | call artDeliverPendingExceptionFromCode // artDeliverExceptionFromCode(Thread*, SP) |
| 114 | int3 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 115 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 116 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 117 | MACRO2(NO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
| 118 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 119 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 120 | VAR(c_name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 121 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 122 | mov %esp, %ecx |
| 123 | // Outgoing argument set up |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 124 | subl LITERAL(8), %esp // alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 125 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 126 | pushl %ecx // pass SP |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 127 | call VAR(cxx_name, 1) // cxx_name(Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 128 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 129 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 130 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 131 | MACRO2(ONE_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
| 132 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 133 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 134 | VAR(c_name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 135 | 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 Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 138 | pushl LITERAL(0) // alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 139 | pushl %ecx // pass SP |
| 140 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 141 | pushl %eax // pass arg1 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 142 | call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 143 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 144 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 145 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 146 | MACRO2(TWO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
| 147 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 148 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 149 | VAR(c_name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 150 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 151 | mov %esp, %edx |
| 152 | // Outgoing argument set up |
| 153 | pushl %edx // pass SP |
| 154 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 155 | pushl %ecx // pass arg2 |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 156 | pushl %eax // pass arg1 |
| 157 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 158 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 159 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 160 | |
| 161 | /* |
| 162 | * Called by managed code to create and deliver a NullPointerException. |
| 163 | */ |
| 164 | NO_ARG_RUNTIME_EXCEPTION art_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode |
| 165 | |
| 166 | /* |
| 167 | * Called by managed code to create and deliver an ArithmeticException. |
| 168 | */ |
| 169 | NO_ARG_RUNTIME_EXCEPTION art_throw_div_zero_from_code, artThrowDivZeroFromCode |
| 170 | |
| 171 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 172 | * Called by managed code to create and deliver a StackOverflowError. |
| 173 | */ |
| 174 | NO_ARG_RUNTIME_EXCEPTION art_throw_stack_overflow_from_code, artThrowStackOverflowFromCode |
| 175 | |
| 176 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 177 | * Called by managed code, saves callee saves and then calls artThrowException |
| 178 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 179 | */ |
| 180 | ONE_ARG_RUNTIME_EXCEPTION art_deliver_exception_from_code, artDeliverExceptionFromCode |
| 181 | |
| 182 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 183 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 184 | */ |
| 185 | ONE_ARG_RUNTIME_EXCEPTION art_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode |
| 186 | |
| 187 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 188 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 189 | * index, arg2 holds limit. |
| 190 | */ |
| 191 | TWO_ARG_RUNTIME_EXCEPTION art_throw_array_bounds_from_code, artThrowArrayBoundsFromCode |
| 192 | |
| 193 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 194 | * Called by managed code to create and deliver verification errors. Arg1 is kind, arg2 is ref. |
| 195 | */ |
| 196 | TWO_ARG_RUNTIME_EXCEPTION art_throw_verification_error_from_code, artThrowVerificationErrorFromCode |
| 197 | |
| 198 | /* |
| 199 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 200 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 201 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 202 | * stack and call the appropriate C helper. |
| 203 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
| 204 | * |
| 205 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 206 | * of the target Method* in r0 and method->code_ in r1. |
| 207 | * |
| 208 | * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the |
| 209 | * thread and we branch to another stub to deliver it. |
| 210 | * |
| 211 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 212 | * pointing back to the original caller. |
| 213 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 214 | MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) |
| 215 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 216 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 217 | VAR(c_name, 0): |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 218 | // Set up the callee save frame to conform with Runtime::CreateCalleeSaveMethod(kRefsAndArgs) |
| 219 | // return address |
| 220 | pushl %edi |
| 221 | pushl %esi |
| 222 | pushl %ebp |
| 223 | pushl %ebx |
| 224 | pushl %edx |
| 225 | pushl %ecx |
| 226 | pushl %eax // <-- callee save Method* to go here |
| 227 | movl %esp, %edx // remember SP |
| 228 | // Outgoing argument set up |
| 229 | subl LITERAL(12), %esp // alignment padding |
| 230 | pushl %edx // pass SP |
| 231 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 232 | pushl 32(%edx) // pass caller Method* |
| 233 | pushl %ecx // pass arg2 |
| 234 | pushl %eax // pass arg1 |
| 235 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
| 236 | movl %edx, %edi // save code pointer in EDI |
| 237 | addl LITERAL(36), %esp // Pop arguments skip eax |
| 238 | popl %ecx // Restore args |
| 239 | popl %edx |
| 240 | popl %ebx |
| 241 | popl %ebp // Restore callee saves. |
| 242 | popl %esi |
| 243 | // Swap EDI callee save with code pointer. |
| 244 | xchgl %edi, (%esp) |
| 245 | testl %eax, %eax // Branch forward if exception pending. |
| 246 | jz 1f |
| 247 | // Tail call to intended method. |
| 248 | ret |
| 249 | 1: |
| 250 | DELIVER_PENDING_EXCEPTION |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 251 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 252 | |
| 253 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 254 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 255 | |
| 256 | INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 257 | INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 258 | INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 259 | INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| 260 | |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 261 | MACRO2(TWO_ARG_ALLOC, c_name, cxx_name) |
| 262 | .globl VAR(c_name, 0) |
| 263 | ALIGN_FUNCTION_ENTRY |
| 264 | VAR(c_name, 0): |
| 265 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 266 | mov %esp, %edx // remember SP |
| 267 | // Outgoing argument set up |
| 268 | pushl %edx // pass SP |
| 269 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 270 | pushl %ecx // pass arg2 |
| 271 | pushl %eax // pass arg1 |
| 272 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
| 273 | addl LITERAL(16), %esp // pop arguments |
| 274 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 275 | testl %eax, %eax // eax == 0 ? |
| 276 | jz 1f |
| 277 | ret |
| 278 | 1: |
| 279 | DELIVER_PENDING_EXCEPTION |
| 280 | END_MACRO |
| 281 | |
| 282 | MACRO2(THREE_ARG_ALLOC, c_name, cxx_name) |
| 283 | .globl VAR(c_name, 0) |
| 284 | ALIGN_FUNCTION_ENTRY |
| 285 | VAR(c_name, 0): |
| 286 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 287 | mov %esp, %ebx // remember SP |
| 288 | // Outgoing argument set up |
| 289 | subl LITERAL(12), %esp // alignment padding |
| 290 | pushl %ebx // pass SP |
| 291 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 292 | pushl %edx // pass arg3 |
| 293 | pushl %ecx // pass arg2 |
| 294 | pushl %eax // pass arg1 |
| 295 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP) |
| 296 | addl LITERAL(32), %esp // pop arguments |
| 297 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 298 | testl %eax, %eax // eax == 0 ? |
| 299 | jz 1f |
| 300 | ret |
| 301 | 1: |
| 302 | DELIVER_PENDING_EXCEPTION |
| 303 | END_MACRO |
| 304 | |
| 305 | TWO_ARG_ALLOC art_alloc_object_from_code, artAllocObjectFromCode |
| 306 | TWO_ARG_ALLOC art_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck |
| 307 | THREE_ARG_ALLOC art_alloc_array_from_code, artAllocArrayFromCode |
| 308 | THREE_ARG_ALLOC art_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck |
| 309 | THREE_ARG_ALLOC art_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode |
| 310 | THREE_ARG_ALLOC art_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck |
| 311 | |
| 312 | TWO_ARG_ALLOC art_resolve_string_from_code, artResolveStringFromCode |
| 313 | TWO_ARG_ALLOC art_initialize_static_storage_from_code, artInitializeStaticStorageFromCode |
| 314 | |
| 315 | .globl art_lock_object_from_code |
| 316 | ALIGN_FUNCTION_ENTRY |
| 317 | art_lock_object_from_code: |
| 318 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 319 | mov %esp, %edx // remember SP |
| 320 | // Outgoing argument set up |
| 321 | pushl %eax // alignment padding |
| 322 | pushl %edx // pass SP |
| 323 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 324 | pushl %eax // pass arg1 |
| 325 | call artLockObjectFromCode // (Object*, Thread*, SP) |
| 326 | addl LITERAL(16), %esp // pop arguments |
| 327 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 328 | ret |
| 329 | |
| 330 | .globl art_unlock_object_from_code |
| 331 | ALIGN_FUNCTION_ENTRY |
| 332 | art_unlock_object_from_code: |
| 333 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 334 | mov %esp, %edx // remember SP |
| 335 | // Outgoing argument set up |
| 336 | pushl %eax // alignment padding |
| 337 | pushl %edx // pass SP |
| 338 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 339 | pushl %eax // pass arg1 |
| 340 | call artUnlockObjectFromCode // (Object*, Thread*, SP) |
| 341 | addl LITERAL(16), %esp // pop arguments |
| 342 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 343 | testl %eax, %eax // eax == 0 ? |
| 344 | jnz 1f |
| 345 | ret |
| 346 | 1: |
| 347 | DELIVER_PENDING_EXCEPTION |
| 348 | |
| 349 | .globl art_handle_fill_data_from_code |
| 350 | ALIGN_FUNCTION_ENTRY |
| 351 | art_handle_fill_data_from_code: |
| 352 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 353 | mov %esp, %edx // remember SP |
| 354 | // Outgoing argument set up |
| 355 | pushl %edx // pass SP |
| 356 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 357 | pushl %ecx // pass arg2 |
| 358 | pushl %eax // pass arg1 |
| 359 | call artHandleFillArrayDataFromCode // (Array* array, const uint16_t* table, Thread*, SP) |
| 360 | addl LITERAL(16), %esp // pop arguments |
| 361 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 362 | testl %eax, %eax // eax == 0 ? |
| 363 | jnz 1f |
| 364 | ret |
| 365 | 1: |
| 366 | DELIVER_PENDING_EXCEPTION |
| 367 | |
| 368 | .globl art_is_assignable_from_code |
| 369 | ALIGN_FUNCTION_ENTRY |
| 370 | art_is_assignable_from_code: |
| 371 | pushl %eax // alignment padding |
| 372 | pushl %ecx // pass arg2 |
| 373 | pushl %eax // pass arg1 |
| 374 | call artIsAssignableFromCode // (Class* a, Class* b, Thread*, SP) |
| 375 | addl LITERAL(12), %esp // pop arguments |
| 376 | ret |
| 377 | |
| 378 | .globl art_memcpy |
| 379 | ALIGN_FUNCTION_ENTRY |
| 380 | art_memcpy: |
| 381 | pushl %edx // pass arg3 |
| 382 | pushl %ecx // pass arg2 |
| 383 | pushl %eax // pass arg1 |
| 384 | call memcpy // (void*, const void*, size_t) |
| 385 | addl LITERAL(12), %esp // pop arguments |
| 386 | ret |
| 387 | |
| 388 | .globl art_check_cast_from_code |
| 389 | ALIGN_FUNCTION_ENTRY |
| 390 | art_check_cast_from_code: |
| 391 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 392 | mov %esp, %edx // remember SP |
| 393 | // Outgoing argument set up |
| 394 | pushl %edx // pass SP |
| 395 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 396 | pushl %ecx // pass arg2 |
| 397 | pushl %eax // pass arg1 |
| 398 | call artCheckCastFromCode // (Class* a, Class* b, Thread*, SP) |
| 399 | addl LITERAL(16), %esp // pop arguments |
| 400 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 401 | testl %eax, %eax // eax == 0 ? |
| 402 | jnz 1f |
| 403 | ret |
| 404 | 1: |
| 405 | DELIVER_PENDING_EXCEPTION |
| 406 | |
| 407 | .globl art_idiv_from_code |
| 408 | ALIGN_FUNCTION_ENTRY |
| 409 | art_idiv_from_code: |
| 410 | cdq // edx:eax = sign extend eax |
| 411 | idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx) |
| 412 | ret |
| 413 | |
| 414 | .globl art_idivmod_from_code |
| 415 | ALIGN_FUNCTION_ENTRY |
| 416 | art_idivmod_from_code: |
| 417 | cdq // edx:eax = sign extend eax |
| 418 | idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx) |
| 419 | movl %eax, %edx |
| 420 | ret |
| 421 | |
| 422 | .globl art_can_put_array_element_from_code |
| 423 | ALIGN_FUNCTION_ENTRY |
| 424 | art_can_put_array_element_from_code: |
| 425 | test %eax, %eax // Null is trivially storable |
| 426 | jz 1f |
| 427 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 428 | mov %esp, %edx // remember SP |
| 429 | // Outgoing argument set up |
| 430 | pushl %edx // pass SP |
| 431 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 432 | pushl %ecx // pass arg2 |
| 433 | pushl %eax // pass arg1 |
| 434 | call artCanPutArrayElementFromCode // (Object* element, Class* array_class, Thread*, SP) |
| 435 | addl LITERAL(16), %esp // pop arguments |
| 436 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 437 | testl %eax, %eax // eax == 0 ? |
| 438 | jnz 2f |
| 439 | 1: |
| 440 | ret |
| 441 | 2: |
| 442 | DELIVER_PENDING_EXCEPTION |
| 443 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 444 | MACRO1(UNIMPLEMENTED,name) |
| 445 | .globl VAR(name, 0) |
| 446 | ALIGN_FUNCTION_ENTRY |
| 447 | VAR(name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 448 | int3 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 449 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 450 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 451 | // TODO: implement these! |
| 452 | UNIMPLEMENTED art_proxy_invoke_handler |
| 453 | UNIMPLEMENTED art_update_debugger |
| 454 | UNIMPLEMENTED art_test_suspend |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 455 | UNIMPLEMENTED art_initialize_type_and_verify_access_from_code |
| 456 | UNIMPLEMENTED art_initialize_type_from_code |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 457 | UNIMPLEMENTED art_set32_instance_from_code |
| 458 | UNIMPLEMENTED art_set64_instance_from_code |
| 459 | UNIMPLEMENTED art_set_obj_instance_from_code |
| 460 | UNIMPLEMENTED art_get32_instance_from_code |
| 461 | UNIMPLEMENTED art_get64_instance_from_code |
| 462 | UNIMPLEMENTED art_get_obj_instance_from_code |
| 463 | UNIMPLEMENTED art_set32_static_from_code |
| 464 | UNIMPLEMENTED art_set64_static_from_code |
| 465 | UNIMPLEMENTED art_set_obj_static_from_code |
| 466 | UNIMPLEMENTED art_get32_static_from_code |
| 467 | UNIMPLEMENTED art_get64_static_from_code |
| 468 | UNIMPLEMENTED art_get_obj_static_from_code |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 469 | UNIMPLEMENTED art_indexof |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame^] | 470 | UNIMPLEMENTED art_memcmp16 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 471 | UNIMPLEMENTED art_string_compareto |