Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * =========================================================================== |
| 3 | * Common subroutines and data |
| 4 | * =========================================================================== |
| 5 | */ |
| 6 | |
| 7 | .text |
| 8 | .align 2 |
| 9 | |
| 10 | /* |
| 11 | * We've detected a condition that will result in an exception, but the exception |
| 12 | * has not yet been thrown. Just bail out to the reference interpreter to deal with it. |
| 13 | * TUNING: for consistency, we may want to just go ahead and handle these here. |
| 14 | */ |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 15 | common_errDivideByZero: |
| 16 | EXPORT_PC |
| 17 | #if MTERP_LOGGING |
| 18 | movl rSELF, %eax |
| 19 | movl %eax, OUT_ARG0(%esp) |
| 20 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 21 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 22 | call SYMBOL(MterpLogDivideByZeroException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 23 | #endif |
| 24 | jmp MterpCommonFallback |
| 25 | |
| 26 | common_errArrayIndex: |
| 27 | EXPORT_PC |
| 28 | #if MTERP_LOGGING |
| 29 | movl rSELF, %eax |
| 30 | movl %eax, OUT_ARG0(%esp) |
| 31 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 32 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 33 | call SYMBOL(MterpLogArrayIndexException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 34 | #endif |
| 35 | jmp MterpCommonFallback |
| 36 | |
| 37 | common_errNegativeArraySize: |
| 38 | EXPORT_PC |
| 39 | #if MTERP_LOGGING |
| 40 | movl rSELF, %eax |
| 41 | movl %eax, OUT_ARG0(%esp) |
| 42 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 43 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 44 | call SYMBOL(MterpLogNegativeArraySizeException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 45 | #endif |
| 46 | jmp MterpCommonFallback |
| 47 | |
| 48 | common_errNoSuchMethod: |
| 49 | EXPORT_PC |
| 50 | #if MTERP_LOGGING |
| 51 | movl rSELF, %eax |
| 52 | movl %eax, OUT_ARG0(%esp) |
| 53 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 54 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 55 | call SYMBOL(MterpLogNoSuchMethodException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 56 | #endif |
| 57 | jmp MterpCommonFallback |
| 58 | |
| 59 | common_errNullObject: |
| 60 | EXPORT_PC |
| 61 | #if MTERP_LOGGING |
| 62 | movl rSELF, %eax |
| 63 | movl %eax, OUT_ARG0(%esp) |
| 64 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 65 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 66 | call SYMBOL(MterpLogNullObjectException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 67 | #endif |
| 68 | jmp MterpCommonFallback |
| 69 | |
| 70 | common_exceptionThrown: |
| 71 | EXPORT_PC |
| 72 | #if MTERP_LOGGING |
| 73 | movl rSELF, %eax |
| 74 | movl %eax, OUT_ARG0(%esp) |
| 75 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 76 | movl %ecx, OUT_ARG0(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 77 | call SYMBOL(MterpLogExceptionThrownException) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 78 | #endif |
| 79 | jmp MterpCommonFallback |
| 80 | |
| 81 | MterpSuspendFallback: |
| 82 | EXPORT_PC |
| 83 | #if MTERP_LOGGING |
| 84 | movl rSELF, %eax |
| 85 | movl %eax, OUT_ARG0(%esp) |
| 86 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 87 | movl %ecx, OUT_ARG0(%esp) |
| 88 | movl THREAD_FLAGS_OFFSET(%eax), %eax |
| 89 | movl %eax, OUT_ARG2(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 90 | call SYMBOL(MterpLogSuspendFallback) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 91 | #endif |
| 92 | jmp MterpCommonFallback |
| 93 | |
| 94 | /* |
| 95 | * If we're here, something is out of the ordinary. If there is a pending |
| 96 | * exception, handle it. Otherwise, roll back and retry with the reference |
| 97 | * interpreter. |
| 98 | */ |
| 99 | MterpPossibleException: |
| 100 | movl rSELF, %eax |
| 101 | testl $$-1, THREAD_EXCEPTION_OFFSET(%eax) |
| 102 | jz MterpFallback |
| 103 | /* intentional fallthrough - handle pending exception. */ |
| 104 | |
| 105 | /* |
| 106 | * On return from a runtime helper routine, we've found a pending exception. |
| 107 | * Can we handle it here - or need to bail out to caller? |
| 108 | * |
| 109 | */ |
| 110 | MterpException: |
| 111 | movl rSELF, %eax |
| 112 | movl %eax, OUT_ARG0(%esp) |
| 113 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 114 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 115 | call SYMBOL(MterpHandleException) |
Serguei Katkov | ff8579e | 2016-02-17 11:30:23 +0600 | [diff] [blame] | 116 | testb %al, %al |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 117 | jz MterpExceptionReturn |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 118 | movl OFF_FP_CODE_ITEM(rFP), %eax |
| 119 | movl OFF_FP_DEX_PC(rFP), %ecx |
| 120 | lea CODEITEM_INSNS_OFFSET(%eax), rPC |
| 121 | lea (rPC, %ecx, 2), rPC |
| 122 | movl rPC, OFF_FP_DEX_PC_PTR(rFP) |
Bill Buzbee | 481352d | 2016-02-25 17:37:46 +0000 | [diff] [blame] | 123 | /* Do we need to switch interpreters? */ |
| 124 | call SYMBOL(MterpShouldSwitchInterpreters) |
| 125 | testb %al, %al |
| 126 | jnz MterpFallback |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 127 | /* resume execution at catch block */ |
Bill Buzbee | 481352d | 2016-02-25 17:37:46 +0000 | [diff] [blame] | 128 | REFRESH_IBASE |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 129 | FETCH_INST |
| 130 | GOTO_NEXT |
| 131 | /* NOTE: no fallthrough */ |
| 132 | |
| 133 | /* |
| 134 | * Check for suspend check request. Assumes rINST already loaded, rPC advanced and |
| 135 | * still needs to get the opcode and branch to it, and flags are in lr. |
| 136 | */ |
| 137 | MterpCheckSuspendAndContinue: |
| 138 | movl rSELF, %eax |
| 139 | EXPORT_PC |
| 140 | testl $$(THREAD_SUSPEND_REQUEST | THREAD_CHECKPOINT_REQUEST), THREAD_FLAGS_OFFSET(%eax) |
| 141 | jz 1f |
| 142 | movl %eax, OUT_ARG0(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 143 | call SYMBOL(MterpSuspendCheck) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 144 | REFRESH_IBASE |
| 145 | 1: |
| 146 | GOTO_NEXT |
| 147 | |
| 148 | /* |
buzbee | 2de973d | 2016-02-23 13:25:00 -0800 | [diff] [blame] | 149 | * On-stack replacement has happened, and now we've returned from the compiled method. |
| 150 | */ |
| 151 | MterpOnStackReplacement: |
| 152 | #if MTERP_LOGGING |
| 153 | movl rSELF, %eax |
| 154 | movl %eax, OUT_ARG0(%esp) |
| 155 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 156 | movl %ecx, OUT_ARG1(%esp) |
| 157 | movl rINST, OUT_ARG2(%esp) |
| 158 | call SYMBOL(MterpLogOSR) |
| 159 | #endif |
| 160 | movl $$1, %eax |
| 161 | jmp MterpDone |
| 162 | |
| 163 | /* |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 164 | * Bail out to reference interpreter. |
| 165 | */ |
| 166 | MterpFallback: |
| 167 | EXPORT_PC |
| 168 | #if MTERP_LOGGING |
| 169 | movl rSELF, %eax |
| 170 | movl %eax, OUT_ARG0(%esp) |
| 171 | lea OFF_FP_SHADOWFRAME(rFP), %ecx |
| 172 | movl %ecx, OUT_ARG1(%esp) |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 173 | call SYMBOL(MterpLogFallback) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 174 | #endif |
| 175 | MterpCommonFallback: |
| 176 | xor %eax, %eax |
| 177 | jmp MterpDone |
| 178 | |
| 179 | /* |
| 180 | * On entry: |
| 181 | * uint32_t* rFP (should still be live, pointer to base of vregs) |
| 182 | */ |
| 183 | MterpExceptionReturn: |
| 184 | movl $$1, %eax |
| 185 | jmp MterpDone |
| 186 | MterpReturn: |
| 187 | movl OFF_FP_RESULT_REGISTER(rFP), %edx |
| 188 | movl %eax, (%edx) |
| 189 | movl %ecx, 4(%edx) |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 190 | mov $$1, %eax |
| 191 | MterpDone: |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 192 | /* pop up frame */ |
| 193 | addl $$FRAME_SIZE, %esp |
| 194 | .cfi_adjust_cfa_offset -FRAME_SIZE |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 195 | |
Serguei Katkov | 897338d | 2016-03-01 15:53:22 +0600 | [diff] [blame^] | 196 | /* Restore callee save register */ |
| 197 | POP %ebx |
| 198 | POP %esi |
| 199 | POP %edi |
| 200 | POP %ebp |
| 201 | ret |
Bill Buzbee | 7c58bd4 | 2016-01-20 20:46:01 +0000 | [diff] [blame] | 202 | .cfi_endproc |
Serguei Katkov | 05dfaaa | 2016-01-28 08:21:26 +0600 | [diff] [blame] | 203 | SIZE(ExecuteMterpImpl,ExecuteMterpImpl) |