Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame^] | 1 | #include "asm_support.h" |
| 2 | |
| 3 | #if defined(__APPLE__) |
| 4 | // Mac OS X mangles the functions with an underscore prefix |
| 5 | #define art_deliver_exception_from_code _art_deliver_exception_from_code |
| 6 | #define art_proxy_invoke_handler _art_proxy_invoke_handler |
| 7 | #define artDeliverExceptionFromCode _artDeliverExceptionFromCode |
| 8 | #endif |
| 9 | |
| 10 | /* Deliver the given exception */ |
| 11 | .extern artDeliverExceptionFromCode |
| 12 | /* Deliver an exception pending on a thread */ |
| 13 | .extern artDeliverPendingException |
| 14 | |
| 15 | /* Cache alignment for function entry */ |
| 16 | .macro ALIGN_FUNCTION_ENTRY |
| 17 | .balign 16 |
| 18 | .endm |
| 19 | |
| 20 | /* |
| 21 | * Macro that sets up the callee save frame to conform with |
| 22 | * Runtime::CreateCalleeSaveMethod(...) |
| 23 | */ |
| 24 | .macro SETUP_SAVE_ALL_CALLEE_SAVE_FRAME |
| 25 | pushl %edi // Save callee saves (ebx is saved/restored by the upcall) |
| 26 | pushl %esi |
| 27 | pushl %ebp |
| 28 | subl $16, %esp // Grow stack by 4 words, bottom word will hold Method* |
| 29 | .endm |
| 30 | |
| 31 | .macro RESTORE_CALLEE_SAVE_FRAME |
| 32 | addl $16, %esp // Remove padding |
| 33 | popl %ebp // Restore callee saves |
| 34 | popl %esi |
| 35 | popl %edi |
| 36 | .endm |
| 37 | |
| 38 | /* |
| 39 | * Macro that sets up the callee save frame to conform with |
| 40 | * Runtime::CreateCalleeSaveMethod(...) |
| 41 | */ |
| 42 | .macro SETUP_REF_AND_ARG_CALLEE_SAVE_FRAME |
| 43 | pushl %edi // Save callee saves |
| 44 | pushl %esi |
| 45 | pushl %ebp |
| 46 | pushl %ebx // Save args |
| 47 | pushl %edx |
| 48 | pushl %ecx |
| 49 | pushl %eax // Align stack, eax will be clobbered by Method* |
| 50 | .endm |
| 51 | |
| 52 | .macro RESTORE_REF_AND_ARG_CALLEE_SAVE_FRAME |
| 53 | addl $16, %esp // Remove padding |
| 54 | popl %ebp // Restore callee saves |
| 55 | popl %esi |
| 56 | popl %edi |
| 57 | .endm |
| 58 | |
| 59 | /* |
| 60 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 61 | * exception is Thread::Current()->exception_. |
| 62 | */ |
| 63 | .macro DELIVER_PENDING_EXCEPTION |
| 64 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save callee saves for throw |
| 65 | mov %esp, %ecx |
| 66 | // Outgoing argument set up |
| 67 | subl $8, %esp // Alignment padding |
| 68 | pushl %ecx // pass SP |
| 69 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 70 | call artDeliverPendingExceptionFromCode // artDeliverExceptionFromCode(Thread*, SP) |
| 71 | int3 |
| 72 | .endm |
| 73 | |
| 74 | .macro NO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 75 | .global \c_name |
| 76 | .extern \cxx_name |
| 77 | ALIGN_FUNCTION_ENTRY |
| 78 | \c_name: |
| 79 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 80 | mov %esp, %ecx |
| 81 | // Outgoing argument set up |
| 82 | subl $8, %esp // alignment padding |
| 83 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 84 | pushl %ecx // pass SP |
| 85 | call \cxx_name // \cxx_name(Thread*, SP) |
| 86 | int3 // unreached |
| 87 | .endm |
| 88 | |
| 89 | .macro ONE_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 90 | .global \c_name |
| 91 | .extern \cxx_name |
| 92 | ALIGN_FUNCTION_ENTRY |
| 93 | \c_name: |
| 94 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 95 | mov %esp, %ecx |
| 96 | // Outgoing argument set up |
| 97 | pushl $0 // alignment padding |
| 98 | pushl %ecx // pass SP |
| 99 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 100 | pushl %eax // pass arg1 |
| 101 | call \cxx_name // \cxx_name(arg1, Thread*, SP) |
| 102 | int3 // unreached |
| 103 | .endm |
| 104 | |
| 105 | .macro TWO_ARG_RUNTIME_EXCEPTION c_name, cxx_name |
| 106 | .global \c_name |
| 107 | .extern \cxx_name |
| 108 | ALIGN_FUNCTION_ENTRY |
| 109 | \c_name: |
| 110 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save all registers as basis for long jump context |
| 111 | mov %esp, %edx |
| 112 | // Outgoing argument set up |
| 113 | pushl %edx // pass SP |
| 114 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 115 | pushl %eax // pass arg1 |
| 116 | pushl %ecx // pass arg2 |
| 117 | call \cxx_name // \cxx_name(arg1, Thread*, SP) |
| 118 | int3 // unreached |
| 119 | .endm |
| 120 | |
| 121 | /* |
| 122 | * Called by managed code, saves callee saves and then calls artThrowException |
| 123 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 124 | */ |
| 125 | ONE_ARG_RUNTIME_EXCEPTION art_deliver_exception_from_code, artDeliverExceptionFromCode |
| 126 | |
| 127 | /* |
| 128 | * Called by managed code to create and deliver a NullPointerException. |
| 129 | */ |
| 130 | NO_ARG_RUNTIME_EXCEPTION art_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode |
| 131 | |
| 132 | /* |
| 133 | * Called by managed code to create and deliver an ArithmeticException. |
| 134 | */ |
| 135 | NO_ARG_RUNTIME_EXCEPTION art_throw_div_zero_from_code, artThrowDivZeroFromCode |
| 136 | |
| 137 | /* |
| 138 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 139 | * index, arg2 holds limit. |
| 140 | */ |
| 141 | TWO_ARG_RUNTIME_EXCEPTION art_throw_array_bounds_from_code, artThrowArrayBoundsFromCode |
| 142 | |
| 143 | /* |
| 144 | * Called by managed code to create and deliver a StackOverflowError. |
| 145 | */ |
| 146 | NO_ARG_RUNTIME_EXCEPTION art_throw_stack_overflow_from_code, artThrowStackOverflowFromCode |
| 147 | |
| 148 | /* |
| 149 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 150 | */ |
| 151 | ONE_ARG_RUNTIME_EXCEPTION art_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode |
| 152 | |
| 153 | /* |
| 154 | * Called by managed code to create and deliver verification errors. Arg1 is kind, arg2 is ref. |
| 155 | */ |
| 156 | TWO_ARG_RUNTIME_EXCEPTION art_throw_verification_error_from_code, artThrowVerificationErrorFromCode |
| 157 | |
| 158 | /* |
| 159 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 160 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 161 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 162 | * stack and call the appropriate C helper. |
| 163 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
| 164 | * |
| 165 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 166 | * of the target Method* in r0 and method->code_ in r1. |
| 167 | * |
| 168 | * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the |
| 169 | * thread and we branch to another stub to deliver it. |
| 170 | * |
| 171 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 172 | * pointing back to the original caller. |
| 173 | */ |
| 174 | .macro INVOKE_TRAMPOLINE c_name, cxx_name |
| 175 | .global \c_name |
| 176 | .extern \cxx_name |
| 177 | ALIGN_FUNCTION_ENTRY |
| 178 | \c_name: |
| 179 | int3 |
| 180 | .endm |
| 181 | |
| 182 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 183 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 184 | |
| 185 | INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 186 | INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 187 | INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 188 | INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| 189 | |
| 190 | // TODO |
| 191 | .globl art_proxy_invoke_handler |
| 192 | art_proxy_invoke_handler: |
| 193 | int3 |
| 194 | |
| 195 | .globl art_update_debugger |
| 196 | art_update_debugger: |
| 197 | int3 |
| 198 | |
| 199 | .globl art_test_suspend |
| 200 | art_test_suspend: |
| 201 | int3 |
| 202 | |
| 203 | .globl art_alloc_object_from_code |
| 204 | art_alloc_object_from_code: |
| 205 | int3 |
| 206 | |
| 207 | .globl art_alloc_object_from_code_with_access_check |
| 208 | art_alloc_object_from_code_with_access_check: |
| 209 | int3 |
| 210 | |
| 211 | .globl art_alloc_array_from_code |
| 212 | art_alloc_array_from_code: |
| 213 | int3 |
| 214 | |
| 215 | .globl art_alloc_array_from_code_with_access_check |
| 216 | art_alloc_array_from_code_with_access_check: |
| 217 | int3 |
| 218 | |
| 219 | .globl art_check_and_alloc_array_from_code |
| 220 | art_check_and_alloc_array_from_code: |
| 221 | int3 |
| 222 | |
| 223 | .globl art_check_and_alloc_array_from_code_with_access_check |
| 224 | art_check_and_alloc_array_from_code_with_access_check: |
| 225 | int3 |
| 226 | |
| 227 | .globl art_can_put_array_element_from_code |
| 228 | art_can_put_array_element_from_code: |
| 229 | int3 |
| 230 | |
| 231 | .globl art_check_cast_from_code |
| 232 | art_check_cast_from_code: |
| 233 | int3 |
| 234 | |
| 235 | .globl art_initialize_static_storage_from_code |
| 236 | art_initialize_static_storage_from_code: |
| 237 | int3 |
| 238 | |
| 239 | .globl art_initialize_type_and_verify_access_from_code |
| 240 | art_initialize_type_and_verify_access_from_code: |
| 241 | int3 |
| 242 | |
| 243 | .globl art_initialize_type_from_code |
| 244 | art_initialize_type_from_code: |
| 245 | int3 |
| 246 | |
| 247 | .globl art_resolve_string_from_code |
| 248 | art_resolve_string_from_code: |
| 249 | int3 |
| 250 | |
| 251 | .globl art_set32_instance_from_code |
| 252 | art_set32_instance_from_code: |
| 253 | int3 |
| 254 | |
| 255 | .globl art_set64_instance_from_code |
| 256 | art_set64_instance_from_code: |
| 257 | int3 |
| 258 | |
| 259 | .globl art_set_obj_instance_from_code |
| 260 | art_set_obj_instance_from_code: |
| 261 | int3 |
| 262 | |
| 263 | .globl art_get32_instance_from_code |
| 264 | art_get32_instance_from_code: |
| 265 | int3 |
| 266 | |
| 267 | .globl art_get64_instance_from_code |
| 268 | art_get64_instance_from_code: |
| 269 | int3 |
| 270 | |
| 271 | .globl art_get_obj_instance_from_code |
| 272 | art_get_obj_instance_from_code: |
| 273 | int3 |
| 274 | |
| 275 | .globl art_set32_static_from_code |
| 276 | art_set32_static_from_code: |
| 277 | int3 |
| 278 | |
| 279 | .globl art_set64_static_from_code |
| 280 | art_set64_static_from_code: |
| 281 | int3 |
| 282 | |
| 283 | .globl art_set_obj_static_from_code |
| 284 | art_set_obj_static_from_code: |
| 285 | int3 |
| 286 | |
| 287 | .globl art_get32_static_from_code |
| 288 | art_get32_static_from_code: |
| 289 | int3 |
| 290 | |
| 291 | .globl art_get64_static_from_code |
| 292 | art_get64_static_from_code: |
| 293 | int3 |
| 294 | |
| 295 | .globl art_get_obj_static_from_code |
| 296 | art_get_obj_static_from_code: |
| 297 | int3 |
| 298 | |
| 299 | .globl art_handle_fill_data_from_code |
| 300 | art_handle_fill_data_from_code: |
| 301 | int3 |
| 302 | |
| 303 | .globl art_lock_object_from_code |
| 304 | art_lock_object_from_code: |
| 305 | int3 |
| 306 | |
| 307 | .globl art_unlock_object_from_code |
| 308 | art_unlock_object_from_code: |
| 309 | int3 |
| 310 | |
| 311 | .globl art_indexof |
| 312 | art_indexof: |
| 313 | int3 |
| 314 | |
| 315 | .globl __memcmp16 |
| 316 | __memcmp16: |
| 317 | int3 |
| 318 | |
| 319 | .globl art_string_compareto |
| 320 | art_string_compareto: |
| 321 | int3 |