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 | 7655f29 | 2013-07-29 11:07:13 -0700 | [diff] [blame] | 17 | #include "asm_support_x86.S" |
Elliott Hughes | 5e28422 | 2012-04-04 13:38:03 -0700 | [diff] [blame] | 18 | |
Hiroshi Yamauchi | 4adeab1 | 2015-10-02 15:27:55 -0700 | [diff] [blame] | 19 | #include "arch/quick_alloc_entrypoints.S" |
| 20 | |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 21 | // For x86, the CFA is esp+4, the address above the pushed return address on the stack. |
| 22 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 25 | * Runtime::CreateCalleeSaveMethod(kSaveAllCalleeSaves) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 26 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 27 | MACRO2(SETUP_SAVE_ALL_CALLEE_SAVES_FRAME, got_reg, temp_reg) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 28 | PUSH edi // Save callee saves (ebx is saved/restored by the upcall) |
| 29 | PUSH esi |
| 30 | PUSH ebp |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 31 | subl MACRO_LITERAL(12), %esp // Grow stack by 3 words. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 32 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 33 | SETUP_GOT_NOSAVE RAW_VAR(got_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 34 | // Load Runtime::instance_ from GOT. |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 35 | movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg)), REG_VAR(temp_reg) |
| 36 | movl (REG_VAR(temp_reg)), REG_VAR(temp_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 37 | // Push save all callee-save method. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 38 | pushl RUNTIME_SAVE_ALL_CALLEE_SAVES_METHOD_OFFSET(REG_VAR(temp_reg)) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 39 | CFI_ADJUST_CFA_OFFSET(4) |
| 40 | // Store esp as the top quick frame. |
| 41 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 42 | // Ugly compile-time check, but we only have the preprocessor. |
| 43 | // Last +4: implicit return address pushed on stack when caller made call. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 44 | #if (FRAME_SIZE_SAVE_ALL_CALLEE_SAVES != 3*4 + 16 + 4) |
| 45 | #error "FRAME_SIZE_SAVE_ALL_CALLEE_SAVES(X86) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 46 | #endif |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 47 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 48 | |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 49 | /* |
| 50 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 51 | * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 52 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 53 | MACRO2(SETUP_SAVE_REFS_ONLY_FRAME, got_reg, temp_reg) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 54 | PUSH edi // Save callee saves (ebx is saved/restored by the upcall) |
| 55 | PUSH esi |
| 56 | PUSH ebp |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 57 | subl MACRO_LITERAL(12), %esp // Grow stack by 3 words. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 58 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 59 | SETUP_GOT_NOSAVE RAW_VAR(got_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 60 | // Load Runtime::instance_ from GOT. |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 61 | movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg)), REG_VAR(temp_reg) |
| 62 | movl (REG_VAR(temp_reg)), REG_VAR(temp_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 63 | // Push save all callee-save method. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 64 | pushl RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET(REG_VAR(temp_reg)) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 65 | CFI_ADJUST_CFA_OFFSET(4) |
| 66 | // Store esp as the top quick frame. |
| 67 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 68 | |
| 69 | // Ugly compile-time check, but we only have the preprocessor. |
| 70 | // Last +4: implicit return address pushed on stack when caller made call. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 71 | #if (FRAME_SIZE_SAVE_REFS_ONLY != 3*4 + 16 + 4) |
| 72 | #error "FRAME_SIZE_SAVE_REFS_ONLY(X86) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 73 | #endif |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 74 | END_MACRO |
| 75 | |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 76 | /* |
| 77 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 78 | * Runtime::CreateCalleeSaveMethod(kSaveRefsOnly) |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 79 | * and preserves the value of got_reg at entry. |
| 80 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 81 | MACRO2(SETUP_SAVE_REFS_ONLY_FRAME_PRESERVE_GOT_REG, got_reg, temp_reg) |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 82 | PUSH edi // Save callee saves (ebx is saved/restored by the upcall) |
| 83 | PUSH esi |
| 84 | PUSH ebp |
Vladimir Marko | 2ebef63 | 2016-06-21 11:24:47 +0100 | [diff] [blame] | 85 | PUSH RAW_VAR(got_reg) // Save got_reg |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 86 | subl MACRO_LITERAL(8), %esp // Grow stack by 2 words. |
| 87 | CFI_ADJUST_CFA_OFFSET(8) |
| 88 | |
| 89 | SETUP_GOT_NOSAVE RAW_VAR(got_reg) |
| 90 | // Load Runtime::instance_ from GOT. |
| 91 | movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg)), REG_VAR(temp_reg) |
| 92 | movl (REG_VAR(temp_reg)), REG_VAR(temp_reg) |
| 93 | // Push save all callee-save method. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 94 | pushl RUNTIME_SAVE_REFS_ONLY_METHOD_OFFSET(REG_VAR(temp_reg)) |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 95 | CFI_ADJUST_CFA_OFFSET(4) |
| 96 | // Store esp as the top quick frame. |
| 97 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
| 98 | // Restore got_reg. |
| 99 | movl 12(%esp), REG_VAR(got_reg) |
Vladimir Marko | 2ebef63 | 2016-06-21 11:24:47 +0100 | [diff] [blame] | 100 | CFI_RESTORE(RAW_VAR(got_reg)) |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 101 | |
| 102 | // Ugly compile-time check, but we only have the preprocessor. |
| 103 | // Last +4: implicit return address pushed on stack when caller made call. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 104 | #if (FRAME_SIZE_SAVE_REFS_ONLY != 3*4 + 16 + 4) |
| 105 | #error "FRAME_SIZE_SAVE_REFS_ONLY(X86) size not as expected." |
Nicolas Geoffray | 0f838aa | 2016-06-08 18:01:22 +0100 | [diff] [blame] | 106 | #endif |
| 107 | END_MACRO |
| 108 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 109 | MACRO0(RESTORE_SAVE_REFS_ONLY_FRAME) |
Ian Rogers | 47d00c0 | 2014-04-16 17:33:27 -0700 | [diff] [blame] | 110 | addl MACRO_LITERAL(16), %esp // Unwind stack up to saved values |
Andreas Gampe | bf6b92a | 2014-03-05 16:11:04 -0800 | [diff] [blame] | 111 | CFI_ADJUST_CFA_OFFSET(-16) |
Mathieu Chartier | 2a6c7b7 | 2013-10-16 11:16:33 -0700 | [diff] [blame] | 112 | POP ebp // Restore callee saves (ebx is saved/restored by the upcall) |
| 113 | POP esi |
| 114 | POP edi |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 115 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 119 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs) |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 120 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 121 | MACRO2(SETUP_SAVE_REFS_AND_ARGS_FRAME, got_reg, temp_reg) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 122 | PUSH edi // Save callee saves |
| 123 | PUSH esi |
| 124 | PUSH ebp |
| 125 | PUSH ebx // Save args |
| 126 | PUSH edx |
| 127 | PUSH ecx |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 128 | // Create space for FPR args. |
| 129 | subl MACRO_LITERAL(4 * 8), %esp |
| 130 | CFI_ADJUST_CFA_OFFSET(4 * 8) |
| 131 | // Save FPRs. |
| 132 | movsd %xmm0, 0(%esp) |
| 133 | movsd %xmm1, 8(%esp) |
| 134 | movsd %xmm2, 16(%esp) |
| 135 | movsd %xmm3, 24(%esp) |
| 136 | |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 137 | SETUP_GOT_NOSAVE RAW_VAR(got_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 138 | // Load Runtime::instance_ from GOT. |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 139 | movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg)), REG_VAR(temp_reg) |
| 140 | movl (REG_VAR(temp_reg)), REG_VAR(temp_reg) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 141 | // Push save all callee-save method. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 142 | pushl RUNTIME_SAVE_REFS_AND_ARGS_METHOD_OFFSET(REG_VAR(temp_reg)) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 143 | CFI_ADJUST_CFA_OFFSET(4) |
| 144 | // Store esp as the stop quick frame. |
| 145 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 146 | |
| 147 | // Ugly compile-time check, but we only have the preprocessor. |
| 148 | // Last +4: implicit return address pushed on stack when caller made call. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 149 | #if (FRAME_SIZE_SAVE_REFS_AND_ARGS != 7*4 + 4*8 + 4) |
| 150 | #error "FRAME_SIZE_SAVE_REFS_AND_ARGS(X86) size not as expected." |
Andreas Gampe | 5c1e435 | 2014-04-21 19:28:24 -0700 | [diff] [blame] | 151 | #endif |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 152 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 153 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 154 | /* |
| 155 | * Macro that sets up the callee save frame to conform with |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 156 | * Runtime::CreateCalleeSaveMethod(kSaveRefsAndArgs) where the method is passed in EAX. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 157 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 158 | MACRO0(SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_EAX) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 159 | // Save callee and GPR args, mixed together to agree with core spills bitmap. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 160 | PUSH edi // Save callee saves |
| 161 | PUSH esi |
| 162 | PUSH ebp |
| 163 | PUSH ebx // Save args |
| 164 | PUSH edx |
| 165 | PUSH ecx |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 166 | |
| 167 | // Create space for FPR args. |
| 168 | subl MACRO_LITERAL(32), %esp |
| 169 | CFI_ADJUST_CFA_OFFSET(32) |
| 170 | |
| 171 | // Save FPRs. |
| 172 | movsd %xmm0, 0(%esp) |
| 173 | movsd %xmm1, 8(%esp) |
| 174 | movsd %xmm2, 16(%esp) |
| 175 | movsd %xmm3, 24(%esp) |
| 176 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 177 | PUSH eax // Store the ArtMethod reference at the bottom of the stack. |
| 178 | // Store esp as the stop quick frame. |
| 179 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
| 180 | END_MACRO |
| 181 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 182 | MACRO0(RESTORE_SAVE_REFS_AND_ARGS_FRAME) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 183 | // Restore FPRs. EAX is still on the stack. |
| 184 | movsd 4(%esp), %xmm0 |
| 185 | movsd 12(%esp), %xmm1 |
| 186 | movsd 20(%esp), %xmm2 |
| 187 | movsd 28(%esp), %xmm3 |
| 188 | |
| 189 | addl MACRO_LITERAL(36), %esp // Remove FPRs and EAX. |
| 190 | CFI_ADJUST_CFA_OFFSET(-36) |
| 191 | |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 192 | POP ecx // Restore args except eax |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 193 | POP edx |
| 194 | POP ebx |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 195 | POP ebp // Restore callee saves |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 196 | POP esi |
| 197 | POP edi |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 198 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 199 | |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 200 | // Restore register and jump to routine |
| 201 | // Inputs: EDI contains pointer to code. |
| 202 | // Notes: Need to pop EAX too (restores Method*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 203 | MACRO0(RESTORE_SAVE_REFS_AND_ARGS_FRAME_AND_JUMP) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 204 | POP eax // Restore Method* |
| 205 | |
| 206 | // Restore FPRs. |
| 207 | movsd 0(%esp), %xmm0 |
| 208 | movsd 8(%esp), %xmm1 |
| 209 | movsd 16(%esp), %xmm2 |
| 210 | movsd 24(%esp), %xmm3 |
| 211 | |
| 212 | addl MACRO_LITERAL(32), %esp // Remove FPRs. |
| 213 | CFI_ADJUST_CFA_OFFSET(-32) |
| 214 | |
| 215 | POP ecx // Restore args except eax |
| 216 | POP edx |
| 217 | POP ebx |
| 218 | POP ebp // Restore callee saves |
| 219 | POP esi |
| 220 | xchgl 0(%esp),%edi // restore EDI and place code pointer as only value on stack |
| 221 | ret |
| 222 | END_MACRO |
| 223 | |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 224 | /* |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 225 | * Macro that sets up the callee save frame to conform with |
| 226 | * Runtime::CreateCalleeSaveMethod(kSaveEverything) |
| 227 | */ |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 228 | MACRO2(SETUP_SAVE_EVERYTHING_FRAME, got_reg, temp_reg) |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 229 | // Save core registers. |
| 230 | PUSH edi |
| 231 | PUSH esi |
| 232 | PUSH ebp |
| 233 | PUSH ebx |
| 234 | PUSH edx |
| 235 | PUSH ecx |
| 236 | PUSH eax |
| 237 | // Create space for FPR registers and stack alignment padding. |
| 238 | subl MACRO_LITERAL(12 + 8 * 8), %esp |
| 239 | CFI_ADJUST_CFA_OFFSET(12 + 8 * 8) |
| 240 | // Save FPRs. |
| 241 | movsd %xmm0, 12(%esp) |
| 242 | movsd %xmm1, 20(%esp) |
| 243 | movsd %xmm2, 28(%esp) |
| 244 | movsd %xmm3, 36(%esp) |
| 245 | movsd %xmm4, 44(%esp) |
| 246 | movsd %xmm5, 52(%esp) |
| 247 | movsd %xmm6, 60(%esp) |
| 248 | movsd %xmm7, 68(%esp) |
| 249 | |
| 250 | SETUP_GOT_NOSAVE RAW_VAR(got_reg) |
| 251 | // Load Runtime::instance_ from GOT. |
| 252 | movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg)), REG_VAR(temp_reg) |
| 253 | movl (REG_VAR(temp_reg)), REG_VAR(temp_reg) |
| 254 | // Push save everything callee-save method. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 255 | pushl RUNTIME_SAVE_EVERYTHING_METHOD_OFFSET(REG_VAR(temp_reg)) |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 256 | CFI_ADJUST_CFA_OFFSET(4) |
| 257 | // Store esp as the stop quick frame. |
| 258 | movl %esp, %fs:THREAD_TOP_QUICK_FRAME_OFFSET |
| 259 | |
| 260 | // Ugly compile-time check, but we only have the preprocessor. |
| 261 | // Last +4: implicit return address pushed on stack when caller made call. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 262 | #if (FRAME_SIZE_SAVE_EVERYTHING != 7*4 + 8*8 + 12 + 4 + 4) |
| 263 | #error "FRAME_SIZE_SAVE_EVERYTHING(X86) size not as expected." |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 264 | #endif |
| 265 | END_MACRO |
| 266 | |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 267 | MACRO0(RESTORE_SAVE_EVERYTHING_FRAME) |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 268 | // Restore FPRs. Method and padding is still on the stack. |
| 269 | movsd 16(%esp), %xmm0 |
| 270 | movsd 24(%esp), %xmm1 |
| 271 | movsd 32(%esp), %xmm2 |
| 272 | movsd 40(%esp), %xmm3 |
| 273 | movsd 48(%esp), %xmm4 |
| 274 | movsd 56(%esp), %xmm5 |
| 275 | movsd 64(%esp), %xmm6 |
| 276 | movsd 72(%esp), %xmm7 |
| 277 | |
| 278 | // Remove save everything callee save method, stack alignment padding and FPRs. |
| 279 | addl MACRO_LITERAL(16 + 8 * 8), %esp |
| 280 | CFI_ADJUST_CFA_OFFSET(-(16 + 8 * 8)) |
| 281 | |
| 282 | // Restore core registers. |
| 283 | POP eax |
| 284 | POP ecx |
| 285 | POP edx |
| 286 | POP ebx |
| 287 | POP ebp |
| 288 | POP esi |
| 289 | POP edi |
| 290 | END_MACRO |
| 291 | |
| 292 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 293 | * Macro that set calls through to artDeliverPendingExceptionFromCode, where the pending |
| 294 | * exception is Thread::Current()->exception_. |
| 295 | */ |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 296 | MACRO0(DELIVER_PENDING_EXCEPTION) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 297 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save callee saves for throw |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 298 | // Outgoing argument set up |
Roland Levillain | a7821bf | 2016-06-30 16:21:31 +0100 | [diff] [blame] | 299 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 300 | CFI_ADJUST_CFA_OFFSET(12) |
| 301 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 302 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 303 | call SYMBOL(artDeliverPendingExceptionFromCode) // artDeliverPendingExceptionFromCode(Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 304 | UNREACHABLE |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 305 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 306 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 307 | MACRO2(NO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 308 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 309 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 310 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 311 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 312 | CFI_ADJUST_CFA_OFFSET(12) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 313 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 314 | CFI_ADJUST_CFA_OFFSET(4) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 315 | call CALLVAR(cxx_name) // cxx_name(Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 316 | UNREACHABLE |
| 317 | END_FUNCTION VAR(c_name) |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 318 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 319 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 320 | MACRO2(ONE_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 321 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 322 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 323 | mov %esp, %ecx |
| 324 | // Outgoing argument set up |
Roland Levillain | a7821bf | 2016-06-30 16:21:31 +0100 | [diff] [blame] | 325 | subl MACRO_LITERAL(8), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 326 | CFI_ADJUST_CFA_OFFSET(8) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 327 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 328 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 329 | PUSH eax // pass arg1 |
| 330 | call CALLVAR(cxx_name) // cxx_name(arg1, Thread*) |
| 331 | UNREACHABLE |
| 332 | END_FUNCTION VAR(c_name) |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 333 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 334 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 335 | MACRO2(TWO_ARG_RUNTIME_EXCEPTION, c_name, cxx_name) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 336 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 337 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 338 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 339 | PUSH eax // alignment padding |
| 340 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 341 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 342 | PUSH ecx // pass arg2 |
| 343 | PUSH eax // pass arg1 |
| 344 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, Thread*) |
| 345 | UNREACHABLE |
| 346 | END_FUNCTION VAR(c_name) |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 347 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 348 | |
| 349 | /* |
| 350 | * Called by managed code to create and deliver a NullPointerException. |
| 351 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 352 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 353 | |
| 354 | /* |
Nicolas Geoffray | e8e1127 | 2016-06-28 18:08:46 +0100 | [diff] [blame] | 355 | * Call installed by a signal handler to create and deliver a NullPointerException. |
| 356 | */ |
| 357 | ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_signal, artThrowNullPointerExceptionFromSignal |
| 358 | |
| 359 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 360 | * Called by managed code to create and deliver an ArithmeticException. |
| 361 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 362 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 363 | |
| 364 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 365 | * Called by managed code to create and deliver a StackOverflowError. |
| 366 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 367 | NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 368 | |
| 369 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 370 | * Called by managed code, saves callee saves and then calls artThrowException |
| 371 | * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. |
| 372 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 373 | ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 374 | |
| 375 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 376 | * Called by managed code to create and deliver a NoSuchMethodError. |
| 377 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 378 | ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 379 | |
| 380 | /* |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 381 | * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds |
| 382 | * index, arg2 holds limit. |
| 383 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 384 | TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 385 | |
| 386 | /* |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 387 | * Called by managed code to create and deliver a StringIndexOutOfBoundsException |
| 388 | * as if thrown from a call to String.charAt(). Arg1 holds index, arg2 holds limit. |
| 389 | */ |
| 390 | TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_string_bounds, artThrowStringBoundsFromCode |
| 391 | |
| 392 | /* |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 393 | * All generated callsites for interface invokes and invocation slow paths will load arguments |
| 394 | * as usual - except instead of loading arg0/r0 with the target Method*, arg0/r0 will contain |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 395 | * the method_idx. This wrapper will save arg1-arg3 and call the appropriate C helper. |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 396 | * NOTE: "this" is first visible argument of the target, and so can be found in arg1/r1. |
| 397 | * |
| 398 | * The helper will attempt to locate the target and return a 64-bit result in r0/r1 consisting |
| 399 | * of the target Method* in r0 and method->code_ in r1. |
| 400 | * |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 401 | * If unsuccessful, the helper will return null/null will bea pending exception in the |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 402 | * thread and we branch to another stub to deliver it. |
| 403 | * |
| 404 | * On success this wrapper will restore arguments and *jump* to the target, leaving the lr |
| 405 | * pointing back to the original caller. |
| 406 | */ |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 407 | MACRO1(INVOKE_TRAMPOLINE_BODY, cxx_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 408 | SETUP_SAVE_REFS_AND_ARGS_FRAME ebx, ebx |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 409 | movl %esp, %edx // remember SP |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 410 | |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 411 | // Outgoing argument set up |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 412 | PUSH edx // pass SP |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 413 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 414 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 415 | PUSH ecx // pass arg2 |
| 416 | PUSH eax // pass arg1 |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 417 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, Thread*, SP) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 418 | movl %edx, %edi // save code pointer in EDI |
Nicolas Geoffray | 7ea6a17 | 2015-05-19 18:58:54 +0100 | [diff] [blame] | 419 | addl MACRO_LITERAL(20), %esp // Pop arguments skip eax |
| 420 | CFI_ADJUST_CFA_OFFSET(-20) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 421 | |
| 422 | // Restore FPRs. |
| 423 | movsd 0(%esp), %xmm0 |
| 424 | movsd 8(%esp), %xmm1 |
| 425 | movsd 16(%esp), %xmm2 |
| 426 | movsd 24(%esp), %xmm3 |
| 427 | |
| 428 | // Remove space for FPR args. |
| 429 | addl MACRO_LITERAL(4 * 8), %esp |
| 430 | CFI_ADJUST_CFA_OFFSET(-4 * 8) |
| 431 | |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 432 | POP ecx // Restore args except eax |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 433 | POP edx |
| 434 | POP ebx |
Dave Allison | bbb32c2 | 2013-11-05 18:25:18 -0800 | [diff] [blame] | 435 | POP ebp // Restore callee saves |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 436 | POP esi |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 437 | // Swap EDI callee save with code pointer. |
| 438 | xchgl %edi, (%esp) |
| 439 | testl %eax, %eax // Branch forward if exception pending. |
| 440 | jz 1f |
| 441 | // Tail call to intended method. |
| 442 | ret |
| 443 | 1: |
jeffhao | 20b5c6c | 2012-05-21 14:15:18 -0700 | [diff] [blame] | 444 | addl MACRO_LITERAL(4), %esp // Pop code pointer off stack |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 445 | CFI_ADJUST_CFA_OFFSET(-4) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 446 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 3031c8d | 2015-07-13 20:11:06 -0700 | [diff] [blame] | 447 | END_MACRO |
| 448 | MACRO2(INVOKE_TRAMPOLINE, c_name, cxx_name) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 449 | DEFINE_FUNCTION VAR(c_name) |
| 450 | INVOKE_TRAMPOLINE_BODY RAW_VAR(cxx_name) |
| 451 | END_FUNCTION VAR(c_name) |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 452 | END_MACRO |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 453 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 454 | INVOKE_TRAMPOLINE art_quick_invoke_interface_trampoline_with_access_check, artInvokeInterfaceTrampolineWithAccessCheck |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 455 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 456 | INVOKE_TRAMPOLINE art_quick_invoke_static_trampoline_with_access_check, artInvokeStaticTrampolineWithAccessCheck |
| 457 | INVOKE_TRAMPOLINE art_quick_invoke_direct_trampoline_with_access_check, artInvokeDirectTrampolineWithAccessCheck |
| 458 | INVOKE_TRAMPOLINE art_quick_invoke_super_trampoline_with_access_check, artInvokeSuperTrampolineWithAccessCheck |
| 459 | INVOKE_TRAMPOLINE art_quick_invoke_virtual_trampoline_with_access_check, artInvokeVirtualTrampolineWithAccessCheck |
Ian Rogers | 57b86d4 | 2012-03-27 16:05:41 -0700 | [diff] [blame] | 460 | |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 461 | /* |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 462 | * Helper for quick invocation stub to set up XMM registers. |
| 463 | * Increments shorty and arg_array and clobbers temp_char. |
| 464 | * Branches to finished if it encounters the end of the shorty. |
| 465 | */ |
| 466 | MACRO5(LOOP_OVER_SHORTY_LOADING_XMMS, xmm_reg, shorty, arg_array, temp_char, finished) |
| 467 | 1: // LOOP |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 468 | movb (REG_VAR(shorty)), REG_VAR(temp_char) // temp_char := *shorty |
| 469 | addl MACRO_LITERAL(1), REG_VAR(shorty) // shorty++ |
| 470 | cmpb MACRO_LITERAL(0), REG_VAR(temp_char) // if (temp_char == '\0') |
| 471 | je VAR(finished) // goto finished |
| 472 | cmpb MACRO_LITERAL(68), REG_VAR(temp_char) // if (temp_char == 'D') |
| 473 | je 2f // goto FOUND_DOUBLE |
| 474 | cmpb MACRO_LITERAL(70), REG_VAR(temp_char) // if (temp_char == 'F') |
| 475 | je 3f // goto FOUND_FLOAT |
| 476 | addl MACRO_LITERAL(4), REG_VAR(arg_array) // arg_array++ |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 477 | // Handle extra space in arg array taken by a long. |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 478 | cmpb MACRO_LITERAL(74), REG_VAR(temp_char) // if (temp_char != 'J') |
| 479 | jne 1b // goto LOOP |
| 480 | addl MACRO_LITERAL(4), REG_VAR(arg_array) // arg_array++ |
| 481 | jmp 1b // goto LOOP |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 482 | 2: // FOUND_DOUBLE |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 483 | movsd (REG_VAR(arg_array)), REG_VAR(xmm_reg) |
| 484 | addl MACRO_LITERAL(8), REG_VAR(arg_array) // arg_array+=2 |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 485 | jmp 4f |
| 486 | 3: // FOUND_FLOAT |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 487 | movss (REG_VAR(arg_array)), REG_VAR(xmm_reg) |
| 488 | addl MACRO_LITERAL(4), REG_VAR(arg_array) // arg_array++ |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 489 | 4: |
| 490 | END_MACRO |
| 491 | |
| 492 | /* |
| 493 | * Helper for quick invocation stub to set up GPR registers. |
| 494 | * Increments shorty and arg_array, and returns the current short character in |
| 495 | * temp_char. Branches to finished if it encounters the end of the shorty. |
| 496 | */ |
| 497 | MACRO4(SKIP_OVER_FLOATS, shorty, arg_array, temp_char, finished) |
| 498 | 1: // LOOP: |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 499 | movb (REG_VAR(shorty)), REG_VAR(temp_char) // temp_char := *shorty |
| 500 | addl MACRO_LITERAL(1), REG_VAR(shorty) // shorty++ |
| 501 | cmpb MACRO_LITERAL(0), REG_VAR(temp_char) // if (temp_char == '\0') |
| 502 | je VAR(finished) // goto finished |
| 503 | cmpb MACRO_LITERAL(70), REG_VAR(temp_char) // if (temp_char == 'F') |
| 504 | je 3f // goto SKIP_FLOAT |
| 505 | cmpb MACRO_LITERAL(68), REG_VAR(temp_char) // if (temp_char == 'D') |
| 506 | je 4f // goto SKIP_DOUBLE |
| 507 | jmp 5f // goto end |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 508 | 3: // SKIP_FLOAT |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 509 | addl MACRO_LITERAL(4), REG_VAR(arg_array) // arg_array++ |
| 510 | jmp 1b // goto LOOP |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 511 | 4: // SKIP_DOUBLE |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 512 | addl MACRO_LITERAL(8), REG_VAR(arg_array) // arg_array+=2 |
| 513 | jmp 1b // goto LOOP |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 514 | 5: |
| 515 | END_MACRO |
| 516 | |
| 517 | /* |
| 518 | * Quick invocation stub (non-static). |
Jeff Hao | 6474d19 | 2013-03-26 14:08:09 -0700 | [diff] [blame] | 519 | * On entry: |
| 520 | * [sp] = return address |
| 521 | * [sp + 4] = method pointer |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 522 | * [sp + 8] = argument array or null for no argument methods |
Jeff Hao | 6474d19 | 2013-03-26 14:08:09 -0700 | [diff] [blame] | 523 | * [sp + 12] = size of argument array in bytes |
| 524 | * [sp + 16] = (managed) thread pointer |
| 525 | * [sp + 20] = JValue* result |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 526 | * [sp + 24] = shorty |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 527 | */ |
| 528 | DEFINE_FUNCTION art_quick_invoke_stub |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 529 | // Save the non-volatiles. |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 530 | PUSH ebp // save ebp |
| 531 | PUSH ebx // save ebx |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 532 | PUSH esi // save esi |
| 533 | PUSH edi // save edi |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 534 | // Set up argument XMM registers. |
| 535 | mov 24+16(%esp), %esi // ESI := shorty + 1 ; ie skip return arg character. |
| 536 | addl LITERAL(1), %esi |
| 537 | mov 8+16(%esp), %edi // EDI := arg_array + 4 ; ie skip this pointer. |
| 538 | addl LITERAL(4), %edi |
| 539 | // Clobbers ESI, EDI, EAX. |
| 540 | LOOP_OVER_SHORTY_LOADING_XMMS xmm0, esi, edi, al, .Lxmm_setup_finished |
| 541 | LOOP_OVER_SHORTY_LOADING_XMMS xmm1, esi, edi, al, .Lxmm_setup_finished |
| 542 | LOOP_OVER_SHORTY_LOADING_XMMS xmm2, esi, edi, al, .Lxmm_setup_finished |
| 543 | LOOP_OVER_SHORTY_LOADING_XMMS xmm3, esi, edi, al, .Lxmm_setup_finished |
| 544 | .balign 16 |
| 545 | .Lxmm_setup_finished: |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 546 | mov %esp, %ebp // copy value of stack pointer into base pointer |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 547 | CFI_DEF_CFA_REGISTER(ebp) |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 548 | mov 28(%ebp), %ebx // get arg array size |
| 549 | // reserve space for return addr, method*, ebx, ebp, esi, and edi in frame |
| 550 | addl LITERAL(36), %ebx |
| 551 | // align frame size to 16 bytes |
| 552 | andl LITERAL(0xFFFFFFF0), %ebx |
| 553 | subl LITERAL(20), %ebx // remove space for return address, ebx, ebp, esi and edi |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 554 | subl %ebx, %esp // reserve stack space for argument array |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 555 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 556 | movl LITERAL(0), (%esp) // store null for method* |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 557 | |
| 558 | // Copy arg array into stack. |
| 559 | movl 28(%ebp), %ecx // ECX = size of args |
| 560 | movl 24(%ebp), %esi // ESI = argument array |
| 561 | leal 4(%esp), %edi // EDI = just after Method* in stack arguments |
| 562 | rep movsb // while (ecx--) { *edi++ = *esi++ } |
| 563 | |
| 564 | mov 40(%ebp), %esi // ESI := shorty + 1 ; ie skip return arg character. |
| 565 | addl LITERAL(1), %esi |
| 566 | mov 24(%ebp), %edi // EDI := arg_array |
| 567 | mov 0(%edi), %ecx // ECX := this pointer |
| 568 | addl LITERAL(4), %edi // EDI := arg_array + 4 ; ie skip this pointer. |
| 569 | |
| 570 | // Enumerate the possible cases for loading GPRS. |
| 571 | // edx (and maybe ebx): |
| 572 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished |
| 573 | cmpb LITERAL(74), %al // if (al == 'J') goto FOUND_LONG |
| 574 | je .LfirstLong |
| 575 | // Must be an integer value. |
| 576 | movl (%edi), %edx |
| 577 | addl LITERAL(4), %edi // arg_array++ |
| 578 | |
| 579 | // Now check ebx |
| 580 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished |
Mark Mendell | 3e6a3bf | 2015-01-19 14:09:22 -0500 | [diff] [blame] | 581 | // Must be first word of a long, or an integer. First word of long doesn't |
| 582 | // go into EBX, but can be loaded there anyways, as it is harmless. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 583 | movl (%edi), %ebx |
| 584 | jmp .Lgpr_setup_finished |
| 585 | .LfirstLong: |
| 586 | movl (%edi), %edx |
| 587 | movl 4(%edi), %ebx |
| 588 | // Nothing left to load. |
| 589 | .Lgpr_setup_finished: |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 590 | mov 20(%ebp), %eax // move method pointer into eax |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 591 | call *ART_METHOD_QUICK_CODE_OFFSET_32(%eax) // call the method |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 592 | mov %ebp, %esp // restore stack pointer |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 593 | CFI_DEF_CFA_REGISTER(esp) |
Nicolas Geoffray | 4808846 | 2014-12-12 10:29:38 +0000 | [diff] [blame] | 594 | POP edi // pop edi |
| 595 | POP esi // pop esi |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 596 | POP ebx // pop ebx |
| 597 | POP ebp // pop ebp |
| 598 | mov 20(%esp), %ecx // get result pointer |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 599 | mov %eax, (%ecx) // store the result assuming its a long, int or Object* |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 600 | mov %edx, 4(%ecx) // store the other half of the result |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 601 | mov 24(%esp), %edx // get the shorty |
| 602 | cmpb LITERAL(68), (%edx) // test if result type char == 'D' |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 603 | je .Lreturn_double_quick |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 604 | cmpb LITERAL(70), (%edx) // test if result type char == 'F' |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 605 | je .Lreturn_float_quick |
Jeff Hao | 6474d19 | 2013-03-26 14:08:09 -0700 | [diff] [blame] | 606 | ret |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 607 | .Lreturn_double_quick: |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 608 | movsd %xmm0, (%ecx) // store the floating point result |
| 609 | ret |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 610 | .Lreturn_float_quick: |
Ian Rogers | 0177e53 | 2014-02-11 16:30:46 -0800 | [diff] [blame] | 611 | movss %xmm0, (%ecx) // store the floating point result |
| 612 | ret |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 613 | END_FUNCTION art_quick_invoke_stub |
| 614 | |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 615 | /* |
| 616 | * Quick invocation stub (static). |
| 617 | * On entry: |
| 618 | * [sp] = return address |
| 619 | * [sp + 4] = method pointer |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 620 | * [sp + 8] = argument array or null for no argument methods |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 621 | * [sp + 12] = size of argument array in bytes |
| 622 | * [sp + 16] = (managed) thread pointer |
| 623 | * [sp + 20] = JValue* result |
| 624 | * [sp + 24] = shorty |
| 625 | */ |
| 626 | DEFINE_FUNCTION art_quick_invoke_static_stub |
| 627 | // Save the non-volatiles. |
| 628 | PUSH ebp // save ebp |
| 629 | PUSH ebx // save ebx |
| 630 | PUSH esi // save esi |
| 631 | PUSH edi // save edi |
| 632 | // Set up argument XMM registers. |
| 633 | mov 24+16(%esp), %esi // ESI := shorty + 1 ; ie skip return arg character. |
| 634 | addl LITERAL(1), %esi |
| 635 | mov 8+16(%esp), %edi // EDI := arg_array |
| 636 | // Clobbers ESI, EDI, EAX. |
| 637 | LOOP_OVER_SHORTY_LOADING_XMMS xmm0, esi, edi, al, .Lxmm_setup_finished2 |
| 638 | LOOP_OVER_SHORTY_LOADING_XMMS xmm1, esi, edi, al, .Lxmm_setup_finished2 |
| 639 | LOOP_OVER_SHORTY_LOADING_XMMS xmm2, esi, edi, al, .Lxmm_setup_finished2 |
| 640 | LOOP_OVER_SHORTY_LOADING_XMMS xmm3, esi, edi, al, .Lxmm_setup_finished2 |
| 641 | .balign 16 |
| 642 | .Lxmm_setup_finished2: |
| 643 | mov %esp, %ebp // copy value of stack pointer into base pointer |
| 644 | CFI_DEF_CFA_REGISTER(ebp) |
| 645 | mov 28(%ebp), %ebx // get arg array size |
| 646 | // reserve space for return addr, method*, ebx, ebp, esi, and edi in frame |
| 647 | addl LITERAL(36), %ebx |
| 648 | // align frame size to 16 bytes |
| 649 | andl LITERAL(0xFFFFFFF0), %ebx |
| 650 | subl LITERAL(20), %ebx // remove space for return address, ebx, ebp, esi and edi |
| 651 | subl %ebx, %esp // reserve stack space for argument array |
| 652 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 653 | movl LITERAL(0), (%esp) // store null for method* |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 654 | |
| 655 | // Copy arg array into stack. |
| 656 | movl 28(%ebp), %ecx // ECX = size of args |
| 657 | movl 24(%ebp), %esi // ESI = argument array |
| 658 | leal 4(%esp), %edi // EDI = just after Method* in stack arguments |
| 659 | rep movsb // while (ecx--) { *edi++ = *esi++ } |
| 660 | |
| 661 | mov 40(%ebp), %esi // ESI := shorty + 1 ; ie skip return arg character. |
| 662 | addl LITERAL(1), %esi |
| 663 | mov 24(%ebp), %edi // EDI := arg_array |
| 664 | |
| 665 | // Enumerate the possible cases for loading GPRS. |
| 666 | // ecx (and maybe edx) |
| 667 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished2 |
| 668 | cmpb LITERAL(74), %al // if (al == 'J') goto FOUND_LONG |
| 669 | je .LfirstLong2 |
| 670 | // Must be an integer value. Load into ECX. |
| 671 | movl (%edi), %ecx |
| 672 | addl LITERAL(4), %edi // arg_array++ |
| 673 | |
| 674 | // Now check edx (and maybe ebx). |
| 675 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished2 |
| 676 | cmpb LITERAL(74), %al // if (al == 'J') goto FOUND_LONG |
| 677 | je .LSecondLong2 |
| 678 | // Must be an integer. Load into EDX. |
| 679 | movl (%edi), %edx |
| 680 | addl LITERAL(4), %edi // arg_array++ |
| 681 | |
| 682 | // Is there anything for ebx? |
| 683 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished2 |
Mark Mendell | 3e6a3bf | 2015-01-19 14:09:22 -0500 | [diff] [blame] | 684 | // Must be first word of a long, or an integer. First word of long doesn't |
| 685 | // go into EBX, but can be loaded there anyways, as it is harmless. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 686 | movl (%edi), %ebx |
| 687 | jmp .Lgpr_setup_finished2 |
| 688 | .LSecondLong2: |
| 689 | // EDX:EBX is long. That is all. |
| 690 | movl (%edi), %edx |
| 691 | movl 4(%edi), %ebx |
| 692 | jmp .Lgpr_setup_finished2 |
| 693 | .LfirstLong2: |
| 694 | // ECX:EDX is a long |
| 695 | movl (%edi), %ecx |
| 696 | movl 4(%edi), %edx |
| 697 | addl LITERAL(8), %edi // arg_array += 2 |
| 698 | |
| 699 | // Anything for EBX? |
| 700 | SKIP_OVER_FLOATS esi, edi, al, .Lgpr_setup_finished2 |
Mark Mendell | 3e6a3bf | 2015-01-19 14:09:22 -0500 | [diff] [blame] | 701 | // Must be first word of a long, or an integer. First word of long doesn't |
| 702 | // go into EBX, but can be loaded there anyways, as it is harmless. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 703 | movl (%edi), %ebx |
| 704 | jmp .Lgpr_setup_finished2 |
| 705 | // Nothing left to load. |
| 706 | .Lgpr_setup_finished2: |
| 707 | mov 20(%ebp), %eax // move method pointer into eax |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 708 | call *ART_METHOD_QUICK_CODE_OFFSET_32(%eax) // call the method |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 709 | mov %ebp, %esp // restore stack pointer |
| 710 | CFI_DEF_CFA_REGISTER(esp) |
| 711 | POP edi // pop edi |
| 712 | POP esi // pop esi |
| 713 | POP ebx // pop ebx |
| 714 | POP ebp // pop ebp |
| 715 | mov 20(%esp), %ecx // get result pointer |
| 716 | mov %eax, (%ecx) // store the result assuming its a long, int or Object* |
| 717 | mov %edx, 4(%ecx) // store the other half of the result |
| 718 | mov 24(%esp), %edx // get the shorty |
| 719 | cmpb LITERAL(68), (%edx) // test if result type char == 'D' |
| 720 | je .Lreturn_double_quick2 |
| 721 | cmpb LITERAL(70), (%edx) // test if result type char == 'F' |
| 722 | je .Lreturn_float_quick2 |
| 723 | ret |
| 724 | .Lreturn_double_quick2: |
| 725 | movsd %xmm0, (%ecx) // store the floating point result |
| 726 | ret |
| 727 | .Lreturn_float_quick2: |
| 728 | movss %xmm0, (%ecx) // store the floating point result |
| 729 | ret |
| 730 | END_FUNCTION art_quick_invoke_static_stub |
| 731 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 732 | MACRO3(ONE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 733 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 734 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 735 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 736 | subl MACRO_LITERAL(8), %esp // push padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 737 | CFI_ADJUST_CFA_OFFSET(8) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 738 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 739 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 740 | PUSH eax // pass arg1 |
| 741 | call CALLVAR(cxx_name) // cxx_name(arg1, Thread*) |
| 742 | addl MACRO_LITERAL(16), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 743 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 744 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 745 | CALL_MACRO(return_macro) // return or deliver exception |
| 746 | END_FUNCTION VAR(c_name) |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 747 | END_MACRO |
| 748 | |
| 749 | MACRO3(TWO_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 750 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 751 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 752 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 753 | PUSH eax // push padding |
| 754 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 755 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 756 | PUSH ecx // pass arg2 |
| 757 | PUSH eax // pass arg1 |
| 758 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, Thread*) |
| 759 | addl MACRO_LITERAL(16), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 760 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 761 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 762 | CALL_MACRO(return_macro) // return or deliver exception |
| 763 | END_FUNCTION VAR(c_name) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 764 | END_MACRO |
| 765 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 766 | MACRO3(THREE_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 767 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 768 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 769 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 770 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 771 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 772 | PUSH edx // pass arg3 |
| 773 | PUSH ecx // pass arg2 |
| 774 | PUSH eax // pass arg1 |
| 775 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, arg3, Thread*) |
| 776 | addl MACRO_LITERAL(16), %esp // pop arguments |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 777 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 778 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 779 | CALL_MACRO(return_macro) // return or deliver exception |
| 780 | END_FUNCTION VAR(c_name) |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 781 | END_MACRO |
| 782 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 783 | MACRO3(FOUR_ARG_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 784 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 785 | SETUP_SAVE_REFS_ONLY_FRAME_PRESERVE_GOT_REG ebx, ebx // save ref containing registers for GC |
Roland Levillain | f969a20 | 2016-03-09 16:14:00 +0000 | [diff] [blame] | 786 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 787 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 788 | subl MACRO_LITERAL(12), %esp // alignment padding |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 789 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 790 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 791 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 792 | PUSH ebx // pass arg4 |
| 793 | PUSH edx // pass arg3 |
| 794 | PUSH ecx // pass arg2 |
| 795 | PUSH eax // pass arg1 |
| 796 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, arg3, arg4, Thread*) |
| 797 | addl MACRO_LITERAL(32), %esp // pop arguments |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 798 | CFI_ADJUST_CFA_OFFSET(-32) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 799 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 800 | CALL_MACRO(return_macro) // return or deliver exception |
| 801 | END_FUNCTION VAR(c_name) |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 802 | END_MACRO |
| 803 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 804 | MACRO3(ONE_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 805 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 806 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 807 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 808 | mov FRAME_SIZE_SAVE_REFS_ONLY(%esp), %ecx // get referrer |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 809 | PUSH eax // push padding |
| 810 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 811 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 812 | PUSH ecx // pass referrer |
| 813 | PUSH eax // pass arg1 |
| 814 | call CALLVAR(cxx_name) // cxx_name(arg1, referrer, Thread*) |
| 815 | addl MACRO_LITERAL(16), %esp // pop arguments |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 816 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 817 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 818 | CALL_MACRO(return_macro) // return or deliver exception |
| 819 | END_FUNCTION VAR(c_name) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 820 | END_MACRO |
| 821 | |
| 822 | MACRO3(TWO_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 823 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 824 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 825 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 826 | mov FRAME_SIZE_SAVE_REFS_ONLY(%esp), %edx // get referrer |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 827 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 828 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 829 | PUSH edx // pass referrer |
| 830 | PUSH ecx // pass arg2 |
| 831 | PUSH eax // pass arg1 |
| 832 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, referrer, Thread*) |
| 833 | addl MACRO_LITERAL(16), %esp // pop arguments |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 834 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 835 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 836 | CALL_MACRO(return_macro) // return or deliver exception |
| 837 | END_FUNCTION VAR(c_name) |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 838 | END_MACRO |
| 839 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 840 | MACRO3(THREE_ARG_REF_DOWNCALL, c_name, cxx_name, return_macro) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 841 | DEFINE_FUNCTION VAR(c_name) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 842 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 843 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 844 | mov FRAME_SIZE_SAVE_REFS_ONLY(%esp), %ebx // get referrer |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 845 | subl MACRO_LITERAL(12), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 846 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 847 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 848 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 849 | PUSH ebx // pass referrer |
| 850 | PUSH edx // pass arg3 |
| 851 | PUSH ecx // pass arg2 |
| 852 | PUSH eax // pass arg1 |
| 853 | call CALLVAR(cxx_name) // cxx_name(arg1, arg2, arg3, referrer, |
| 854 | // Thread*) |
| 855 | addl LITERAL(32), %esp // pop arguments |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 856 | CFI_ADJUST_CFA_OFFSET(-32) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 857 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 858 | CALL_MACRO(return_macro) // return or deliver exception |
| 859 | END_FUNCTION VAR(c_name) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 860 | END_MACRO |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 861 | |
Hiroshi Yamauchi | 4adeab1 | 2015-10-02 15:27:55 -0700 | [diff] [blame] | 862 | MACRO0(RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 863 | testl %eax, %eax // eax == 0 ? |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 864 | jz 1f // if eax == 0 goto 1 |
| 865 | ret // return |
| 866 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 867 | DELIVER_PENDING_EXCEPTION |
| 868 | END_MACRO |
| 869 | |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 870 | MACRO0(RETURN_IF_EAX_ZERO) |
| 871 | testl %eax, %eax // eax == 0 ? |
| 872 | jnz 1f // if eax != 0 goto 1 |
| 873 | ret // return |
| 874 | 1: // deliver exception on current thread |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 875 | DELIVER_PENDING_EXCEPTION |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 876 | END_MACRO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 877 | |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 878 | MACRO0(RETURN_OR_DELIVER_PENDING_EXCEPTION) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 879 | cmpl MACRO_LITERAL(0),%fs:THREAD_EXCEPTION_OFFSET // exception field == 0 ? |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 880 | jne 1f // if exception field != 0 goto 1 |
| 881 | ret // return |
| 882 | 1: // deliver exception on current thread |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 883 | DELIVER_PENDING_EXCEPTION |
| 884 | END_MACRO |
| 885 | |
Mathieu Chartier | 7410f29 | 2013-11-24 13:17:35 -0800 | [diff] [blame] | 886 | // Generate the allocation entrypoints for each allocator. |
Hiroshi Yamauchi | 4adeab1 | 2015-10-02 15:27:55 -0700 | [diff] [blame] | 887 | GENERATE_ALLOC_ENTRYPOINTS_FOR_EACH_ALLOCATOR |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 888 | |
| 889 | // A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_rosalloc, RosAlloc). |
| 890 | DEFINE_FUNCTION art_quick_alloc_object_rosalloc |
| 891 | // Fast path rosalloc allocation. |
| 892 | // eax: uint32_t type_idx/return value, ecx: ArtMethod* |
| 893 | // ebx, edx: free |
| 894 | PUSH edi |
| 895 | movl ART_METHOD_DEX_CACHE_TYPES_OFFSET_32(%ecx), %edx // Load dex cache resolved types array |
| 896 | // Load the class (edx) |
| 897 | movl 0(%edx, %eax, COMPRESSED_REFERENCE_SIZE), %edx |
| 898 | testl %edx, %edx // Check null class |
| 899 | jz .Lart_quick_alloc_object_rosalloc_slow_path |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 900 | |
| 901 | movl %fs:THREAD_SELF_OFFSET, %ebx // ebx = thread |
| 902 | // Check if the thread local allocation |
| 903 | // stack has room |
| 904 | movl THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET(%ebx), %edi |
| 905 | cmpl THREAD_LOCAL_ALLOC_STACK_END_OFFSET(%ebx), %edi |
| 906 | jae .Lart_quick_alloc_object_rosalloc_slow_path |
| 907 | |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 908 | movl MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET(%edx), %edi // Load the object size (edi) |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 909 | // Check if the size is for a thread |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 910 | // local allocation. Also does the |
| 911 | // finalizable and initialization check. |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 912 | cmpl LITERAL(ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE), %edi |
| 913 | ja .Lart_quick_alloc_object_rosalloc_slow_path |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 914 | shrl LITERAL(ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT), %edi // Calculate the rosalloc bracket index |
| 915 | // from object size. |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 916 | // Load thread local rosalloc run (ebx) |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 917 | // Subtract __SIZEOF_POINTER__ to subtract |
| 918 | // one from edi as there is no 0 byte run |
| 919 | // and the size is already aligned. |
| 920 | movl (THREAD_ROSALLOC_RUNS_OFFSET - __SIZEOF_POINTER__)(%ebx, %edi, __SIZEOF_POINTER__), %ebx |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 921 | // Load free_list head (edi), |
| 922 | // this will be the return value. |
| 923 | movl (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)(%ebx), %edi |
| 924 | test %edi, %edi |
| 925 | jz .Lart_quick_alloc_object_rosalloc_slow_path |
| 926 | // Point of no slow path. Won't go to |
| 927 | // the slow path from here on. Ok to |
| 928 | // clobber eax and ecx. |
| 929 | movl %edi, %eax |
| 930 | // Load the next pointer of the head |
| 931 | // and update head of free list with |
| 932 | // next pointer |
| 933 | movl ROSALLOC_SLOT_NEXT_OFFSET(%eax), %edi |
| 934 | movl %edi, (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET)(%ebx) |
| 935 | // Decrement size of free list by 1 |
| 936 | decl (ROSALLOC_RUN_FREE_LIST_OFFSET + ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET)(%ebx) |
| 937 | // Store the class pointer in the |
| 938 | // header. This also overwrites the |
| 939 | // next pointer. The offsets are |
| 940 | // asserted to match. |
| 941 | #if ROSALLOC_SLOT_NEXT_OFFSET != MIRROR_OBJECT_CLASS_OFFSET |
| 942 | #error "Class pointer needs to overwrite next pointer." |
| 943 | #endif |
| 944 | POISON_HEAP_REF edx |
| 945 | movl %edx, MIRROR_OBJECT_CLASS_OFFSET(%eax) |
| 946 | movl %fs:THREAD_SELF_OFFSET, %ebx // ebx = thread |
| 947 | // Push the new object onto the thread |
| 948 | // local allocation stack and |
| 949 | // increment the thread local |
| 950 | // allocation stack top. |
| 951 | movl THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET(%ebx), %edi |
| 952 | movl %eax, (%edi) |
| 953 | addl LITERAL(COMPRESSED_REFERENCE_SIZE), %edi |
| 954 | movl %edi, THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET(%ebx) |
| 955 | // No fence needed for x86. |
| 956 | POP edi |
| 957 | ret |
| 958 | .Lart_quick_alloc_object_rosalloc_slow_path: |
| 959 | POP edi |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 960 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 961 | // Outgoing argument set up |
| 962 | PUSH eax // alignment padding |
| 963 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 964 | CFI_ADJUST_CFA_OFFSET(4) |
| 965 | PUSH ecx |
| 966 | PUSH eax |
| 967 | call SYMBOL(artAllocObjectFromCodeRosAlloc) // cxx_name(arg0, arg1, Thread*) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 968 | addl LITERAL(16), %esp // pop arguments |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 969 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 970 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
lwang85 | de95c87 | 2015-11-10 17:26:31 +0800 | [diff] [blame] | 971 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER // return or deliver exception |
| 972 | END_FUNCTION art_quick_alloc_object_rosalloc |
| 973 | |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 974 | // The common fast path code for art_quick_alloc_object_tlab and art_quick_alloc_object_region_tlab. |
| 975 | // |
| 976 | // EAX: type_idx/return_value, ECX: ArtMethod*, EDX: the class. |
| 977 | MACRO1(ALLOC_OBJECT_TLAB_FAST_PATH, slowPathLabel) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 978 | testl %edx, %edx // Check null class |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 979 | jz VAR(slowPathLabel) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 980 | movl %fs:THREAD_SELF_OFFSET, %ebx // ebx = thread |
| 981 | movl THREAD_LOCAL_END_OFFSET(%ebx), %edi // Load thread_local_end. |
| 982 | subl THREAD_LOCAL_POS_OFFSET(%ebx), %edi // Compute the remaining buffer size. |
Mathieu Chartier | 93bbee0 | 2016-08-31 09:38:40 -0700 | [diff] [blame] | 983 | movl MIRROR_CLASS_OBJECT_SIZE_ALLOC_FAST_PATH_OFFSET(%edx), %esi // Load the object size. |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 984 | cmpl %edi, %esi // Check if it fits. |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 985 | ja VAR(slowPathLabel) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 986 | movl THREAD_LOCAL_POS_OFFSET(%ebx), %eax // Load thread_local_pos |
| 987 | // as allocated object. |
| 988 | addl %eax, %esi // Add the object size. |
| 989 | movl %esi, THREAD_LOCAL_POS_OFFSET(%ebx) // Update thread_local_pos. |
Mathieu Chartier | 93bbee0 | 2016-08-31 09:38:40 -0700 | [diff] [blame] | 990 | incl THREAD_LOCAL_OBJECTS_OFFSET(%ebx) // Increase thread_local_objects. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 991 | // Store the class pointer in the header. |
| 992 | // No fence needed for x86. |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 993 | POISON_HEAP_REF edx |
| 994 | movl %edx, MIRROR_OBJECT_CLASS_OFFSET(%eax) |
| 995 | POP edi |
| 996 | POP esi |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 997 | ret // Fast path succeeded. |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 998 | END_MACRO |
| 999 | |
| 1000 | // The common slow path code for art_quick_alloc_object_tlab and art_quick_alloc_object_region_tlab. |
| 1001 | MACRO1(ALLOC_OBJECT_TLAB_SLOW_PATH, cxx_name) |
| 1002 | POP edi |
| 1003 | POP esi |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1004 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1005 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1006 | PUSH eax // alignment padding |
| 1007 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1008 | CFI_ADJUST_CFA_OFFSET(4) |
| 1009 | PUSH ecx |
| 1010 | PUSH eax |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1011 | call CALLVAR(cxx_name) // cxx_name(arg0, arg1, Thread*) |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1012 | addl LITERAL(16), %esp |
| 1013 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1014 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
| 1015 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER // return or deliver exception |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1016 | END_MACRO |
| 1017 | |
| 1018 | // A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_tlab, TLAB). |
| 1019 | DEFINE_FUNCTION art_quick_alloc_object_tlab |
| 1020 | // Fast path tlab allocation. |
| 1021 | // EAX: uint32_t type_idx/return value, ECX: ArtMethod*. |
| 1022 | // EBX, EDX: free. |
| 1023 | #if defined(USE_READ_BARRIER) |
| 1024 | int3 |
| 1025 | int3 |
| 1026 | #endif |
| 1027 | PUSH esi |
| 1028 | PUSH edi |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1029 | movl ART_METHOD_DEX_CACHE_TYPES_OFFSET_32(%ecx), %edx // Load dex cache resolved types array |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1030 | // Might need to break down into multiple instructions to get the base address in a register. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1031 | // Load the class |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1032 | movl 0(%edx, %eax, COMPRESSED_REFERENCE_SIZE), %edx |
| 1033 | ALLOC_OBJECT_TLAB_FAST_PATH .Lart_quick_alloc_object_tlab_slow_path |
| 1034 | .Lart_quick_alloc_object_tlab_slow_path: |
| 1035 | ALLOC_OBJECT_TLAB_SLOW_PATH artAllocObjectFromCodeTLAB |
| 1036 | END_FUNCTION art_quick_alloc_object_tlab |
| 1037 | |
| 1038 | // A hand-written override for GENERATE_ALLOC_ENTRYPOINTS_ALLOC_OBJECT(_region_tlab, RegionTLAB). |
| 1039 | DEFINE_FUNCTION art_quick_alloc_object_region_tlab |
| 1040 | // Fast path region tlab allocation. |
| 1041 | // EAX: uint32_t type_idx/return value, ECX: ArtMethod*. |
| 1042 | // EBX, EDX: free. |
| 1043 | #if !defined(USE_READ_BARRIER) |
| 1044 | int3 |
| 1045 | int3 |
| 1046 | #endif |
| 1047 | PUSH esi |
| 1048 | PUSH edi |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1049 | movl ART_METHOD_DEX_CACHE_TYPES_OFFSET_32(%ecx), %edx // Load dex cache resolved types array |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1050 | // Might need to break down into multiple instructions to get the base address in a register. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1051 | // Load the class |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1052 | movl 0(%edx, %eax, COMPRESSED_REFERENCE_SIZE), %edx |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1053 | // Read barrier for class load. |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1054 | cmpl LITERAL(0), %fs:THREAD_IS_GC_MARKING_OFFSET |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1055 | jz .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit |
| 1056 | // Null check so that we can load the lock word. |
| 1057 | testl %edx, %edx |
| 1058 | jz .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit |
| 1059 | // Check the mark bit, if it is 1 return. |
| 1060 | testl LITERAL(LOCK_WORD_MARK_BIT_MASK_SHIFTED), MIRROR_OBJECT_LOCK_WORD_OFFSET(%edx) |
| 1061 | jz .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1062 | .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit: |
| 1063 | ALLOC_OBJECT_TLAB_FAST_PATH .Lart_quick_alloc_object_region_tlab_slow_path |
| 1064 | .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path: |
| 1065 | // The read barrier slow path. Mark the class. |
| 1066 | PUSH eax |
| 1067 | PUSH ecx |
| 1068 | // Outgoing argument set up |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1069 | subl MACRO_LITERAL(8), %esp // Alignment padding |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1070 | CFI_ADJUST_CFA_OFFSET(8) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1071 | PUSH edx // Pass the class as the first param. |
| 1072 | call SYMBOL(artReadBarrierMark) // cxx_name(mirror::Object* obj) |
Sang, Chunlei | 69cee6a | 2016-04-21 10:22:02 +0800 | [diff] [blame] | 1073 | movl %eax, %edx |
| 1074 | addl MACRO_LITERAL(12), %esp |
| 1075 | CFI_ADJUST_CFA_OFFSET(-12) |
| 1076 | POP ecx |
| 1077 | POP eax |
| 1078 | jmp .Lart_quick_alloc_object_region_tlab_class_load_read_barrier_slow_path_exit |
| 1079 | .Lart_quick_alloc_object_region_tlab_slow_path: |
| 1080 | ALLOC_OBJECT_TLAB_SLOW_PATH artAllocObjectFromCodeRegionTLAB |
| 1081 | END_FUNCTION art_quick_alloc_object_region_tlab |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1082 | |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1083 | DEFINE_FUNCTION art_quick_resolve_string |
Christina Wadsworth | 74898e7 | 2016-08-25 13:23:01 -0700 | [diff] [blame] | 1084 | movl 4(%esp), %ecx // get referrer |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1085 | movl ART_METHOD_DECLARING_CLASS_OFFSET(%ecx), %ecx // get declaring class |
| 1086 | movl DECLARING_CLASS_DEX_CACHE_STRINGS_OFFSET(%ecx), %ecx // get string dex cache |
| 1087 | movl LITERAL(STRING_DEX_CACHE_SIZE_MINUS_ONE), %edx |
| 1088 | andl %eax, %edx |
Christina Wadsworth | 74898e7 | 2016-08-25 13:23:01 -0700 | [diff] [blame] | 1089 | movlps (%ecx, %edx, STRING_DEX_CACHE_ELEMENT_SIZE), %xmm0 // load string idx and ptr to xmm0 |
| 1090 | movd %xmm0, %ecx // extract pointer |
| 1091 | pshufd LITERAL(0x55), %xmm0, %xmm0 // shuffle index into lowest bits |
| 1092 | movd %xmm0, %edx // extract index |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1093 | cmp %edx, %eax |
| 1094 | jne .Lart_quick_resolve_string_slow_path |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1095 | movl %ecx, %eax |
Christina Wadsworth | 4489fb3 | 2016-08-23 14:13:43 -0700 | [diff] [blame] | 1096 | #ifdef USE_READ_BARRIER |
| 1097 | cmpl LITERAL(0), %fs:THREAD_IS_GC_MARKING_OFFSET |
| 1098 | jne .Lart_quick_resolve_string_marking |
| 1099 | #endif |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1100 | ret |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1101 | .Lart_quick_resolve_string_slow_path: |
| 1102 | // Outgoing argument set up |
Christina Wadsworth | 74898e7 | 2016-08-25 13:23:01 -0700 | [diff] [blame] | 1103 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1104 | subl LITERAL(8), %esp // push padding |
| 1105 | CFI_ADJUST_CFA_OFFSET(8) |
| 1106 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 1107 | CFI_ADJUST_CFA_OFFSET(4) |
| 1108 | PUSH eax // pass arg1 |
| 1109 | call SYMBOL(artResolveStringFromCode) |
| 1110 | addl LITERAL(16), %esp // pop arguments |
| 1111 | CFI_ADJUST_CFA_OFFSET(-16) |
| 1112 | RESTORE_SAVE_REFS_ONLY_FRAME |
| 1113 | RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Christina Wadsworth | 4489fb3 | 2016-08-23 14:13:43 -0700 | [diff] [blame] | 1114 | .Lart_quick_resolve_string_marking: |
Christina Wadsworth | 74898e7 | 2016-08-25 13:23:01 -0700 | [diff] [blame] | 1115 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx |
Christina Wadsworth | 4489fb3 | 2016-08-23 14:13:43 -0700 | [diff] [blame] | 1116 | testl LITERAL(LOCK_WORD_MARK_BIT_MASK_SHIFTED), MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax) |
| 1117 | jnz .Lart_quick_resolve_string_no_rb |
| 1118 | subl LITERAL(12), %esp // alignment padding |
| 1119 | CFI_ADJUST_CFA_OFFSET(12) |
| 1120 | PUSH eax // Pass the string as the first param. |
| 1121 | call SYMBOL(artReadBarrierMark) |
| 1122 | addl LITERAL(16), %esp |
| 1123 | CFI_ADJUST_CFA_OFFSET(-16) |
| 1124 | .Lart_quick_resolve_string_no_rb: |
| 1125 | RESTORE_SAVE_REFS_ONLY_FRAME |
| 1126 | ret |
Christina Wadsworth | 39c8a11 | 2016-08-22 13:22:36 -0700 | [diff] [blame] | 1127 | END_FUNCTION art_quick_resolve_string |
| 1128 | |
Hiroshi Yamauchi | 4adeab1 | 2015-10-02 15:27:55 -0700 | [diff] [blame] | 1129 | ONE_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1130 | ONE_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
| 1131 | ONE_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER |
Ian Rogers | d36c52e | 2012-04-09 16:29:25 -0700 | [diff] [blame] | 1132 | |
Ian Rogers | 832336b | 2014-10-08 15:35:22 -0700 | [diff] [blame] | 1133 | TWO_ARG_REF_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1134 | |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1135 | DEFINE_FUNCTION art_quick_lock_object |
| 1136 | testl %eax, %eax // null check object/eax |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1137 | jz .Lslow_lock |
| 1138 | .Lretry_lock: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1139 | movl MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax), %ecx // ecx := lock word |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1140 | test LITERAL(LOCK_WORD_STATE_MASK), %ecx // test the 2 high bits. |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1141 | jne .Lslow_lock // slow path if either of the two high bits are set. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1142 | movl %ecx, %edx // save lock word (edx) to keep read barrier bits. |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1143 | andl LITERAL(LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED), %ecx // zero the gc bits. |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1144 | test %ecx, %ecx |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1145 | jnz .Lalready_thin // lock word contains a thin lock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1146 | // unlocked case - edx: original lock word, eax: obj. |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1147 | movl %eax, %ecx // remember object in case of retry |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1148 | movl %edx, %eax // eax: lock word zero except for read barrier bits. |
| 1149 | movl %fs:THREAD_ID_OFFSET, %edx // load thread id. |
| 1150 | or %eax, %edx // edx: thread id with count of 0 + read barrier bits. |
| 1151 | lock cmpxchg %edx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%ecx) // eax: old val, edx: new val. |
| 1152 | jnz .Llock_cmpxchg_fail // cmpxchg failed retry |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1153 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1154 | .Lalready_thin: // edx: lock word (with high 2 bits zero and original rb bits), eax: obj. |
| 1155 | movl %fs:THREAD_ID_OFFSET, %ecx // ecx := thread id |
Serguei Katkov | 8ef84af | 2014-04-03 15:17:26 +0700 | [diff] [blame] | 1156 | cmpw %cx, %dx // do we hold the lock already? |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1157 | jne .Lslow_lock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1158 | movl %edx, %ecx // copy the lock word to check count overflow. |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1159 | andl LITERAL(LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED), %ecx // zero the read barrier bits. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1160 | addl LITERAL(LOCK_WORD_THIN_LOCK_COUNT_ONE), %ecx // increment recursion count for overflow check. |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1161 | test LITERAL(LOCK_WORD_GC_STATE_MASK_SHIFTED), %ecx // overflowed if the first gc state bit is set. |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1162 | jne .Lslow_lock // count overflowed so go slow |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1163 | movl %eax, %ecx // save obj to use eax for cmpxchg. |
| 1164 | movl %edx, %eax // copy the lock word as the old val for cmpxchg. |
| 1165 | addl LITERAL(LOCK_WORD_THIN_LOCK_COUNT_ONE), %edx // increment recursion count again for real. |
| 1166 | // update lockword, cmpxchg necessary for read barrier bits. |
| 1167 | lock cmpxchg %edx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%ecx) // eax: old val, edx: new val. |
| 1168 | jnz .Llock_cmpxchg_fail // cmpxchg failed retry |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1169 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1170 | .Llock_cmpxchg_fail: |
| 1171 | movl %ecx, %eax // restore eax |
| 1172 | jmp .Lretry_lock |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1173 | .Lslow_lock: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1174 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1175 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1176 | subl LITERAL(8), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1177 | CFI_ADJUST_CFA_OFFSET(8) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1178 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1179 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1180 | PUSH eax // pass object |
| 1181 | call SYMBOL(artLockObjectFromCode) // artLockObjectFromCode(object, Thread*) |
| 1182 | addl LITERAL(16), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1183 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1184 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1185 | RETURN_IF_EAX_ZERO |
| 1186 | END_FUNCTION art_quick_lock_object |
| 1187 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1188 | DEFINE_FUNCTION art_quick_lock_object_no_inline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1189 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1190 | // Outgoing argument set up |
| 1191 | subl LITERAL(8), %esp // alignment padding |
| 1192 | CFI_ADJUST_CFA_OFFSET(8) |
| 1193 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 1194 | CFI_ADJUST_CFA_OFFSET(4) |
| 1195 | PUSH eax // pass object |
| 1196 | call SYMBOL(artLockObjectFromCode) // artLockObjectFromCode(object, Thread*) |
| 1197 | addl LITERAL(16), %esp // pop arguments |
| 1198 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1199 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1200 | RETURN_IF_EAX_ZERO |
| 1201 | END_FUNCTION art_quick_lock_object_no_inline |
| 1202 | |
| 1203 | |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1204 | DEFINE_FUNCTION art_quick_unlock_object |
| 1205 | testl %eax, %eax // null check object/eax |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1206 | jz .Lslow_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1207 | .Lretry_unlock: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1208 | movl MIRROR_OBJECT_LOCK_WORD_OFFSET(%eax), %ecx // ecx := lock word |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1209 | movl %fs:THREAD_ID_OFFSET, %edx // edx := thread id |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1210 | test LITERAL(LOCK_WORD_STATE_MASK), %ecx |
Serguei Katkov | e78d4e1 | 2014-04-07 10:14:08 +0700 | [diff] [blame] | 1211 | jnz .Lslow_unlock // lock word contains a monitor |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1212 | cmpw %cx, %dx // does the thread id match? |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1213 | jne .Lslow_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1214 | movl %ecx, %edx // copy the lock word to detect new count of 0. |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1215 | andl LITERAL(LOCK_WORD_GC_STATE_MASK_SHIFTED_TOGGLED), %edx // zero the gc bits. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1216 | cmpl LITERAL(LOCK_WORD_THIN_LOCK_COUNT_ONE), %edx |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1217 | jae .Lrecursive_thin_unlock |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1218 | // update lockword, cmpxchg necessary for read barrier bits. |
| 1219 | movl %eax, %edx // edx: obj |
| 1220 | movl %ecx, %eax // eax: old lock word. |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 1221 | andl LITERAL(LOCK_WORD_GC_STATE_MASK_SHIFTED), %ecx // ecx: new lock word zero except original rb bits. |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1222 | #ifndef USE_READ_BARRIER |
| 1223 | movl %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%edx) |
| 1224 | #else |
| 1225 | lock cmpxchg %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%edx) // eax: old val, ecx: new val. |
| 1226 | jnz .Lunlock_cmpxchg_fail // cmpxchg failed retry |
| 1227 | #endif |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1228 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1229 | .Lrecursive_thin_unlock: // ecx: original lock word, eax: obj |
| 1230 | // update lockword, cmpxchg necessary for read barrier bits. |
| 1231 | movl %eax, %edx // edx: obj |
| 1232 | movl %ecx, %eax // eax: old lock word. |
| 1233 | subl LITERAL(LOCK_WORD_THIN_LOCK_COUNT_ONE), %ecx // ecx: new lock word with decremented count. |
| 1234 | #ifndef USE_READ_BARRIER |
| 1235 | mov %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%edx) |
| 1236 | #else |
| 1237 | lock cmpxchg %ecx, MIRROR_OBJECT_LOCK_WORD_OFFSET(%edx) // eax: old val, ecx: new val. |
| 1238 | jnz .Lunlock_cmpxchg_fail // cmpxchg failed retry |
| 1239 | #endif |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1240 | ret |
Hiroshi Yamauchi | e15ea08 | 2015-02-09 17:11:42 -0800 | [diff] [blame] | 1241 | .Lunlock_cmpxchg_fail: // edx: obj |
| 1242 | movl %edx, %eax // restore eax |
| 1243 | jmp .Lretry_unlock |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1244 | .Lslow_unlock: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1245 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1246 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1247 | subl LITERAL(8), %esp // alignment padding |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1248 | CFI_ADJUST_CFA_OFFSET(8) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1249 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1250 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1251 | PUSH eax // pass object |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1252 | call SYMBOL(artUnlockObjectFromCode) // artUnlockObjectFromCode(object, Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1253 | addl LITERAL(16), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1254 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1255 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 1256 | RETURN_IF_EAX_ZERO |
| 1257 | END_FUNCTION art_quick_unlock_object |
| 1258 | |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1259 | DEFINE_FUNCTION art_quick_unlock_object_no_inline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1260 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1261 | // Outgoing argument set up |
| 1262 | subl LITERAL(8), %esp // alignment padding |
| 1263 | CFI_ADJUST_CFA_OFFSET(8) |
| 1264 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 1265 | CFI_ADJUST_CFA_OFFSET(4) |
| 1266 | PUSH eax // pass object |
| 1267 | call SYMBOL(artUnlockObjectFromCode) // artUnlockObjectFromCode(object, Thread*) |
| 1268 | addl LITERAL(16), %esp // pop arguments |
| 1269 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1270 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
Andreas Gampe | c7ed09b | 2016-04-25 20:08:55 -0700 | [diff] [blame] | 1271 | RETURN_IF_EAX_ZERO |
| 1272 | END_FUNCTION art_quick_unlock_object_no_inline |
| 1273 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1274 | DEFINE_FUNCTION art_quick_is_assignable |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1275 | PUSH eax // alignment padding |
| 1276 | PUSH ecx // pass arg2 - obj->klass |
| 1277 | PUSH eax // pass arg1 - checked class |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1278 | call SYMBOL(artIsAssignableFromCode) // (Class* klass, Class* ref_klass) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1279 | addl LITERAL(12), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1280 | CFI_ADJUST_CFA_OFFSET(-12) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1281 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1282 | END_FUNCTION art_quick_is_assignable |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1283 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1284 | DEFINE_FUNCTION art_quick_check_cast |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1285 | PUSH eax // alignment padding |
| 1286 | PUSH ecx // pass arg2 - obj->klass |
| 1287 | PUSH eax // pass arg1 - checked class |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1288 | call SYMBOL(artIsAssignableFromCode) // (Class* klass, Class* ref_klass) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1289 | testl %eax, %eax |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1290 | jz 1f // jump forward if not assignable |
| 1291 | addl LITERAL(12), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1292 | CFI_ADJUST_CFA_OFFSET(-12) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1293 | ret |
Andreas Gampe | 6b90d42 | 2015-06-26 19:49:24 -0700 | [diff] [blame] | 1294 | |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1295 | CFI_ADJUST_CFA_OFFSET(12) // Reset unwind info so following code unwinds. |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1296 | 1: |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1297 | POP eax // pop arguments |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1298 | POP ecx |
| 1299 | addl LITERAL(4), %esp |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1300 | CFI_ADJUST_CFA_OFFSET(-4) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1301 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1302 | // Outgoing argument set up |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1303 | PUSH eax // alignment padding |
| 1304 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1305 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1306 | PUSH ecx // pass arg2 |
| 1307 | PUSH eax // pass arg1 |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1308 | call SYMBOL(artThrowClassCastException) // (Class* a, Class* b, Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1309 | UNREACHABLE |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1310 | END_FUNCTION art_quick_check_cast |
| 1311 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1312 | // Restore reg's value if reg is not the same as exclude_reg, otherwise just adjust stack. |
| 1313 | MACRO2(POP_REG_NE, reg, exclude_reg) |
| 1314 | .ifc RAW_VAR(reg), RAW_VAR(exclude_reg) |
| 1315 | addl MACRO_LITERAL(4), %esp |
| 1316 | CFI_ADJUST_CFA_OFFSET(-4) |
| 1317 | .else |
| 1318 | POP RAW_VAR(reg) |
| 1319 | .endif |
| 1320 | END_MACRO |
| 1321 | |
| 1322 | /* |
| 1323 | * Macro to insert read barrier, only used in art_quick_aput_obj. |
| 1324 | * obj_reg and dest_reg are registers, offset is a defined literal such as |
| 1325 | * MIRROR_OBJECT_CLASS_OFFSET. |
| 1326 | * pop_eax is a boolean flag, indicating if eax is popped after the call. |
| 1327 | * TODO: When read barrier has a fast path, add heap unpoisoning support for the fast path. |
| 1328 | */ |
| 1329 | MACRO4(READ_BARRIER, obj_reg, offset, dest_reg, pop_eax) |
| 1330 | #ifdef USE_READ_BARRIER |
| 1331 | PUSH eax // save registers used in art_quick_aput_obj |
| 1332 | PUSH ebx |
| 1333 | PUSH edx |
| 1334 | PUSH ecx |
| 1335 | // Outgoing argument set up |
| 1336 | pushl MACRO_LITERAL((RAW_VAR(offset))) // pass offset, double parentheses are necessary |
| 1337 | CFI_ADJUST_CFA_OFFSET(4) |
| 1338 | PUSH RAW_VAR(obj_reg) // pass obj_reg |
| 1339 | PUSH eax // pass ref, just pass eax for now since parameter ref is unused |
| 1340 | call SYMBOL(artReadBarrierSlow) // artReadBarrierSlow(ref, obj_reg, offset) |
| 1341 | // No need to unpoison return value in eax, artReadBarrierSlow() would do the unpoisoning. |
| 1342 | .ifnc RAW_VAR(dest_reg), eax |
| 1343 | movl %eax, REG_VAR(dest_reg) // save loaded ref in dest_reg |
| 1344 | .endif |
| 1345 | addl MACRO_LITERAL(12), %esp // pop arguments |
| 1346 | CFI_ADJUST_CFA_OFFSET(-12) |
| 1347 | POP_REG_NE ecx, RAW_VAR(dest_reg) // Restore args except dest_reg |
| 1348 | POP_REG_NE edx, RAW_VAR(dest_reg) |
| 1349 | POP_REG_NE ebx, RAW_VAR(dest_reg) |
| 1350 | .ifc RAW_VAR(pop_eax), true |
| 1351 | POP_REG_NE eax, RAW_VAR(dest_reg) |
| 1352 | .endif |
| 1353 | #else |
| 1354 | movl RAW_VAR(offset)(REG_VAR(obj_reg)), REG_VAR(dest_reg) |
| 1355 | UNPOISON_HEAP_REF RAW_VAR(dest_reg) |
| 1356 | #endif // USE_READ_BARRIER |
| 1357 | END_MACRO |
| 1358 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1359 | /* |
| 1360 | * Entry from managed code for array put operations of objects where the value being stored |
| 1361 | * needs to be checked for compatibility. |
| 1362 | * eax = array, ecx = index, edx = value |
| 1363 | */ |
| 1364 | DEFINE_FUNCTION art_quick_aput_obj_with_null_and_bound_check |
| 1365 | testl %eax, %eax |
Dan Albert | 3bed41c | 2014-08-07 17:39:34 -0700 | [diff] [blame] | 1366 | jnz SYMBOL(art_quick_aput_obj_with_bound_check) |
| 1367 | jmp SYMBOL(art_quick_throw_null_pointer_exception) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1368 | END_FUNCTION art_quick_aput_obj_with_null_and_bound_check |
| 1369 | |
| 1370 | DEFINE_FUNCTION art_quick_aput_obj_with_bound_check |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1371 | movl MIRROR_ARRAY_LENGTH_OFFSET(%eax), %ebx |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1372 | cmpl %ebx, %ecx |
Dan Albert | 3bed41c | 2014-08-07 17:39:34 -0700 | [diff] [blame] | 1373 | jb SYMBOL(art_quick_aput_obj) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1374 | mov %ecx, %eax |
| 1375 | mov %ebx, %ecx |
Dan Albert | 3bed41c | 2014-08-07 17:39:34 -0700 | [diff] [blame] | 1376 | jmp SYMBOL(art_quick_throw_array_bounds) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1377 | END_FUNCTION art_quick_aput_obj_with_bound_check |
| 1378 | |
| 1379 | DEFINE_FUNCTION art_quick_aput_obj |
| 1380 | test %edx, %edx // store of null |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1381 | jz .Ldo_aput_null |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1382 | READ_BARRIER eax, MIRROR_OBJECT_CLASS_OFFSET, ebx, true |
| 1383 | READ_BARRIER ebx, MIRROR_CLASS_COMPONENT_TYPE_OFFSET, ebx, true |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1384 | // value's type == array's component type - trivial assignability |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1385 | #if defined(USE_READ_BARRIER) |
| 1386 | READ_BARRIER edx, MIRROR_OBJECT_CLASS_OFFSET, eax, false |
| 1387 | cmpl %eax, %ebx |
| 1388 | POP eax // restore eax from the push in the beginning of READ_BARRIER macro |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1389 | // This asymmetric push/pop saves a push of eax and maintains stack alignment. |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1390 | #elif defined(USE_HEAP_POISONING) |
| 1391 | PUSH eax // save eax |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1392 | movl MIRROR_OBJECT_CLASS_OFFSET(%edx), %eax |
| 1393 | UNPOISON_HEAP_REF eax |
| 1394 | cmpl %eax, %ebx |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 1395 | POP eax // restore eax |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1396 | #else |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1397 | cmpl MIRROR_OBJECT_CLASS_OFFSET(%edx), %ebx |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1398 | #endif |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1399 | jne .Lcheck_assignability |
| 1400 | .Ldo_aput: |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1401 | POISON_HEAP_REF edx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1402 | movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1403 | movl %fs:THREAD_CARD_TABLE_OFFSET, %edx |
| 1404 | shrl LITERAL(7), %eax |
| 1405 | movb %dl, (%edx, %eax) |
| 1406 | ret |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1407 | .Ldo_aput_null: |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1408 | movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1409 | ret |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1410 | .Lcheck_assignability: |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1411 | PUSH eax // save arguments |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1412 | PUSH ecx |
| 1413 | PUSH edx |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1414 | #if defined(USE_READ_BARRIER) |
| 1415 | subl LITERAL(4), %esp // alignment padding |
| 1416 | CFI_ADJUST_CFA_OFFSET(4) |
| 1417 | READ_BARRIER edx, MIRROR_OBJECT_CLASS_OFFSET, eax, true |
| 1418 | subl LITERAL(4), %esp // alignment padding |
| 1419 | CFI_ADJUST_CFA_OFFSET(4) |
| 1420 | PUSH eax // pass arg2 - type of the value to be stored |
| 1421 | #elif defined(USE_HEAP_POISONING) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1422 | subl LITERAL(8), %esp // alignment padding |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1423 | CFI_ADJUST_CFA_OFFSET(8) |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1424 | movl MIRROR_OBJECT_CLASS_OFFSET(%edx), %eax |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1425 | UNPOISON_HEAP_REF eax |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1426 | PUSH eax // pass arg2 - type of the value to be stored |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1427 | #else |
Man Cao | 6306921 | 2015-08-21 15:51:39 -0700 | [diff] [blame] | 1428 | subl LITERAL(8), %esp // alignment padding |
| 1429 | CFI_ADJUST_CFA_OFFSET(8) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1430 | pushl MIRROR_OBJECT_CLASS_OFFSET(%edx) // pass arg2 - type of the value to be stored |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1431 | CFI_ADJUST_CFA_OFFSET(4) |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1432 | #endif |
Mathieu Chartier | 2738639 | 2015-06-27 15:42:27 -0700 | [diff] [blame] | 1433 | PUSH ebx // pass arg1 - component type of the array |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1434 | call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b) |
Mathieu Chartier | 2738639 | 2015-06-27 15:42:27 -0700 | [diff] [blame] | 1435 | addl LITERAL(16), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1436 | CFI_ADJUST_CFA_OFFSET(-16) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1437 | testl %eax, %eax |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1438 | jz .Lthrow_array_store_exception |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1439 | POP edx |
| 1440 | POP ecx |
| 1441 | POP eax |
Hiroshi Yamauchi | bfa5eb6 | 2015-05-29 15:04:41 -0700 | [diff] [blame] | 1442 | POISON_HEAP_REF edx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1443 | movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) // do the aput |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1444 | movl %fs:THREAD_CARD_TABLE_OFFSET, %edx |
| 1445 | shrl LITERAL(7), %eax |
| 1446 | movb %dl, (%edx, %eax) |
| 1447 | ret |
Mathieu Chartier | 2738639 | 2015-06-27 15:42:27 -0700 | [diff] [blame] | 1448 | CFI_ADJUST_CFA_OFFSET(12) // 3 POP after the jz for unwinding. |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1449 | .Lthrow_array_store_exception: |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1450 | POP edx |
| 1451 | POP ecx |
| 1452 | POP eax |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1453 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx // save all registers as basis for long jump context |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1454 | // Outgoing argument set up |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1455 | PUSH eax // alignment padding |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1456 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1457 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1458 | PUSH edx // pass arg2 - value |
| 1459 | PUSH eax // pass arg1 - array |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1460 | call SYMBOL(artThrowArrayStoreException) // (array, value, Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1461 | UNREACHABLE |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1462 | END_FUNCTION art_quick_aput_obj |
| 1463 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 1464 | DEFINE_FUNCTION art_quick_memcpy |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1465 | SETUP_GOT_NOSAVE ebx // clobbers EBX |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1466 | PUSH edx // pass arg3 |
| 1467 | PUSH ecx // pass arg2 |
| 1468 | PUSH eax // pass arg1 |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1469 | call PLT_SYMBOL(memcpy) // (void*, const void*, size_t) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 1470 | addl LITERAL(12), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1471 | CFI_ADJUST_CFA_OFFSET(-12) |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1472 | ret |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1473 | END_FUNCTION art_quick_memcpy |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1474 | |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1475 | DEFINE_FUNCTION art_quick_test_suspend |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1476 | SETUP_SAVE_EVERYTHING_FRAME ebx, ebx // save everything for GC |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1477 | // Outgoing argument set up |
| 1478 | subl MACRO_LITERAL(12), %esp // push padding |
| 1479 | CFI_ADJUST_CFA_OFFSET(12) |
| 1480 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
| 1481 | CFI_ADJUST_CFA_OFFSET(4) |
Vladimir Marko | 603b7ca | 2016-08-04 16:46:51 +0100 | [diff] [blame] | 1482 | call SYMBOL(artTestSuspendFromCode) // (Thread*) |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1483 | addl MACRO_LITERAL(16), %esp // pop arguments |
| 1484 | CFI_ADJUST_CFA_OFFSET(-16) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1485 | RESTORE_SAVE_EVERYTHING_FRAME // restore frame up to return address |
Vladimir Marko | 952dbb1 | 2016-07-28 12:01:51 +0100 | [diff] [blame] | 1486 | ret // return |
| 1487 | END_FUNCTION art_quick_test_suspend |
Ian Rogers | 7caad77 | 2012-03-30 01:07:54 -0700 | [diff] [blame] | 1488 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1489 | DEFINE_FUNCTION art_quick_d2l |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1490 | subl LITERAL(12), %esp // alignment padding, room for argument |
| 1491 | CFI_ADJUST_CFA_OFFSET(12) |
| 1492 | movsd %xmm0, 0(%esp) // arg a |
| 1493 | call SYMBOL(art_d2l) // (jdouble a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1494 | addl LITERAL(12), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1495 | CFI_ADJUST_CFA_OFFSET(-12) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1496 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1497 | END_FUNCTION art_quick_d2l |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1498 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1499 | DEFINE_FUNCTION art_quick_f2l |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1500 | subl LITERAL(12), %esp // alignment padding |
| 1501 | CFI_ADJUST_CFA_OFFSET(12) |
| 1502 | movss %xmm0, 0(%esp) // arg a |
| 1503 | call SYMBOL(art_f2l) // (jfloat a) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1504 | addl LITERAL(12), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1505 | CFI_ADJUST_CFA_OFFSET(-12) |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1506 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1507 | END_FUNCTION art_quick_f2l |
jeffhao | 41005dd | 2012-05-09 17:58:52 -0700 | [diff] [blame] | 1508 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1509 | DEFINE_FUNCTION art_quick_ldiv |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1510 | subl LITERAL(12), %esp // alignment padding |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1511 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1512 | PUSH ebx // pass arg4 b.hi |
| 1513 | PUSH edx // pass arg3 b.lo |
| 1514 | PUSH ecx // pass arg2 a.hi |
| 1515 | PUSH eax // pass arg1 a.lo |
| 1516 | call SYMBOL(artLdiv) // (jlong a, jlong b) |
| 1517 | addl LITERAL(28), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1518 | CFI_ADJUST_CFA_OFFSET(-28) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 1519 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1520 | END_FUNCTION art_quick_ldiv |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 1521 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1522 | DEFINE_FUNCTION art_quick_lmod |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1523 | subl LITERAL(12), %esp // alignment padding |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1524 | CFI_ADJUST_CFA_OFFSET(12) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1525 | PUSH ebx // pass arg4 b.hi |
| 1526 | PUSH edx // pass arg3 b.lo |
| 1527 | PUSH ecx // pass arg2 a.hi |
| 1528 | PUSH eax // pass arg1 a.lo |
| 1529 | call SYMBOL(artLmod) // (jlong a, jlong b) |
| 1530 | addl LITERAL(28), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1531 | CFI_ADJUST_CFA_OFFSET(-28) |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 1532 | ret |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 1533 | END_FUNCTION art_quick_lmod |
Ian Rogers | 55bd45f | 2012-04-04 17:31:20 -0700 | [diff] [blame] | 1534 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1535 | DEFINE_FUNCTION art_quick_lmul |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1536 | imul %eax, %ebx // ebx = a.lo(eax) * b.hi(ebx) |
| 1537 | imul %edx, %ecx // ecx = b.lo(edx) * a.hi(ecx) |
| 1538 | mul %edx // edx:eax = a.lo(eax) * b.lo(edx) |
Ian Rogers | 5793fea | 2013-02-14 13:33:34 -0800 | [diff] [blame] | 1539 | add %ebx, %ecx |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1540 | add %ecx, %edx // edx += (a.lo * b.hi) + (b.lo * a.hi) |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1541 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1542 | END_FUNCTION art_quick_lmul |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1543 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1544 | DEFINE_FUNCTION art_quick_lshl |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1545 | // ecx:eax << edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1546 | xchg %edx, %ecx |
| 1547 | shld %cl,%eax,%edx |
| 1548 | shl %cl,%eax |
| 1549 | test LITERAL(32), %cl |
| 1550 | jz 1f |
| 1551 | mov %eax, %edx |
| 1552 | xor %eax, %eax |
| 1553 | 1: |
| 1554 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1555 | END_FUNCTION art_quick_lshl |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1556 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1557 | DEFINE_FUNCTION art_quick_lshr |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1558 | // ecx:eax >> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1559 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1560 | shrd %cl,%edx,%eax |
| 1561 | sar %cl,%edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1562 | test LITERAL(32),%cl |
| 1563 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 1564 | mov %edx, %eax |
| 1565 | sar LITERAL(31), %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1566 | 1: |
| 1567 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1568 | END_FUNCTION art_quick_lshr |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1569 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1570 | DEFINE_FUNCTION art_quick_lushr |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1571 | // ecx:eax >>> edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1572 | xchg %edx, %ecx |
jeffhao | 644d531 | 2012-05-03 19:04:49 -0700 | [diff] [blame] | 1573 | shrd %cl,%edx,%eax |
| 1574 | shr %cl,%edx |
| 1575 | test LITERAL(32),%cl |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1576 | jz 1f |
jeffhao | 5121e0b | 2012-05-08 18:23:38 -0700 | [diff] [blame] | 1577 | mov %edx, %eax |
| 1578 | xor %edx, %edx |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1579 | 1: |
| 1580 | ret |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1581 | END_FUNCTION art_quick_lushr |
Ian Rogers | 141d622 | 2012-04-05 12:23:06 -0700 | [diff] [blame] | 1582 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1583 | ONE_ARG_REF_DOWNCALL art_quick_get_boolean_static, artGetBooleanStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1584 | ONE_ARG_REF_DOWNCALL art_quick_get_byte_static, artGetByteStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1585 | ONE_ARG_REF_DOWNCALL art_quick_get_char_static, artGetCharStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1586 | ONE_ARG_REF_DOWNCALL art_quick_get_short_static, artGetShortStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1587 | ONE_ARG_REF_DOWNCALL art_quick_get32_static, artGet32StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1588 | ONE_ARG_REF_DOWNCALL art_quick_get64_static, artGet64StaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1589 | ONE_ARG_REF_DOWNCALL art_quick_get_obj_static, artGetObjStaticFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1590 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1591 | TWO_ARG_REF_DOWNCALL art_quick_get_boolean_instance, artGetBooleanInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1592 | TWO_ARG_REF_DOWNCALL art_quick_get_byte_instance, artGetByteInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1593 | TWO_ARG_REF_DOWNCALL art_quick_get_char_instance, artGetCharInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1594 | TWO_ARG_REF_DOWNCALL art_quick_get_short_instance, artGetShortInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1595 | TWO_ARG_REF_DOWNCALL art_quick_get32_instance, artGet32InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1596 | TWO_ARG_REF_DOWNCALL art_quick_get64_instance, artGet64InstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
| 1597 | TWO_ARG_REF_DOWNCALL art_quick_get_obj_instance, artGetObjInstanceFromCode, RETURN_OR_DELIVER_PENDING_EXCEPTION |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 1598 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1599 | TWO_ARG_REF_DOWNCALL art_quick_set8_static, artSet8StaticFromCode, RETURN_IF_EAX_ZERO |
| 1600 | TWO_ARG_REF_DOWNCALL art_quick_set16_static, artSet16StaticFromCode, RETURN_IF_EAX_ZERO |
| 1601 | TWO_ARG_REF_DOWNCALL art_quick_set32_static, artSet32StaticFromCode, RETURN_IF_EAX_ZERO |
| 1602 | TWO_ARG_REF_DOWNCALL art_quick_set_obj_static, artSetObjStaticFromCode, RETURN_IF_EAX_ZERO |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1603 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1604 | THREE_ARG_REF_DOWNCALL art_quick_set8_instance, artSet8InstanceFromCode, RETURN_IF_EAX_ZERO |
| 1605 | THREE_ARG_REF_DOWNCALL art_quick_set16_instance, artSet16InstanceFromCode, RETURN_IF_EAX_ZERO |
| 1606 | THREE_ARG_REF_DOWNCALL art_quick_set32_instance, artSet32InstanceFromCode, RETURN_IF_EAX_ZERO |
| 1607 | THREE_ARG_REF_DOWNCALL art_quick_set_obj_instance, artSetObjInstanceFromCode, RETURN_IF_EAX_ZERO |
| 1608 | |
| 1609 | // Call artSet64InstanceFromCode with 4 word size arguments and the referrer. |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1610 | DEFINE_FUNCTION art_quick_set64_instance |
Serguei Katkov | e0b46a7 | 2014-11-05 16:13:18 +0600 | [diff] [blame] | 1611 | movd %ebx, %xmm0 |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1612 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Serguei Katkov | e0b46a7 | 2014-11-05 16:13:18 +0600 | [diff] [blame] | 1613 | movd %xmm0, %ebx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1614 | // Outgoing argument set up |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 1615 | subl LITERAL(8), %esp // alignment padding |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1616 | CFI_ADJUST_CFA_OFFSET(8) |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1617 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1618 | CFI_ADJUST_CFA_OFFSET(4) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1619 | pushl (FRAME_SIZE_SAVE_REFS_ONLY+12)(%esp) // pass referrer |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1620 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1621 | PUSH ebx // pass high half of new_val |
| 1622 | PUSH edx // pass low half of new_val |
| 1623 | PUSH ecx // pass object |
| 1624 | PUSH eax // pass field_idx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1625 | call SYMBOL(artSet64InstanceFromCode) // (field_idx, Object*, new_val, referrer, Thread*) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 1626 | addl LITERAL(32), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1627 | CFI_ADJUST_CFA_OFFSET(-32) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1628 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1629 | RETURN_IF_EAX_ZERO // return or deliver exception |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1630 | END_FUNCTION art_quick_set64_instance |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1631 | |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1632 | // Call artSet64StaticFromCode with 3 word size arguments plus with the referrer in the 2nd position |
| 1633 | // so that new_val is aligned on even registers were we passing arguments in registers. |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1634 | DEFINE_FUNCTION art_quick_set64_static |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 1635 | // TODO: Implement SETUP_GOT_NOSAVE for got_reg = ecx to avoid moving around the registers. |
| 1636 | movd %ebx, %xmm0 |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1637 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx // save ref containing registers for GC |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 1638 | movd %xmm0, %ebx |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1639 | mov FRAME_SIZE_SAVE_REFS_ONLY(%esp), %ecx // get referrer |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1640 | subl LITERAL(12), %esp // alignment padding |
| 1641 | CFI_ADJUST_CFA_OFFSET(12) |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1642 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1643 | CFI_ADJUST_CFA_OFFSET(4) |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame] | 1644 | PUSH ebx // pass high half of new_val |
| 1645 | PUSH edx // pass low half of new_val |
| 1646 | PUSH ecx // pass referrer |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1647 | PUSH eax // pass field_idx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1648 | call SYMBOL(artSet64StaticFromCode) // (field_idx, referrer, new_val, Thread*) |
jeffhao | 1ff4cd7 | 2012-05-21 11:17:48 -0700 | [diff] [blame] | 1649 | addl LITERAL(32), %esp // pop arguments |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1650 | CFI_ADJUST_CFA_OFFSET(-32) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1651 | RESTORE_SAVE_REFS_ONLY_FRAME // restore frame up to return address |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1652 | RETURN_IF_EAX_ZERO // return or deliver exception |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1653 | END_FUNCTION art_quick_set64_static |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1654 | |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 1655 | DEFINE_FUNCTION art_quick_proxy_invoke_handler |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1656 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_EAX |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1657 | PUSH esp // pass SP |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 1658 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1659 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1660 | PUSH ecx // pass receiver |
| 1661 | PUSH eax // pass proxy method |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1662 | call SYMBOL(artQuickProxyInvokeHandler) // (proxy method, receiver, Thread*, SP) |
Ian Rogers | af6e67a | 2013-01-16 08:38:37 -0800 | [diff] [blame] | 1663 | movd %eax, %xmm0 // place return value also into floating point return value |
| 1664 | movd %edx, %xmm1 |
| 1665 | punpckldq %xmm1, %xmm0 |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1666 | addl LITERAL(16 + FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY), %esp |
| 1667 | CFI_ADJUST_CFA_OFFSET(-(16 + FRAME_SIZE_SAVE_REFS_AND_ARGS - FRAME_SIZE_SAVE_REFS_ONLY)) |
| 1668 | RESTORE_SAVE_REFS_ONLY_FRAME |
jeffhao | d66a875 | 2012-05-22 15:30:16 -0700 | [diff] [blame] | 1669 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1670 | END_FUNCTION art_quick_proxy_invoke_handler |
jeffhao | 9dbb23e | 2012-05-18 17:03:57 -0700 | [diff] [blame] | 1671 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1672 | /* |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 1673 | * Called to resolve an imt conflict. |
| 1674 | * eax is the conflict ArtMethod. |
| 1675 | * xmm7 is a hidden argument that holds the target interface method's dex method index. |
| 1676 | * |
| 1677 | * Note that this stub writes to eax. |
| 1678 | * Because of lack of free registers, it also saves and restores edi. |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1679 | */ |
| 1680 | DEFINE_FUNCTION art_quick_imt_conflict_trampoline |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 1681 | PUSH EDI |
| 1682 | movl 8(%esp), %edi // Load referrer |
| 1683 | movl ART_METHOD_DEX_CACHE_METHODS_OFFSET_32(%edi), %edi // Load dex cache methods array |
| 1684 | pushl ART_METHOD_JNI_OFFSET_32(%eax) // Push ImtConflictTable. |
| 1685 | CFI_ADJUST_CFA_OFFSET(4) |
Nicolas Geoffray | 8ea18d0 | 2015-05-26 16:29:08 +0100 | [diff] [blame] | 1686 | movd %xmm7, %eax // get target method index stored in xmm7 |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 1687 | movl 0(%edi, %eax, __SIZEOF_POINTER__), %edi // Load interface method |
| 1688 | popl %eax // Pop ImtConflictTable. |
| 1689 | CFI_ADJUST_CFA_OFFSET(-4) |
| 1690 | .Limt_table_iterate: |
| 1691 | cmpl %edi, 0(%eax) |
| 1692 | jne .Limt_table_next_entry |
Goran Jakovljevic | 59028d9 | 2016-03-29 18:05:03 +0200 | [diff] [blame] | 1693 | // We successfully hit an entry in the table. Load the target method |
Nicolas Geoffray | 796d630 | 2016-03-13 22:22:31 +0000 | [diff] [blame] | 1694 | // and jump to it. |
| 1695 | POP EDI |
| 1696 | movl __SIZEOF_POINTER__(%eax), %eax |
| 1697 | jmp *ART_METHOD_QUICK_CODE_OFFSET_32(%eax) |
| 1698 | .Limt_table_next_entry: |
| 1699 | // If the entry is null, the interface method is not in the ImtConflictTable. |
| 1700 | cmpl LITERAL(0), 0(%eax) |
| 1701 | jz .Lconflict_trampoline |
| 1702 | // Iterate over the entries of the ImtConflictTable. |
| 1703 | addl LITERAL(2 * __SIZEOF_POINTER__), %eax |
| 1704 | jmp .Limt_table_iterate |
| 1705 | .Lconflict_trampoline: |
| 1706 | // Call the runtime stub to populate the ImtConflictTable and jump to the |
| 1707 | // resolved method. |
| 1708 | POP EDI |
Andreas Gampe | 55978b8 | 2015-07-14 17:57:43 -0700 | [diff] [blame] | 1709 | INVOKE_TRAMPOLINE_BODY artInvokeInterfaceTrampoline |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1710 | END_FUNCTION art_quick_imt_conflict_trampoline |
| 1711 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1712 | DEFINE_FUNCTION art_quick_resolution_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1713 | SETUP_SAVE_REFS_AND_ARGS_FRAME ebx, ebx |
Tong Shen | 35e1e6a | 2014-07-30 09:31:22 -0700 | [diff] [blame] | 1714 | movl %esp, %edi |
| 1715 | PUSH EDI // pass SP. do not just PUSH ESP; that messes up unwinding |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1716 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1717 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1718 | PUSH ecx // pass receiver |
| 1719 | PUSH eax // pass method |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1720 | call SYMBOL(artQuickResolutionTrampoline) // (Method* called, receiver, Thread*, SP) |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1721 | movl %eax, %edi // remember code pointer in EDI |
| 1722 | addl LITERAL(16), %esp // pop arguments |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1723 | CFI_ADJUST_CFA_OFFSET(-16) |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1724 | test %eax, %eax // if code pointer is null goto deliver pending exception |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1725 | jz 1f |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1726 | RESTORE_SAVE_REFS_AND_ARGS_FRAME_AND_JUMP |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1727 | 1: |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1728 | RESTORE_SAVE_REFS_AND_ARGS_FRAME |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1729 | DELIVER_PENDING_EXCEPTION |
| 1730 | END_FUNCTION art_quick_resolution_trampoline |
| 1731 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 1732 | DEFINE_FUNCTION art_quick_generic_jni_trampoline |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1733 | SETUP_SAVE_REFS_AND_ARGS_FRAME_WITH_METHOD_IN_EAX |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1734 | movl %esp, %ebp // save SP at callee-save frame |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1735 | CFI_DEF_CFA_REGISTER(ebp) |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1736 | subl LITERAL(5120), %esp |
| 1737 | // prepare for artQuickGenericJniTrampoline call |
| 1738 | // (Thread*, SP) |
| 1739 | // (esp) 4(esp) <= C calling convention |
| 1740 | // fs:... ebp <= where they are |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1741 | |
| 1742 | subl LITERAL(8), %esp // Padding for 16B alignment. |
| 1743 | pushl %ebp // Pass SP (to ArtMethod). |
| 1744 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1745 | call SYMBOL(artQuickGenericJniTrampoline) // (Thread*, sp) |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1746 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1747 | // The C call will have registered the complete save-frame on success. |
| 1748 | // The result of the call is: |
| 1749 | // eax: pointer to native code, 0 on error. |
| 1750 | // edx: pointer to the bottom of the used area of the alloca, can restore stack till there. |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1751 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1752 | // Check for error = 0. |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1753 | test %eax, %eax |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1754 | jz .Lexception_in_native |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1755 | |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1756 | // Release part of the alloca. |
| 1757 | movl %edx, %esp |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1758 | |
| 1759 | // On x86 there are no registers passed, so nothing to pop here. |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1760 | // Native call. |
| 1761 | call *%eax |
| 1762 | |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1763 | // result sign extension is handled in C code |
| 1764 | // prepare for artQuickGenericJniEndTrampoline call |
Andreas Gampe | c200a4a | 2014-06-16 18:39:09 -0700 | [diff] [blame] | 1765 | // (Thread*, result, result_f) |
| 1766 | // (esp) 4(esp) 12(esp) <= C calling convention |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 1767 | // fs:... eax:edx fp0 <= where they are |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1768 | |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1769 | subl LITERAL(20), %esp // Padding & pass float result. |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 1770 | fstpl (%esp) |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1771 | pushl %edx // Pass int result. |
| 1772 | pushl %eax |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1773 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1774 | call SYMBOL(artQuickGenericJniEndTrampoline) |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1775 | |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1776 | // Pending exceptions possible. |
| 1777 | mov %fs:THREAD_EXCEPTION_OFFSET, %ebx |
| 1778 | testl %ebx, %ebx |
| 1779 | jnz .Lexception_in_native |
| 1780 | |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1781 | // Tear down the alloca. |
| 1782 | movl %ebp, %esp |
| 1783 | CFI_DEF_CFA_REGISTER(esp) |
| 1784 | |
| 1785 | |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1786 | // Tear down the callee-save frame. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1787 | // Remove space for FPR args and EAX |
| 1788 | addl LITERAL(4 + 4 * 8), %esp |
| 1789 | CFI_ADJUST_CFA_OFFSET(-(4 + 4 * 8)) |
| 1790 | |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1791 | POP ecx |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1792 | addl LITERAL(4), %esp // Avoid edx, as it may be part of the result. |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1793 | CFI_ADJUST_CFA_OFFSET(-4) |
| 1794 | POP ebx |
| 1795 | POP ebp // Restore callee saves |
| 1796 | POP esi |
| 1797 | POP edi |
Nicolas Geoffray | 54accbc | 2014-08-13 03:40:45 +0100 | [diff] [blame] | 1798 | // Quick expects the return value to be in xmm0. |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1799 | movd %eax, %xmm0 |
| 1800 | movd %edx, %xmm1 |
| 1801 | punpckldq %xmm1, %xmm0 |
| 1802 | ret |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1803 | .Lexception_in_native: |
Nicolas Geoffray | 126d659 | 2015-03-03 14:28:35 +0000 | [diff] [blame] | 1804 | movl %fs:THREAD_TOP_QUICK_FRAME_OFFSET, %esp |
| 1805 | // Do a call to push a new save-all frame required by the runtime. |
| 1806 | call .Lexception_call |
| 1807 | .Lexception_call: |
Andreas Gampe | 779f8c9 | 2014-06-09 18:29:38 -0700 | [diff] [blame] | 1808 | DELIVER_PENDING_EXCEPTION |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 1809 | END_FUNCTION art_quick_generic_jni_trampoline |
| 1810 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 1811 | DEFINE_FUNCTION art_quick_to_interpreter_bridge |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1812 | SETUP_SAVE_REFS_AND_ARGS_FRAME ebx, ebx // save frame |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1813 | mov %esp, %edx // remember SP |
| 1814 | PUSH eax // alignment padding |
| 1815 | PUSH edx // pass SP |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 1816 | pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1817 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1818 | PUSH eax // pass method |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1819 | call SYMBOL(artQuickToInterpreterBridge) // (method, Thread*, SP) |
Vladimir Marko | 949c91f | 2015-01-27 10:48:44 +0000 | [diff] [blame] | 1820 | addl LITERAL(16), %esp // pop arguments |
| 1821 | CFI_ADJUST_CFA_OFFSET(-16) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1822 | |
| 1823 | // Return eax:edx in xmm0 also. |
| 1824 | movd %eax, %xmm0 |
| 1825 | movd %edx, %xmm1 |
| 1826 | punpckldq %xmm1, %xmm0 |
| 1827 | |
| 1828 | addl LITERAL(48), %esp // Remove FPRs and EAX, ECX, EDX, EBX. |
| 1829 | CFI_ADJUST_CFA_OFFSET(-48) |
| 1830 | |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1831 | POP ebp // Restore callee saves |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1832 | POP esi |
| 1833 | POP edi |
| 1834 | |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 1835 | RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1836 | END_FUNCTION art_quick_to_interpreter_bridge |
Ian Rogers | 7db619b | 2013-01-16 18:35:48 -0800 | [diff] [blame] | 1837 | |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 1838 | /* |
| 1839 | * Routine that intercepts method calls and returns. |
| 1840 | */ |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1841 | DEFINE_FUNCTION art_quick_instrumentation_entry |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1842 | SETUP_SAVE_REFS_AND_ARGS_FRAME ebx, edx |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1843 | PUSH eax // Save eax which will be clobbered by the callee-save method. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1844 | subl LITERAL(12), %esp // Align stack. |
| 1845 | CFI_ADJUST_CFA_OFFSET(12) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1846 | pushl FRAME_SIZE_SAVE_REFS_AND_ARGS-4+16(%esp) // Pass LR. |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1847 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1848 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1849 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1850 | PUSH ecx // Pass receiver. |
| 1851 | PUSH eax // Pass Method*. |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1852 | call SYMBOL(artInstrumentationMethodEntryFromCode) // (Method*, Object*, Thread*, LR) |
Elliott Hughes | 7ac7e32 | 2014-06-27 17:20:59 -0700 | [diff] [blame] | 1853 | addl LITERAL(28), %esp // Pop arguments upto saved Method*. |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1854 | CFI_ADJUST_CFA_OFFSET(-28) |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1855 | movl 60(%esp), %edi // Restore edi. |
| 1856 | movl %eax, 60(%esp) // Place code* over edi, just under return pc. |
Elliott Hughes | 7ac7e32 | 2014-06-27 17:20:59 -0700 | [diff] [blame] | 1857 | movl SYMBOL(art_quick_instrumentation_exit)@GOT(%ebx), %ebx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1858 | // Place instrumentation exit as return pc. ebx holds the GOT computed on entry. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1859 | movl %ebx, 64(%esp) |
| 1860 | movl 0(%esp), %eax // Restore eax. |
| 1861 | // Restore FPRs (extra 4 bytes of offset due to EAX push at top). |
| 1862 | movsd 8(%esp), %xmm0 |
| 1863 | movsd 16(%esp), %xmm1 |
| 1864 | movsd 24(%esp), %xmm2 |
| 1865 | movsd 32(%esp), %xmm3 |
| 1866 | |
| 1867 | // Restore GPRs. |
| 1868 | movl 40(%esp), %ecx // Restore ecx. |
Sebastien Hertz | f551d1b | 2015-02-19 10:30:48 +0100 | [diff] [blame] | 1869 | movl 44(%esp), %edx // Restore edx. |
Mark P Mendell | 966c3ae | 2015-01-27 15:45:27 +0000 | [diff] [blame] | 1870 | movl 48(%esp), %ebx // Restore ebx. |
| 1871 | movl 52(%esp), %ebp // Restore ebp. |
| 1872 | movl 56(%esp), %esi // Restore esi. |
| 1873 | addl LITERAL(60), %esp // Wind stack back upto code*. |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1874 | CFI_ADJUST_CFA_OFFSET(-60) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1875 | ret // Call method (and pop). |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1876 | END_FUNCTION art_quick_instrumentation_entry |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1877 | |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1878 | DEFINE_FUNCTION art_quick_instrumentation_exit |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1879 | pushl LITERAL(0) // Push a fake return PC as there will be none on the stack. |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1880 | CFI_ADJUST_CFA_OFFSET(4) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1881 | SETUP_SAVE_REFS_ONLY_FRAME ebx, ebx |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1882 | mov %esp, %ecx // Remember SP |
| 1883 | subl LITERAL(8), %esp // Save float return value. |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1884 | CFI_ADJUST_CFA_OFFSET(8) |
Andreas Gampe | fea2901 | 2014-07-23 10:05:02 -0700 | [diff] [blame] | 1885 | movq %xmm0, (%esp) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1886 | PUSH edx // Save gpr return value. |
| 1887 | PUSH eax |
Jeff Hao | cf2e7b0 | 2014-07-22 18:38:42 -0700 | [diff] [blame] | 1888 | subl LITERAL(16), %esp // Align stack |
| 1889 | CFI_ADJUST_CFA_OFFSET(16) |
Andreas Gampe | fea2901 | 2014-07-23 10:05:02 -0700 | [diff] [blame] | 1890 | movq %xmm0, (%esp) // Pass float return value. |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1891 | PUSH edx // Pass gpr return value. |
| 1892 | PUSH eax |
| 1893 | PUSH ecx // Pass SP. |
| 1894 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current. |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1895 | CFI_ADJUST_CFA_OFFSET(4) |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 1896 | call SYMBOL(artInstrumentationMethodExitFromCode) // (Thread*, SP, gpr_result, fpr_result) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1897 | mov %eax, %ecx // Move returned link register. |
| 1898 | addl LITERAL(32), %esp // Pop arguments. |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1899 | CFI_ADJUST_CFA_OFFSET(-32) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1900 | movl %edx, %ebx // Move returned link register for deopt |
| 1901 | // (ebx is pretending to be our LR). |
| 1902 | POP eax // Restore gpr return value. |
| 1903 | POP edx |
Andreas Gampe | fea2901 | 2014-07-23 10:05:02 -0700 | [diff] [blame] | 1904 | movq (%esp), %xmm0 // Restore fpr return value. |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1905 | addl LITERAL(8), %esp |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1906 | CFI_ADJUST_CFA_OFFSET(-8) |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1907 | RESTORE_SAVE_REFS_ONLY_FRAME |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1908 | addl LITERAL(4), %esp // Remove fake return pc. |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1909 | CFI_ADJUST_CFA_OFFSET(-4) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1910 | jmp *%ecx // Return. |
Ian Rogers | 468532e | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 1911 | END_FUNCTION art_quick_instrumentation_exit |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 1912 | |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 1913 | /* |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1914 | * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization |
| 1915 | * will long jump to the upcall with a special exception of -1. |
jeffhao | 7e4fcb8 | 2013-01-10 18:11:08 -0800 | [diff] [blame] | 1916 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 1917 | DEFINE_FUNCTION art_quick_deoptimize |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1918 | PUSH ebx // Entry point for a jump. Fake that we were called. |
Vladimir Marko | fd36f1f | 2016-08-03 18:49:58 +0100 | [diff] [blame] | 1919 | SETUP_SAVE_ALL_CALLEE_SAVES_FRAME ebx, ebx |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1920 | subl LITERAL(12), %esp // Align stack. |
| 1921 | CFI_ADJUST_CFA_OFFSET(12) |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 1922 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). |
Mark Mendell | 3f2d031 | 2014-01-20 17:20:27 -0800 | [diff] [blame] | 1923 | CFI_ADJUST_CFA_OFFSET(4) |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1924 | call SYMBOL(artDeoptimize) // artDeoptimize(Thread*) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1925 | UNREACHABLE |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1926 | END_FUNCTION art_quick_deoptimize |
jeffhao | 162fd33 | 2013-01-08 16:21:01 -0800 | [diff] [blame] | 1927 | |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1928 | /* |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 1929 | * Compiled code has requested that we deoptimize into the interpreter. The deoptimization |
Andreas Gampe | 639bdd1 | 2015-06-03 11:22:45 -0700 | [diff] [blame] | 1930 | * will long jump to the interpreter bridge. |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 1931 | */ |
| 1932 | DEFINE_FUNCTION art_quick_deoptimize_from_compiled_code |
Vladimir Marko | 239d6ea | 2016-09-05 10:44:04 +0100 | [diff] [blame^] | 1933 | SETUP_SAVE_EVERYTHING_FRAME ebx, ebx |
Sebastien Hertz | 0747466 | 2015-08-25 15:12:33 +0000 | [diff] [blame] | 1934 | subl LITERAL(12), %esp // Align stack. |
| 1935 | CFI_ADJUST_CFA_OFFSET(12) |
| 1936 | pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). |
| 1937 | CFI_ADJUST_CFA_OFFSET(4) |
| 1938 | call SYMBOL(artDeoptimizeFromCompiledCode) // artDeoptimizeFromCompiledCode(Thread*) |
| 1939 | UNREACHABLE |
| 1940 | END_FUNCTION art_quick_deoptimize_from_compiled_code |
| 1941 | |
| 1942 | /* |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1943 | * String's compareTo. |
| 1944 | * |
| 1945 | * On entry: |
| 1946 | * eax: this string object (known non-null) |
| 1947 | * ecx: comp string object (known non-null) |
| 1948 | */ |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 1949 | DEFINE_FUNCTION art_quick_string_compareto |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1950 | PUSH esi // push callee save reg |
| 1951 | PUSH edi // push callee save reg |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1952 | mov MIRROR_STRING_COUNT_OFFSET(%eax), %edx |
| 1953 | mov MIRROR_STRING_COUNT_OFFSET(%ecx), %ebx |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1954 | lea MIRROR_STRING_VALUE_OFFSET(%eax), %esi |
| 1955 | lea MIRROR_STRING_VALUE_OFFSET(%ecx), %edi |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1956 | /* Calculate min length and count diff */ |
| 1957 | mov %edx, %ecx |
| 1958 | mov %edx, %eax |
| 1959 | subl %ebx, %eax |
| 1960 | cmovg %ebx, %ecx |
| 1961 | /* |
| 1962 | * At this point we have: |
| 1963 | * eax: value to return if first part of strings are equal |
| 1964 | * ecx: minimum among the lengths of the two strings |
| 1965 | * esi: pointer to this string data |
| 1966 | * edi: pointer to comp string data |
| 1967 | */ |
Alexei Zavjalov | 4554bfd | 2014-02-26 17:28:35 +0700 | [diff] [blame] | 1968 | jecxz .Lkeep_length |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1969 | repe cmpsw // find nonmatching chars in [%esi] and [%edi], up to length %ecx |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1970 | jne .Lnot_equal |
Alexei Zavjalov | 4554bfd | 2014-02-26 17:28:35 +0700 | [diff] [blame] | 1971 | .Lkeep_length: |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1972 | POP edi // pop callee save reg |
| 1973 | POP esi // pop callee save reg |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1974 | ret |
| 1975 | .balign 16 |
Ian Rogers | 8016a12 | 2014-02-21 20:37:21 -0800 | [diff] [blame] | 1976 | .Lnot_equal: |
Ian Rogers | 1b09b09 | 2012-08-20 15:35:52 -0700 | [diff] [blame] | 1977 | movzwl -2(%esi), %eax // get last compared char from this string |
| 1978 | movzwl -2(%edi), %ecx // get last compared char from comp string |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1979 | subl %ecx, %eax // return the difference |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1980 | POP edi // pop callee save reg |
| 1981 | POP esi // pop callee save reg |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1982 | ret |
Ian Rogers | aeeada4 | 2013-02-13 11:28:34 -0800 | [diff] [blame] | 1983 | END_FUNCTION art_quick_string_compareto |
jeffhao | 86e4671 | 2012-08-08 17:30:59 -0700 | [diff] [blame] | 1984 | |
Dave Allison | 8ce6b90 | 2014-08-26 11:07:58 -0700 | [diff] [blame] | 1985 | // Return from a nested signal: |
| 1986 | // Entry: |
| 1987 | // eax: address of jmp_buf in TLS |
| 1988 | |
| 1989 | DEFINE_FUNCTION art_nested_signal_return |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 1990 | SETUP_GOT_NOSAVE ebx // sets %ebx for call into PLT |
Dave Allison | 8ce6b90 | 2014-08-26 11:07:58 -0700 | [diff] [blame] | 1991 | movl LITERAL(1), %ecx |
Christopher Ferris | 9f5e1d9 | 2015-07-13 12:21:00 -0700 | [diff] [blame] | 1992 | PUSH ecx // second arg to longjmp (1) |
| 1993 | PUSH eax // first arg to longjmp (jmp_buf) |
Dave Allison | 8ce6b90 | 2014-08-26 11:07:58 -0700 | [diff] [blame] | 1994 | call PLT_SYMBOL(longjmp) |
Andreas Gampe | 4360be2 | 2015-07-14 23:34:44 -0700 | [diff] [blame] | 1995 | UNREACHABLE |
Dave Allison | 8ce6b90 | 2014-08-26 11:07:58 -0700 | [diff] [blame] | 1996 | END_FUNCTION art_nested_signal_return |
| 1997 | |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 1998 | // Create a function `name` calling the ReadBarrier::Mark routine, |
| 1999 | // getting its argument and returning its result through register |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2000 | // `reg`, saving and restoring all caller-save registers. |
| 2001 | // |
| 2002 | // If `reg` is different from `eax`, the generated function follows a |
| 2003 | // non-standard runtime calling convention: |
| 2004 | // - register `reg` is used to pass the (sole) argument of this function |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2005 | // (instead of EAX); |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2006 | // - register `reg` is used to return the result of this function |
| 2007 | // (instead of EAX); |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2008 | // - EAX is treated like a normal (non-argument) caller-save register; |
| 2009 | // - everything else is the same as in the standard runtime calling |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2010 | // convention (e.g. standard callee-save registers are preserved). |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2011 | MACRO2(READ_BARRIER_MARK_REG, name, reg) |
| 2012 | DEFINE_FUNCTION VAR(name) |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 2013 | // Null check so that we can load the lock word. |
| 2014 | test REG_VAR(reg), REG_VAR(reg) |
| 2015 | jz .Lret_rb_\name |
| 2016 | // Check the mark bit, if it is 1 return. |
| 2017 | testl LITERAL(LOCK_WORD_MARK_BIT_MASK_SHIFTED), MIRROR_OBJECT_LOCK_WORD_OFFSET(REG_VAR(reg)) |
| 2018 | jz .Lslow_rb_\name |
| 2019 | ret |
| 2020 | .Lslow_rb_\name: |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2021 | // Save all potentially live caller-save core registers. |
| 2022 | PUSH eax |
| 2023 | PUSH ecx |
| 2024 | PUSH edx |
| 2025 | PUSH ebx |
| 2026 | // 8-byte align the stack to improve (8-byte) XMM register saving and restoring. |
| 2027 | // and create space for caller-save floating-point registers. |
| 2028 | subl MACRO_LITERAL(4 + 8 * 8), %esp |
| 2029 | CFI_ADJUST_CFA_OFFSET(4 + 8 * 8) |
| 2030 | // Save all potentially live caller-save floating-point registers. |
| 2031 | movsd %xmm0, 0(%esp) |
| 2032 | movsd %xmm1, 8(%esp) |
| 2033 | movsd %xmm2, 16(%esp) |
| 2034 | movsd %xmm3, 24(%esp) |
| 2035 | movsd %xmm4, 32(%esp) |
| 2036 | movsd %xmm5, 40(%esp) |
| 2037 | movsd %xmm6, 48(%esp) |
| 2038 | movsd %xmm7, 56(%esp) |
| 2039 | |
| 2040 | subl LITERAL(4), %esp // alignment padding |
| 2041 | CFI_ADJUST_CFA_OFFSET(4) |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2042 | PUSH RAW_VAR(reg) // pass arg1 - obj from `reg` |
| 2043 | call SYMBOL(artReadBarrierMark) // artReadBarrierMark(obj) |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2044 | .ifnc RAW_VAR(reg), eax |
| 2045 | movl %eax, REG_VAR(reg) // return result into `reg` |
| 2046 | .endif |
| 2047 | addl LITERAL(8), %esp // pop argument and remove padding |
| 2048 | CFI_ADJUST_CFA_OFFSET(-8) |
| 2049 | |
| 2050 | // Restore floating-point registers. |
| 2051 | movsd 0(%esp), %xmm0 |
| 2052 | movsd 8(%esp), %xmm1 |
| 2053 | movsd 16(%esp), %xmm2 |
| 2054 | movsd 24(%esp), %xmm3 |
| 2055 | movsd 32(%esp), %xmm4 |
| 2056 | movsd 40(%esp), %xmm5 |
| 2057 | movsd 48(%esp), %xmm6 |
| 2058 | movsd 56(%esp), %xmm7 |
| 2059 | // Remove floating-point registers and padding. |
| 2060 | addl MACRO_LITERAL(8 * 8 + 4), %esp |
| 2061 | CFI_ADJUST_CFA_OFFSET(-(8 * 8 + 4)) |
| 2062 | // Restore core regs, except `reg`, as it is used to return the |
| 2063 | // result of this function (simply remove it from the stack instead). |
| 2064 | POP_REG_NE ebx, RAW_VAR(reg) |
| 2065 | POP_REG_NE edx, RAW_VAR(reg) |
| 2066 | POP_REG_NE ecx, RAW_VAR(reg) |
| 2067 | POP_REG_NE eax, RAW_VAR(reg) |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 2068 | .Lret_rb_\name: |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2069 | ret |
| 2070 | END_FUNCTION VAR(name) |
| 2071 | END_MACRO |
| 2072 | |
Roland Levillain | 4359e61 | 2016-07-20 11:32:19 +0100 | [diff] [blame] | 2073 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg00, eax |
Roland Levillain | 02b7580 | 2016-07-13 11:54:35 +0100 | [diff] [blame] | 2074 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg01, ecx |
| 2075 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg02, edx |
| 2076 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg03, ebx |
| 2077 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg05, ebp |
| 2078 | // Note: There is no art_quick_read_barrier_mark_reg04, as register 4 (ESP) |
| 2079 | // cannot be used to pass arguments. |
| 2080 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg06, esi |
| 2081 | READ_BARRIER_MARK_REG art_quick_read_barrier_mark_reg07, edi |
Roland Levillain | 7c1559a | 2015-12-15 10:55:36 +0000 | [diff] [blame] | 2082 | |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 2083 | DEFINE_FUNCTION art_quick_read_barrier_slow |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 2084 | PUSH edx // pass arg3 - offset |
| 2085 | PUSH ecx // pass arg2 - obj |
| 2086 | PUSH eax // pass arg1 - ref |
| 2087 | call SYMBOL(artReadBarrierSlow) // artReadBarrierSlow(ref, obj, offset) |
| 2088 | addl LITERAL(12), %esp // pop arguments |
Man Cao | 1aee900 | 2015-07-14 22:31:42 -0700 | [diff] [blame] | 2089 | CFI_ADJUST_CFA_OFFSET(-12) |
| 2090 | ret |
| 2091 | END_FUNCTION art_quick_read_barrier_slow |
| 2092 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 2093 | DEFINE_FUNCTION art_quick_read_barrier_for_root_slow |
Roland Levillain | a7821bf | 2016-06-30 16:21:31 +0100 | [diff] [blame] | 2094 | subl LITERAL(8), %esp // alignment padding |
| 2095 | CFI_ADJUST_CFA_OFFSET(8) |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 2096 | PUSH eax // pass arg1 - root |
| 2097 | call SYMBOL(artReadBarrierForRootSlow) // artReadBarrierForRootSlow(root) |
Roland Levillain | a7821bf | 2016-06-30 16:21:31 +0100 | [diff] [blame] | 2098 | addl LITERAL(12), %esp // pop argument and remove padding |
| 2099 | CFI_ADJUST_CFA_OFFSET(-12) |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 2100 | ret |
| 2101 | END_FUNCTION art_quick_read_barrier_for_root_slow |
| 2102 | |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 2103 | /* |
| 2104 | * On stack replacement stub. |
| 2105 | * On entry: |
| 2106 | * [sp] = return address |
| 2107 | * [sp + 4] = stack to copy |
| 2108 | * [sp + 8] = size of stack |
| 2109 | * [sp + 12] = pc to call |
| 2110 | * [sp + 16] = JValue* result |
| 2111 | * [sp + 20] = shorty |
| 2112 | * [sp + 24] = thread |
| 2113 | */ |
| 2114 | DEFINE_FUNCTION art_quick_osr_stub |
| 2115 | // Save native callee saves. |
| 2116 | PUSH ebp |
| 2117 | PUSH ebx |
| 2118 | PUSH esi |
| 2119 | PUSH edi |
| 2120 | mov 4+16(%esp), %esi // ESI = argument array |
| 2121 | mov 8+16(%esp), %ecx // ECX = size of args |
| 2122 | mov 12+16(%esp), %ebx // EBX = pc to call |
| 2123 | mov %esp, %ebp // Save stack pointer |
| 2124 | andl LITERAL(0xFFFFFFF0), %esp // Align stack |
| 2125 | PUSH ebp // Save old stack pointer |
| 2126 | subl LITERAL(12), %esp // Align stack |
| 2127 | movl LITERAL(0), (%esp) // Store null for ArtMethod* slot |
| 2128 | call .Losr_entry |
| 2129 | |
| 2130 | // Restore stack pointer. |
| 2131 | addl LITERAL(12), %esp |
| 2132 | POP ebp |
| 2133 | mov %ebp, %esp |
| 2134 | |
| 2135 | // Restore callee saves. |
| 2136 | POP edi |
| 2137 | POP esi |
| 2138 | POP ebx |
| 2139 | POP ebp |
| 2140 | mov 16(%esp), %ecx // Get JValue result |
| 2141 | mov %eax, (%ecx) // Store the result assuming it is a long, int or Object* |
| 2142 | mov %edx, 4(%ecx) // Store the other half of the result |
| 2143 | mov 20(%esp), %edx // Get the shorty |
| 2144 | cmpb LITERAL(68), (%edx) // Test if result type char == 'D' |
| 2145 | je .Losr_return_double_quick |
| 2146 | cmpb LITERAL(70), (%edx) // Test if result type char == 'F' |
| 2147 | je .Losr_return_float_quick |
| 2148 | ret |
| 2149 | .Losr_return_double_quick: |
| 2150 | movsd %xmm0, (%ecx) // Store the floating point result |
| 2151 | ret |
| 2152 | .Losr_return_float_quick: |
| 2153 | movss %xmm0, (%ecx) // Store the floating point result |
| 2154 | ret |
| 2155 | .Losr_entry: |
| 2156 | subl LITERAL(4), %ecx // Given stack size contains pushed frame pointer, substract it. |
| 2157 | subl %ecx, %esp |
| 2158 | mov %esp, %edi // EDI = beginning of stack |
| 2159 | rep movsb // while (ecx--) { *edi++ = *esi++ } |
| 2160 | jmp *%ebx |
| 2161 | END_FUNCTION art_quick_osr_stub |
| 2162 | |
Elliott Hughes | 787ec20 | 2012-03-29 17:14:15 -0700 | [diff] [blame] | 2163 | // TODO: implement these! |
Logan Chien | 8dbb708 | 2013-01-25 20:31:17 +0800 | [diff] [blame] | 2164 | UNIMPLEMENTED art_quick_memcmp16 |