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 |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 24 | #define MACRO3(macro_name, macro_arg1, macro_args2, macro_args3) .macro macro_name |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 25 | #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 Hughes | 20a7a07 | 2012-04-04 12:54:00 -0700 | [diff] [blame] | 30 | #define SYMBOL(name) _ ## name |
Elliott Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 31 | #define VAR(name,index) SYMBOL($index) |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 32 | #define CALL_MACRO(name,index) $index |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 33 | #define LITERAL(value) $value |
| 34 | #define MACRO_LITERAL(value) $$value |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 35 | #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 Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 40 | #define MACRO3(macro_name, macro_arg1, macro_arg2, macro_arg3) .macro macro_name macro_arg1, macro_arg2, macro_arg3 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 41 | #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 Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 48 | #define SYMBOL(name) name |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 49 | #define VAR(name,index) name& |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 50 | #define CALL_MACRO(name,index) name& |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 51 | #define LITERAL(value) $value |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 52 | #define MACRO_LITERAL(value) $value |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 53 | #endif |
| 54 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 55 | /* Cache alignment for function entry */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 56 | MACRO0(ALIGN_FUNCTION_ENTRY) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 57 | .balign 16 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 58 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 59 | |
Elliott Hughes | 5e28422 | 2012-04-04 13:38:03 -0700 | [diff] [blame] | 60 | MACRO1(DEFINE_FUNCTION,c_name) |
| 61 | .globl VAR(c_name, 0) |
| 62 | ALIGN_FUNCTION_ENTRY |
| 63 | VAR(c_name, 0): |
| 64 | END_MACRO |
| 65 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 66 | /* |
| 67 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 68 | * Runtime::CreateCalleeSaveMethod(kSaveAll) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 69 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 70 | MACRO0(SETUP_SAVE_ALL_CALLEE_SAVE_FRAME) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 71 | pushl %edi // Save callee saves (ebx is saved/restored by the upcall) |
| 72 | pushl %esi |
| 73 | pushl %ebp |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 74 | subl MACRO_LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 75 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 76 | |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 77 | /* |
| 78 | * Macro that sets up the callee save frame to conform with |
| 79 | * Runtime::CreateCalleeSaveMethod(kRefsOnly) |
| 80 | */ |
| 81 | MACRO0(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 Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 85 | subl MACRO_LITERAL(16), %esp // Grow stack by 4 words, bottom word will hold Method* |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 86 | END_MACRO |
| 87 | |
| 88 | MACRO0(RESTORE_REF_ONLY_CALLEE_SAVE_FRAME) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 89 | addl MACRO_LITERAL(28), %esp // Unwind stack up to return address |
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 | |
| 92 | /* |
| 93 | * Macro that sets up the callee save frame to conform with |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 94 | * Runtime::CreateCalleeSaveMethod(kRefsAndArgs) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 95 | */ |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 96 | MACRO0(SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 97 | 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 Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 104 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 105 | |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 106 | MACRO0(RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 107 | addl MACRO_LITERAL(4), %esp // Remove padding |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 108 | popl %ecx // Restore args except eax |
| 109 | popl %edx |
| 110 | popl %ebx |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 111 | popl %ebp // Restore callee saves |
| 112 | popl %esi |
| 113 | popl %edi |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 114 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 115 | |
| 116 | /* |
| 117 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 118 | * exception is Thread::Current()->exception_. |
| 119 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 120 | MACRO0(DELIVER_PENDING_EXCEPTION) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 121 | SETUP_SAVE_ALL_CALLEE_SAVE_FRAME // save callee saves for throw |
| 122 | mov %esp, %ecx |
| 123 | // Outgoing argument set up |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 124 | subl MACRO_LITERAL(8), %esp // Alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 125 | pushl %ecx // pass SP |
| 126 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 127 | call SYMBOL(artDeliverPendingExceptionFromCode) // artDeliverPendingExceptionFromCode(Thread*, SP) |
| 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(NO_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 | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 138 | subl MACRO_LITERAL(8), %esp // alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 139 | pushl %ecx // pass SP |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 140 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 141 | call VAR(cxx_name, 1) // cxx_name(Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 142 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 143 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 144 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 145 | MACRO2(ONE_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
| 146 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 147 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 148 | VAR(c_name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 149 | 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 Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 152 | pushl %eax // alignment padding |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 153 | pushl %ecx // pass SP |
| 154 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 155 | pushl %eax // pass arg1 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 156 | call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 157 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 158 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 159 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 160 | MACRO2(TWO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
| 161 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 162 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 163 | VAR(c_name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 164 | 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 Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 169 | pushl %ecx // pass arg2 |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 170 | pushl %eax // pass arg1 |
| 171 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 172 | int3 // unreached |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 173 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 174 | |
| 175 | /* |
| 176 | * Called by managed code to create and deliver a NullPointerException. |
| 177 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 178 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 179 | |
| 180 | /* |
| 181 | * Called by managed code to create and deliver an ArithmeticException. |
| 182 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 183 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero_from_code, artThrowDivZeroFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 184 | |
| 185 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 186 | * Called by managed code to create and deliver a StackOverflowError. |
| 187 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 188 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow_from_code, artThrowStackOverflowFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 189 | |
| 190 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 191 | * 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 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 194 | ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception_from_code, artDeliverExceptionFromCode |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 195 | |
| 196 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 197 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 198 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 199 | ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 200 | |
| 201 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 202 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 203 | * index, arg2 holds limit. |
| 204 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 205 | TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds_from_code, artThrowArrayBoundsFromCode |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 206 | |
| 207 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 208 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 209 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 210 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 211 | * stack and call the appropriate C helper. |
| 212 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
| 213 | * |
| 214 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 215 | * of the target Method* in r0 and method->code_ in r1. |
| 216 | * |
| 217 | * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the |
| 218 | * thread and we branch to another stub to deliver it. |
| 219 | * |
| 220 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 221 | * pointing back to the original caller. |
| 222 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 223 | MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) |
| 224 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 225 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 226 | VAR(c_name, 0): |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 227 | // Set up the callee save frame to conform with Runtime::CreateCalleeSaveMethod(kRefsAndArgs) |
| 228 | // return address |
| 229 | pushl %edi |
| 230 | pushl %esi |
| 231 | pushl %ebp |
| 232 | pushl %ebx |
| 233 | pushl %edx |
| 234 | pushl %ecx |
| 235 | pushl %eax // <-- callee save Method* to go here |
| 236 | movl %esp, %edx // remember SP |
| 237 | // Outgoing argument set up |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 238 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 239 | pushl %edx // pass SP |
| 240 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 241 | pushl 32(%edx) // pass caller Method* |
| 242 | pushl %ecx // pass arg2 |
| 243 | pushl %eax // pass arg1 |
| 244 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
| 245 | movl %edx, %edi // save code pointer in EDI |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 246 | addl MACRO_LITERAL(36), %esp // Pop arguments skip eax |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 247 | popl %ecx // Restore args |
| 248 | popl %edx |
| 249 | popl %ebx |
| 250 | popl %ebp // Restore callee saves. |
| 251 | popl %esi |
| 252 | // Swap EDI callee save with code pointer. |
| 253 | xchgl %edi, (%esp) |
| 254 | testl %eax, %eax // Branch forward if exception pending. |
| 255 | jz 1f |
| 256 | // Tail call to intended method. |
| 257 | ret |
| 258 | 1: |
jeffhao | 20b5c6c | 2012-05-21 14:15:18 -0700 | [diff] [blame] | 259 | addl MACRO_LITERAL(4), %esp // Pop code pointer off stack |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 260 | DELIVER_PENDING_EXCEPTION |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 261 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 262 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 263 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 264 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 265 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 266 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 267 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 268 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 269 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 270 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 271 | MACRO3(NO_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
| 272 | .globl VAR(c_name, 0) |
| 273 | ALIGN_FUNCTION_ENTRY |
| 274 | VAR(c_name, 0): |
| 275 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 276 | mov %esp, %edx // remember SP |
| 277 | // Outgoing argument set up |
| 278 | subl MACRO_LITERAL(8), %esp // push padding |
| 279 | pushl %edx // pass SP |
| 280 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 281 | call VAR(cxx_name, 1) // cxx_name(Thread*, SP) |
| 282 | addl MACRO_LITERAL(16), %esp // pop arguments |
| 283 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 284 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 285 | END_MACRO |
| 286 | |
| 287 | MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
| 288 | .globl VAR(c_name, 0) |
| 289 | ALIGN_FUNCTION_ENTRY |
| 290 | VAR(c_name, 0): |
| 291 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 292 | mov %esp, %edx // remember SP |
| 293 | // Outgoing argument set up |
| 294 | pushl %eax // push padding |
| 295 | pushl %edx // pass SP |
| 296 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 297 | pushl %eax // pass arg1 |
| 298 | call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP) |
| 299 | addl MACRO_LITERAL(16), %esp // pop arguments |
| 300 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 301 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 302 | END_MACRO |
| 303 | |
| 304 | MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 305 | .globl VAR(c_name, 0) |
| 306 | ALIGN_FUNCTION_ENTRY |
| 307 | VAR(c_name, 0): |
| 308 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 309 | mov %esp, %edx // remember SP |
| 310 | // Outgoing argument set up |
| 311 | pushl %edx // pass SP |
| 312 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 313 | pushl %ecx // pass arg2 |
| 314 | pushl %eax // pass arg1 |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 315 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 316 | addl MACRO_LITERAL(16), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 317 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 318 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 319 | END_MACRO |
| 320 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 321 | MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 322 | .globl VAR(c_name, 0) |
| 323 | ALIGN_FUNCTION_ENTRY |
| 324 | VAR(c_name, 0): |
| 325 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 326 | mov %esp, %ebx // remember SP |
| 327 | // Outgoing argument set up |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 328 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 329 | pushl %ebx // pass SP |
| 330 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 331 | pushl %edx // pass arg3 |
| 332 | pushl %ecx // pass arg2 |
| 333 | pushl %eax // pass arg1 |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 334 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 335 | addl MACRO_LITERAL(32), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 336 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 337 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 338 | END_MACRO |
| 339 | |
| 340 | MACRO0(RETURN_IF_EAX_NOT_ZERO) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 341 | testl %eax, %eax // eax == 0 ? |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 342 | jz 1f // if eax == 0 goto 1 |
| 343 | ret // return |
| 344 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 345 | DELIVER_PENDING_EXCEPTION |
| 346 | END_MACRO |
| 347 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 348 | MACRO0(RETURN_IF_EAX_ZERO) |
| 349 | testl %eax, %eax // eax == 0 ? |
| 350 | jnz 1f // if eax != 0 goto 1 |
| 351 | ret // return |
| 352 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 353 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 354 | END_MACRO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 355 | |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 356 | MACRO0(RETURN_OR_DELIVER_PENDING_EXCEPTION) |
| 357 | mov %fs:THREAD_EXCEPTION_OFFSET, %ebx // get exception field |
| 358 | testl %ebx, %ebx // ebx == 0 ? |
| 359 | jnz 1f // if ebx != 0 goto 1 |
| 360 | ret // return |
| 361 | 1: // deliver exception on current thread |
| 362 | DELIVER_PENDING_EXCEPTION |
| 363 | END_MACRO |
| 364 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 365 | TWO_ARG_DOWNCALL art_quick_alloc_object_from_code, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO |
| 366 | TWO_ARG_DOWNCALL art_quick_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
| 367 | THREE_ARG_DOWNCALL art_quick_alloc_array_from_code, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO |
| 368 | THREE_ARG_DOWNCALL art_quick_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
| 369 | THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO |
| 370 | THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 371 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 372 | TWO_ARG_DOWNCALL art_quick_resolve_string_from_code, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO |
| 373 | TWO_ARG_DOWNCALL art_quick_initialize_static_storage_from_code, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO |
| 374 | TWO_ARG_DOWNCALL art_quick_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO |
| 375 | TWO_ARG_DOWNCALL art_quick_initialize_type_and_verify_access_from_code, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 376 | |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 377 | /* |
| 378 | * On entry, eax and ecx must be preserved, edx is dex PC |
| 379 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 380 | DEFINE_FUNCTION art_quick_update_debugger |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 381 | mov %eax, %ebx // stash away eax so that it's saved as if it were an argument |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 382 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 383 | subl LITERAL(4), %esp // alignment padding |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 384 | pushl %esp // pass arg2 (sp) |
| 385 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 386 | pushl %edx // pass arg0 (dex pc) |
| 387 | call SYMBOL(artUpdateDebuggerFromCode) // artUpdateDebuggerFromCode(int32_t, Thread*, Method**) |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 388 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 389 | RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 390 | mov %ebx, %eax // restore original eax |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 391 | ret |
| 392 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 393 | ONE_ARG_DOWNCALL art_quick_lock_object_from_code, artLockObjectFromCode, ret |
| 394 | ONE_ARG_DOWNCALL art_quick_unlock_object_from_code, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 395 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 396 | TWO_ARG_DOWNCALL art_quick_handle_fill_data_from_code, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 397 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 398 | DEFINE_FUNCTION art_quick_is_assignable_from_code |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 399 | pushl %eax // alignment padding |
| 400 | pushl %ecx // pass arg2 |
| 401 | pushl %eax // pass arg1 |
Elliott Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 402 | call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b, Thread*, SP) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 403 | addl LITERAL(12), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 404 | ret |
| 405 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 406 | DEFINE_FUNCTION art_quick_memcpy |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 407 | pushl %edx // pass arg3 |
| 408 | pushl %ecx // pass arg2 |
| 409 | pushl %eax // pass arg1 |
Elliott Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 410 | call SYMBOL(memcpy) // (void*, const void*, size_t) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 411 | addl LITERAL(12), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 412 | ret |
| 413 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 414 | TWO_ARG_DOWNCALL art_quick_check_cast_from_code, artCheckCastFromCode, RETURN_IF_EAX_ZERO |
| 415 | TWO_ARG_DOWNCALL art_quick_can_put_array_element_from_code, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 416 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 417 | NO_ARG_DOWNCALL art_quick_test_suspend, artTestSuspendFromCode, ret |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 418 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 419 | DEFINE_FUNCTION art_quick_fmod_from_code |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 420 | subl LITERAL(12), %esp // alignment padding |
| 421 | pushl %ebx // pass arg4 b.hi |
| 422 | pushl %edx // pass arg3 b.lo |
| 423 | pushl %ecx // pass arg2 a.hi |
| 424 | pushl %eax // pass arg1 a.lo |
| 425 | call SYMBOL(fmod) // (jdouble a, jdouble b) |
| 426 | fstpl (%esp) // pop return value off fp stack |
| 427 | movsd (%esp), %xmm0 // place into %xmm0 |
| 428 | addl LITERAL(28), %esp // pop arguments |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 429 | ret |
| 430 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 431 | DEFINE_FUNCTION art_quick_fmodf_from_code |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 432 | pushl %eax // alignment padding |
| 433 | pushl %ecx // pass arg2 b |
| 434 | pushl %eax // pass arg1 a |
| 435 | call SYMBOL(fmodf) // (jfloat a, jfloat b) |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 436 | fstps (%esp) // pop return value off fp stack |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 437 | movss (%esp), %xmm0 // place into %xmm0 |
| 438 | addl LITERAL(12), %esp // pop arguments |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 439 | ret |
| 440 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 441 | DEFINE_FUNCTION art_quick_l2d_from_code |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 442 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 443 | pushl %ecx // pass arg2 a.hi |
| 444 | pushl %eax // pass arg1 a.lo |
| 445 | call SYMBOL(art_l2d) // (jlong a) |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 446 | fstpl (%esp) // pop return value off fp stack |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 447 | movsd (%esp), %xmm0 // place into %xmm0 |
| 448 | addl LITERAL(12), %esp // pop arguments |
| 449 | ret |
| 450 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 451 | DEFINE_FUNCTION art_quick_l2f_from_code |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 452 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 453 | pushl %ecx // pass arg2 a.hi |
| 454 | pushl %eax // pass arg1 a.lo |
| 455 | call SYMBOL(art_l2f) // (jlong a) |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 456 | fstps (%esp) // pop return value off fp stack |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 457 | movss (%esp), %xmm0 // place into %xmm0 |
| 458 | addl LITERAL(12), %esp // pop arguments |
| 459 | ret |
| 460 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 461 | DEFINE_FUNCTION art_quick_d2l_from_code |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 462 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 463 | pushl %ecx // pass arg2 a.hi |
| 464 | pushl %eax // pass arg1 a.lo |
| 465 | call SYMBOL(art_d2l) // (jdouble a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 466 | addl LITERAL(12), %esp // pop arguments |
| 467 | ret |
| 468 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 469 | DEFINE_FUNCTION art_quick_f2l_from_code |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 470 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 471 | pushl %eax // pass arg1 a |
| 472 | call SYMBOL(art_f2l) // (jfloat a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 473 | addl LITERAL(12), %esp // pop arguments |
| 474 | ret |
| 475 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 476 | DEFINE_FUNCTION art_quick_idivmod_from_code |
jeffhao | 174651d | 2012-04-19 15:27:22 -0700 | [diff] [blame] | 477 | cmpl LITERAL(0x80000000), %eax |
| 478 | je check_arg2 // special case |
| 479 | args_ok: |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 480 | cdq // edx:eax = sign extend eax |
| 481 | idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 482 | ret |
jeffhao | 174651d | 2012-04-19 15:27:22 -0700 | [diff] [blame] | 483 | check_arg2: |
| 484 | cmpl LITERAL(-1), %ecx |
| 485 | jne args_ok |
| 486 | xorl %edx, %edx |
| 487 | ret // eax already holds min int |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 488 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 489 | DEFINE_FUNCTION art_quick_ldiv_from_code |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 490 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 491 | pushl %ebx // pass arg4 b.hi |
| 492 | pushl %edx // pass arg3 b.lo |
| 493 | pushl %ecx // pass arg2 a.hi |
| 494 | pushl %eax // pass arg1 a.lo |
| 495 | call SYMBOL(artLdivFromCode) // (jlong a, jlong b) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 496 | addl LITERAL(28), %esp // pop arguments |
| 497 | ret |
| 498 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 499 | DEFINE_FUNCTION art_quick_ldivmod_from_code |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 500 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 501 | pushl %ebx // pass arg4 b.hi |
| 502 | pushl %edx // pass arg3 b.lo |
| 503 | pushl %ecx // pass arg2 a.hi |
| 504 | pushl %eax // pass arg1 a.lo |
| 505 | call SYMBOL(artLdivmodFromCode) // (jlong a, jlong b) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 506 | addl LITERAL(28), %esp // pop arguments |
| 507 | ret |
| 508 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 509 | DEFINE_FUNCTION art_quick_lmul_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 510 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 511 | pushl %ebx // pass arg4 b.hi |
| 512 | pushl %edx // pass arg3 b.lo |
| 513 | pushl %ecx // pass arg2 a.hi |
| 514 | pushl %eax // pass arg1 a.lo |
| 515 | call SYMBOL(artLmulFromCode) // (jlong a, jlong b) |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 516 | addl LITERAL(28), %esp // pop arguments |
| 517 | ret |
| 518 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 519 | DEFINE_FUNCTION art_quick_lshl_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 520 | // ecx:eax << edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 521 | xchg %edx, %ecx |
| 522 | shld %cl,%eax,%edx |
| 523 | shl %cl,%eax |
| 524 | test LITERAL(32), %cl |
| 525 | jz 1f |
| 526 | mov %eax, %edx |
| 527 | xor %eax, %eax |
| 528 | 1: |
| 529 | ret |
| 530 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 531 | DEFINE_FUNCTION art_quick_lshr_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 532 | // ecx:eax >> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 533 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 534 | shrd %cl,%edx,%eax |
| 535 | sar %cl,%edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 536 | test LITERAL(32),%cl |
| 537 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 538 | mov %edx, %eax |
| 539 | sar LITERAL(31), %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 540 | 1: |
| 541 | ret |
| 542 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 543 | DEFINE_FUNCTION art_quick_lushr_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 544 | // ecx:eax >>> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 545 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 546 | shrd %cl,%edx,%eax |
| 547 | shr %cl,%edx |
| 548 | test LITERAL(32),%cl |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 549 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 550 | mov %edx, %eax |
| 551 | xor %edx, %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 552 | 1: |
| 553 | ret |
| 554 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 555 | DEFINE_FUNCTION art_quick_set32_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 556 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 557 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 558 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 559 | pushl %ebx // pass SP |
| 560 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 561 | mov 32(%ebx), %ebx // get referrer |
| 562 | pushl %ebx // pass referrer |
| 563 | pushl %edx // pass new_val |
| 564 | pushl %ecx // pass object |
| 565 | pushl %eax // pass field_idx |
| 566 | call SYMBOL(artSet32InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 567 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 568 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 569 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 570 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 571 | DEFINE_FUNCTION art_quick_set64_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 572 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 573 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 574 | pushl %esp // pass SP-8 |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 575 | addl LITERAL(8), (%esp) // fix SP on stack by adding 8 |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 576 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 577 | pushl %ebx // pass high half of new_val |
| 578 | pushl %edx // pass low half of new_val |
| 579 | pushl %ecx // pass object |
| 580 | pushl %eax // pass field_idx |
| 581 | call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 582 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 583 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 584 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 585 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 586 | DEFINE_FUNCTION art_quick_set_obj_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 587 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 588 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 589 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 590 | pushl %ebx // pass SP |
| 591 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 592 | mov 32(%ebx), %ebx // get referrer |
| 593 | pushl %ebx // pass referrer |
| 594 | pushl %edx // pass new_val |
| 595 | pushl %ecx // pass object |
| 596 | pushl %eax // pass field_idx |
| 597 | call SYMBOL(artSetObjInstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 598 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 599 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 600 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 601 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 602 | DEFINE_FUNCTION art_quick_get32_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 603 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 604 | mov %esp, %ebx // remember SP |
| 605 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 606 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 607 | pushl %ebx // pass SP |
| 608 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 609 | pushl %edx // pass referrer |
| 610 | pushl %ecx // pass object |
| 611 | pushl %eax // pass field_idx |
| 612 | call SYMBOL(artGet32InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 613 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 614 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 615 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 616 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 617 | DEFINE_FUNCTION art_quick_get64_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 618 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 619 | mov %esp, %ebx // remember SP |
| 620 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 621 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 622 | pushl %ebx // pass SP |
| 623 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 624 | pushl %edx // pass referrer |
| 625 | pushl %ecx // pass object |
| 626 | pushl %eax // pass field_idx |
| 627 | call SYMBOL(artGet64InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 628 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 629 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 630 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 631 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 632 | DEFINE_FUNCTION art_quick_get_obj_instance_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 633 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 634 | mov %esp, %ebx // remember SP |
| 635 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 636 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 637 | pushl %ebx // pass SP |
| 638 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 639 | pushl %edx // pass referrer |
| 640 | pushl %ecx // pass object |
| 641 | pushl %eax // pass field_idx |
| 642 | call SYMBOL(artGetObjInstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 643 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 644 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 645 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 646 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 647 | DEFINE_FUNCTION art_quick_set32_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 648 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 649 | mov %esp, %ebx // remember SP |
| 650 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 651 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 652 | pushl %ebx // pass SP |
| 653 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 654 | pushl %edx // pass referrer |
| 655 | pushl %ecx // pass new_val |
| 656 | pushl %eax // pass field_idx |
| 657 | call SYMBOL(artSet32StaticFromCode) // (field_idx, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 658 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 659 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 660 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 661 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 662 | DEFINE_FUNCTION art_quick_set64_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 663 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 664 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 665 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 666 | pushl %ebx // pass SP |
| 667 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 668 | mov 32(%ebx), %ebx // get referrer |
| 669 | pushl %edx // pass high half of new_val |
| 670 | pushl %ecx // pass low half of new_val |
| 671 | pushl %ebx // pass referrer |
| 672 | pushl %eax // pass field_idx |
| 673 | call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 674 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 675 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 676 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 677 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 678 | DEFINE_FUNCTION art_quick_set_obj_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 679 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 680 | mov %esp, %ebx // remember SP |
| 681 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 682 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 683 | pushl %ebx // pass SP |
| 684 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 685 | pushl %edx // pass referrer |
| 686 | pushl %ecx // pass new_val |
| 687 | pushl %eax // pass field_idx |
| 688 | call SYMBOL(artSetObjStaticFromCode) // (field_idx, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 689 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 690 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 691 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 692 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 693 | DEFINE_FUNCTION art_quick_get32_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 694 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 695 | mov %esp, %edx // remember SP |
| 696 | mov 32(%esp), %ecx // get referrer |
| 697 | pushl %edx // pass SP |
| 698 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 699 | pushl %ecx // pass referrer |
| 700 | pushl %eax // pass field_idx |
| 701 | call SYMBOL(artGet32StaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 702 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 703 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 704 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 705 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 706 | DEFINE_FUNCTION art_quick_get64_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 707 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 708 | mov %esp, %edx // remember SP |
| 709 | mov 32(%esp), %ecx // get referrer |
| 710 | pushl %edx // pass SP |
| 711 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 712 | pushl %ecx // pass referrer |
| 713 | pushl %eax // pass field_idx |
| 714 | call SYMBOL(artGet64StaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 715 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 716 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 717 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 718 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 719 | DEFINE_FUNCTION art_quick_get_obj_static_from_code |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 720 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 721 | mov %esp, %edx // remember SP |
| 722 | mov 32(%esp), %ecx // get referrer |
| 723 | pushl %edx // pass SP |
| 724 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 725 | pushl %ecx // pass referrer |
| 726 | pushl %eax // pass field_idx |
| 727 | call SYMBOL(artGetObjStaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 728 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 729 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 730 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
| 731 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 732 | DEFINE_FUNCTION art_quick_proxy_invoke_handler |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 733 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // save frame and Method* |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 734 | pushl %esp // pass SP |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 735 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 736 | pushl %ecx // pass receiver |
| 737 | pushl %eax // pass proxy method |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 738 | call SYMBOL(artProxyInvokeHandler) // (proxy method, receiver, Thread*, SP) |
| 739 | movd %eax, %xmm0 // place return value also into floating point return value |
| 740 | movd %edx, %xmm1 |
| 741 | punpckldq %xmm1, %xmm0 |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 742 | addl LITERAL(44), %esp // pop arguments |
| 743 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 744 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 745 | DEFINE_FUNCTION art_quick_interpreter_entry |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 746 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // save frame and Method* |
| 747 | pushl %eax // alignment padding |
| 748 | pushl %esp // pass SP |
| 749 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 750 | pushl %eax // pass method |
| 751 | call SYMBOL(artInterpreterEntry) // (method, Thread*, SP) |
| 752 | movd %eax, %xmm0 // place return value also into floating point return value |
| 753 | movd %edx, %xmm1 |
| 754 | punpckldq %xmm1, %xmm0 |
| 755 | addl LITERAL(44), %esp // pop arguments |
| 756 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
| 757 | |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 758 | /* |
| 759 | * Routine that intercepts method calls and returns. |
| 760 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 761 | DEFINE_FUNCTION art_quick_instrumentation_entry_from_code |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 762 | xchgl %eax, (%esp) // place LR in eax, save eax |
| 763 | pushl %ecx // save ecx |
| 764 | pushl %edx // save edx |
| 765 | pushl %ebx // save ebx |
| 766 | lea 16(%esp), %edx // remember bottom of caller's frame |
| 767 | pushl %eax // pass LR |
| 768 | pushl %edx // pass SP |
| 769 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 770 | pushl 24(%esp) // pass Method* |
| 771 | call SYMBOL(artInstrumentationMethodEntryFromCode) // (Method*, Thread*, SP, LR) |
| 772 | addl LITERAL(16), %esp // pop arguments |
| 773 | popl %ebx // restore ebx |
| 774 | popl %edx // restore edx |
| 775 | movl (%esp), %ecx // restore ecx (without popping) |
| 776 | movl %eax, (%esp) // place method's code pointer on stack |
| 777 | movl 4(%esp), %eax // restore eax (without popping) |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 778 | movl LITERAL(SYMBOL(art_quick_instrumentation_exit_from_code)), 4(%esp) |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 779 | // place instrumentation exit as return pc |
| 780 | ret // call method (and pop) |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 781 | DEFINE_FUNCTION art_quick_instrumentation_exit_from_code |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 782 | mov %esp, %ecx // remember bottom of caller's frame |
| 783 | pushl %edx // save return value |
| 784 | pushl %eax // save other half of return value |
| 785 | pushl %ecx // pass SP |
| 786 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current |
| 787 | call SYMBOL(artInstrumentationMethodExitFromCode) // (Thread*, SP) |
| 788 | mov %eax, %ecx // move returned link register |
| 789 | // TODO: Set link register for deopt |
| 790 | addl LITERAL(8), %esp // pop arguments |
| 791 | popl %eax // restore return value |
| 792 | popl %edx // restore other half of return value |
| 793 | jmp *%ecx // return |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 794 | |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 795 | /* |
| 796 | * The thread's enter interpreter flag is set and so we should transition to the interpreter |
| 797 | * rather than allow execution to continue in the frame below. There may be live results in |
| 798 | * registers depending on how complete the operation is when we safepoint - for example, a |
| 799 | * set operation may have completed while a get operation needs writing back into the vregs. |
| 800 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 801 | DEFINE_FUNCTION art_quick_deoptimize |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 802 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME |
| 803 | pushl %esp // pass SP |
| 804 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 805 | pushl %edx // push half of return value |
| 806 | pushl %eax // push other half of return value |
| 807 | call SYMBOL(artDeoptimize) // artDeoptimize(return value, Thread*, SP) |
| 808 | // Returns caller method's frame size. |
| 809 | addl LITERAL(16), %esp // pop arguments |
| 810 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 811 | testl %eax, %eax // Was the caller an upcall? |
| 812 | jz 1f // Return if caller was upcall. |
| 813 | lea (%esp, %eax), %edx // edx == bottom of caller's frame. |
| 814 | mov %edx, %esp // Remove frame. |
| 815 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME |
| 816 | call SYMBOL(artEnterInterpreterFromDeoptimize) // Enter interpreter, callee-save ends stack fragment. |
| 817 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME |
| 818 | 1: |
| 819 | ret // Return to caller. |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 820 | |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 821 | /* |
| 822 | * String's indexOf. |
| 823 | * |
| 824 | * On entry: |
| 825 | * eax: string object (known non-null) |
| 826 | * ecx: char to match (known <= 0xFFFF) |
| 827 | * edx: Starting offset in string data |
| 828 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 829 | DEFINE_FUNCTION art_quick_indexof |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 830 | pushl %edi // push callee save reg |
| 831 | mov STRING_COUNT_OFFSET(%eax), %ebx |
| 832 | mov STRING_VALUE_OFFSET(%eax), %edi |
| 833 | mov STRING_OFFSET_OFFSET(%eax), %eax |
| 834 | testl %edx, %edx // check if start < 0 |
| 835 | jl clamp_min |
| 836 | clamp_done: |
| 837 | cmpl %ebx, %edx // check if start >= count |
| 838 | jge not_found |
| 839 | lea STRING_DATA_OFFSET(%edi, %eax, 2), %edi // build a pointer to the start of string data |
| 840 | mov %edi, %eax // save a copy in eax to later compute result |
| 841 | lea (%edi, %edx, 2), %edi // build pointer to start of data to compare |
| 842 | subl %edx, %ebx // compute iteration count |
| 843 | /* |
| 844 | * At this point we have: |
| 845 | * eax: original start of string data |
| 846 | * ecx: char to compare |
| 847 | * ebx: length to compare |
| 848 | * edi: start of data to test |
| 849 | */ |
| 850 | mov %eax, %edx |
| 851 | mov %ecx, %eax // put char to match in %eax |
| 852 | mov %ebx, %ecx // put length to compare in %ecx |
| 853 | repne scasw // find %ax, starting at [%edi], up to length %ecx |
| 854 | jne not_found |
| 855 | subl %edx, %edi |
| 856 | sar LITERAL(1), %edi |
| 857 | decl %edi // index = ((curr_ptr - orig_ptr) / 2) - 1 |
| 858 | mov %edi, %eax |
| 859 | popl %edi // pop callee save reg |
| 860 | ret |
| 861 | .balign 16 |
| 862 | not_found: |
| 863 | mov LITERAL(-1), %eax // return -1 (not found) |
| 864 | popl %edi // pop callee save reg |
| 865 | ret |
| 866 | clamp_min: |
| 867 | xor %edx, %edx // clamp start to 0 |
| 868 | jmp clamp_done |
| 869 | |
| 870 | /* |
| 871 | * String's compareTo. |
| 872 | * |
| 873 | * On entry: |
| 874 | * eax: this string object (known non-null) |
| 875 | * ecx: comp string object (known non-null) |
| 876 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 877 | DEFINE_FUNCTION art_quick_string_compareto |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 878 | pushl %esi // push callee save reg |
| 879 | pushl %edi // push callee save reg |
| 880 | mov STRING_COUNT_OFFSET(%eax), %edx |
| 881 | mov STRING_COUNT_OFFSET(%ecx), %ebx |
| 882 | mov STRING_VALUE_OFFSET(%eax), %esi |
| 883 | mov STRING_VALUE_OFFSET(%ecx), %edi |
| 884 | mov STRING_OFFSET_OFFSET(%eax), %eax |
| 885 | mov STRING_OFFSET_OFFSET(%ecx), %ecx |
| 886 | /* Build pointers to the start of string data */ |
| 887 | lea STRING_DATA_OFFSET(%esi, %eax, 2), %esi |
| 888 | lea STRING_DATA_OFFSET(%edi, %ecx, 2), %edi |
| 889 | /* Calculate min length and count diff */ |
| 890 | mov %edx, %ecx |
| 891 | mov %edx, %eax |
| 892 | subl %ebx, %eax |
| 893 | cmovg %ebx, %ecx |
| 894 | /* |
| 895 | * At this point we have: |
| 896 | * eax: value to return if first part of strings are equal |
| 897 | * ecx: minimum among the lengths of the two strings |
| 898 | * esi: pointer to this string data |
| 899 | * edi: pointer to comp string data |
| 900 | */ |
| 901 | repe cmpsw // find nonmatching chars in [%esi] and [%edi], up to length %ecx |
| 902 | jne not_equal |
| 903 | popl %edi // pop callee save reg |
| 904 | popl %esi // pop callee save reg |
| 905 | ret |
| 906 | .balign 16 |
| 907 | not_equal: |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 908 | movzwl -2(%esi), %eax // get last compared char from this string |
| 909 | movzwl -2(%edi), %ecx // get last compared char from comp string |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 910 | subl %ecx, %eax // return the difference |
| 911 | popl %edi // pop callee save reg |
| 912 | popl %esi // pop callee save reg |
| 913 | ret |
| 914 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 915 | MACRO1(UNIMPLEMENTED,name) |
| 916 | .globl VAR(name, 0) |
| 917 | ALIGN_FUNCTION_ENTRY |
| 918 | VAR(name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 919 | int3 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 920 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 921 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 922 | // TODO: implement these! |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame^] | 923 | UNIMPLEMENTED art_quick_memcmp16 |