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 | */ |
| 178 | NO_ARG_RUNTIME_EXCEPTION art_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode |
| 179 | |
| 180 | /* |
| 181 | * Called by managed code to create and deliver an ArithmeticException. |
| 182 | */ |
| 183 | NO_ARG_RUNTIME_EXCEPTION art_throw_div_zero_from_code, artThrowDivZeroFromCode |
| 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 | */ |
| 188 | NO_ARG_RUNTIME_EXCEPTION art_throw_stack_overflow_from_code, artThrowStackOverflowFromCode |
| 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 | */ |
| 194 | ONE_ARG_RUNTIME_EXCEPTION art_deliver_exception_from_code, artDeliverExceptionFromCode |
| 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 | */ |
| 199 | ONE_ARG_RUNTIME_EXCEPTION art_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode |
| 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 | */ |
| 205 | TWO_ARG_RUNTIME_EXCEPTION art_throw_array_bounds_from_code, artThrowArrayBoundsFromCode |
| 206 | |
| 207 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 208 | * Called by managed code to create and deliver verification errors. Arg1 is kind, arg2 is ref. |
| 209 | */ |
| 210 | TWO_ARG_RUNTIME_EXCEPTION art_throw_verification_error_from_code, artThrowVerificationErrorFromCode |
| 211 | |
| 212 | /* |
| 213 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 214 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
| 215 | * the method_idx. This wrapper will save arg1-arg3, load the caller's Method*, align the |
| 216 | * stack and call the appropriate C helper. |
| 217 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
| 218 | * |
| 219 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 220 | * of the target Method* in r0 and method->code_ in r1. |
| 221 | * |
| 222 | * If unsuccessful, the helper will return NULL/NULL. There will bea pending exception in the |
| 223 | * thread and we branch to another stub to deliver it. |
| 224 | * |
| 225 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 226 | * pointing back to the original caller. |
| 227 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 228 | MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) |
| 229 | .globl VAR(c_name, 0) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 230 | ALIGN_FUNCTION_ENTRY |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 231 | VAR(c_name, 0): |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 232 | // Set up the callee save frame to conform with Runtime::CreateCalleeSaveMethod(kRefsAndArgs) |
| 233 | // return address |
| 234 | pushl %edi |
| 235 | pushl %esi |
| 236 | pushl %ebp |
| 237 | pushl %ebx |
| 238 | pushl %edx |
| 239 | pushl %ecx |
| 240 | pushl %eax // <-- callee save Method* to go here |
| 241 | movl %esp, %edx // remember SP |
| 242 | // Outgoing argument set up |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 243 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 244 | pushl %edx // pass SP |
| 245 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 246 | pushl 32(%edx) // pass caller Method* |
| 247 | pushl %ecx // pass arg2 |
| 248 | pushl %eax // pass arg1 |
| 249 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
| 250 | movl %edx, %edi // save code pointer in EDI |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 251 | addl MACRO_LITERAL(36), %esp // Pop arguments skip eax |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 252 | popl %ecx // Restore args |
| 253 | popl %edx |
| 254 | popl %ebx |
| 255 | popl %ebp // Restore callee saves. |
| 256 | popl %esi |
| 257 | // Swap EDI callee save with code pointer. |
| 258 | xchgl %edi, (%esp) |
| 259 | testl %eax, %eax // Branch forward if exception pending. |
| 260 | jz 1f |
| 261 | // Tail call to intended method. |
| 262 | ret |
| 263 | 1: |
jeffhao | 20b5c6c | 2012-05-21 14:15:18 -0700 | [diff] [blame] | 264 | addl MACRO_LITERAL(4), %esp // Pop code pointer off stack |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 265 | DELIVER_PENDING_EXCEPTION |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 266 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 267 | |
| 268 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline, artInvokeInterfaceTrampoline |
| 269 | INVOKE_TRAMPOLINE art_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
| 270 | |
| 271 | INVOKE_TRAMPOLINE art_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 272 | INVOKE_TRAMPOLINE art_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 273 | INVOKE_TRAMPOLINE art_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 274 | INVOKE_TRAMPOLINE art_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
| 275 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 276 | MACRO3(NO_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
| 277 | .globl VAR(c_name, 0) |
| 278 | ALIGN_FUNCTION_ENTRY |
| 279 | VAR(c_name, 0): |
| 280 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 281 | mov %esp, %edx // remember SP |
| 282 | // Outgoing argument set up |
| 283 | subl MACRO_LITERAL(8), %esp // push padding |
| 284 | pushl %edx // pass SP |
| 285 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 286 | call VAR(cxx_name, 1) // cxx_name(Thread*, SP) |
| 287 | addl MACRO_LITERAL(16), %esp // pop arguments |
| 288 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 289 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 290 | END_MACRO |
| 291 | |
| 292 | MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
| 293 | .globl VAR(c_name, 0) |
| 294 | ALIGN_FUNCTION_ENTRY |
| 295 | VAR(c_name, 0): |
| 296 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 297 | mov %esp, %edx // remember SP |
| 298 | // Outgoing argument set up |
| 299 | pushl %eax // push padding |
| 300 | pushl %edx // pass SP |
| 301 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 302 | pushl %eax // pass arg1 |
| 303 | call VAR(cxx_name, 1) // cxx_name(arg1, Thread*, SP) |
| 304 | addl MACRO_LITERAL(16), %esp // pop arguments |
| 305 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 306 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 307 | END_MACRO |
| 308 | |
| 309 | MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 310 | .globl VAR(c_name, 0) |
| 311 | ALIGN_FUNCTION_ENTRY |
| 312 | VAR(c_name, 0): |
| 313 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 314 | mov %esp, %edx // remember SP |
| 315 | // Outgoing argument set up |
| 316 | pushl %edx // pass SP |
| 317 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 318 | pushl %ecx // pass arg2 |
| 319 | pushl %eax // pass arg1 |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 320 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, Thread*, SP) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 321 | addl MACRO_LITERAL(16), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 322 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 323 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 324 | END_MACRO |
| 325 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 326 | MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 327 | .globl VAR(c_name, 0) |
| 328 | ALIGN_FUNCTION_ENTRY |
| 329 | VAR(c_name, 0): |
| 330 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 331 | mov %esp, %ebx // remember SP |
| 332 | // Outgoing argument set up |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 333 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 334 | pushl %ebx // pass SP |
| 335 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 336 | pushl %edx // pass arg3 |
| 337 | pushl %ecx // pass arg2 |
| 338 | pushl %eax // pass arg1 |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 339 | call VAR(cxx_name, 1) // cxx_name(arg1, arg2, arg3, Thread*, SP) |
Elliott Hughes | ea94421 | 2012-04-05 13:11:53 -0700 | [diff] [blame] | 340 | addl MACRO_LITERAL(32), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 341 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
Elliott Hughes | 754caaa | 2012-04-10 10:57:36 -0700 | [diff] [blame] | 342 | CALL_MACRO(return_macro, 2) // return or deliver exception |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 343 | END_MACRO |
| 344 | |
| 345 | MACRO0(RETURN_IF_EAX_NOT_ZERO) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 346 | testl %eax, %eax // eax == 0 ? |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 347 | jz 1f // if eax == 0 goto 1 |
| 348 | ret // return |
| 349 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 350 | DELIVER_PENDING_EXCEPTION |
| 351 | END_MACRO |
| 352 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 353 | MACRO0(RETURN_IF_EAX_ZERO) |
| 354 | testl %eax, %eax // eax == 0 ? |
| 355 | jnz 1f // if eax != 0 goto 1 |
| 356 | ret // return |
| 357 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 358 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 359 | END_MACRO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 360 | |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 361 | MACRO0(RETURN_OR_DELIVER_PENDING_EXCEPTION) |
| 362 | mov %fs:THREAD_EXCEPTION_OFFSET, %ebx // get exception field |
| 363 | testl %ebx, %ebx // ebx == 0 ? |
| 364 | jnz 1f // if ebx != 0 goto 1 |
| 365 | ret // return |
| 366 | 1: // deliver exception on current thread |
| 367 | DELIVER_PENDING_EXCEPTION |
| 368 | END_MACRO |
| 369 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 370 | TWO_ARG_DOWNCALL art_alloc_object_from_code, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO |
| 371 | TWO_ARG_DOWNCALL art_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
| 372 | THREE_ARG_DOWNCALL art_alloc_array_from_code, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO |
| 373 | THREE_ARG_DOWNCALL art_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
| 374 | THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO |
| 375 | THREE_ARG_DOWNCALL art_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO |
| 376 | |
| 377 | TWO_ARG_DOWNCALL art_resolve_string_from_code, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO |
| 378 | TWO_ARG_DOWNCALL art_initialize_static_storage_from_code, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO |
Elliott Hughes | e87c7bc | 2012-04-16 20:42:34 -0700 | [diff] [blame] | 379 | TWO_ARG_DOWNCALL art_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO |
| 380 | TWO_ARG_DOWNCALL art_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] | 381 | |
| 382 | ONE_ARG_DOWNCALL art_lock_object_from_code, artLockObjectFromCode, ret |
| 383 | ONE_ARG_DOWNCALL art_unlock_object_from_code, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO |
| 384 | |
| 385 | TWO_ARG_DOWNCALL art_handle_fill_data_from_code, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 386 | |
Elliott Hughes | 5e28422 | 2012-04-04 13:38:03 -0700 | [diff] [blame] | 387 | DEFINE_FUNCTION art_is_assignable_from_code |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 388 | pushl %eax // alignment padding |
| 389 | pushl %ecx // pass arg2 |
| 390 | pushl %eax // pass arg1 |
Elliott Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 391 | call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b, Thread*, SP) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 392 | addl LITERAL(12), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 393 | ret |
| 394 | |
Elliott Hughes | 5e28422 | 2012-04-04 13:38:03 -0700 | [diff] [blame] | 395 | DEFINE_FUNCTION art_memcpy |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 396 | pushl %edx // pass arg3 |
| 397 | pushl %ecx // pass arg2 |
| 398 | pushl %eax // pass arg1 |
Elliott Hughes | adc078a | 2012-04-04 11:39:05 -0700 | [diff] [blame] | 399 | call SYMBOL(memcpy) // (void*, const void*, size_t) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 400 | addl LITERAL(12), %esp // pop arguments |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 401 | ret |
| 402 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 403 | TWO_ARG_DOWNCALL art_check_cast_from_code, artCheckCastFromCode, RETURN_IF_EAX_ZERO |
| 404 | TWO_ARG_DOWNCALL art_can_put_array_element_from_code, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO |
| 405 | |
| 406 | NO_ARG_DOWNCALL art_test_suspend, artTestSuspendFromCode, ret |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 407 | |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 408 | DEFINE_FUNCTION art_fmod_from_code |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 409 | subl LITERAL(12), %esp // alignment padding |
| 410 | pushl %ebx // pass arg4 b.hi |
| 411 | pushl %edx // pass arg3 b.lo |
| 412 | pushl %ecx // pass arg2 a.hi |
| 413 | pushl %eax // pass arg1 a.lo |
| 414 | call SYMBOL(fmod) // (jdouble a, jdouble b) |
| 415 | fstpl (%esp) // pop return value off fp stack |
| 416 | movsd (%esp), %xmm0 // place into %xmm0 |
| 417 | addl LITERAL(28), %esp // pop arguments |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 418 | ret |
| 419 | |
| 420 | DEFINE_FUNCTION art_fmodf_from_code |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 421 | pushl %eax // alignment padding |
| 422 | pushl %ecx // pass arg2 b |
| 423 | pushl %eax // pass arg1 a |
| 424 | call SYMBOL(fmodf) // (jfloat a, jfloat b) |
| 425 | fstp (%esp) // pop return value off fp stack |
| 426 | movss (%esp), %xmm0 // place into %xmm0 |
| 427 | addl LITERAL(12), %esp // pop arguments |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 428 | ret |
| 429 | |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 430 | DEFINE_FUNCTION art_l2d_from_code |
| 431 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 432 | pushl %ecx // pass arg2 a.hi |
| 433 | pushl %eax // pass arg1 a.lo |
| 434 | call SYMBOL(art_l2d) // (jlong a) |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 435 | fstpl (%esp) // pop return value off fp stack |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 436 | movsd (%esp), %xmm0 // place into %xmm0 |
| 437 | addl LITERAL(12), %esp // pop arguments |
| 438 | ret |
| 439 | |
| 440 | DEFINE_FUNCTION art_l2f_from_code |
| 441 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 442 | pushl %ecx // pass arg2 a.hi |
| 443 | pushl %eax // pass arg1 a.lo |
| 444 | call SYMBOL(art_l2f) // (jlong a) |
jeffhao | 292188d | 2012-05-17 15:45:04 -0700 | [diff] [blame] | 445 | fstp (%esp) // pop return value off fp stack |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 446 | movss (%esp), %xmm0 // place into %xmm0 |
| 447 | addl LITERAL(12), %esp // pop arguments |
| 448 | ret |
| 449 | |
| 450 | DEFINE_FUNCTION art_d2l_from_code |
| 451 | pushl %eax // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 452 | pushl %ecx // pass arg2 a.hi |
| 453 | pushl %eax // pass arg1 a.lo |
| 454 | call SYMBOL(art_d2l) // (jdouble a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 455 | addl LITERAL(12), %esp // pop arguments |
| 456 | ret |
| 457 | |
| 458 | DEFINE_FUNCTION art_f2l_from_code |
| 459 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 460 | pushl %eax // pass arg1 a |
| 461 | call SYMBOL(art_f2l) // (jfloat a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 462 | addl LITERAL(12), %esp // pop arguments |
| 463 | ret |
| 464 | |
Elliott Hughes | 5e28422 | 2012-04-04 13:38:03 -0700 | [diff] [blame] | 465 | DEFINE_FUNCTION art_idivmod_from_code |
jeffhao | 174651d | 2012-04-19 15:27:22 -0700 | [diff] [blame] | 466 | cmpl LITERAL(0x80000000), %eax |
| 467 | je check_arg2 // special case |
| 468 | args_ok: |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 469 | cdq // edx:eax = sign extend eax |
| 470 | idiv %ecx // (edx,eax) = (edx:eax % ecx, edx:eax / ecx) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 471 | ret |
jeffhao | 174651d | 2012-04-19 15:27:22 -0700 | [diff] [blame] | 472 | check_arg2: |
| 473 | cmpl LITERAL(-1), %ecx |
| 474 | jne args_ok |
| 475 | xorl %edx, %edx |
| 476 | ret // eax already holds min int |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 477 | |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 478 | DEFINE_FUNCTION art_ldiv_from_code |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 479 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 480 | pushl %ebx // pass arg4 b.hi |
| 481 | pushl %edx // pass arg3 b.lo |
| 482 | pushl %ecx // pass arg2 a.hi |
| 483 | pushl %eax // pass arg1 a.lo |
| 484 | call SYMBOL(artLdivFromCode) // (jlong a, jlong b) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 485 | addl LITERAL(28), %esp // pop arguments |
| 486 | ret |
| 487 | |
| 488 | DEFINE_FUNCTION art_ldivmod_from_code |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 489 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 490 | pushl %ebx // pass arg4 b.hi |
| 491 | pushl %edx // pass arg3 b.lo |
| 492 | pushl %ecx // pass arg2 a.hi |
| 493 | pushl %eax // pass arg1 a.lo |
| 494 | call SYMBOL(artLdivmodFromCode) // (jlong a, jlong b) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 495 | addl LITERAL(28), %esp // pop arguments |
| 496 | ret |
| 497 | |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 498 | DEFINE_FUNCTION art_lmul_from_code |
| 499 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 1395b1e | 2012-06-13 18:05:13 -0700 | [diff] [blame] | 500 | pushl %ebx // pass arg4 b.hi |
| 501 | pushl %edx // pass arg3 b.lo |
| 502 | pushl %ecx // pass arg2 a.hi |
| 503 | pushl %eax // pass arg1 a.lo |
| 504 | call SYMBOL(artLmulFromCode) // (jlong a, jlong b) |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 505 | addl LITERAL(28), %esp // pop arguments |
| 506 | ret |
| 507 | |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 508 | DEFINE_FUNCTION art_lshl_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 509 | // ecx:eax << edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 510 | xchg %edx, %ecx |
| 511 | shld %cl,%eax,%edx |
| 512 | shl %cl,%eax |
| 513 | test LITERAL(32), %cl |
| 514 | jz 1f |
| 515 | mov %eax, %edx |
| 516 | xor %eax, %eax |
| 517 | 1: |
| 518 | ret |
| 519 | |
| 520 | DEFINE_FUNCTION art_lshr_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 521 | // ecx:eax >> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 522 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 523 | shrd %cl,%edx,%eax |
| 524 | sar %cl,%edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 525 | test LITERAL(32),%cl |
| 526 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 527 | mov %edx, %eax |
| 528 | sar LITERAL(31), %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 529 | 1: |
| 530 | ret |
| 531 | |
| 532 | DEFINE_FUNCTION art_lushr_from_code |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 533 | // ecx:eax >>> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 534 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 535 | shrd %cl,%edx,%eax |
| 536 | shr %cl,%edx |
| 537 | test LITERAL(32),%cl |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 538 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 539 | mov %edx, %eax |
| 540 | xor %edx, %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 541 | 1: |
| 542 | ret |
| 543 | |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 544 | DEFINE_FUNCTION art_set32_instance_from_code |
| 545 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 546 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 547 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 548 | pushl %ebx // pass SP |
| 549 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 550 | mov 32(%ebx), %ebx // get referrer |
| 551 | pushl %ebx // pass referrer |
| 552 | pushl %edx // pass new_val |
| 553 | pushl %ecx // pass object |
| 554 | pushl %eax // pass field_idx |
| 555 | call SYMBOL(artSet32InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 556 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 557 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 558 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 559 | |
| 560 | DEFINE_FUNCTION art_set64_instance_from_code |
| 561 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 562 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 563 | pushl %esp // pass SP-8 |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 564 | addl LITERAL(8), (%esp) // fix SP on stack by adding 8 |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 565 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 566 | pushl %ebx // pass high half of new_val |
| 567 | pushl %edx // pass low half of new_val |
| 568 | pushl %ecx // pass object |
| 569 | pushl %eax // pass field_idx |
| 570 | call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 571 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 572 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 573 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 574 | |
| 575 | DEFINE_FUNCTION art_set_obj_instance_from_code |
| 576 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 577 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 578 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 579 | pushl %ebx // pass SP |
| 580 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 581 | mov 32(%ebx), %ebx // get referrer |
| 582 | pushl %ebx // pass referrer |
| 583 | pushl %edx // pass new_val |
| 584 | pushl %ecx // pass object |
| 585 | pushl %eax // pass field_idx |
| 586 | call SYMBOL(artSetObjInstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 587 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 588 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 589 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 590 | |
| 591 | DEFINE_FUNCTION art_get32_instance_from_code |
| 592 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 593 | mov %esp, %ebx // remember SP |
| 594 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 595 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 596 | pushl %ebx // pass SP |
| 597 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 598 | pushl %edx // pass referrer |
| 599 | pushl %ecx // pass object |
| 600 | pushl %eax // pass field_idx |
| 601 | call SYMBOL(artGet32InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 602 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 603 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 604 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 605 | |
| 606 | DEFINE_FUNCTION art_get64_instance_from_code |
| 607 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 608 | mov %esp, %ebx // remember SP |
| 609 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 610 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 611 | pushl %ebx // pass SP |
| 612 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 613 | pushl %edx // pass referrer |
| 614 | pushl %ecx // pass object |
| 615 | pushl %eax // pass field_idx |
| 616 | call SYMBOL(artGet64InstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 617 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 618 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 619 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 620 | |
| 621 | DEFINE_FUNCTION art_get_obj_instance_from_code |
| 622 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 623 | mov %esp, %ebx // remember SP |
| 624 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 625 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 626 | pushl %ebx // pass SP |
| 627 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 628 | pushl %edx // pass referrer |
| 629 | pushl %ecx // pass object |
| 630 | pushl %eax // pass field_idx |
| 631 | call SYMBOL(artGetObjInstanceFromCode) // (field_idx, Object*, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 632 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 633 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 634 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 635 | |
| 636 | DEFINE_FUNCTION art_set32_static_from_code |
| 637 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 638 | mov %esp, %ebx // remember SP |
| 639 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 640 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 641 | pushl %ebx // pass SP |
| 642 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 643 | pushl %edx // pass referrer |
| 644 | pushl %ecx // pass new_val |
| 645 | pushl %eax // pass field_idx |
| 646 | call SYMBOL(artSet32StaticFromCode) // (field_idx, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 647 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 648 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 649 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 650 | |
| 651 | DEFINE_FUNCTION art_set64_static_from_code |
| 652 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 653 | mov %esp, %ebx // remember SP |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 654 | subl LITERAL(8), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 655 | pushl %ebx // pass SP |
| 656 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 657 | mov 32(%ebx), %ebx // get referrer |
| 658 | pushl %edx // pass high half of new_val |
| 659 | pushl %ecx // pass low half of new_val |
| 660 | pushl %ebx // pass referrer |
| 661 | pushl %eax // pass field_idx |
| 662 | call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 663 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 664 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 665 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 666 | |
| 667 | DEFINE_FUNCTION art_set_obj_static_from_code |
| 668 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 669 | mov %esp, %ebx // remember SP |
| 670 | mov 32(%esp), %edx // get referrer |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 671 | subl LITERAL(12), %esp // alignment padding |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 672 | pushl %ebx // pass SP |
| 673 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 674 | pushl %edx // pass referrer |
| 675 | pushl %ecx // pass new_val |
| 676 | pushl %eax // pass field_idx |
| 677 | call SYMBOL(artSetObjStaticFromCode) // (field_idx, new_val, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 678 | addl LITERAL(32), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 679 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
| 680 | RETURN_IF_EAX_ZERO // return or deliver exception |
| 681 | |
| 682 | DEFINE_FUNCTION art_get32_static_from_code |
| 683 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 684 | mov %esp, %edx // remember SP |
| 685 | mov 32(%esp), %ecx // get referrer |
| 686 | pushl %edx // pass SP |
| 687 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 688 | pushl %ecx // pass referrer |
| 689 | pushl %eax // pass field_idx |
| 690 | call SYMBOL(artGet32StaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 691 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 692 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 693 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 694 | |
| 695 | DEFINE_FUNCTION art_get64_static_from_code |
| 696 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 697 | mov %esp, %edx // remember SP |
| 698 | mov 32(%esp), %ecx // get referrer |
| 699 | pushl %edx // pass SP |
| 700 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 701 | pushl %ecx // pass referrer |
| 702 | pushl %eax // pass field_idx |
| 703 | call SYMBOL(artGet64StaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 704 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 705 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 706 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 707 | |
| 708 | DEFINE_FUNCTION art_get_obj_static_from_code |
| 709 | SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC |
| 710 | mov %esp, %edx // remember SP |
| 711 | mov 32(%esp), %ecx // get referrer |
| 712 | pushl %edx // pass SP |
| 713 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 714 | pushl %ecx // pass referrer |
| 715 | pushl %eax // pass field_idx |
| 716 | call SYMBOL(artGetObjStaticFromCode) // (field_idx, referrer, Thread*, SP) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 717 | addl LITERAL(16), %esp // pop arguments |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 718 | RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 719 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
| 720 | |
| 721 | DEFINE_FUNCTION art_proxy_invoke_handler |
| 722 | SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // save frame |
| 723 | lea 8(%esp), %ebx // pointer to r2/r3/LR/caller's Method**/out-args as second arg |
| 724 | pushl %ebx // pass args |
| 725 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 726 | pushl %ecx // pass receiver |
| 727 | pushl %eax // pass proxy method |
| 728 | call SYMBOL(artProxyInvokeHandler) // (proxy method, receiver, Thread*, args...) |
| 729 | mov 24(%esp), %eax // get ret0 which was written into r2 on the stack |
| 730 | mov 28(%esp), %edx // get ret1 which was written into r3 on the stack |
jeffhao | 5d05c75 | 2012-05-23 10:57:48 -0700 | [diff] [blame] | 731 | movsd 24(%esp), %xmm0 // get ret0/ret1 from stack for floating point |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 732 | addl LITERAL(44), %esp // pop arguments |
| 733 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 734 | |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame^] | 735 | /* |
| 736 | * String's indexOf. |
| 737 | * |
| 738 | * On entry: |
| 739 | * eax: string object (known non-null) |
| 740 | * ecx: char to match (known <= 0xFFFF) |
| 741 | * edx: Starting offset in string data |
| 742 | */ |
| 743 | DEFINE_FUNCTION art_indexof |
| 744 | pushl %edi // push callee save reg |
| 745 | mov STRING_COUNT_OFFSET(%eax), %ebx |
| 746 | mov STRING_VALUE_OFFSET(%eax), %edi |
| 747 | mov STRING_OFFSET_OFFSET(%eax), %eax |
| 748 | testl %edx, %edx // check if start < 0 |
| 749 | jl clamp_min |
| 750 | clamp_done: |
| 751 | cmpl %ebx, %edx // check if start >= count |
| 752 | jge not_found |
| 753 | lea STRING_DATA_OFFSET(%edi, %eax, 2), %edi // build a pointer to the start of string data |
| 754 | mov %edi, %eax // save a copy in eax to later compute result |
| 755 | lea (%edi, %edx, 2), %edi // build pointer to start of data to compare |
| 756 | subl %edx, %ebx // compute iteration count |
| 757 | /* |
| 758 | * At this point we have: |
| 759 | * eax: original start of string data |
| 760 | * ecx: char to compare |
| 761 | * ebx: length to compare |
| 762 | * edi: start of data to test |
| 763 | */ |
| 764 | mov %eax, %edx |
| 765 | mov %ecx, %eax // put char to match in %eax |
| 766 | mov %ebx, %ecx // put length to compare in %ecx |
| 767 | repne scasw // find %ax, starting at [%edi], up to length %ecx |
| 768 | jne not_found |
| 769 | subl %edx, %edi |
| 770 | sar LITERAL(1), %edi |
| 771 | decl %edi // index = ((curr_ptr - orig_ptr) / 2) - 1 |
| 772 | mov %edi, %eax |
| 773 | popl %edi // pop callee save reg |
| 774 | ret |
| 775 | .balign 16 |
| 776 | not_found: |
| 777 | mov LITERAL(-1), %eax // return -1 (not found) |
| 778 | popl %edi // pop callee save reg |
| 779 | ret |
| 780 | clamp_min: |
| 781 | xor %edx, %edx // clamp start to 0 |
| 782 | jmp clamp_done |
| 783 | |
| 784 | /* |
| 785 | * String's compareTo. |
| 786 | * |
| 787 | * On entry: |
| 788 | * eax: this string object (known non-null) |
| 789 | * ecx: comp string object (known non-null) |
| 790 | */ |
| 791 | DEFINE_FUNCTION art_string_compareto |
| 792 | pushl %esi // push callee save reg |
| 793 | pushl %edi // push callee save reg |
| 794 | mov STRING_COUNT_OFFSET(%eax), %edx |
| 795 | mov STRING_COUNT_OFFSET(%ecx), %ebx |
| 796 | mov STRING_VALUE_OFFSET(%eax), %esi |
| 797 | mov STRING_VALUE_OFFSET(%ecx), %edi |
| 798 | mov STRING_OFFSET_OFFSET(%eax), %eax |
| 799 | mov STRING_OFFSET_OFFSET(%ecx), %ecx |
| 800 | /* Build pointers to the start of string data */ |
| 801 | lea STRING_DATA_OFFSET(%esi, %eax, 2), %esi |
| 802 | lea STRING_DATA_OFFSET(%edi, %ecx, 2), %edi |
| 803 | /* Calculate min length and count diff */ |
| 804 | mov %edx, %ecx |
| 805 | mov %edx, %eax |
| 806 | subl %ebx, %eax |
| 807 | cmovg %ebx, %ecx |
| 808 | /* |
| 809 | * At this point we have: |
| 810 | * eax: value to return if first part of strings are equal |
| 811 | * ecx: minimum among the lengths of the two strings |
| 812 | * esi: pointer to this string data |
| 813 | * edi: pointer to comp string data |
| 814 | */ |
| 815 | repe cmpsw // find nonmatching chars in [%esi] and [%edi], up to length %ecx |
| 816 | jne not_equal |
| 817 | popl %edi // pop callee save reg |
| 818 | popl %esi // pop callee save reg |
| 819 | ret |
| 820 | .balign 16 |
| 821 | not_equal: |
| 822 | movzxw -2(%esi), %eax // get last compared char from this string |
| 823 | movzxw -2(%edi), %ecx // get last compared char from comp string |
| 824 | subl %ecx, %eax // return the difference |
| 825 | popl %edi // pop callee save reg |
| 826 | popl %esi // pop callee save reg |
| 827 | ret |
| 828 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 829 | MACRO1(UNIMPLEMENTED,name) |
| 830 | .globl VAR(name, 0) |
| 831 | ALIGN_FUNCTION_ENTRY |
| 832 | VAR(name, 0): |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 833 | int3 |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 834 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 835 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 836 | // TODO: implement these! |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 837 | UNIMPLEMENTED art_update_debugger |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 838 | UNIMPLEMENTED art_memcmp16 |