| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file was generated automatically by gen-mterp.py for 'allstubs'. |
| 3 | * |
| 4 | * --> DO NOT EDIT <-- |
| 5 | */ |
| 6 | |
| 7 | /* File: c/header.c */ |
| 8 | /* |
| 9 | * Copyright (C) 2008 The Android Open Source Project |
| 10 | * |
| 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 12 | * you may not use this file except in compliance with the License. |
| 13 | * You may obtain a copy of the License at |
| 14 | * |
| 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | * |
| 17 | * Unless required by applicable law or agreed to in writing, software |
| 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | * See the License for the specific language governing permissions and |
| 21 | * limitations under the License. |
| 22 | */ |
| 23 | |
| 24 | /* common includes */ |
| 25 | #include "Dalvik.h" |
| 26 | #include "interp/InterpDefs.h" |
| 27 | #include "mterp/Mterp.h" |
| 28 | #include <math.h> // needed for fmod, fmodf |
| 29 | |
| 30 | /* |
| 31 | * Configuration defines. These affect the C implementations, i.e. the |
| 32 | * portable interpreter(s) and C stubs. |
| 33 | * |
| 34 | * Some defines are controlled by the Makefile, e.g.: |
| 35 | * WITH_PROFILER |
| 36 | * WITH_DEBUGGER |
| 37 | * WITH_INSTR_CHECKS |
| 38 | * WITH_TRACKREF_CHECKS |
| 39 | * EASY_GDB |
| 40 | * NDEBUG |
| 41 | * |
| 42 | * If THREADED_INTERP is not defined, we use a classic "while true / switch" |
| 43 | * interpreter. If it is defined, then the tail end of each instruction |
| 44 | * handler fetches the next instruction and jumps directly to the handler. |
| 45 | * This increases the size of the "Std" interpreter by about 10%, but |
| 46 | * provides a speedup of about the same magnitude. |
| 47 | * |
| 48 | * There's a "hybrid" approach that uses a goto table instead of a switch |
| 49 | * statement, avoiding the "is the opcode in range" tests required for switch. |
| 50 | * The performance is close to the threaded version, and without the 10% |
| 51 | * size increase, but the benchmark results are off enough that it's not |
| 52 | * worth adding as a third option. |
| 53 | */ |
| 54 | #define THREADED_INTERP /* threaded vs. while-loop interpreter */ |
| 55 | |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 56 | #ifdef WITH_INSTR_CHECKS /* instruction-level paranoia (slow!) */ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 57 | # define CHECK_BRANCH_OFFSETS |
| 58 | # define CHECK_REGISTER_INDICES |
| 59 | #endif |
| 60 | |
| 61 | /* |
| 62 | * ARM EABI requires 64-bit alignment for access to 64-bit data types. We |
| 63 | * can't just use pointers to copy 64-bit values out of our interpreted |
| 64 | * register set, because gcc will generate ldrd/strd. |
| 65 | * |
| 66 | * The __UNION version copies data in and out of a union. The __MEMCPY |
| 67 | * version uses a memcpy() call to do the transfer; gcc is smart enough to |
| 68 | * not actually call memcpy(). The __UNION version is very bad on ARM; |
| 69 | * it only uses one more instruction than __MEMCPY, but for some reason |
| 70 | * gcc thinks it needs separate storage for every instance of the union. |
| 71 | * On top of that, it feels the need to zero them out at the start of the |
| 72 | * method. Net result is we zero out ~700 bytes of stack space at the top |
| 73 | * of the interpreter using ARM STM instructions. |
| 74 | */ |
| 75 | #if defined(__ARM_EABI__) |
| 76 | //# define NO_UNALIGN_64__UNION |
| 77 | # define NO_UNALIGN_64__MEMCPY |
| 78 | #endif |
| 79 | |
| 80 | //#define LOG_INSTR /* verbose debugging */ |
| 81 | /* set and adjust ANDROID_LOG_TAGS='*:i jdwp:i dalvikvm:i dalvikvmi:i' */ |
| 82 | |
| 83 | /* |
| 84 | * Keep a tally of accesses to fields. Currently only works if full DEX |
| 85 | * optimization is disabled. |
| 86 | */ |
| 87 | #ifdef PROFILE_FIELD_ACCESS |
| 88 | # define UPDATE_FIELD_GET(_field) { (_field)->gets++; } |
| 89 | # define UPDATE_FIELD_PUT(_field) { (_field)->puts++; } |
| 90 | #else |
| 91 | # define UPDATE_FIELD_GET(_field) ((void)0) |
| 92 | # define UPDATE_FIELD_PUT(_field) ((void)0) |
| 93 | #endif |
| 94 | |
| 95 | /* |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 96 | * Export another copy of the PC on every instruction; this is largely |
| 97 | * redundant with EXPORT_PC and the debugger code. This value can be |
| 98 | * compared against what we have stored on the stack with EXPORT_PC to |
| 99 | * help ensure that we aren't missing any export calls. |
| 100 | */ |
| 101 | #if WITH_EXTRA_GC_CHECKS > 1 |
| 102 | # define EXPORT_EXTRA_PC() (self->currentPc2 = pc) |
| 103 | #else |
| 104 | # define EXPORT_EXTRA_PC() |
| 105 | #endif |
| 106 | |
| 107 | /* |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 108 | * Adjust the program counter. "_offset" is a signed int, in 16-bit units. |
| 109 | * |
| 110 | * Assumes the existence of "const u2* pc" and "const u2* curMethod->insns". |
| 111 | * |
| 112 | * We don't advance the program counter until we finish an instruction or |
| 113 | * branch, because we do want to have to unroll the PC if there's an |
| 114 | * exception. |
| 115 | */ |
| 116 | #ifdef CHECK_BRANCH_OFFSETS |
| 117 | # define ADJUST_PC(_offset) do { \ |
| 118 | int myoff = _offset; /* deref only once */ \ |
| 119 | if (pc + myoff < curMethod->insns || \ |
| 120 | pc + myoff >= curMethod->insns + dvmGetMethodInsnsSize(curMethod)) \ |
| 121 | { \ |
| 122 | char* desc; \ |
| 123 | desc = dexProtoCopyMethodDescriptor(&curMethod->prototype); \ |
| 124 | LOGE("Invalid branch %d at 0x%04x in %s.%s %s\n", \ |
| 125 | myoff, (int) (pc - curMethod->insns), \ |
| 126 | curMethod->clazz->descriptor, curMethod->name, desc); \ |
| 127 | free(desc); \ |
| 128 | dvmAbort(); \ |
| 129 | } \ |
| 130 | pc += myoff; \ |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 131 | EXPORT_EXTRA_PC(); \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 132 | } while (false) |
| 133 | #else |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 134 | # define ADJUST_PC(_offset) do { \ |
| 135 | pc += _offset; \ |
| 136 | EXPORT_EXTRA_PC(); \ |
| 137 | } while (false) |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 138 | #endif |
| 139 | |
| 140 | /* |
| 141 | * If enabled, log instructions as we execute them. |
| 142 | */ |
| 143 | #ifdef LOG_INSTR |
| 144 | # define ILOGD(...) ILOG(LOG_DEBUG, __VA_ARGS__) |
| 145 | # define ILOGV(...) ILOG(LOG_VERBOSE, __VA_ARGS__) |
| 146 | # define ILOG(_level, ...) do { \ |
| 147 | char debugStrBuf[128]; \ |
| 148 | snprintf(debugStrBuf, sizeof(debugStrBuf), __VA_ARGS__); \ |
| 149 | if (curMethod != NULL) \ |
| 150 | LOG(_level, LOG_TAG"i", "%-2d|%04x%s\n", \ |
| 151 | self->threadId, (int)(pc - curMethod->insns), debugStrBuf); \ |
| 152 | else \ |
| 153 | LOG(_level, LOG_TAG"i", "%-2d|####%s\n", \ |
| 154 | self->threadId, debugStrBuf); \ |
| 155 | } while(false) |
| 156 | void dvmDumpRegs(const Method* method, const u4* framePtr, bool inOnly); |
| 157 | # define DUMP_REGS(_meth, _frame, _inOnly) dvmDumpRegs(_meth, _frame, _inOnly) |
| 158 | static const char kSpacing[] = " "; |
| 159 | #else |
| 160 | # define ILOGD(...) ((void)0) |
| 161 | # define ILOGV(...) ((void)0) |
| 162 | # define DUMP_REGS(_meth, _frame, _inOnly) ((void)0) |
| 163 | #endif |
| 164 | |
| 165 | /* get a long from an array of u4 */ |
| 166 | static inline s8 getLongFromArray(const u4* ptr, int idx) |
| 167 | { |
| 168 | #if defined(NO_UNALIGN_64__UNION) |
| 169 | union { s8 ll; u4 parts[2]; } conv; |
| 170 | |
| 171 | ptr += idx; |
| 172 | conv.parts[0] = ptr[0]; |
| 173 | conv.parts[1] = ptr[1]; |
| 174 | return conv.ll; |
| 175 | #elif defined(NO_UNALIGN_64__MEMCPY) |
| 176 | s8 val; |
| 177 | memcpy(&val, &ptr[idx], 8); |
| 178 | return val; |
| 179 | #else |
| 180 | return *((s8*) &ptr[idx]); |
| 181 | #endif |
| 182 | } |
| 183 | |
| 184 | /* store a long into an array of u4 */ |
| 185 | static inline void putLongToArray(u4* ptr, int idx, s8 val) |
| 186 | { |
| 187 | #if defined(NO_UNALIGN_64__UNION) |
| 188 | union { s8 ll; u4 parts[2]; } conv; |
| 189 | |
| 190 | ptr += idx; |
| 191 | conv.ll = val; |
| 192 | ptr[0] = conv.parts[0]; |
| 193 | ptr[1] = conv.parts[1]; |
| 194 | #elif defined(NO_UNALIGN_64__MEMCPY) |
| 195 | memcpy(&ptr[idx], &val, 8); |
| 196 | #else |
| 197 | *((s8*) &ptr[idx]) = val; |
| 198 | #endif |
| 199 | } |
| 200 | |
| 201 | /* get a double from an array of u4 */ |
| 202 | static inline double getDoubleFromArray(const u4* ptr, int idx) |
| 203 | { |
| 204 | #if defined(NO_UNALIGN_64__UNION) |
| 205 | union { double d; u4 parts[2]; } conv; |
| 206 | |
| 207 | ptr += idx; |
| 208 | conv.parts[0] = ptr[0]; |
| 209 | conv.parts[1] = ptr[1]; |
| 210 | return conv.d; |
| 211 | #elif defined(NO_UNALIGN_64__MEMCPY) |
| 212 | double dval; |
| 213 | memcpy(&dval, &ptr[idx], 8); |
| 214 | return dval; |
| 215 | #else |
| 216 | return *((double*) &ptr[idx]); |
| 217 | #endif |
| 218 | } |
| 219 | |
| 220 | /* store a double into an array of u4 */ |
| 221 | static inline void putDoubleToArray(u4* ptr, int idx, double dval) |
| 222 | { |
| 223 | #if defined(NO_UNALIGN_64__UNION) |
| 224 | union { double d; u4 parts[2]; } conv; |
| 225 | |
| 226 | ptr += idx; |
| 227 | conv.d = dval; |
| 228 | ptr[0] = conv.parts[0]; |
| 229 | ptr[1] = conv.parts[1]; |
| 230 | #elif defined(NO_UNALIGN_64__MEMCPY) |
| 231 | memcpy(&ptr[idx], &dval, 8); |
| 232 | #else |
| 233 | *((double*) &ptr[idx]) = dval; |
| 234 | #endif |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | * If enabled, validate the register number on every access. Otherwise, |
| 239 | * just do an array access. |
| 240 | * |
| 241 | * Assumes the existence of "u4* fp". |
| 242 | * |
| 243 | * "_idx" may be referenced more than once. |
| 244 | */ |
| 245 | #ifdef CHECK_REGISTER_INDICES |
| 246 | # define GET_REGISTER(_idx) \ |
| 247 | ( (_idx) < curMethod->registersSize ? \ |
| 248 | (fp[(_idx)]) : (assert(!"bad reg"),1969) ) |
| 249 | # define SET_REGISTER(_idx, _val) \ |
| 250 | ( (_idx) < curMethod->registersSize ? \ |
| 251 | (fp[(_idx)] = (u4)(_val)) : (assert(!"bad reg"),1969) ) |
| 252 | # define GET_REGISTER_AS_OBJECT(_idx) ((Object *)GET_REGISTER(_idx)) |
| 253 | # define SET_REGISTER_AS_OBJECT(_idx, _val) SET_REGISTER(_idx, (s4)_val) |
| 254 | # define GET_REGISTER_INT(_idx) ((s4) GET_REGISTER(_idx)) |
| 255 | # define SET_REGISTER_INT(_idx, _val) SET_REGISTER(_idx, (s4)_val) |
| 256 | # define GET_REGISTER_WIDE(_idx) \ |
| 257 | ( (_idx) < curMethod->registersSize-1 ? \ |
| 258 | getLongFromArray(fp, (_idx)) : (assert(!"bad reg"),1969) ) |
| 259 | # define SET_REGISTER_WIDE(_idx, _val) \ |
| 260 | ( (_idx) < curMethod->registersSize-1 ? \ |
| 261 | putLongToArray(fp, (_idx), (_val)) : (assert(!"bad reg"),1969) ) |
| 262 | # define GET_REGISTER_FLOAT(_idx) \ |
| 263 | ( (_idx) < curMethod->registersSize ? \ |
| 264 | (*((float*) &fp[(_idx)])) : (assert(!"bad reg"),1969.0f) ) |
| 265 | # define SET_REGISTER_FLOAT(_idx, _val) \ |
| 266 | ( (_idx) < curMethod->registersSize ? \ |
| 267 | (*((float*) &fp[(_idx)]) = (_val)) : (assert(!"bad reg"),1969.0f) ) |
| 268 | # define GET_REGISTER_DOUBLE(_idx) \ |
| 269 | ( (_idx) < curMethod->registersSize-1 ? \ |
| 270 | getDoubleFromArray(fp, (_idx)) : (assert(!"bad reg"),1969.0) ) |
| 271 | # define SET_REGISTER_DOUBLE(_idx, _val) \ |
| 272 | ( (_idx) < curMethod->registersSize-1 ? \ |
| 273 | putDoubleToArray(fp, (_idx), (_val)) : (assert(!"bad reg"),1969.0) ) |
| 274 | #else |
| 275 | # define GET_REGISTER(_idx) (fp[(_idx)]) |
| 276 | # define SET_REGISTER(_idx, _val) (fp[(_idx)] = (_val)) |
| 277 | # define GET_REGISTER_AS_OBJECT(_idx) ((Object*) fp[(_idx)]) |
| 278 | # define SET_REGISTER_AS_OBJECT(_idx, _val) (fp[(_idx)] = (u4)(_val)) |
| 279 | # define GET_REGISTER_INT(_idx) ((s4)GET_REGISTER(_idx)) |
| 280 | # define SET_REGISTER_INT(_idx, _val) SET_REGISTER(_idx, (s4)_val) |
| 281 | # define GET_REGISTER_WIDE(_idx) getLongFromArray(fp, (_idx)) |
| 282 | # define SET_REGISTER_WIDE(_idx, _val) putLongToArray(fp, (_idx), (_val)) |
| 283 | # define GET_REGISTER_FLOAT(_idx) (*((float*) &fp[(_idx)])) |
| 284 | # define SET_REGISTER_FLOAT(_idx, _val) (*((float*) &fp[(_idx)]) = (_val)) |
| 285 | # define GET_REGISTER_DOUBLE(_idx) getDoubleFromArray(fp, (_idx)) |
| 286 | # define SET_REGISTER_DOUBLE(_idx, _val) putDoubleToArray(fp, (_idx), (_val)) |
| 287 | #endif |
| 288 | |
| 289 | /* |
| 290 | * Get 16 bits from the specified offset of the program counter. We always |
| 291 | * want to load 16 bits at a time from the instruction stream -- it's more |
| 292 | * efficient than 8 and won't have the alignment problems that 32 might. |
| 293 | * |
| 294 | * Assumes existence of "const u2* pc". |
| 295 | */ |
| 296 | #define FETCH(_offset) (pc[(_offset)]) |
| 297 | |
| 298 | /* |
| 299 | * Extract instruction byte from 16-bit fetch (_inst is a u2). |
| 300 | */ |
| 301 | #define INST_INST(_inst) ((_inst) & 0xff) |
| 302 | |
| 303 | /* |
| 304 | * Extract the "vA, vB" 4-bit registers from the instruction word (_inst is u2). |
| 305 | */ |
| 306 | #define INST_A(_inst) (((_inst) >> 8) & 0x0f) |
| 307 | #define INST_B(_inst) ((_inst) >> 12) |
| 308 | |
| 309 | /* |
| 310 | * Get the 8-bit "vAA" 8-bit register index from the instruction word. |
| 311 | * (_inst is u2) |
| 312 | */ |
| 313 | #define INST_AA(_inst) ((_inst) >> 8) |
| 314 | |
| 315 | /* |
| 316 | * The current PC must be available to Throwable constructors, e.g. |
| 317 | * those created by dvmThrowException(), so that the exception stack |
| 318 | * trace can be generated correctly. If we don't do this, the offset |
| 319 | * within the current method won't be shown correctly. See the notes |
| 320 | * in Exception.c. |
| 321 | * |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 322 | * This is also used to determine the address for precise GC. |
| 323 | * |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 324 | * Assumes existence of "u4* fp" and "const u2* pc". |
| 325 | */ |
| 326 | #define EXPORT_PC() (SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc) |
| 327 | |
| 328 | /* |
| 329 | * Determine if we need to switch to a different interpreter. "_current" |
| 330 | * is either INTERP_STD or INTERP_DBG. It should be fixed for a given |
| 331 | * interpreter generation file, which should remove the outer conditional |
| 332 | * from the following. |
| 333 | * |
| 334 | * If we're building without debug and profiling support, we never switch. |
| 335 | */ |
| 336 | #if defined(WITH_PROFILER) || defined(WITH_DEBUGGER) |
| 337 | # define NEED_INTERP_SWITCH(_current) ( \ |
| 338 | (_current == INTERP_STD) ? \ |
| 339 | dvmDebuggerOrProfilerActive() : !dvmDebuggerOrProfilerActive() ) |
| 340 | #else |
| 341 | # define NEED_INTERP_SWITCH(_current) (false) |
| 342 | #endif |
| 343 | |
| 344 | /* |
| 345 | * Look up an interface on a class using the cache. |
| 346 | */ |
| 347 | INLINE Method* dvmFindInterfaceMethodInCache(ClassObject* thisClass, |
| 348 | u4 methodIdx, const Method* method, DvmDex* methodClassDex) |
| 349 | { |
| 350 | #define ATOMIC_CACHE_CALC \ |
| 351 | dvmInterpFindInterfaceMethod(thisClass, methodIdx, method, methodClassDex) |
| 352 | |
| 353 | return (Method*) ATOMIC_CACHE_LOOKUP(methodClassDex->pInterfaceCache, |
| 354 | DEX_INTERFACE_CACHE_SIZE, thisClass, methodIdx); |
| 355 | |
| 356 | #undef ATOMIC_CACHE_CALC |
| 357 | } |
| 358 | |
| 359 | /* |
| 360 | * Check to see if "obj" is NULL. If so, throw an exception. Assumes the |
| 361 | * pc has already been exported to the stack. |
| 362 | * |
| 363 | * Perform additional checks on debug builds. |
| 364 | * |
| 365 | * Use this to check for NULL when the instruction handler calls into |
| 366 | * something that could throw an exception (so we have already called |
| 367 | * EXPORT_PC at the top). |
| 368 | */ |
| 369 | static inline bool checkForNull(Object* obj) |
| 370 | { |
| 371 | if (obj == NULL) { |
| 372 | dvmThrowException("Ljava/lang/NullPointerException;", NULL); |
| 373 | return false; |
| 374 | } |
| 375 | #ifdef WITH_EXTRA_OBJECT_VALIDATION |
| 376 | if (!dvmIsValidObject(obj)) { |
| 377 | LOGE("Invalid object %p\n", obj); |
| 378 | dvmAbort(); |
| 379 | } |
| 380 | #endif |
| 381 | #ifndef NDEBUG |
| 382 | if (obj->clazz == NULL || ((u4) obj->clazz) <= 65536) { |
| 383 | /* probable heap corruption */ |
| 384 | LOGE("Invalid object class %p (in %p)\n", obj->clazz, obj); |
| 385 | dvmAbort(); |
| 386 | } |
| 387 | #endif |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | /* |
| 392 | * Check to see if "obj" is NULL. If so, export the PC into the stack |
| 393 | * frame and throw an exception. |
| 394 | * |
| 395 | * Perform additional checks on debug builds. |
| 396 | * |
| 397 | * Use this to check for NULL when the instruction handler doesn't do |
| 398 | * anything else that can throw an exception. |
| 399 | */ |
| 400 | static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc) |
| 401 | { |
| 402 | if (obj == NULL) { |
| 403 | EXPORT_PC(); |
| 404 | dvmThrowException("Ljava/lang/NullPointerException;", NULL); |
| 405 | return false; |
| 406 | } |
| 407 | #ifdef WITH_EXTRA_OBJECT_VALIDATION |
| 408 | if (!dvmIsValidObject(obj)) { |
| 409 | LOGE("Invalid object %p\n", obj); |
| 410 | dvmAbort(); |
| 411 | } |
| 412 | #endif |
| 413 | #ifndef NDEBUG |
| 414 | if (obj->clazz == NULL || ((u4) obj->clazz) <= 65536) { |
| 415 | /* probable heap corruption */ |
| 416 | LOGE("Invalid object class %p (in %p)\n", obj->clazz, obj); |
| 417 | dvmAbort(); |
| 418 | } |
| 419 | #endif |
| 420 | return true; |
| 421 | } |
| 422 | |
| 423 | |
| 424 | /* File: cstubs/stubdefs.c */ |
| 425 | /* this is a standard (no debug support) interpreter */ |
| 426 | #define INTERP_TYPE INTERP_STD |
| 427 | #define CHECK_DEBUG_AND_PROF() ((void)0) |
| 428 | # define CHECK_TRACKED_REFS() ((void)0) |
| 429 | |
| 430 | /* |
| 431 | * In the C mterp stubs, "goto" is a function call followed immediately |
| 432 | * by a return. |
| 433 | */ |
| 434 | |
| 435 | #define GOTO_TARGET_DECL(_target, ...) \ |
| 436 | void dvmMterp_##_target(MterpGlue* glue, ## __VA_ARGS__); |
| 437 | |
| 438 | #define GOTO_TARGET(_target, ...) \ |
| 439 | void dvmMterp_##_target(MterpGlue* glue, ## __VA_ARGS__) { \ |
| 440 | u2 ref, vsrc1, vsrc2, vdst; \ |
| 441 | u2 inst = FETCH(0); \ |
| 442 | const Method* methodToCall; \ |
| 443 | StackSaveArea* debugSaveArea; |
| 444 | |
| 445 | #define GOTO_TARGET_END } |
| 446 | |
| 447 | /* |
| 448 | * Redefine what used to be local variable accesses into MterpGlue struct |
| 449 | * references. (These are undefined down in "footer.c".) |
| 450 | */ |
| 451 | #define retval glue->retval |
| 452 | #define pc glue->pc |
| 453 | #define fp glue->fp |
| 454 | #define curMethod glue->method |
| 455 | #define methodClassDex glue->methodClassDex |
| 456 | #define self glue->self |
| 457 | #define debugTrackedRefStart glue->debugTrackedRefStart |
| 458 | |
| 459 | /* ugh */ |
| 460 | #define STUB_HACK(x) x |
| 461 | |
| 462 | |
| 463 | /* |
| 464 | * Opcode handler framing macros. Here, each opcode is a separate function |
| 465 | * that takes a "glue" argument and returns void. We can't declare |
| 466 | * these "static" because they may be called from an assembly stub. |
| 467 | */ |
| 468 | #define HANDLE_OPCODE(_op) \ |
| 469 | void dvmMterp_##_op(MterpGlue* glue) { \ |
| 470 | u2 ref, vsrc1, vsrc2, vdst; \ |
| 471 | u2 inst = FETCH(0); |
| 472 | |
| 473 | #define OP_END } |
| 474 | |
| 475 | /* |
| 476 | * Like the "portable" FINISH, but don't reload "inst", and return to caller |
| 477 | * when done. |
| 478 | */ |
| 479 | #define FINISH(_offset) { \ |
| 480 | ADJUST_PC(_offset); \ |
| 481 | CHECK_DEBUG_AND_PROF(); \ |
| 482 | CHECK_TRACKED_REFS(); \ |
| 483 | return; \ |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /* |
| 488 | * The "goto label" statements turn into function calls followed by |
| 489 | * return statements. Some of the functions take arguments, which in the |
| 490 | * portable interpreter are handled by assigning values to globals. |
| 491 | */ |
| 492 | |
| 493 | #define GOTO_exceptionThrown() \ |
| 494 | do { \ |
| 495 | dvmMterp_exceptionThrown(glue); \ |
| 496 | return; \ |
| 497 | } while(false) |
| 498 | |
| 499 | #define GOTO_returnFromMethod() \ |
| 500 | do { \ |
| 501 | dvmMterp_returnFromMethod(glue); \ |
| 502 | return; \ |
| 503 | } while(false) |
| 504 | |
| 505 | #define GOTO_invoke(_target, _methodCallRange) \ |
| 506 | do { \ |
| 507 | dvmMterp_##_target(glue, _methodCallRange); \ |
| 508 | return; \ |
| 509 | } while(false) |
| 510 | |
| 511 | #define GOTO_invokeMethod(_methodCallRange, _methodToCall, _vsrc1, _vdst) \ |
| 512 | do { \ |
| 513 | dvmMterp_invokeMethod(glue, _methodCallRange, _methodToCall, \ |
| 514 | _vsrc1, _vdst); \ |
| 515 | return; \ |
| 516 | } while(false) |
| 517 | |
| 518 | /* |
| 519 | * As a special case, "goto bail" turns into a longjmp. Use "bail_switch" |
| 520 | * if we need to switch to the other interpreter upon our return. |
| 521 | */ |
| 522 | #define GOTO_bail() \ |
| 523 | dvmMterpStdBail(glue, false); |
| 524 | #define GOTO_bail_switch() \ |
| 525 | dvmMterpStdBail(glue, true); |
| 526 | |
| 527 | /* |
| 528 | * Periodically check for thread suspension. |
| 529 | * |
| 530 | * While we're at it, see if a debugger has attached or the profiler has |
| 531 | * started. If so, switch to a different "goto" table. |
| 532 | */ |
| 533 | #define PERIODIC_CHECKS(_entryPoint, _pcadj) { \ |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 534 | if (dvmCheckSuspendQuick(self)) { \ |
| 535 | EXPORT_PC(); /* need for precise GC */ \ |
| 536 | dvmCheckSuspendPending(self); \ |
| 537 | } \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 538 | if (NEED_INTERP_SWITCH(INTERP_TYPE)) { \ |
| 539 | ADJUST_PC(_pcadj); \ |
| 540 | glue->entryPoint = _entryPoint; \ |
| 541 | LOGVV("threadid=%d: switch to STD ep=%d adj=%d\n", \ |
| 542 | glue->self->threadId, (_entryPoint), (_pcadj)); \ |
| 543 | GOTO_bail_switch(); \ |
| 544 | } \ |
| 545 | } |
| 546 | |
| 547 | |
| 548 | /* File: c/opcommon.c */ |
| 549 | /* forward declarations of goto targets */ |
| 550 | GOTO_TARGET_DECL(filledNewArray, bool methodCallRange); |
| 551 | GOTO_TARGET_DECL(invokeVirtual, bool methodCallRange); |
| 552 | GOTO_TARGET_DECL(invokeSuper, bool methodCallRange); |
| 553 | GOTO_TARGET_DECL(invokeInterface, bool methodCallRange); |
| 554 | GOTO_TARGET_DECL(invokeDirect, bool methodCallRange); |
| 555 | GOTO_TARGET_DECL(invokeStatic, bool methodCallRange); |
| 556 | GOTO_TARGET_DECL(invokeVirtualQuick, bool methodCallRange); |
| 557 | GOTO_TARGET_DECL(invokeSuperQuick, bool methodCallRange); |
| 558 | GOTO_TARGET_DECL(invokeMethod, bool methodCallRange, const Method* methodToCall, |
| 559 | u2 count, u2 regs); |
| 560 | GOTO_TARGET_DECL(returnFromMethod); |
| 561 | GOTO_TARGET_DECL(exceptionThrown); |
| 562 | |
| 563 | /* |
| 564 | * =========================================================================== |
| 565 | * |
| 566 | * What follows are opcode definitions shared between multiple opcodes with |
| 567 | * minor substitutions handled by the C pre-processor. These should probably |
| 568 | * use the mterp substitution mechanism instead, with the code here moved |
| 569 | * into common fragment files (like the asm "binop.S"), although it's hard |
| 570 | * to give up the C preprocessor in favor of the much simpler text subst. |
| 571 | * |
| 572 | * =========================================================================== |
| 573 | */ |
| 574 | |
| 575 | #define HANDLE_NUMCONV(_opcode, _opname, _fromtype, _totype) \ |
| 576 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 577 | vdst = INST_A(inst); \ |
| 578 | vsrc1 = INST_B(inst); \ |
| 579 | ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \ |
| 580 | SET_REGISTER##_totype(vdst, \ |
| 581 | GET_REGISTER##_fromtype(vsrc1)); \ |
| 582 | FINISH(1); |
| 583 | |
| 584 | #define HANDLE_FLOAT_TO_INT(_opcode, _opname, _fromvtype, _fromrtype, \ |
| 585 | _tovtype, _tortype) \ |
| 586 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 587 | { \ |
| 588 | /* spec defines specific handling for +/- inf and NaN values */ \ |
| 589 | _fromvtype val; \ |
| 590 | _tovtype intMin, intMax, result; \ |
| 591 | vdst = INST_A(inst); \ |
| 592 | vsrc1 = INST_B(inst); \ |
| 593 | ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \ |
| 594 | val = GET_REGISTER##_fromrtype(vsrc1); \ |
| 595 | intMin = (_tovtype) 1 << (sizeof(_tovtype) * 8 -1); \ |
| 596 | intMax = ~intMin; \ |
| 597 | result = (_tovtype) val; \ |
| 598 | if (val >= intMax) /* +inf */ \ |
| 599 | result = intMax; \ |
| 600 | else if (val <= intMin) /* -inf */ \ |
| 601 | result = intMin; \ |
| 602 | else if (val != val) /* NaN */ \ |
| 603 | result = 0; \ |
| 604 | else \ |
| 605 | result = (_tovtype) val; \ |
| 606 | SET_REGISTER##_tortype(vdst, result); \ |
| 607 | } \ |
| 608 | FINISH(1); |
| 609 | |
| 610 | #define HANDLE_INT_TO_SMALL(_opcode, _opname, _type) \ |
| 611 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 612 | vdst = INST_A(inst); \ |
| 613 | vsrc1 = INST_B(inst); \ |
| 614 | ILOGV("|int-to-%s v%d,v%d", (_opname), vdst, vsrc1); \ |
| 615 | SET_REGISTER(vdst, (_type) GET_REGISTER(vsrc1)); \ |
| 616 | FINISH(1); |
| 617 | |
| 618 | /* NOTE: the comparison result is always a signed 4-byte integer */ |
| 619 | #define HANDLE_OP_CMPX(_opcode, _opname, _varType, _type, _nanVal) \ |
| 620 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 621 | { \ |
| 622 | int result; \ |
| 623 | u2 regs; \ |
| 624 | _varType val1, val2; \ |
| 625 | vdst = INST_AA(inst); \ |
| 626 | regs = FETCH(1); \ |
| 627 | vsrc1 = regs & 0xff; \ |
| 628 | vsrc2 = regs >> 8; \ |
| 629 | ILOGV("|cmp%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 630 | val1 = GET_REGISTER##_type(vsrc1); \ |
| 631 | val2 = GET_REGISTER##_type(vsrc2); \ |
| 632 | if (val1 == val2) \ |
| 633 | result = 0; \ |
| 634 | else if (val1 < val2) \ |
| 635 | result = -1; \ |
| 636 | else if (val1 > val2) \ |
| 637 | result = 1; \ |
| 638 | else \ |
| 639 | result = (_nanVal); \ |
| 640 | ILOGV("+ result=%d\n", result); \ |
| 641 | SET_REGISTER(vdst, result); \ |
| 642 | } \ |
| 643 | FINISH(2); |
| 644 | |
| 645 | #define HANDLE_OP_IF_XX(_opcode, _opname, _cmp) \ |
| 646 | HANDLE_OPCODE(_opcode /*vA, vB, +CCCC*/) \ |
| 647 | vsrc1 = INST_A(inst); \ |
| 648 | vsrc2 = INST_B(inst); \ |
| 649 | if ((s4) GET_REGISTER(vsrc1) _cmp (s4) GET_REGISTER(vsrc2)) { \ |
| 650 | int branchOffset = (s2)FETCH(1); /* sign-extended */ \ |
| 651 | ILOGV("|if-%s v%d,v%d,+0x%04x", (_opname), vsrc1, vsrc2, \ |
| 652 | branchOffset); \ |
| 653 | ILOGV("> branch taken"); \ |
| 654 | if (branchOffset < 0) \ |
| 655 | PERIODIC_CHECKS(kInterpEntryInstr, branchOffset); \ |
| 656 | FINISH(branchOffset); \ |
| 657 | } else { \ |
| 658 | ILOGV("|if-%s v%d,v%d,-", (_opname), vsrc1, vsrc2); \ |
| 659 | FINISH(2); \ |
| 660 | } |
| 661 | |
| 662 | #define HANDLE_OP_IF_XXZ(_opcode, _opname, _cmp) \ |
| 663 | HANDLE_OPCODE(_opcode /*vAA, +BBBB*/) \ |
| 664 | vsrc1 = INST_AA(inst); \ |
| 665 | if ((s4) GET_REGISTER(vsrc1) _cmp 0) { \ |
| 666 | int branchOffset = (s2)FETCH(1); /* sign-extended */ \ |
| 667 | ILOGV("|if-%s v%d,+0x%04x", (_opname), vsrc1, branchOffset); \ |
| 668 | ILOGV("> branch taken"); \ |
| 669 | if (branchOffset < 0) \ |
| 670 | PERIODIC_CHECKS(kInterpEntryInstr, branchOffset); \ |
| 671 | FINISH(branchOffset); \ |
| 672 | } else { \ |
| 673 | ILOGV("|if-%s v%d,-", (_opname), vsrc1); \ |
| 674 | FINISH(2); \ |
| 675 | } |
| 676 | |
| 677 | #define HANDLE_UNOP(_opcode, _opname, _pfx, _sfx, _type) \ |
| 678 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 679 | vdst = INST_A(inst); \ |
| 680 | vsrc1 = INST_B(inst); \ |
| 681 | ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \ |
| 682 | SET_REGISTER##_type(vdst, _pfx GET_REGISTER##_type(vsrc1) _sfx); \ |
| 683 | FINISH(1); |
| 684 | |
| 685 | #define HANDLE_OP_X_INT(_opcode, _opname, _op, _chkdiv) \ |
| 686 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 687 | { \ |
| 688 | u2 srcRegs; \ |
| 689 | vdst = INST_AA(inst); \ |
| 690 | srcRegs = FETCH(1); \ |
| 691 | vsrc1 = srcRegs & 0xff; \ |
| 692 | vsrc2 = srcRegs >> 8; \ |
| 693 | ILOGV("|%s-int v%d,v%d", (_opname), vdst, vsrc1); \ |
| 694 | if (_chkdiv != 0) { \ |
| 695 | s4 firstVal, secondVal, result; \ |
| 696 | firstVal = GET_REGISTER(vsrc1); \ |
| 697 | secondVal = GET_REGISTER(vsrc2); \ |
| 698 | if (secondVal == 0) { \ |
| 699 | EXPORT_PC(); \ |
| 700 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 701 | "divide by zero"); \ |
| 702 | GOTO_exceptionThrown(); \ |
| 703 | } \ |
| 704 | if ((u4)firstVal == 0x80000000 && secondVal == -1) { \ |
| 705 | if (_chkdiv == 1) \ |
| 706 | result = firstVal; /* division */ \ |
| 707 | else \ |
| 708 | result = 0; /* remainder */ \ |
| 709 | } else { \ |
| 710 | result = firstVal _op secondVal; \ |
| 711 | } \ |
| 712 | SET_REGISTER(vdst, result); \ |
| 713 | } else { \ |
| 714 | /* non-div/rem case */ \ |
| 715 | SET_REGISTER(vdst, \ |
| 716 | (s4) GET_REGISTER(vsrc1) _op (s4) GET_REGISTER(vsrc2)); \ |
| 717 | } \ |
| 718 | } \ |
| 719 | FINISH(2); |
| 720 | |
| 721 | #define HANDLE_OP_SHX_INT(_opcode, _opname, _cast, _op) \ |
| 722 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 723 | { \ |
| 724 | u2 srcRegs; \ |
| 725 | vdst = INST_AA(inst); \ |
| 726 | srcRegs = FETCH(1); \ |
| 727 | vsrc1 = srcRegs & 0xff; \ |
| 728 | vsrc2 = srcRegs >> 8; \ |
| 729 | ILOGV("|%s-int v%d,v%d", (_opname), vdst, vsrc1); \ |
| 730 | SET_REGISTER(vdst, \ |
| 731 | _cast GET_REGISTER(vsrc1) _op (GET_REGISTER(vsrc2) & 0x1f)); \ |
| 732 | } \ |
| 733 | FINISH(2); |
| 734 | |
| 735 | #define HANDLE_OP_X_INT_LIT16(_opcode, _opname, _op, _chkdiv) \ |
| 736 | HANDLE_OPCODE(_opcode /*vA, vB, #+CCCC*/) \ |
| 737 | vdst = INST_A(inst); \ |
| 738 | vsrc1 = INST_B(inst); \ |
| 739 | vsrc2 = FETCH(1); \ |
| 740 | ILOGV("|%s-int/lit16 v%d,v%d,#+0x%04x", \ |
| 741 | (_opname), vdst, vsrc1, vsrc2); \ |
| 742 | if (_chkdiv != 0) { \ |
| 743 | s4 firstVal, result; \ |
| 744 | firstVal = GET_REGISTER(vsrc1); \ |
| 745 | if ((s2) vsrc2 == 0) { \ |
| 746 | EXPORT_PC(); \ |
| 747 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 748 | "divide by zero"); \ |
| 749 | GOTO_exceptionThrown(); \ |
| 750 | } \ |
| 751 | if ((u4)firstVal == 0x80000000 && ((s2) vsrc2) == -1) { \ |
| 752 | /* won't generate /lit16 instr for this; check anyway */ \ |
| 753 | if (_chkdiv == 1) \ |
| 754 | result = firstVal; /* division */ \ |
| 755 | else \ |
| 756 | result = 0; /* remainder */ \ |
| 757 | } else { \ |
| 758 | result = firstVal _op (s2) vsrc2; \ |
| 759 | } \ |
| 760 | SET_REGISTER(vdst, result); \ |
| 761 | } else { \ |
| 762 | /* non-div/rem case */ \ |
| 763 | SET_REGISTER(vdst, GET_REGISTER(vsrc1) _op (s2) vsrc2); \ |
| 764 | } \ |
| 765 | FINISH(2); |
| 766 | |
| 767 | #define HANDLE_OP_X_INT_LIT8(_opcode, _opname, _op, _chkdiv) \ |
| 768 | HANDLE_OPCODE(_opcode /*vAA, vBB, #+CC*/) \ |
| 769 | { \ |
| 770 | u2 litInfo; \ |
| 771 | vdst = INST_AA(inst); \ |
| 772 | litInfo = FETCH(1); \ |
| 773 | vsrc1 = litInfo & 0xff; \ |
| 774 | vsrc2 = litInfo >> 8; /* constant */ \ |
| 775 | ILOGV("|%s-int/lit8 v%d,v%d,#+0x%02x", \ |
| 776 | (_opname), vdst, vsrc1, vsrc2); \ |
| 777 | if (_chkdiv != 0) { \ |
| 778 | s4 firstVal, result; \ |
| 779 | firstVal = GET_REGISTER(vsrc1); \ |
| 780 | if ((s1) vsrc2 == 0) { \ |
| 781 | EXPORT_PC(); \ |
| 782 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 783 | "divide by zero"); \ |
| 784 | GOTO_exceptionThrown(); \ |
| 785 | } \ |
| 786 | if ((u4)firstVal == 0x80000000 && ((s1) vsrc2) == -1) { \ |
| 787 | if (_chkdiv == 1) \ |
| 788 | result = firstVal; /* division */ \ |
| 789 | else \ |
| 790 | result = 0; /* remainder */ \ |
| 791 | } else { \ |
| 792 | result = firstVal _op ((s1) vsrc2); \ |
| 793 | } \ |
| 794 | SET_REGISTER(vdst, result); \ |
| 795 | } else { \ |
| 796 | SET_REGISTER(vdst, \ |
| 797 | (s4) GET_REGISTER(vsrc1) _op (s1) vsrc2); \ |
| 798 | } \ |
| 799 | } \ |
| 800 | FINISH(2); |
| 801 | |
| 802 | #define HANDLE_OP_SHX_INT_LIT8(_opcode, _opname, _cast, _op) \ |
| 803 | HANDLE_OPCODE(_opcode /*vAA, vBB, #+CC*/) \ |
| 804 | { \ |
| 805 | u2 litInfo; \ |
| 806 | vdst = INST_AA(inst); \ |
| 807 | litInfo = FETCH(1); \ |
| 808 | vsrc1 = litInfo & 0xff; \ |
| 809 | vsrc2 = litInfo >> 8; /* constant */ \ |
| 810 | ILOGV("|%s-int/lit8 v%d,v%d,#+0x%02x", \ |
| 811 | (_opname), vdst, vsrc1, vsrc2); \ |
| 812 | SET_REGISTER(vdst, \ |
| 813 | _cast GET_REGISTER(vsrc1) _op (vsrc2 & 0x1f)); \ |
| 814 | } \ |
| 815 | FINISH(2); |
| 816 | |
| 817 | #define HANDLE_OP_X_INT_2ADDR(_opcode, _opname, _op, _chkdiv) \ |
| 818 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 819 | vdst = INST_A(inst); \ |
| 820 | vsrc1 = INST_B(inst); \ |
| 821 | ILOGV("|%s-int-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 822 | if (_chkdiv != 0) { \ |
| 823 | s4 firstVal, secondVal, result; \ |
| 824 | firstVal = GET_REGISTER(vdst); \ |
| 825 | secondVal = GET_REGISTER(vsrc1); \ |
| 826 | if (secondVal == 0) { \ |
| 827 | EXPORT_PC(); \ |
| 828 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 829 | "divide by zero"); \ |
| 830 | GOTO_exceptionThrown(); \ |
| 831 | } \ |
| 832 | if ((u4)firstVal == 0x80000000 && secondVal == -1) { \ |
| 833 | if (_chkdiv == 1) \ |
| 834 | result = firstVal; /* division */ \ |
| 835 | else \ |
| 836 | result = 0; /* remainder */ \ |
| 837 | } else { \ |
| 838 | result = firstVal _op secondVal; \ |
| 839 | } \ |
| 840 | SET_REGISTER(vdst, result); \ |
| 841 | } else { \ |
| 842 | SET_REGISTER(vdst, \ |
| 843 | (s4) GET_REGISTER(vdst) _op (s4) GET_REGISTER(vsrc1)); \ |
| 844 | } \ |
| 845 | FINISH(1); |
| 846 | |
| 847 | #define HANDLE_OP_SHX_INT_2ADDR(_opcode, _opname, _cast, _op) \ |
| 848 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 849 | vdst = INST_A(inst); \ |
| 850 | vsrc1 = INST_B(inst); \ |
| 851 | ILOGV("|%s-int-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 852 | SET_REGISTER(vdst, \ |
| 853 | _cast GET_REGISTER(vdst) _op (GET_REGISTER(vsrc1) & 0x1f)); \ |
| 854 | FINISH(1); |
| 855 | |
| 856 | #define HANDLE_OP_X_LONG(_opcode, _opname, _op, _chkdiv) \ |
| 857 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 858 | { \ |
| 859 | u2 srcRegs; \ |
| 860 | vdst = INST_AA(inst); \ |
| 861 | srcRegs = FETCH(1); \ |
| 862 | vsrc1 = srcRegs & 0xff; \ |
| 863 | vsrc2 = srcRegs >> 8; \ |
| 864 | ILOGV("|%s-long v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 865 | if (_chkdiv != 0) { \ |
| 866 | s8 firstVal, secondVal, result; \ |
| 867 | firstVal = GET_REGISTER_WIDE(vsrc1); \ |
| 868 | secondVal = GET_REGISTER_WIDE(vsrc2); \ |
| 869 | if (secondVal == 0LL) { \ |
| 870 | EXPORT_PC(); \ |
| 871 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 872 | "divide by zero"); \ |
| 873 | GOTO_exceptionThrown(); \ |
| 874 | } \ |
| 875 | if ((u8)firstVal == 0x8000000000000000ULL && \ |
| 876 | secondVal == -1LL) \ |
| 877 | { \ |
| 878 | if (_chkdiv == 1) \ |
| 879 | result = firstVal; /* division */ \ |
| 880 | else \ |
| 881 | result = 0; /* remainder */ \ |
| 882 | } else { \ |
| 883 | result = firstVal _op secondVal; \ |
| 884 | } \ |
| 885 | SET_REGISTER_WIDE(vdst, result); \ |
| 886 | } else { \ |
| 887 | SET_REGISTER_WIDE(vdst, \ |
| 888 | (s8) GET_REGISTER_WIDE(vsrc1) _op (s8) GET_REGISTER_WIDE(vsrc2)); \ |
| 889 | } \ |
| 890 | } \ |
| 891 | FINISH(2); |
| 892 | |
| 893 | #define HANDLE_OP_SHX_LONG(_opcode, _opname, _cast, _op) \ |
| 894 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 895 | { \ |
| 896 | u2 srcRegs; \ |
| 897 | vdst = INST_AA(inst); \ |
| 898 | srcRegs = FETCH(1); \ |
| 899 | vsrc1 = srcRegs & 0xff; \ |
| 900 | vsrc2 = srcRegs >> 8; \ |
| 901 | ILOGV("|%s-long v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 902 | SET_REGISTER_WIDE(vdst, \ |
| 903 | _cast GET_REGISTER_WIDE(vsrc1) _op (GET_REGISTER(vsrc2) & 0x3f)); \ |
| 904 | } \ |
| 905 | FINISH(2); |
| 906 | |
| 907 | #define HANDLE_OP_X_LONG_2ADDR(_opcode, _opname, _op, _chkdiv) \ |
| 908 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 909 | vdst = INST_A(inst); \ |
| 910 | vsrc1 = INST_B(inst); \ |
| 911 | ILOGV("|%s-long-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 912 | if (_chkdiv != 0) { \ |
| 913 | s8 firstVal, secondVal, result; \ |
| 914 | firstVal = GET_REGISTER_WIDE(vdst); \ |
| 915 | secondVal = GET_REGISTER_WIDE(vsrc1); \ |
| 916 | if (secondVal == 0LL) { \ |
| 917 | EXPORT_PC(); \ |
| 918 | dvmThrowException("Ljava/lang/ArithmeticException;", \ |
| 919 | "divide by zero"); \ |
| 920 | GOTO_exceptionThrown(); \ |
| 921 | } \ |
| 922 | if ((u8)firstVal == 0x8000000000000000ULL && \ |
| 923 | secondVal == -1LL) \ |
| 924 | { \ |
| 925 | if (_chkdiv == 1) \ |
| 926 | result = firstVal; /* division */ \ |
| 927 | else \ |
| 928 | result = 0; /* remainder */ \ |
| 929 | } else { \ |
| 930 | result = firstVal _op secondVal; \ |
| 931 | } \ |
| 932 | SET_REGISTER_WIDE(vdst, result); \ |
| 933 | } else { \ |
| 934 | SET_REGISTER_WIDE(vdst, \ |
| 935 | (s8) GET_REGISTER_WIDE(vdst) _op (s8)GET_REGISTER_WIDE(vsrc1));\ |
| 936 | } \ |
| 937 | FINISH(1); |
| 938 | |
| 939 | #define HANDLE_OP_SHX_LONG_2ADDR(_opcode, _opname, _cast, _op) \ |
| 940 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 941 | vdst = INST_A(inst); \ |
| 942 | vsrc1 = INST_B(inst); \ |
| 943 | ILOGV("|%s-long-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 944 | SET_REGISTER_WIDE(vdst, \ |
| 945 | _cast GET_REGISTER_WIDE(vdst) _op (GET_REGISTER(vsrc1) & 0x3f)); \ |
| 946 | FINISH(1); |
| 947 | |
| 948 | #define HANDLE_OP_X_FLOAT(_opcode, _opname, _op) \ |
| 949 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 950 | { \ |
| 951 | u2 srcRegs; \ |
| 952 | vdst = INST_AA(inst); \ |
| 953 | srcRegs = FETCH(1); \ |
| 954 | vsrc1 = srcRegs & 0xff; \ |
| 955 | vsrc2 = srcRegs >> 8; \ |
| 956 | ILOGV("|%s-float v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 957 | SET_REGISTER_FLOAT(vdst, \ |
| 958 | GET_REGISTER_FLOAT(vsrc1) _op GET_REGISTER_FLOAT(vsrc2)); \ |
| 959 | } \ |
| 960 | FINISH(2); |
| 961 | |
| 962 | #define HANDLE_OP_X_DOUBLE(_opcode, _opname, _op) \ |
| 963 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 964 | { \ |
| 965 | u2 srcRegs; \ |
| 966 | vdst = INST_AA(inst); \ |
| 967 | srcRegs = FETCH(1); \ |
| 968 | vsrc1 = srcRegs & 0xff; \ |
| 969 | vsrc2 = srcRegs >> 8; \ |
| 970 | ILOGV("|%s-double v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 971 | SET_REGISTER_DOUBLE(vdst, \ |
| 972 | GET_REGISTER_DOUBLE(vsrc1) _op GET_REGISTER_DOUBLE(vsrc2)); \ |
| 973 | } \ |
| 974 | FINISH(2); |
| 975 | |
| 976 | #define HANDLE_OP_X_FLOAT_2ADDR(_opcode, _opname, _op) \ |
| 977 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 978 | vdst = INST_A(inst); \ |
| 979 | vsrc1 = INST_B(inst); \ |
| 980 | ILOGV("|%s-float-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 981 | SET_REGISTER_FLOAT(vdst, \ |
| 982 | GET_REGISTER_FLOAT(vdst) _op GET_REGISTER_FLOAT(vsrc1)); \ |
| 983 | FINISH(1); |
| 984 | |
| 985 | #define HANDLE_OP_X_DOUBLE_2ADDR(_opcode, _opname, _op) \ |
| 986 | HANDLE_OPCODE(_opcode /*vA, vB*/) \ |
| 987 | vdst = INST_A(inst); \ |
| 988 | vsrc1 = INST_B(inst); \ |
| 989 | ILOGV("|%s-double-2addr v%d,v%d", (_opname), vdst, vsrc1); \ |
| 990 | SET_REGISTER_DOUBLE(vdst, \ |
| 991 | GET_REGISTER_DOUBLE(vdst) _op GET_REGISTER_DOUBLE(vsrc1)); \ |
| 992 | FINISH(1); |
| 993 | |
| 994 | #define HANDLE_OP_AGET(_opcode, _opname, _type, _regsize) \ |
| 995 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 996 | { \ |
| 997 | ArrayObject* arrayObj; \ |
| 998 | u2 arrayInfo; \ |
| 999 | EXPORT_PC(); \ |
| 1000 | vdst = INST_AA(inst); \ |
| 1001 | arrayInfo = FETCH(1); \ |
| 1002 | vsrc1 = arrayInfo & 0xff; /* array ptr */ \ |
| 1003 | vsrc2 = arrayInfo >> 8; /* index */ \ |
| 1004 | ILOGV("|aget%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 1005 | arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); \ |
| 1006 | if (!checkForNull((Object*) arrayObj)) \ |
| 1007 | GOTO_exceptionThrown(); \ |
| 1008 | if (GET_REGISTER(vsrc2) >= arrayObj->length) { \ |
| 1009 | LOGV("Invalid array access: %p %d (len=%d)\n", \ |
| 1010 | arrayObj, vsrc2, arrayObj->length); \ |
| 1011 | dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", \ |
| 1012 | NULL); \ |
| 1013 | GOTO_exceptionThrown(); \ |
| 1014 | } \ |
| 1015 | SET_REGISTER##_regsize(vdst, \ |
| 1016 | ((_type*) arrayObj->contents)[GET_REGISTER(vsrc2)]); \ |
| 1017 | ILOGV("+ AGET[%d]=0x%x", GET_REGISTER(vsrc2), GET_REGISTER(vdst)); \ |
| 1018 | } \ |
| 1019 | FINISH(2); |
| 1020 | |
| 1021 | #define HANDLE_OP_APUT(_opcode, _opname, _type, _regsize) \ |
| 1022 | HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \ |
| 1023 | { \ |
| 1024 | ArrayObject* arrayObj; \ |
| 1025 | u2 arrayInfo; \ |
| 1026 | EXPORT_PC(); \ |
| 1027 | vdst = INST_AA(inst); /* AA: source value */ \ |
| 1028 | arrayInfo = FETCH(1); \ |
| 1029 | vsrc1 = arrayInfo & 0xff; /* BB: array ptr */ \ |
| 1030 | vsrc2 = arrayInfo >> 8; /* CC: index */ \ |
| 1031 | ILOGV("|aput%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \ |
| 1032 | arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); \ |
| 1033 | if (!checkForNull((Object*) arrayObj)) \ |
| 1034 | GOTO_exceptionThrown(); \ |
| 1035 | if (GET_REGISTER(vsrc2) >= arrayObj->length) { \ |
| 1036 | dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", \ |
| 1037 | NULL); \ |
| 1038 | GOTO_exceptionThrown(); \ |
| 1039 | } \ |
| 1040 | ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\ |
| 1041 | ((_type*) arrayObj->contents)[GET_REGISTER(vsrc2)] = \ |
| 1042 | GET_REGISTER##_regsize(vdst); \ |
| 1043 | } \ |
| 1044 | FINISH(2); |
| 1045 | |
| 1046 | /* |
| 1047 | * It's possible to get a bad value out of a field with sub-32-bit stores |
| 1048 | * because the -quick versions always operate on 32 bits. Consider: |
| 1049 | * short foo = -1 (sets a 32-bit register to 0xffffffff) |
| 1050 | * iput-quick foo (writes all 32 bits to the field) |
| 1051 | * short bar = 1 (sets a 32-bit register to 0x00000001) |
| 1052 | * iput-short (writes the low 16 bits to the field) |
| 1053 | * iget-quick foo (reads all 32 bits from the field, yielding 0xffff0001) |
| 1054 | * This can only happen when optimized and non-optimized code has interleaved |
| 1055 | * access to the same field. This is unlikely but possible. |
| 1056 | * |
| 1057 | * The easiest way to fix this is to always read/write 32 bits at a time. On |
| 1058 | * a device with a 16-bit data bus this is sub-optimal. (The alternative |
| 1059 | * approach is to have sub-int versions of iget-quick, but now we're wasting |
| 1060 | * Dalvik instruction space and making it less likely that handler code will |
| 1061 | * already be in the CPU i-cache.) |
| 1062 | */ |
| 1063 | #define HANDLE_IGET_X(_opcode, _opname, _ftype, _regsize) \ |
| 1064 | HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \ |
| 1065 | { \ |
| 1066 | InstField* ifield; \ |
| 1067 | Object* obj; \ |
| 1068 | EXPORT_PC(); \ |
| 1069 | vdst = INST_A(inst); \ |
| 1070 | vsrc1 = INST_B(inst); /* object ptr */ \ |
| 1071 | ref = FETCH(1); /* field ref */ \ |
| 1072 | ILOGV("|iget%s v%d,v%d,field@0x%04x", (_opname), vdst, vsrc1, ref); \ |
| 1073 | obj = (Object*) GET_REGISTER(vsrc1); \ |
| 1074 | if (!checkForNull(obj)) \ |
| 1075 | GOTO_exceptionThrown(); \ |
| 1076 | ifield = (InstField*) dvmDexGetResolvedField(methodClassDex, ref); \ |
| 1077 | if (ifield == NULL) { \ |
| 1078 | ifield = dvmResolveInstField(curMethod->clazz, ref); \ |
| 1079 | if (ifield == NULL) \ |
| 1080 | GOTO_exceptionThrown(); \ |
| 1081 | } \ |
| 1082 | SET_REGISTER##_regsize(vdst, \ |
| 1083 | dvmGetField##_ftype(obj, ifield->byteOffset)); \ |
| 1084 | ILOGV("+ IGET '%s'=0x%08llx", ifield->field.name, \ |
| 1085 | (u8) GET_REGISTER##_regsize(vdst)); \ |
| 1086 | UPDATE_FIELD_GET(&ifield->field); \ |
| 1087 | } \ |
| 1088 | FINISH(2); |
| 1089 | |
| 1090 | #define HANDLE_IGET_X_QUICK(_opcode, _opname, _ftype, _regsize) \ |
| 1091 | HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \ |
| 1092 | { \ |
| 1093 | Object* obj; \ |
| 1094 | vdst = INST_A(inst); \ |
| 1095 | vsrc1 = INST_B(inst); /* object ptr */ \ |
| 1096 | ref = FETCH(1); /* field offset */ \ |
| 1097 | ILOGV("|iget%s-quick v%d,v%d,field@+%u", \ |
| 1098 | (_opname), vdst, vsrc1, ref); \ |
| 1099 | obj = (Object*) GET_REGISTER(vsrc1); \ |
| 1100 | if (!checkForNullExportPC(obj, fp, pc)) \ |
| 1101 | GOTO_exceptionThrown(); \ |
| 1102 | SET_REGISTER##_regsize(vdst, dvmGetField##_ftype(obj, ref)); \ |
| 1103 | ILOGV("+ IGETQ %d=0x%08llx", ref, \ |
| 1104 | (u8) GET_REGISTER##_regsize(vdst)); \ |
| 1105 | } \ |
| 1106 | FINISH(2); |
| 1107 | |
| 1108 | #define HANDLE_IPUT_X(_opcode, _opname, _ftype, _regsize) \ |
| 1109 | HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \ |
| 1110 | { \ |
| 1111 | InstField* ifield; \ |
| 1112 | Object* obj; \ |
| 1113 | EXPORT_PC(); \ |
| 1114 | vdst = INST_A(inst); \ |
| 1115 | vsrc1 = INST_B(inst); /* object ptr */ \ |
| 1116 | ref = FETCH(1); /* field ref */ \ |
| 1117 | ILOGV("|iput%s v%d,v%d,field@0x%04x", (_opname), vdst, vsrc1, ref); \ |
| 1118 | obj = (Object*) GET_REGISTER(vsrc1); \ |
| 1119 | if (!checkForNull(obj)) \ |
| 1120 | GOTO_exceptionThrown(); \ |
| 1121 | ifield = (InstField*) dvmDexGetResolvedField(methodClassDex, ref); \ |
| 1122 | if (ifield == NULL) { \ |
| 1123 | ifield = dvmResolveInstField(curMethod->clazz, ref); \ |
| 1124 | if (ifield == NULL) \ |
| 1125 | GOTO_exceptionThrown(); \ |
| 1126 | } \ |
| 1127 | dvmSetField##_ftype(obj, ifield->byteOffset, \ |
| 1128 | GET_REGISTER##_regsize(vdst)); \ |
| 1129 | ILOGV("+ IPUT '%s'=0x%08llx", ifield->field.name, \ |
| 1130 | (u8) GET_REGISTER##_regsize(vdst)); \ |
| 1131 | UPDATE_FIELD_PUT(&ifield->field); \ |
| 1132 | } \ |
| 1133 | FINISH(2); |
| 1134 | |
| 1135 | #define HANDLE_IPUT_X_QUICK(_opcode, _opname, _ftype, _regsize) \ |
| 1136 | HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \ |
| 1137 | { \ |
| 1138 | Object* obj; \ |
| 1139 | vdst = INST_A(inst); \ |
| 1140 | vsrc1 = INST_B(inst); /* object ptr */ \ |
| 1141 | ref = FETCH(1); /* field offset */ \ |
| 1142 | ILOGV("|iput%s-quick v%d,v%d,field@0x%04x", \ |
| 1143 | (_opname), vdst, vsrc1, ref); \ |
| 1144 | obj = (Object*) GET_REGISTER(vsrc1); \ |
| 1145 | if (!checkForNullExportPC(obj, fp, pc)) \ |
| 1146 | GOTO_exceptionThrown(); \ |
| 1147 | dvmSetField##_ftype(obj, ref, GET_REGISTER##_regsize(vdst)); \ |
| 1148 | ILOGV("+ IPUTQ %d=0x%08llx", ref, \ |
| 1149 | (u8) GET_REGISTER##_regsize(vdst)); \ |
| 1150 | } \ |
| 1151 | FINISH(2); |
| 1152 | |
| 1153 | #define HANDLE_SGET_X(_opcode, _opname, _ftype, _regsize) \ |
| 1154 | HANDLE_OPCODE(_opcode /*vAA, field@BBBB*/) \ |
| 1155 | { \ |
| 1156 | StaticField* sfield; \ |
| 1157 | vdst = INST_AA(inst); \ |
| 1158 | ref = FETCH(1); /* field ref */ \ |
| 1159 | ILOGV("|sget%s v%d,sfield@0x%04x", (_opname), vdst, ref); \ |
| 1160 | sfield = (StaticField*)dvmDexGetResolvedField(methodClassDex, ref); \ |
| 1161 | if (sfield == NULL) { \ |
| 1162 | EXPORT_PC(); \ |
| 1163 | sfield = dvmResolveStaticField(curMethod->clazz, ref); \ |
| 1164 | if (sfield == NULL) \ |
| 1165 | GOTO_exceptionThrown(); \ |
| 1166 | } \ |
| 1167 | SET_REGISTER##_regsize(vdst, dvmGetStaticField##_ftype(sfield)); \ |
| 1168 | ILOGV("+ SGET '%s'=0x%08llx", \ |
| 1169 | sfield->field.name, (u8)GET_REGISTER##_regsize(vdst)); \ |
| 1170 | UPDATE_FIELD_GET(&sfield->field); \ |
| 1171 | } \ |
| 1172 | FINISH(2); |
| 1173 | |
| 1174 | #define HANDLE_SPUT_X(_opcode, _opname, _ftype, _regsize) \ |
| 1175 | HANDLE_OPCODE(_opcode /*vAA, field@BBBB*/) \ |
| 1176 | { \ |
| 1177 | StaticField* sfield; \ |
| 1178 | vdst = INST_AA(inst); \ |
| 1179 | ref = FETCH(1); /* field ref */ \ |
| 1180 | ILOGV("|sput%s v%d,sfield@0x%04x", (_opname), vdst, ref); \ |
| 1181 | sfield = (StaticField*)dvmDexGetResolvedField(methodClassDex, ref); \ |
| 1182 | if (sfield == NULL) { \ |
| 1183 | EXPORT_PC(); \ |
| 1184 | sfield = dvmResolveStaticField(curMethod->clazz, ref); \ |
| 1185 | if (sfield == NULL) \ |
| 1186 | GOTO_exceptionThrown(); \ |
| 1187 | } \ |
| 1188 | dvmSetStaticField##_ftype(sfield, GET_REGISTER##_regsize(vdst)); \ |
| 1189 | ILOGV("+ SPUT '%s'=0x%08llx", \ |
| 1190 | sfield->field.name, (u8)GET_REGISTER##_regsize(vdst)); \ |
| 1191 | UPDATE_FIELD_PUT(&sfield->field); \ |
| 1192 | } \ |
| 1193 | FINISH(2); |
| 1194 | |
| 1195 | |
| 1196 | /* File: c/OP_NOP.c */ |
| 1197 | HANDLE_OPCODE(OP_NOP) |
| 1198 | FINISH(1); |
| 1199 | OP_END |
| 1200 | |
| 1201 | /* File: c/OP_MOVE.c */ |
| 1202 | HANDLE_OPCODE(OP_MOVE /*vA, vB*/) |
| 1203 | vdst = INST_A(inst); |
| 1204 | vsrc1 = INST_B(inst); |
| 1205 | ILOGV("|move%s v%d,v%d %s(v%d=0x%08x)", |
| 1206 | (INST_INST(inst) == OP_MOVE) ? "" : "-object", vdst, vsrc1, |
| 1207 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1208 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1209 | FINISH(1); |
| 1210 | OP_END |
| 1211 | |
| 1212 | /* File: c/OP_MOVE_FROM16.c */ |
| 1213 | HANDLE_OPCODE(OP_MOVE_FROM16 /*vAA, vBBBB*/) |
| 1214 | vdst = INST_AA(inst); |
| 1215 | vsrc1 = FETCH(1); |
| 1216 | ILOGV("|move%s/from16 v%d,v%d %s(v%d=0x%08x)", |
| 1217 | (INST_INST(inst) == OP_MOVE_FROM16) ? "" : "-object", vdst, vsrc1, |
| 1218 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1219 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1220 | FINISH(2); |
| 1221 | OP_END |
| 1222 | |
| 1223 | /* File: c/OP_MOVE_16.c */ |
| 1224 | HANDLE_OPCODE(OP_MOVE_16 /*vAAAA, vBBBB*/) |
| 1225 | vdst = FETCH(1); |
| 1226 | vsrc1 = FETCH(2); |
| 1227 | ILOGV("|move%s/16 v%d,v%d %s(v%d=0x%08x)", |
| 1228 | (INST_INST(inst) == OP_MOVE_16) ? "" : "-object", vdst, vsrc1, |
| 1229 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1230 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1231 | FINISH(3); |
| 1232 | OP_END |
| 1233 | |
| 1234 | /* File: c/OP_MOVE_WIDE.c */ |
| 1235 | HANDLE_OPCODE(OP_MOVE_WIDE /*vA, vB*/) |
| 1236 | /* IMPORTANT: must correctly handle overlapping registers, e.g. both |
| 1237 | * "move-wide v6, v7" and "move-wide v7, v6" */ |
| 1238 | vdst = INST_A(inst); |
| 1239 | vsrc1 = INST_B(inst); |
| 1240 | ILOGV("|move-wide v%d,v%d %s(v%d=0x%08llx)", vdst, vsrc1, |
| 1241 | kSpacing+5, vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1242 | SET_REGISTER_WIDE(vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1243 | FINISH(1); |
| 1244 | OP_END |
| 1245 | |
| 1246 | /* File: c/OP_MOVE_WIDE_FROM16.c */ |
| 1247 | HANDLE_OPCODE(OP_MOVE_WIDE_FROM16 /*vAA, vBBBB*/) |
| 1248 | vdst = INST_AA(inst); |
| 1249 | vsrc1 = FETCH(1); |
| 1250 | ILOGV("|move-wide/from16 v%d,v%d (v%d=0x%08llx)", vdst, vsrc1, |
| 1251 | vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1252 | SET_REGISTER_WIDE(vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1253 | FINISH(2); |
| 1254 | OP_END |
| 1255 | |
| 1256 | /* File: c/OP_MOVE_WIDE_16.c */ |
| 1257 | HANDLE_OPCODE(OP_MOVE_WIDE_16 /*vAAAA, vBBBB*/) |
| 1258 | vdst = FETCH(1); |
| 1259 | vsrc1 = FETCH(2); |
| 1260 | ILOGV("|move-wide/16 v%d,v%d %s(v%d=0x%08llx)", vdst, vsrc1, |
| 1261 | kSpacing+8, vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1262 | SET_REGISTER_WIDE(vdst, GET_REGISTER_WIDE(vsrc1)); |
| 1263 | FINISH(3); |
| 1264 | OP_END |
| 1265 | |
| 1266 | /* File: c/OP_MOVE_OBJECT.c */ |
| 1267 | /* File: c/OP_MOVE.c */ |
| 1268 | HANDLE_OPCODE(OP_MOVE_OBJECT /*vA, vB*/) |
| 1269 | vdst = INST_A(inst); |
| 1270 | vsrc1 = INST_B(inst); |
| 1271 | ILOGV("|move%s v%d,v%d %s(v%d=0x%08x)", |
| 1272 | (INST_INST(inst) == OP_MOVE) ? "" : "-object", vdst, vsrc1, |
| 1273 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1274 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1275 | FINISH(1); |
| 1276 | OP_END |
| 1277 | |
| 1278 | |
| 1279 | /* File: c/OP_MOVE_OBJECT_FROM16.c */ |
| 1280 | /* File: c/OP_MOVE_FROM16.c */ |
| 1281 | HANDLE_OPCODE(OP_MOVE_OBJECT_FROM16 /*vAA, vBBBB*/) |
| 1282 | vdst = INST_AA(inst); |
| 1283 | vsrc1 = FETCH(1); |
| 1284 | ILOGV("|move%s/from16 v%d,v%d %s(v%d=0x%08x)", |
| 1285 | (INST_INST(inst) == OP_MOVE_FROM16) ? "" : "-object", vdst, vsrc1, |
| 1286 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1287 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1288 | FINISH(2); |
| 1289 | OP_END |
| 1290 | |
| 1291 | |
| 1292 | /* File: c/OP_MOVE_OBJECT_16.c */ |
| 1293 | /* File: c/OP_MOVE_16.c */ |
| 1294 | HANDLE_OPCODE(OP_MOVE_OBJECT_16 /*vAAAA, vBBBB*/) |
| 1295 | vdst = FETCH(1); |
| 1296 | vsrc1 = FETCH(2); |
| 1297 | ILOGV("|move%s/16 v%d,v%d %s(v%d=0x%08x)", |
| 1298 | (INST_INST(inst) == OP_MOVE_16) ? "" : "-object", vdst, vsrc1, |
| 1299 | kSpacing, vdst, GET_REGISTER(vsrc1)); |
| 1300 | SET_REGISTER(vdst, GET_REGISTER(vsrc1)); |
| 1301 | FINISH(3); |
| 1302 | OP_END |
| 1303 | |
| 1304 | |
| 1305 | /* File: c/OP_MOVE_RESULT.c */ |
| 1306 | HANDLE_OPCODE(OP_MOVE_RESULT /*vAA*/) |
| 1307 | vdst = INST_AA(inst); |
| 1308 | ILOGV("|move-result%s v%d %s(v%d=0x%08x)", |
| 1309 | (INST_INST(inst) == OP_MOVE_RESULT) ? "" : "-object", |
| 1310 | vdst, kSpacing+4, vdst,retval.i); |
| 1311 | SET_REGISTER(vdst, retval.i); |
| 1312 | FINISH(1); |
| 1313 | OP_END |
| 1314 | |
| 1315 | /* File: c/OP_MOVE_RESULT_WIDE.c */ |
| 1316 | HANDLE_OPCODE(OP_MOVE_RESULT_WIDE /*vAA*/) |
| 1317 | vdst = INST_AA(inst); |
| 1318 | ILOGV("|move-result-wide v%d %s(0x%08llx)", vdst, kSpacing, retval.j); |
| 1319 | SET_REGISTER_WIDE(vdst, retval.j); |
| 1320 | FINISH(1); |
| 1321 | OP_END |
| 1322 | |
| 1323 | /* File: c/OP_MOVE_RESULT_OBJECT.c */ |
| 1324 | /* File: c/OP_MOVE_RESULT.c */ |
| 1325 | HANDLE_OPCODE(OP_MOVE_RESULT_OBJECT /*vAA*/) |
| 1326 | vdst = INST_AA(inst); |
| 1327 | ILOGV("|move-result%s v%d %s(v%d=0x%08x)", |
| 1328 | (INST_INST(inst) == OP_MOVE_RESULT) ? "" : "-object", |
| 1329 | vdst, kSpacing+4, vdst,retval.i); |
| 1330 | SET_REGISTER(vdst, retval.i); |
| 1331 | FINISH(1); |
| 1332 | OP_END |
| 1333 | |
| 1334 | |
| 1335 | /* File: c/OP_MOVE_EXCEPTION.c */ |
| 1336 | HANDLE_OPCODE(OP_MOVE_EXCEPTION /*vAA*/) |
| 1337 | vdst = INST_AA(inst); |
| 1338 | ILOGV("|move-exception v%d", vdst); |
| 1339 | assert(self->exception != NULL); |
| 1340 | SET_REGISTER(vdst, (u4)self->exception); |
| 1341 | dvmClearException(self); |
| 1342 | FINISH(1); |
| 1343 | OP_END |
| 1344 | |
| 1345 | /* File: c/OP_RETURN_VOID.c */ |
| 1346 | HANDLE_OPCODE(OP_RETURN_VOID /**/) |
| 1347 | ILOGV("|return-void"); |
| 1348 | #ifndef NDEBUG |
| 1349 | retval.j = 0xababababULL; // placate valgrind |
| 1350 | #endif |
| 1351 | GOTO_returnFromMethod(); |
| 1352 | OP_END |
| 1353 | |
| 1354 | /* File: c/OP_RETURN.c */ |
| 1355 | HANDLE_OPCODE(OP_RETURN /*vAA*/) |
| 1356 | vsrc1 = INST_AA(inst); |
| 1357 | ILOGV("|return%s v%d", |
| 1358 | (INST_INST(inst) == OP_RETURN) ? "" : "-object", vsrc1); |
| 1359 | retval.i = GET_REGISTER(vsrc1); |
| 1360 | GOTO_returnFromMethod(); |
| 1361 | OP_END |
| 1362 | |
| 1363 | /* File: c/OP_RETURN_WIDE.c */ |
| 1364 | HANDLE_OPCODE(OP_RETURN_WIDE /*vAA*/) |
| 1365 | vsrc1 = INST_AA(inst); |
| 1366 | ILOGV("|return-wide v%d", vsrc1); |
| 1367 | retval.j = GET_REGISTER_WIDE(vsrc1); |
| 1368 | GOTO_returnFromMethod(); |
| 1369 | OP_END |
| 1370 | |
| 1371 | /* File: c/OP_RETURN_OBJECT.c */ |
| 1372 | /* File: c/OP_RETURN.c */ |
| 1373 | HANDLE_OPCODE(OP_RETURN_OBJECT /*vAA*/) |
| 1374 | vsrc1 = INST_AA(inst); |
| 1375 | ILOGV("|return%s v%d", |
| 1376 | (INST_INST(inst) == OP_RETURN) ? "" : "-object", vsrc1); |
| 1377 | retval.i = GET_REGISTER(vsrc1); |
| 1378 | GOTO_returnFromMethod(); |
| 1379 | OP_END |
| 1380 | |
| 1381 | |
| 1382 | /* File: c/OP_CONST_4.c */ |
| 1383 | HANDLE_OPCODE(OP_CONST_4 /*vA, #+B*/) |
| 1384 | { |
| 1385 | s4 tmp; |
| 1386 | |
| 1387 | vdst = INST_A(inst); |
| 1388 | tmp = (s4) (INST_B(inst) << 28) >> 28; // sign extend 4-bit value |
| 1389 | ILOGV("|const/4 v%d,#0x%02x", vdst, (s4)tmp); |
| 1390 | SET_REGISTER(vdst, tmp); |
| 1391 | } |
| 1392 | FINISH(1); |
| 1393 | OP_END |
| 1394 | |
| 1395 | /* File: c/OP_CONST_16.c */ |
| 1396 | HANDLE_OPCODE(OP_CONST_16 /*vAA, #+BBBB*/) |
| 1397 | vdst = INST_AA(inst); |
| 1398 | vsrc1 = FETCH(1); |
| 1399 | ILOGV("|const/16 v%d,#0x%04x", vdst, (s2)vsrc1); |
| 1400 | SET_REGISTER(vdst, (s2) vsrc1); |
| 1401 | FINISH(2); |
| 1402 | OP_END |
| 1403 | |
| 1404 | /* File: c/OP_CONST.c */ |
| 1405 | HANDLE_OPCODE(OP_CONST /*vAA, #+BBBBBBBB*/) |
| 1406 | { |
| 1407 | u4 tmp; |
| 1408 | |
| 1409 | vdst = INST_AA(inst); |
| 1410 | tmp = FETCH(1); |
| 1411 | tmp |= (u4)FETCH(2) << 16; |
| 1412 | ILOGV("|const v%d,#0x%08x", vdst, tmp); |
| 1413 | SET_REGISTER(vdst, tmp); |
| 1414 | } |
| 1415 | FINISH(3); |
| 1416 | OP_END |
| 1417 | |
| 1418 | /* File: c/OP_CONST_HIGH16.c */ |
| 1419 | HANDLE_OPCODE(OP_CONST_HIGH16 /*vAA, #+BBBB0000*/) |
| 1420 | vdst = INST_AA(inst); |
| 1421 | vsrc1 = FETCH(1); |
| 1422 | ILOGV("|const/high16 v%d,#0x%04x0000", vdst, vsrc1); |
| 1423 | SET_REGISTER(vdst, vsrc1 << 16); |
| 1424 | FINISH(2); |
| 1425 | OP_END |
| 1426 | |
| 1427 | /* File: c/OP_CONST_WIDE_16.c */ |
| 1428 | HANDLE_OPCODE(OP_CONST_WIDE_16 /*vAA, #+BBBB*/) |
| 1429 | vdst = INST_AA(inst); |
| 1430 | vsrc1 = FETCH(1); |
| 1431 | ILOGV("|const-wide/16 v%d,#0x%04x", vdst, (s2)vsrc1); |
| 1432 | SET_REGISTER_WIDE(vdst, (s2)vsrc1); |
| 1433 | FINISH(2); |
| 1434 | OP_END |
| 1435 | |
| 1436 | /* File: c/OP_CONST_WIDE_32.c */ |
| 1437 | HANDLE_OPCODE(OP_CONST_WIDE_32 /*vAA, #+BBBBBBBB*/) |
| 1438 | { |
| 1439 | u4 tmp; |
| 1440 | |
| 1441 | vdst = INST_AA(inst); |
| 1442 | tmp = FETCH(1); |
| 1443 | tmp |= (u4)FETCH(2) << 16; |
| 1444 | ILOGV("|const-wide/32 v%d,#0x%08x", vdst, tmp); |
| 1445 | SET_REGISTER_WIDE(vdst, (s4) tmp); |
| 1446 | } |
| 1447 | FINISH(3); |
| 1448 | OP_END |
| 1449 | |
| 1450 | /* File: c/OP_CONST_WIDE.c */ |
| 1451 | HANDLE_OPCODE(OP_CONST_WIDE /*vAA, #+BBBBBBBBBBBBBBBB*/) |
| 1452 | { |
| 1453 | u8 tmp; |
| 1454 | |
| 1455 | vdst = INST_AA(inst); |
| 1456 | tmp = FETCH(1); |
| 1457 | tmp |= (u8)FETCH(2) << 16; |
| 1458 | tmp |= (u8)FETCH(3) << 32; |
| 1459 | tmp |= (u8)FETCH(4) << 48; |
| 1460 | ILOGV("|const-wide v%d,#0x%08llx", vdst, tmp); |
| 1461 | SET_REGISTER_WIDE(vdst, tmp); |
| 1462 | } |
| 1463 | FINISH(5); |
| 1464 | OP_END |
| 1465 | |
| 1466 | /* File: c/OP_CONST_WIDE_HIGH16.c */ |
| 1467 | HANDLE_OPCODE(OP_CONST_WIDE_HIGH16 /*vAA, #+BBBB000000000000*/) |
| 1468 | vdst = INST_AA(inst); |
| 1469 | vsrc1 = FETCH(1); |
| 1470 | ILOGV("|const-wide/high16 v%d,#0x%04x000000000000", vdst, vsrc1); |
| 1471 | SET_REGISTER_WIDE(vdst, ((u8) vsrc1) << 48); |
| 1472 | FINISH(2); |
| 1473 | OP_END |
| 1474 | |
| 1475 | /* File: c/OP_CONST_STRING.c */ |
| 1476 | HANDLE_OPCODE(OP_CONST_STRING /*vAA, string@BBBB*/) |
| 1477 | { |
| 1478 | StringObject* strObj; |
| 1479 | |
| 1480 | vdst = INST_AA(inst); |
| 1481 | ref = FETCH(1); |
| 1482 | ILOGV("|const-string v%d string@0x%04x", vdst, ref); |
| 1483 | strObj = dvmDexGetResolvedString(methodClassDex, ref); |
| 1484 | if (strObj == NULL) { |
| 1485 | EXPORT_PC(); |
| 1486 | strObj = dvmResolveString(curMethod->clazz, ref); |
| 1487 | if (strObj == NULL) |
| 1488 | GOTO_exceptionThrown(); |
| 1489 | } |
| 1490 | SET_REGISTER(vdst, (u4) strObj); |
| 1491 | } |
| 1492 | FINISH(2); |
| 1493 | OP_END |
| 1494 | |
| 1495 | /* File: c/OP_CONST_STRING_JUMBO.c */ |
| 1496 | HANDLE_OPCODE(OP_CONST_STRING_JUMBO /*vAA, string@BBBBBBBB*/) |
| 1497 | { |
| 1498 | StringObject* strObj; |
| 1499 | u4 tmp; |
| 1500 | |
| 1501 | vdst = INST_AA(inst); |
| 1502 | tmp = FETCH(1); |
| 1503 | tmp |= (u4)FETCH(2) << 16; |
| 1504 | ILOGV("|const-string/jumbo v%d string@0x%08x", vdst, tmp); |
| 1505 | strObj = dvmDexGetResolvedString(methodClassDex, tmp); |
| 1506 | if (strObj == NULL) { |
| 1507 | EXPORT_PC(); |
| 1508 | strObj = dvmResolveString(curMethod->clazz, tmp); |
| 1509 | if (strObj == NULL) |
| 1510 | GOTO_exceptionThrown(); |
| 1511 | } |
| 1512 | SET_REGISTER(vdst, (u4) strObj); |
| 1513 | } |
| 1514 | FINISH(3); |
| 1515 | OP_END |
| 1516 | |
| 1517 | /* File: c/OP_CONST_CLASS.c */ |
| 1518 | HANDLE_OPCODE(OP_CONST_CLASS /*vAA, class@BBBB*/) |
| 1519 | { |
| 1520 | ClassObject* clazz; |
| 1521 | |
| 1522 | vdst = INST_AA(inst); |
| 1523 | ref = FETCH(1); |
| 1524 | ILOGV("|const-class v%d class@0x%04x", vdst, ref); |
| 1525 | clazz = dvmDexGetResolvedClass(methodClassDex, ref); |
| 1526 | if (clazz == NULL) { |
| 1527 | EXPORT_PC(); |
| 1528 | clazz = dvmResolveClass(curMethod->clazz, ref, true); |
| 1529 | if (clazz == NULL) |
| 1530 | GOTO_exceptionThrown(); |
| 1531 | } |
| 1532 | SET_REGISTER(vdst, (u4) clazz); |
| 1533 | } |
| 1534 | FINISH(2); |
| 1535 | OP_END |
| 1536 | |
| 1537 | /* File: c/OP_MONITOR_ENTER.c */ |
| 1538 | HANDLE_OPCODE(OP_MONITOR_ENTER /*vAA*/) |
| 1539 | { |
| 1540 | Object* obj; |
| 1541 | |
| 1542 | vsrc1 = INST_AA(inst); |
| 1543 | ILOGV("|monitor-enter v%d %s(0x%08x)", |
| 1544 | vsrc1, kSpacing+6, GET_REGISTER(vsrc1)); |
| 1545 | obj = (Object*)GET_REGISTER(vsrc1); |
| 1546 | if (!checkForNullExportPC(obj, fp, pc)) |
| 1547 | GOTO_exceptionThrown(); |
| 1548 | ILOGV("+ locking %p %s\n", obj, obj->clazz->descriptor); |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame^] | 1549 | EXPORT_PC(); /* need for precise GC, also WITH_MONITOR_TRACKING */ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1550 | dvmLockObject(self, obj); |
| 1551 | #ifdef WITH_DEADLOCK_PREDICTION |
| 1552 | if (dvmCheckException(self)) |
| 1553 | GOTO_exceptionThrown(); |
| 1554 | #endif |
| 1555 | } |
| 1556 | FINISH(1); |
| 1557 | OP_END |
| 1558 | |
| 1559 | /* File: c/OP_MONITOR_EXIT.c */ |
| 1560 | HANDLE_OPCODE(OP_MONITOR_EXIT /*vAA*/) |
| 1561 | { |
| 1562 | Object* obj; |
| 1563 | |
| 1564 | EXPORT_PC(); |
| 1565 | |
| 1566 | vsrc1 = INST_AA(inst); |
| 1567 | ILOGV("|monitor-exit v%d %s(0x%08x)", |
| 1568 | vsrc1, kSpacing+5, GET_REGISTER(vsrc1)); |
| 1569 | obj = (Object*)GET_REGISTER(vsrc1); |
| 1570 | if (!checkForNull(obj)) { |
| 1571 | /* |
| 1572 | * The exception needs to be processed at the *following* |
| 1573 | * instruction, not the current instruction (see the Dalvik |
| 1574 | * spec). Because we're jumping to an exception handler, |
| 1575 | * we're not actually at risk of skipping an instruction |
| 1576 | * by doing so. |
| 1577 | */ |
| 1578 | ADJUST_PC(1); /* monitor-exit width is 1 */ |
| 1579 | GOTO_exceptionThrown(); |
| 1580 | } |
| 1581 | ILOGV("+ unlocking %p %s\n", obj, obj->clazz->descriptor); |
| 1582 | if (!dvmUnlockObject(self, obj)) { |
| 1583 | assert(dvmCheckException(self)); |
| 1584 | ADJUST_PC(1); |
| 1585 | GOTO_exceptionThrown(); |
| 1586 | } |
| 1587 | } |
| 1588 | FINISH(1); |
| 1589 | OP_END |
| 1590 | |
| 1591 | /* File: c/OP_CHECK_CAST.c */ |
| 1592 | HANDLE_OPCODE(OP_CHECK_CAST /*vAA, class@BBBB*/) |
| 1593 | { |
| 1594 | ClassObject* clazz; |
| 1595 | Object* obj; |
| 1596 | |
| 1597 | EXPORT_PC(); |
| 1598 | |
| 1599 | vsrc1 = INST_AA(inst); |
| 1600 | ref = FETCH(1); /* class to check against */ |
| 1601 | ILOGV("|check-cast v%d,class@0x%04x", vsrc1, ref); |
| 1602 | |
| 1603 | obj = (Object*)GET_REGISTER(vsrc1); |
| 1604 | if (obj != NULL) { |
| 1605 | #if defined(WITH_EXTRA_OBJECT_VALIDATION) |
| 1606 | if (!checkForNull(obj)) |
| 1607 | GOTO_exceptionThrown(); |
| 1608 | #endif |
| 1609 | clazz = dvmDexGetResolvedClass(methodClassDex, ref); |
| 1610 | if (clazz == NULL) { |
| 1611 | clazz = dvmResolveClass(curMethod->clazz, ref, false); |
| 1612 | if (clazz == NULL) |
| 1613 | GOTO_exceptionThrown(); |
| 1614 | } |
| 1615 | if (!dvmInstanceof(obj->clazz, clazz)) { |
| 1616 | dvmThrowExceptionWithClassMessage( |
| 1617 | "Ljava/lang/ClassCastException;", obj->clazz->descriptor); |
| 1618 | GOTO_exceptionThrown(); |
| 1619 | } |
| 1620 | } |
| 1621 | } |
| 1622 | FINISH(2); |
| 1623 | OP_END |
| 1624 | |
| 1625 | /* File: c/OP_INSTANCE_OF.c */ |
| 1626 | HANDLE_OPCODE(OP_INSTANCE_OF /*vA, vB, class@CCCC*/) |
| 1627 | { |
| 1628 | ClassObject* clazz; |
| 1629 | Object* obj; |
| 1630 | |
| 1631 | vdst = INST_A(inst); |
| 1632 | vsrc1 = INST_B(inst); /* object to check */ |
| 1633 | ref = FETCH(1); /* class to check against */ |
| 1634 | ILOGV("|instance-of v%d,v%d,class@0x%04x", vdst, vsrc1, ref); |
| 1635 | |
| 1636 | obj = (Object*)GET_REGISTER(vsrc1); |
| 1637 | if (obj == NULL) { |
| 1638 | SET_REGISTER(vdst, 0); |
| 1639 | } else { |
| 1640 | #if defined(WITH_EXTRA_OBJECT_VALIDATION) |
| 1641 | if (!checkForNullExportPC(obj, fp, pc)) |
| 1642 | GOTO_exceptionThrown(); |
| 1643 | #endif |
| 1644 | clazz = dvmDexGetResolvedClass(methodClassDex, ref); |
| 1645 | if (clazz == NULL) { |
| 1646 | EXPORT_PC(); |
| 1647 | clazz = dvmResolveClass(curMethod->clazz, ref, true); |
| 1648 | if (clazz == NULL) |
| 1649 | GOTO_exceptionThrown(); |
| 1650 | } |
| 1651 | SET_REGISTER(vdst, dvmInstanceof(obj->clazz, clazz)); |
| 1652 | } |
| 1653 | } |
| 1654 | FINISH(2); |
| 1655 | OP_END |
| 1656 | |
| 1657 | /* File: c/OP_ARRAY_LENGTH.c */ |
| 1658 | HANDLE_OPCODE(OP_ARRAY_LENGTH /*vA, vB*/) |
| 1659 | { |
| 1660 | ArrayObject* arrayObj; |
| 1661 | |
| 1662 | vdst = INST_A(inst); |
| 1663 | vsrc1 = INST_B(inst); |
| 1664 | arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); |
| 1665 | ILOGV("|array-length v%d,v%d (%p)", vdst, vsrc1, arrayObj); |
| 1666 | if (!checkForNullExportPC((Object*) arrayObj, fp, pc)) |
| 1667 | GOTO_exceptionThrown(); |
| 1668 | /* verifier guarantees this is an array reference */ |
| 1669 | SET_REGISTER(vdst, arrayObj->length); |
| 1670 | } |
| 1671 | FINISH(1); |
| 1672 | OP_END |
| 1673 | |
| 1674 | /* File: c/OP_NEW_INSTANCE.c */ |
| 1675 | HANDLE_OPCODE(OP_NEW_INSTANCE /*vAA, class@BBBB*/) |
| 1676 | { |
| 1677 | ClassObject* clazz; |
| 1678 | Object* newObj; |
| 1679 | |
| 1680 | EXPORT_PC(); |
| 1681 | |
| 1682 | vdst = INST_AA(inst); |
| 1683 | ref = FETCH(1); |
| 1684 | ILOGV("|new-instance v%d,class@0x%04x", vdst, ref); |
| 1685 | clazz = dvmDexGetResolvedClass(methodClassDex, ref); |
| 1686 | if (clazz == NULL) { |
| 1687 | clazz = dvmResolveClass(curMethod->clazz, ref, false); |
| 1688 | if (clazz == NULL) |
| 1689 | GOTO_exceptionThrown(); |
| 1690 | } |
| 1691 | |
| 1692 | if (!dvmIsClassInitialized(clazz) && !dvmInitClass(clazz)) |
| 1693 | GOTO_exceptionThrown(); |
| 1694 | |
| 1695 | /* |
| 1696 | * Note: the verifier can ensure that this never happens, allowing us |
| 1697 | * to remove the check. However, the spec requires we throw the |
| 1698 | * exception at runtime, not verify time, so the verifier would |
| 1699 | * need to replace the new-instance call with a magic "throw |
| 1700 | * InstantiationError" instruction. |
| 1701 | * |
| 1702 | * Since this relies on the verifier, which is optional, we would |
| 1703 | * also need a "new-instance-quick" instruction to identify instances |
| 1704 | * that don't require the check. |
| 1705 | */ |
| 1706 | if (dvmIsInterfaceClass(clazz) || dvmIsAbstractClass(clazz)) { |
| 1707 | dvmThrowExceptionWithClassMessage("Ljava/lang/InstantiationError;", |
| 1708 | clazz->descriptor); |
| 1709 | GOTO_exceptionThrown(); |
| 1710 | } |
| 1711 | newObj = dvmAllocObject(clazz, ALLOC_DONT_TRACK); |
| 1712 | if (newObj == NULL) |
| 1713 | GOTO_exceptionThrown(); |
| 1714 | SET_REGISTER(vdst, (u4) newObj); |
| 1715 | } |
| 1716 | FINISH(2); |
| 1717 | OP_END |
| 1718 | |
| 1719 | /* File: c/OP_NEW_ARRAY.c */ |
| 1720 | HANDLE_OPCODE(OP_NEW_ARRAY /*vA, vB, class@CCCC*/) |
| 1721 | { |
| 1722 | ClassObject* arrayClass; |
| 1723 | ArrayObject* newArray; |
| 1724 | s4 length; |
| 1725 | |
| 1726 | EXPORT_PC(); |
| 1727 | |
| 1728 | vdst = INST_A(inst); |
| 1729 | vsrc1 = INST_B(inst); /* length reg */ |
| 1730 | ref = FETCH(1); |
| 1731 | ILOGV("|new-array v%d,v%d,class@0x%04x (%d elements)", |
| 1732 | vdst, vsrc1, ref, (s4) GET_REGISTER(vsrc1)); |
| 1733 | length = (s4) GET_REGISTER(vsrc1); |
| 1734 | if (length < 0) { |
| 1735 | dvmThrowException("Ljava/lang/NegativeArraySizeException;", NULL); |
| 1736 | GOTO_exceptionThrown(); |
| 1737 | } |
| 1738 | arrayClass = dvmDexGetResolvedClass(methodClassDex, ref); |
| 1739 | if (arrayClass == NULL) { |
| 1740 | arrayClass = dvmResolveClass(curMethod->clazz, ref, false); |
| 1741 | if (arrayClass == NULL) |
| 1742 | GOTO_exceptionThrown(); |
| 1743 | } |
| 1744 | /* verifier guarantees this is an array class */ |
| 1745 | assert(dvmIsArrayClass(arrayClass)); |
| 1746 | assert(dvmIsClassInitialized(arrayClass)); |
| 1747 | |
| 1748 | newArray = dvmAllocArrayByClass(arrayClass, length, ALLOC_DONT_TRACK); |
| 1749 | if (newArray == NULL) |
| 1750 | GOTO_exceptionThrown(); |
| 1751 | SET_REGISTER(vdst, (u4) newArray); |
| 1752 | } |
| 1753 | FINISH(2); |
| 1754 | OP_END |
| 1755 | |
| 1756 | |
| 1757 | /* File: c/OP_FILLED_NEW_ARRAY.c */ |
| 1758 | HANDLE_OPCODE(OP_FILLED_NEW_ARRAY /*vB, {vD, vE, vF, vG, vA}, class@CCCC*/) |
| 1759 | GOTO_invoke(filledNewArray, false); |
| 1760 | OP_END |
| 1761 | |
| 1762 | /* File: c/OP_FILLED_NEW_ARRAY_RANGE.c */ |
| 1763 | HANDLE_OPCODE(OP_FILLED_NEW_ARRAY_RANGE /*{vCCCC..v(CCCC+AA-1)}, class@BBBB*/) |
| 1764 | GOTO_invoke(filledNewArray, true); |
| 1765 | OP_END |
| 1766 | |
| 1767 | /* File: c/OP_FILL_ARRAY_DATA.c */ |
| 1768 | HANDLE_OPCODE(OP_FILL_ARRAY_DATA) /*vAA, +BBBBBBBB*/ |
| 1769 | { |
| 1770 | const u2* arrayData; |
| 1771 | s4 offset; |
| 1772 | ArrayObject* arrayObj; |
| 1773 | |
| 1774 | EXPORT_PC(); |
| 1775 | vsrc1 = INST_AA(inst); |
| 1776 | offset = FETCH(1) | (((s4) FETCH(2)) << 16); |
| 1777 | ILOGV("|fill-array-data v%d +0x%04x", vsrc1, offset); |
| 1778 | arrayData = pc + offset; // offset in 16-bit units |
| 1779 | #ifndef NDEBUG |
| 1780 | if (arrayData < curMethod->insns || |
| 1781 | arrayData >= curMethod->insns + dvmGetMethodInsnsSize(curMethod)) |
| 1782 | { |
| 1783 | /* should have been caught in verifier */ |
| 1784 | dvmThrowException("Ljava/lang/InternalError;", |
| 1785 | "bad fill array data"); |
| 1786 | GOTO_exceptionThrown(); |
| 1787 | } |
| 1788 | #endif |
| 1789 | arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); |
| 1790 | if (!dvmInterpHandleFillArrayData(arrayObj, arrayData)) { |
| 1791 | GOTO_exceptionThrown(); |
| 1792 | } |
| 1793 | FINISH(3); |
| 1794 | } |
| 1795 | OP_END |
| 1796 | |
| 1797 | /* File: c/OP_THROW.c */ |
| 1798 | HANDLE_OPCODE(OP_THROW /*vAA*/) |
| 1799 | { |
| 1800 | Object* obj; |
| 1801 | |
| 1802 | vsrc1 = INST_AA(inst); |
| 1803 | ILOGV("|throw v%d (%p)", vsrc1, (void*)GET_REGISTER(vsrc1)); |
| 1804 | obj = (Object*) GET_REGISTER(vsrc1); |
| 1805 | if (!checkForNullExportPC(obj, fp, pc)) { |
| 1806 | /* will throw a null pointer exception */ |
| 1807 | LOGVV("Bad exception\n"); |
| 1808 | } else { |
| 1809 | /* use the requested exception */ |
| 1810 | dvmSetException(self, obj); |
| 1811 | } |
| 1812 | GOTO_exceptionThrown(); |
| 1813 | } |
| 1814 | OP_END |
| 1815 | |
| 1816 | /* File: c/OP_GOTO.c */ |
| 1817 | HANDLE_OPCODE(OP_GOTO /*+AA*/) |
| 1818 | vdst = INST_AA(inst); |
| 1819 | if ((s1)vdst < 0) |
| 1820 | ILOGV("|goto -0x%02x", -((s1)vdst)); |
| 1821 | else |
| 1822 | ILOGV("|goto +0x%02x", ((s1)vdst)); |
| 1823 | ILOGV("> branch taken"); |
| 1824 | if ((s1)vdst < 0) |
| 1825 | PERIODIC_CHECKS(kInterpEntryInstr, (s1)vdst); |
| 1826 | FINISH((s1)vdst); |
| 1827 | OP_END |
| 1828 | |
| 1829 | /* File: c/OP_GOTO_16.c */ |
| 1830 | HANDLE_OPCODE(OP_GOTO_16 /*+AAAA*/) |
| 1831 | { |
| 1832 | s4 offset = (s2) FETCH(1); /* sign-extend next code unit */ |
| 1833 | |
| 1834 | if (offset < 0) |
| 1835 | ILOGV("|goto/16 -0x%04x", -offset); |
| 1836 | else |
| 1837 | ILOGV("|goto/16 +0x%04x", offset); |
| 1838 | ILOGV("> branch taken"); |
| 1839 | if (offset < 0) |
| 1840 | PERIODIC_CHECKS(kInterpEntryInstr, offset); |
| 1841 | FINISH(offset); |
| 1842 | } |
| 1843 | OP_END |
| 1844 | |
| 1845 | /* File: c/OP_GOTO_32.c */ |
| 1846 | HANDLE_OPCODE(OP_GOTO_32 /*+AAAAAAAA*/) |
| 1847 | { |
| 1848 | s4 offset = FETCH(1); /* low-order 16 bits */ |
| 1849 | offset |= ((s4) FETCH(2)) << 16; /* high-order 16 bits */ |
| 1850 | |
| 1851 | if (offset < 0) |
| 1852 | ILOGV("|goto/32 -0x%08x", -offset); |
| 1853 | else |
| 1854 | ILOGV("|goto/32 +0x%08x", offset); |
| 1855 | ILOGV("> branch taken"); |
| 1856 | if (offset <= 0) /* allowed to branch to self */ |
| 1857 | PERIODIC_CHECKS(kInterpEntryInstr, offset); |
| 1858 | FINISH(offset); |
| 1859 | } |
| 1860 | OP_END |
| 1861 | |
| 1862 | /* File: c/OP_PACKED_SWITCH.c */ |
| 1863 | HANDLE_OPCODE(OP_PACKED_SWITCH /*vAA, +BBBB*/) |
| 1864 | { |
| 1865 | const u2* switchData; |
| 1866 | u4 testVal; |
| 1867 | s4 offset; |
| 1868 | |
| 1869 | vsrc1 = INST_AA(inst); |
| 1870 | offset = FETCH(1) | (((s4) FETCH(2)) << 16); |
| 1871 | ILOGV("|packed-switch v%d +0x%04x", vsrc1, vsrc2); |
| 1872 | switchData = pc + offset; // offset in 16-bit units |
| 1873 | #ifndef NDEBUG |
| 1874 | if (switchData < curMethod->insns || |
| 1875 | switchData >= curMethod->insns + dvmGetMethodInsnsSize(curMethod)) |
| 1876 | { |
| 1877 | /* should have been caught in verifier */ |
| 1878 | EXPORT_PC(); |
| 1879 | dvmThrowException("Ljava/lang/InternalError;", "bad packed switch"); |
| 1880 | GOTO_exceptionThrown(); |
| 1881 | } |
| 1882 | #endif |
| 1883 | testVal = GET_REGISTER(vsrc1); |
| 1884 | |
| 1885 | offset = dvmInterpHandlePackedSwitch(switchData, testVal); |
| 1886 | ILOGV("> branch taken (0x%04x)\n", offset); |
| 1887 | if (offset <= 0) /* uncommon */ |
| 1888 | PERIODIC_CHECKS(kInterpEntryInstr, offset); |
| 1889 | FINISH(offset); |
| 1890 | } |
| 1891 | OP_END |
| 1892 | |
| 1893 | /* File: c/OP_SPARSE_SWITCH.c */ |
| 1894 | HANDLE_OPCODE(OP_SPARSE_SWITCH /*vAA, +BBBB*/) |
| 1895 | { |
| 1896 | const u2* switchData; |
| 1897 | u4 testVal; |
| 1898 | s4 offset; |
| 1899 | |
| 1900 | vsrc1 = INST_AA(inst); |
| 1901 | offset = FETCH(1) | (((s4) FETCH(2)) << 16); |
| 1902 | ILOGV("|sparse-switch v%d +0x%04x", vsrc1, vsrc2); |
| 1903 | switchData = pc + offset; // offset in 16-bit units |
| 1904 | #ifndef NDEBUG |
| 1905 | if (switchData < curMethod->insns || |
| 1906 | switchData >= curMethod->insns + dvmGetMethodInsnsSize(curMethod)) |
| 1907 | { |
| 1908 | /* should have been caught in verifier */ |
| 1909 | EXPORT_PC(); |
| 1910 | dvmThrowException("Ljava/lang/InternalError;", "bad sparse switch"); |
| 1911 | GOTO_exceptionThrown(); |
| 1912 | } |
| 1913 | #endif |
| 1914 | testVal = GET_REGISTER(vsrc1); |
| 1915 | |
| 1916 | offset = dvmInterpHandleSparseSwitch(switchData, testVal); |
| 1917 | ILOGV("> branch taken (0x%04x)\n", offset); |
| 1918 | if (offset <= 0) /* uncommon */ |
| 1919 | PERIODIC_CHECKS(kInterpEntryInstr, offset); |
| 1920 | FINISH(offset); |
| 1921 | } |
| 1922 | OP_END |
| 1923 | |
| 1924 | /* File: c/OP_CMPL_FLOAT.c */ |
| 1925 | HANDLE_OP_CMPX(OP_CMPL_FLOAT, "l-float", float, _FLOAT, -1) |
| 1926 | OP_END |
| 1927 | |
| 1928 | /* File: c/OP_CMPG_FLOAT.c */ |
| 1929 | HANDLE_OP_CMPX(OP_CMPG_FLOAT, "g-float", float, _FLOAT, 1) |
| 1930 | OP_END |
| 1931 | |
| 1932 | /* File: c/OP_CMPL_DOUBLE.c */ |
| 1933 | HANDLE_OP_CMPX(OP_CMPL_DOUBLE, "l-double", double, _DOUBLE, -1) |
| 1934 | OP_END |
| 1935 | |
| 1936 | /* File: c/OP_CMPG_DOUBLE.c */ |
| 1937 | HANDLE_OP_CMPX(OP_CMPG_DOUBLE, "g-double", double, _DOUBLE, 1) |
| 1938 | OP_END |
| 1939 | |
| 1940 | /* File: c/OP_CMP_LONG.c */ |
| 1941 | HANDLE_OP_CMPX(OP_CMP_LONG, "-long", s8, _WIDE, 0) |
| 1942 | OP_END |
| 1943 | |
| 1944 | /* File: c/OP_IF_EQ.c */ |
| 1945 | HANDLE_OP_IF_XX(OP_IF_EQ, "eq", ==) |
| 1946 | OP_END |
| 1947 | |
| 1948 | /* File: c/OP_IF_NE.c */ |
| 1949 | HANDLE_OP_IF_XX(OP_IF_NE, "ne", !=) |
| 1950 | OP_END |
| 1951 | |
| 1952 | /* File: c/OP_IF_LT.c */ |
| 1953 | HANDLE_OP_IF_XX(OP_IF_LT, "lt", <) |
| 1954 | OP_END |
| 1955 | |
| 1956 | /* File: c/OP_IF_GE.c */ |
| 1957 | HANDLE_OP_IF_XX(OP_IF_GE, "ge", >=) |
| 1958 | OP_END |
| 1959 | |
| 1960 | /* File: c/OP_IF_GT.c */ |
| 1961 | HANDLE_OP_IF_XX(OP_IF_GT, "gt", >) |
| 1962 | OP_END |
| 1963 | |
| 1964 | /* File: c/OP_IF_LE.c */ |
| 1965 | HANDLE_OP_IF_XX(OP_IF_LE, "le", <=) |
| 1966 | OP_END |
| 1967 | |
| 1968 | /* File: c/OP_IF_EQZ.c */ |
| 1969 | HANDLE_OP_IF_XXZ(OP_IF_EQZ, "eqz", ==) |
| 1970 | OP_END |
| 1971 | |
| 1972 | /* File: c/OP_IF_NEZ.c */ |
| 1973 | HANDLE_OP_IF_XXZ(OP_IF_NEZ, "nez", !=) |
| 1974 | OP_END |
| 1975 | |
| 1976 | /* File: c/OP_IF_LTZ.c */ |
| 1977 | HANDLE_OP_IF_XXZ(OP_IF_LTZ, "ltz", <) |
| 1978 | OP_END |
| 1979 | |
| 1980 | /* File: c/OP_IF_GEZ.c */ |
| 1981 | HANDLE_OP_IF_XXZ(OP_IF_GEZ, "gez", >=) |
| 1982 | OP_END |
| 1983 | |
| 1984 | /* File: c/OP_IF_GTZ.c */ |
| 1985 | HANDLE_OP_IF_XXZ(OP_IF_GTZ, "gtz", >) |
| 1986 | OP_END |
| 1987 | |
| 1988 | /* File: c/OP_IF_LEZ.c */ |
| 1989 | HANDLE_OP_IF_XXZ(OP_IF_LEZ, "lez", <=) |
| 1990 | OP_END |
| 1991 | |
| 1992 | /* File: c/OP_UNUSED_3E.c */ |
| 1993 | HANDLE_OPCODE(OP_UNUSED_3E) |
| 1994 | OP_END |
| 1995 | |
| 1996 | /* File: c/OP_UNUSED_3F.c */ |
| 1997 | HANDLE_OPCODE(OP_UNUSED_3F) |
| 1998 | OP_END |
| 1999 | |
| 2000 | /* File: c/OP_UNUSED_40.c */ |
| 2001 | HANDLE_OPCODE(OP_UNUSED_40) |
| 2002 | OP_END |
| 2003 | |
| 2004 | /* File: c/OP_UNUSED_41.c */ |
| 2005 | HANDLE_OPCODE(OP_UNUSED_41) |
| 2006 | OP_END |
| 2007 | |
| 2008 | /* File: c/OP_UNUSED_42.c */ |
| 2009 | HANDLE_OPCODE(OP_UNUSED_42) |
| 2010 | OP_END |
| 2011 | |
| 2012 | /* File: c/OP_UNUSED_43.c */ |
| 2013 | HANDLE_OPCODE(OP_UNUSED_43) |
| 2014 | OP_END |
| 2015 | |
| 2016 | /* File: c/OP_AGET.c */ |
| 2017 | HANDLE_OP_AGET(OP_AGET, "", u4, ) |
| 2018 | OP_END |
| 2019 | |
| 2020 | /* File: c/OP_AGET_WIDE.c */ |
| 2021 | HANDLE_OP_AGET(OP_AGET_WIDE, "-wide", s8, _WIDE) |
| 2022 | OP_END |
| 2023 | |
| 2024 | /* File: c/OP_AGET_OBJECT.c */ |
| 2025 | HANDLE_OP_AGET(OP_AGET_OBJECT, "-object", u4, ) |
| 2026 | OP_END |
| 2027 | |
| 2028 | /* File: c/OP_AGET_BOOLEAN.c */ |
| 2029 | HANDLE_OP_AGET(OP_AGET_BOOLEAN, "-boolean", u1, ) |
| 2030 | OP_END |
| 2031 | |
| 2032 | /* File: c/OP_AGET_BYTE.c */ |
| 2033 | HANDLE_OP_AGET(OP_AGET_BYTE, "-byte", s1, ) |
| 2034 | OP_END |
| 2035 | |
| 2036 | /* File: c/OP_AGET_CHAR.c */ |
| 2037 | HANDLE_OP_AGET(OP_AGET_CHAR, "-char", u2, ) |
| 2038 | OP_END |
| 2039 | |
| 2040 | /* File: c/OP_AGET_SHORT.c */ |
| 2041 | HANDLE_OP_AGET(OP_AGET_SHORT, "-short", s2, ) |
| 2042 | OP_END |
| 2043 | |
| 2044 | /* File: c/OP_APUT.c */ |
| 2045 | HANDLE_OP_APUT(OP_APUT, "", u4, ) |
| 2046 | OP_END |
| 2047 | |
| 2048 | /* File: c/OP_APUT_WIDE.c */ |
| 2049 | HANDLE_OP_APUT(OP_APUT_WIDE, "-wide", s8, _WIDE) |
| 2050 | OP_END |
| 2051 | |
| 2052 | /* File: c/OP_APUT_OBJECT.c */ |
| 2053 | HANDLE_OPCODE(OP_APUT_OBJECT /*vAA, vBB, vCC*/) |
| 2054 | { |
| 2055 | ArrayObject* arrayObj; |
| 2056 | Object* obj; |
| 2057 | u2 arrayInfo; |
| 2058 | EXPORT_PC(); |
| 2059 | vdst = INST_AA(inst); /* AA: source value */ |
| 2060 | arrayInfo = FETCH(1); |
| 2061 | vsrc1 = arrayInfo & 0xff; /* BB: array ptr */ |
| 2062 | vsrc2 = arrayInfo >> 8; /* CC: index */ |
| 2063 | ILOGV("|aput%s v%d,v%d,v%d", "-object", vdst, vsrc1, vsrc2); |
| 2064 | arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); |
| 2065 | if (!checkForNull((Object*) arrayObj)) |
| 2066 | GOTO_exceptionThrown(); |
| 2067 | if (GET_REGISTER(vsrc2) >= arrayObj->length) { |
| 2068 | dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", |
| 2069 | NULL); |
| 2070 | GOTO_exceptionThrown(); |
| 2071 | } |
| 2072 | obj = (Object*) GET_REGISTER(vdst); |
| 2073 | if (obj != NULL) { |
| 2074 | if (!checkForNull(obj)) |
| 2075 | GOTO_exceptionThrown(); |
| 2076 | if (!dvmCanPutArrayElement(obj->clazz, arrayObj->obj.clazz)) { |
| 2077 | LOGV("Can't put a '%s'(%p) into array type='%s'(%p)\n", |
| 2078 | obj->clazz->descriptor, obj, |
| 2079 | arrayObj->obj.clazz->descriptor, arrayObj); |
| 2080 | //dvmDumpClass(obj->clazz); |
| 2081 | //dvmDumpClass(arrayObj->obj.clazz); |
| 2082 | dvmThrowException("Ljava/lang/ArrayStoreException;", NULL); |
| 2083 | GOTO_exceptionThrown(); |
| 2084 | } |
| 2085 | } |
| 2086 | ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst)); |
| 2087 | ((u4*) arrayObj->contents)[GET_REGISTER(vsrc2)] = |
| 2088 | GET_REGISTER(vdst); |
| 2089 | } |
| 2090 | FINISH(2); |
| 2091 | OP_END |
| 2092 | |
| 2093 | /* File: c/OP_APUT_BOOLEAN.c */ |
| 2094 | HANDLE_OP_APUT(OP_APUT_BOOLEAN, "-boolean", u1, ) |
| 2095 | OP_END |
| 2096 | |
| 2097 | /* File: c/OP_APUT_BYTE.c */ |
| 2098 | HANDLE_OP_APUT(OP_APUT_BYTE, "-byte", s1, ) |
| 2099 | OP_END |
| 2100 | |
| 2101 | /* File: c/OP_APUT_CHAR.c */ |
| 2102 | HANDLE_OP_APUT(OP_APUT_CHAR, "-char", u2, ) |
| 2103 | OP_END |
| 2104 | |
| 2105 | /* File: c/OP_APUT_SHORT.c */ |
| 2106 | HANDLE_OP_APUT(OP_APUT_SHORT, "-short", s2, ) |
| 2107 | OP_END |
| 2108 | |
| 2109 | /* File: c/OP_IGET.c */ |
| 2110 | HANDLE_IGET_X(OP_IGET, "", Int, ) |
| 2111 | OP_END |
| 2112 | |
| 2113 | /* File: c/OP_IGET_WIDE.c */ |
| 2114 | HANDLE_IGET_X(OP_IGET_WIDE, "-wide", Long, _WIDE) |
| 2115 | OP_END |
| 2116 | |
| 2117 | /* File: c/OP_IGET_OBJECT.c */ |
| 2118 | HANDLE_IGET_X(OP_IGET_OBJECT, "-object", Object, _AS_OBJECT) |
| 2119 | OP_END |
| 2120 | |
| 2121 | /* File: c/OP_IGET_BOOLEAN.c */ |
| 2122 | HANDLE_IGET_X(OP_IGET_BOOLEAN, "", Int, ) |
| 2123 | OP_END |
| 2124 | |
| 2125 | /* File: c/OP_IGET_BYTE.c */ |
| 2126 | HANDLE_IGET_X(OP_IGET_BYTE, "", Int, ) |
| 2127 | OP_END |
| 2128 | |
| 2129 | /* File: c/OP_IGET_CHAR.c */ |
| 2130 | HANDLE_IGET_X(OP_IGET_CHAR, "", Int, ) |
| 2131 | OP_END |
| 2132 | |
| 2133 | /* File: c/OP_IGET_SHORT.c */ |
| 2134 | HANDLE_IGET_X(OP_IGET_SHORT, "", Int, ) |
| 2135 | OP_END |
| 2136 | |
| 2137 | /* File: c/OP_IPUT.c */ |
| 2138 | HANDLE_IPUT_X(OP_IPUT, "", Int, ) |
| 2139 | OP_END |
| 2140 | |
| 2141 | /* File: c/OP_IPUT_WIDE.c */ |
| 2142 | HANDLE_IPUT_X(OP_IPUT_WIDE, "-wide", Long, _WIDE) |
| 2143 | OP_END |
| 2144 | |
| 2145 | /* File: c/OP_IPUT_OBJECT.c */ |
| 2146 | /* |
| 2147 | * The VM spec says we should verify that the reference being stored into |
| 2148 | * the field is assignment compatible. In practice, many popular VMs don't |
| 2149 | * do this because it slows down a very common operation. It's not so bad |
| 2150 | * for us, since "dexopt" quickens it whenever possible, but it's still an |
| 2151 | * issue. |
| 2152 | * |
| 2153 | * To make this spec-complaint, we'd need to add a ClassObject pointer to |
| 2154 | * the Field struct, resolve the field's type descriptor at link or class |
| 2155 | * init time, and then verify the type here. |
| 2156 | */ |
| 2157 | HANDLE_IPUT_X(OP_IPUT_OBJECT, "-object", Object, _AS_OBJECT) |
| 2158 | OP_END |
| 2159 | |
| 2160 | /* File: c/OP_IPUT_BOOLEAN.c */ |
| 2161 | HANDLE_IPUT_X(OP_IPUT_BOOLEAN, "", Int, ) |
| 2162 | OP_END |
| 2163 | |
| 2164 | /* File: c/OP_IPUT_BYTE.c */ |
| 2165 | HANDLE_IPUT_X(OP_IPUT_BYTE, "", Int, ) |
| 2166 | OP_END |
| 2167 | |
| 2168 | /* File: c/OP_IPUT_CHAR.c */ |
| 2169 | HANDLE_IPUT_X(OP_IPUT_CHAR, "", Int, ) |
| 2170 | OP_END |
| 2171 | |
| 2172 | /* File: c/OP_IPUT_SHORT.c */ |
| 2173 | HANDLE_IPUT_X(OP_IPUT_SHORT, "", Int, ) |
| 2174 | OP_END |
| 2175 | |
| 2176 | /* File: c/OP_SGET.c */ |
| 2177 | HANDLE_SGET_X(OP_SGET, "", Int, ) |
| 2178 | OP_END |
| 2179 | |
| 2180 | /* File: c/OP_SGET_WIDE.c */ |
| 2181 | HANDLE_SGET_X(OP_SGET_WIDE, "-wide", Long, _WIDE) |
| 2182 | OP_END |
| 2183 | |
| 2184 | /* File: c/OP_SGET_OBJECT.c */ |
| 2185 | HANDLE_SGET_X(OP_SGET_OBJECT, "-object", Object, _AS_OBJECT) |
| 2186 | OP_END |
| 2187 | |
| 2188 | /* File: c/OP_SGET_BOOLEAN.c */ |
| 2189 | HANDLE_SGET_X(OP_SGET_BOOLEAN, "", Int, ) |
| 2190 | OP_END |
| 2191 | |
| 2192 | /* File: c/OP_SGET_BYTE.c */ |
| 2193 | HANDLE_SGET_X(OP_SGET_BYTE, "", Int, ) |
| 2194 | OP_END |
| 2195 | |
| 2196 | /* File: c/OP_SGET_CHAR.c */ |
| 2197 | HANDLE_SGET_X(OP_SGET_CHAR, "", Int, ) |
| 2198 | OP_END |
| 2199 | |
| 2200 | /* File: c/OP_SGET_SHORT.c */ |
| 2201 | HANDLE_SGET_X(OP_SGET_SHORT, "", Int, ) |
| 2202 | OP_END |
| 2203 | |
| 2204 | /* File: c/OP_SPUT.c */ |
| 2205 | HANDLE_SPUT_X(OP_SPUT, "", Int, ) |
| 2206 | OP_END |
| 2207 | |
| 2208 | /* File: c/OP_SPUT_WIDE.c */ |
| 2209 | HANDLE_SPUT_X(OP_SPUT_WIDE, "-wide", Long, _WIDE) |
| 2210 | OP_END |
| 2211 | |
| 2212 | /* File: c/OP_SPUT_OBJECT.c */ |
| 2213 | HANDLE_SPUT_X(OP_SPUT_OBJECT, "-object", Object, _AS_OBJECT) |
| 2214 | OP_END |
| 2215 | |
| 2216 | /* File: c/OP_SPUT_BOOLEAN.c */ |
| 2217 | HANDLE_SPUT_X(OP_SPUT_BOOLEAN, "", Int, ) |
| 2218 | OP_END |
| 2219 | |
| 2220 | /* File: c/OP_SPUT_BYTE.c */ |
| 2221 | HANDLE_SPUT_X(OP_SPUT_BYTE, "", Int, ) |
| 2222 | OP_END |
| 2223 | |
| 2224 | /* File: c/OP_SPUT_CHAR.c */ |
| 2225 | HANDLE_SPUT_X(OP_SPUT_CHAR, "", Int, ) |
| 2226 | OP_END |
| 2227 | |
| 2228 | /* File: c/OP_SPUT_SHORT.c */ |
| 2229 | HANDLE_SPUT_X(OP_SPUT_SHORT, "", Int, ) |
| 2230 | OP_END |
| 2231 | |
| 2232 | /* File: c/OP_INVOKE_VIRTUAL.c */ |
| 2233 | HANDLE_OPCODE(OP_INVOKE_VIRTUAL /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2234 | GOTO_invoke(invokeVirtual, false); |
| 2235 | OP_END |
| 2236 | |
| 2237 | /* File: c/OP_INVOKE_SUPER.c */ |
| 2238 | HANDLE_OPCODE(OP_INVOKE_SUPER /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2239 | GOTO_invoke(invokeSuper, false); |
| 2240 | OP_END |
| 2241 | |
| 2242 | /* File: c/OP_INVOKE_DIRECT.c */ |
| 2243 | HANDLE_OPCODE(OP_INVOKE_DIRECT /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2244 | GOTO_invoke(invokeDirect, false); |
| 2245 | OP_END |
| 2246 | |
| 2247 | /* File: c/OP_INVOKE_STATIC.c */ |
| 2248 | HANDLE_OPCODE(OP_INVOKE_STATIC /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2249 | GOTO_invoke(invokeStatic, false); |
| 2250 | OP_END |
| 2251 | |
| 2252 | /* File: c/OP_INVOKE_INTERFACE.c */ |
| 2253 | HANDLE_OPCODE(OP_INVOKE_INTERFACE /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2254 | GOTO_invoke(invokeInterface, false); |
| 2255 | OP_END |
| 2256 | |
| 2257 | /* File: c/OP_UNUSED_73.c */ |
| 2258 | HANDLE_OPCODE(OP_UNUSED_73) |
| 2259 | OP_END |
| 2260 | |
| 2261 | /* File: c/OP_INVOKE_VIRTUAL_RANGE.c */ |
| 2262 | HANDLE_OPCODE(OP_INVOKE_VIRTUAL_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2263 | GOTO_invoke(invokeVirtual, true); |
| 2264 | OP_END |
| 2265 | |
| 2266 | /* File: c/OP_INVOKE_SUPER_RANGE.c */ |
| 2267 | HANDLE_OPCODE(OP_INVOKE_SUPER_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2268 | GOTO_invoke(invokeSuper, true); |
| 2269 | OP_END |
| 2270 | |
| 2271 | /* File: c/OP_INVOKE_DIRECT_RANGE.c */ |
| 2272 | HANDLE_OPCODE(OP_INVOKE_DIRECT_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2273 | GOTO_invoke(invokeDirect, true); |
| 2274 | OP_END |
| 2275 | |
| 2276 | /* File: c/OP_INVOKE_STATIC_RANGE.c */ |
| 2277 | HANDLE_OPCODE(OP_INVOKE_STATIC_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2278 | GOTO_invoke(invokeStatic, true); |
| 2279 | OP_END |
| 2280 | |
| 2281 | /* File: c/OP_INVOKE_INTERFACE_RANGE.c */ |
| 2282 | HANDLE_OPCODE(OP_INVOKE_INTERFACE_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2283 | GOTO_invoke(invokeInterface, true); |
| 2284 | OP_END |
| 2285 | |
| 2286 | /* File: c/OP_UNUSED_79.c */ |
| 2287 | HANDLE_OPCODE(OP_UNUSED_79) |
| 2288 | OP_END |
| 2289 | |
| 2290 | /* File: c/OP_UNUSED_7A.c */ |
| 2291 | HANDLE_OPCODE(OP_UNUSED_7A) |
| 2292 | OP_END |
| 2293 | |
| 2294 | /* File: c/OP_NEG_INT.c */ |
| 2295 | HANDLE_UNOP(OP_NEG_INT, "neg-int", -, , ) |
| 2296 | OP_END |
| 2297 | |
| 2298 | /* File: c/OP_NOT_INT.c */ |
| 2299 | HANDLE_UNOP(OP_NOT_INT, "not-int", , ^ 0xffffffff, ) |
| 2300 | OP_END |
| 2301 | |
| 2302 | /* File: c/OP_NEG_LONG.c */ |
| 2303 | HANDLE_UNOP(OP_NEG_LONG, "neg-long", -, , _WIDE) |
| 2304 | OP_END |
| 2305 | |
| 2306 | /* File: c/OP_NOT_LONG.c */ |
| 2307 | HANDLE_UNOP(OP_NOT_LONG, "not-long", , ^ 0xffffffffffffffffULL, _WIDE) |
| 2308 | OP_END |
| 2309 | |
| 2310 | /* File: c/OP_NEG_FLOAT.c */ |
| 2311 | HANDLE_UNOP(OP_NEG_FLOAT, "neg-float", -, , _FLOAT) |
| 2312 | OP_END |
| 2313 | |
| 2314 | /* File: c/OP_NEG_DOUBLE.c */ |
| 2315 | HANDLE_UNOP(OP_NEG_DOUBLE, "neg-double", -, , _DOUBLE) |
| 2316 | OP_END |
| 2317 | |
| 2318 | /* File: c/OP_INT_TO_LONG.c */ |
| 2319 | HANDLE_NUMCONV(OP_INT_TO_LONG, "int-to-long", _INT, _WIDE) |
| 2320 | OP_END |
| 2321 | |
| 2322 | /* File: c/OP_INT_TO_FLOAT.c */ |
| 2323 | HANDLE_NUMCONV(OP_INT_TO_FLOAT, "int-to-float", _INT, _FLOAT) |
| 2324 | OP_END |
| 2325 | |
| 2326 | /* File: c/OP_INT_TO_DOUBLE.c */ |
| 2327 | HANDLE_NUMCONV(OP_INT_TO_DOUBLE, "int-to-double", _INT, _DOUBLE) |
| 2328 | OP_END |
| 2329 | |
| 2330 | /* File: c/OP_LONG_TO_INT.c */ |
| 2331 | HANDLE_NUMCONV(OP_LONG_TO_INT, "long-to-int", _WIDE, _INT) |
| 2332 | OP_END |
| 2333 | |
| 2334 | /* File: c/OP_LONG_TO_FLOAT.c */ |
| 2335 | HANDLE_NUMCONV(OP_LONG_TO_FLOAT, "long-to-float", _WIDE, _FLOAT) |
| 2336 | OP_END |
| 2337 | |
| 2338 | /* File: c/OP_LONG_TO_DOUBLE.c */ |
| 2339 | HANDLE_NUMCONV(OP_LONG_TO_DOUBLE, "long-to-double", _WIDE, _DOUBLE) |
| 2340 | OP_END |
| 2341 | |
| 2342 | /* File: c/OP_FLOAT_TO_INT.c */ |
| 2343 | HANDLE_FLOAT_TO_INT(OP_FLOAT_TO_INT, "float-to-int", |
| 2344 | float, _FLOAT, s4, _INT) |
| 2345 | OP_END |
| 2346 | |
| 2347 | /* File: c/OP_FLOAT_TO_LONG.c */ |
| 2348 | HANDLE_FLOAT_TO_INT(OP_FLOAT_TO_LONG, "float-to-long", |
| 2349 | float, _FLOAT, s8, _WIDE) |
| 2350 | OP_END |
| 2351 | |
| 2352 | /* File: c/OP_FLOAT_TO_DOUBLE.c */ |
| 2353 | HANDLE_NUMCONV(OP_FLOAT_TO_DOUBLE, "float-to-double", _FLOAT, _DOUBLE) |
| 2354 | OP_END |
| 2355 | |
| 2356 | /* File: c/OP_DOUBLE_TO_INT.c */ |
| 2357 | HANDLE_FLOAT_TO_INT(OP_DOUBLE_TO_INT, "double-to-int", |
| 2358 | double, _DOUBLE, s4, _INT) |
| 2359 | OP_END |
| 2360 | |
| 2361 | /* File: c/OP_DOUBLE_TO_LONG.c */ |
| 2362 | HANDLE_FLOAT_TO_INT(OP_DOUBLE_TO_LONG, "double-to-long", |
| 2363 | double, _DOUBLE, s8, _WIDE) |
| 2364 | OP_END |
| 2365 | |
| 2366 | /* File: c/OP_DOUBLE_TO_FLOAT.c */ |
| 2367 | HANDLE_NUMCONV(OP_DOUBLE_TO_FLOAT, "double-to-float", _DOUBLE, _FLOAT) |
| 2368 | OP_END |
| 2369 | |
| 2370 | /* File: c/OP_INT_TO_BYTE.c */ |
| 2371 | HANDLE_INT_TO_SMALL(OP_INT_TO_BYTE, "byte", s1) |
| 2372 | OP_END |
| 2373 | |
| 2374 | /* File: c/OP_INT_TO_CHAR.c */ |
| 2375 | HANDLE_INT_TO_SMALL(OP_INT_TO_CHAR, "char", u2) |
| 2376 | OP_END |
| 2377 | |
| 2378 | /* File: c/OP_INT_TO_SHORT.c */ |
| 2379 | HANDLE_INT_TO_SMALL(OP_INT_TO_SHORT, "short", s2) /* want sign bit */ |
| 2380 | OP_END |
| 2381 | |
| 2382 | /* File: c/OP_ADD_INT.c */ |
| 2383 | HANDLE_OP_X_INT(OP_ADD_INT, "add", +, 0) |
| 2384 | OP_END |
| 2385 | |
| 2386 | /* File: c/OP_SUB_INT.c */ |
| 2387 | HANDLE_OP_X_INT(OP_SUB_INT, "sub", -, 0) |
| 2388 | OP_END |
| 2389 | |
| 2390 | /* File: c/OP_MUL_INT.c */ |
| 2391 | HANDLE_OP_X_INT(OP_MUL_INT, "mul", *, 0) |
| 2392 | OP_END |
| 2393 | |
| 2394 | /* File: c/OP_DIV_INT.c */ |
| 2395 | HANDLE_OP_X_INT(OP_DIV_INT, "div", /, 1) |
| 2396 | OP_END |
| 2397 | |
| 2398 | /* File: c/OP_REM_INT.c */ |
| 2399 | HANDLE_OP_X_INT(OP_REM_INT, "rem", %, 2) |
| 2400 | OP_END |
| 2401 | |
| 2402 | /* File: c/OP_AND_INT.c */ |
| 2403 | HANDLE_OP_X_INT(OP_AND_INT, "and", &, 0) |
| 2404 | OP_END |
| 2405 | |
| 2406 | /* File: c/OP_OR_INT.c */ |
| 2407 | HANDLE_OP_X_INT(OP_OR_INT, "or", |, 0) |
| 2408 | OP_END |
| 2409 | |
| 2410 | /* File: c/OP_XOR_INT.c */ |
| 2411 | HANDLE_OP_X_INT(OP_XOR_INT, "xor", ^, 0) |
| 2412 | OP_END |
| 2413 | |
| 2414 | /* File: c/OP_SHL_INT.c */ |
| 2415 | HANDLE_OP_SHX_INT(OP_SHL_INT, "shl", (s4), <<) |
| 2416 | OP_END |
| 2417 | |
| 2418 | /* File: c/OP_SHR_INT.c */ |
| 2419 | HANDLE_OP_SHX_INT(OP_SHR_INT, "shr", (s4), >>) |
| 2420 | OP_END |
| 2421 | |
| 2422 | /* File: c/OP_USHR_INT.c */ |
| 2423 | HANDLE_OP_SHX_INT(OP_USHR_INT, "ushr", (u4), >>) |
| 2424 | OP_END |
| 2425 | |
| 2426 | /* File: c/OP_ADD_LONG.c */ |
| 2427 | HANDLE_OP_X_LONG(OP_ADD_LONG, "add", +, 0) |
| 2428 | OP_END |
| 2429 | |
| 2430 | /* File: c/OP_SUB_LONG.c */ |
| 2431 | HANDLE_OP_X_LONG(OP_SUB_LONG, "sub", -, 0) |
| 2432 | OP_END |
| 2433 | |
| 2434 | /* File: c/OP_MUL_LONG.c */ |
| 2435 | HANDLE_OP_X_LONG(OP_MUL_LONG, "mul", *, 0) |
| 2436 | OP_END |
| 2437 | |
| 2438 | /* File: c/OP_DIV_LONG.c */ |
| 2439 | HANDLE_OP_X_LONG(OP_DIV_LONG, "div", /, 1) |
| 2440 | OP_END |
| 2441 | |
| 2442 | /* File: c/OP_REM_LONG.c */ |
| 2443 | HANDLE_OP_X_LONG(OP_REM_LONG, "rem", %, 2) |
| 2444 | OP_END |
| 2445 | |
| 2446 | /* File: c/OP_AND_LONG.c */ |
| 2447 | HANDLE_OP_X_LONG(OP_AND_LONG, "and", &, 0) |
| 2448 | OP_END |
| 2449 | |
| 2450 | /* File: c/OP_OR_LONG.c */ |
| 2451 | HANDLE_OP_X_LONG(OP_OR_LONG, "or", |, 0) |
| 2452 | OP_END |
| 2453 | |
| 2454 | /* File: c/OP_XOR_LONG.c */ |
| 2455 | HANDLE_OP_X_LONG(OP_XOR_LONG, "xor", ^, 0) |
| 2456 | OP_END |
| 2457 | |
| 2458 | /* File: c/OP_SHL_LONG.c */ |
| 2459 | HANDLE_OP_SHX_LONG(OP_SHL_LONG, "shl", (s8), <<) |
| 2460 | OP_END |
| 2461 | |
| 2462 | /* File: c/OP_SHR_LONG.c */ |
| 2463 | HANDLE_OP_SHX_LONG(OP_SHR_LONG, "shr", (s8), >>) |
| 2464 | OP_END |
| 2465 | |
| 2466 | /* File: c/OP_USHR_LONG.c */ |
| 2467 | HANDLE_OP_SHX_LONG(OP_USHR_LONG, "ushr", (u8), >>) |
| 2468 | OP_END |
| 2469 | |
| 2470 | /* File: c/OP_ADD_FLOAT.c */ |
| 2471 | HANDLE_OP_X_FLOAT(OP_ADD_FLOAT, "add", +) |
| 2472 | OP_END |
| 2473 | |
| 2474 | /* File: c/OP_SUB_FLOAT.c */ |
| 2475 | HANDLE_OP_X_FLOAT(OP_SUB_FLOAT, "sub", -) |
| 2476 | OP_END |
| 2477 | |
| 2478 | /* File: c/OP_MUL_FLOAT.c */ |
| 2479 | HANDLE_OP_X_FLOAT(OP_MUL_FLOAT, "mul", *) |
| 2480 | OP_END |
| 2481 | |
| 2482 | /* File: c/OP_DIV_FLOAT.c */ |
| 2483 | HANDLE_OP_X_FLOAT(OP_DIV_FLOAT, "div", /) |
| 2484 | OP_END |
| 2485 | |
| 2486 | /* File: c/OP_REM_FLOAT.c */ |
| 2487 | HANDLE_OPCODE(OP_REM_FLOAT /*vAA, vBB, vCC*/) |
| 2488 | { |
| 2489 | u2 srcRegs; |
| 2490 | vdst = INST_AA(inst); |
| 2491 | srcRegs = FETCH(1); |
| 2492 | vsrc1 = srcRegs & 0xff; |
| 2493 | vsrc2 = srcRegs >> 8; |
| 2494 | ILOGV("|%s-float v%d,v%d,v%d", "mod", vdst, vsrc1, vsrc2); |
| 2495 | SET_REGISTER_FLOAT(vdst, |
| 2496 | fmodf(GET_REGISTER_FLOAT(vsrc1), GET_REGISTER_FLOAT(vsrc2))); |
| 2497 | } |
| 2498 | FINISH(2); |
| 2499 | OP_END |
| 2500 | |
| 2501 | /* File: c/OP_ADD_DOUBLE.c */ |
| 2502 | HANDLE_OP_X_DOUBLE(OP_ADD_DOUBLE, "add", +) |
| 2503 | OP_END |
| 2504 | |
| 2505 | /* File: c/OP_SUB_DOUBLE.c */ |
| 2506 | HANDLE_OP_X_DOUBLE(OP_SUB_DOUBLE, "sub", -) |
| 2507 | OP_END |
| 2508 | |
| 2509 | /* File: c/OP_MUL_DOUBLE.c */ |
| 2510 | HANDLE_OP_X_DOUBLE(OP_MUL_DOUBLE, "mul", *) |
| 2511 | OP_END |
| 2512 | |
| 2513 | /* File: c/OP_DIV_DOUBLE.c */ |
| 2514 | HANDLE_OP_X_DOUBLE(OP_DIV_DOUBLE, "div", /) |
| 2515 | OP_END |
| 2516 | |
| 2517 | /* File: c/OP_REM_DOUBLE.c */ |
| 2518 | HANDLE_OPCODE(OP_REM_DOUBLE /*vAA, vBB, vCC*/) |
| 2519 | { |
| 2520 | u2 srcRegs; |
| 2521 | vdst = INST_AA(inst); |
| 2522 | srcRegs = FETCH(1); |
| 2523 | vsrc1 = srcRegs & 0xff; |
| 2524 | vsrc2 = srcRegs >> 8; |
| 2525 | ILOGV("|%s-double v%d,v%d,v%d", "mod", vdst, vsrc1, vsrc2); |
| 2526 | SET_REGISTER_DOUBLE(vdst, |
| 2527 | fmod(GET_REGISTER_DOUBLE(vsrc1), GET_REGISTER_DOUBLE(vsrc2))); |
| 2528 | } |
| 2529 | FINISH(2); |
| 2530 | OP_END |
| 2531 | |
| 2532 | /* File: c/OP_ADD_INT_2ADDR.c */ |
| 2533 | HANDLE_OP_X_INT_2ADDR(OP_ADD_INT_2ADDR, "add", +, 0) |
| 2534 | OP_END |
| 2535 | |
| 2536 | /* File: c/OP_SUB_INT_2ADDR.c */ |
| 2537 | HANDLE_OP_X_INT_2ADDR(OP_SUB_INT_2ADDR, "sub", -, 0) |
| 2538 | OP_END |
| 2539 | |
| 2540 | /* File: c/OP_MUL_INT_2ADDR.c */ |
| 2541 | HANDLE_OP_X_INT_2ADDR(OP_MUL_INT_2ADDR, "mul", *, 0) |
| 2542 | OP_END |
| 2543 | |
| 2544 | /* File: c/OP_DIV_INT_2ADDR.c */ |
| 2545 | HANDLE_OP_X_INT_2ADDR(OP_DIV_INT_2ADDR, "div", /, 1) |
| 2546 | OP_END |
| 2547 | |
| 2548 | /* File: c/OP_REM_INT_2ADDR.c */ |
| 2549 | HANDLE_OP_X_INT_2ADDR(OP_REM_INT_2ADDR, "rem", %, 2) |
| 2550 | OP_END |
| 2551 | |
| 2552 | /* File: c/OP_AND_INT_2ADDR.c */ |
| 2553 | HANDLE_OP_X_INT_2ADDR(OP_AND_INT_2ADDR, "and", &, 0) |
| 2554 | OP_END |
| 2555 | |
| 2556 | /* File: c/OP_OR_INT_2ADDR.c */ |
| 2557 | HANDLE_OP_X_INT_2ADDR(OP_OR_INT_2ADDR, "or", |, 0) |
| 2558 | OP_END |
| 2559 | |
| 2560 | /* File: c/OP_XOR_INT_2ADDR.c */ |
| 2561 | HANDLE_OP_X_INT_2ADDR(OP_XOR_INT_2ADDR, "xor", ^, 0) |
| 2562 | OP_END |
| 2563 | |
| 2564 | /* File: c/OP_SHL_INT_2ADDR.c */ |
| 2565 | HANDLE_OP_SHX_INT_2ADDR(OP_SHL_INT_2ADDR, "shl", (s4), <<) |
| 2566 | OP_END |
| 2567 | |
| 2568 | /* File: c/OP_SHR_INT_2ADDR.c */ |
| 2569 | HANDLE_OP_SHX_INT_2ADDR(OP_SHR_INT_2ADDR, "shr", (s4), >>) |
| 2570 | OP_END |
| 2571 | |
| 2572 | /* File: c/OP_USHR_INT_2ADDR.c */ |
| 2573 | HANDLE_OP_SHX_INT_2ADDR(OP_USHR_INT_2ADDR, "ushr", (u4), >>) |
| 2574 | OP_END |
| 2575 | |
| 2576 | /* File: c/OP_ADD_LONG_2ADDR.c */ |
| 2577 | HANDLE_OP_X_LONG_2ADDR(OP_ADD_LONG_2ADDR, "add", +, 0) |
| 2578 | OP_END |
| 2579 | |
| 2580 | /* File: c/OP_SUB_LONG_2ADDR.c */ |
| 2581 | HANDLE_OP_X_LONG_2ADDR(OP_SUB_LONG_2ADDR, "sub", -, 0) |
| 2582 | OP_END |
| 2583 | |
| 2584 | /* File: c/OP_MUL_LONG_2ADDR.c */ |
| 2585 | HANDLE_OP_X_LONG_2ADDR(OP_MUL_LONG_2ADDR, "mul", *, 0) |
| 2586 | OP_END |
| 2587 | |
| 2588 | /* File: c/OP_DIV_LONG_2ADDR.c */ |
| 2589 | HANDLE_OP_X_LONG_2ADDR(OP_DIV_LONG_2ADDR, "div", /, 1) |
| 2590 | OP_END |
| 2591 | |
| 2592 | /* File: c/OP_REM_LONG_2ADDR.c */ |
| 2593 | HANDLE_OP_X_LONG_2ADDR(OP_REM_LONG_2ADDR, "rem", %, 2) |
| 2594 | OP_END |
| 2595 | |
| 2596 | /* File: c/OP_AND_LONG_2ADDR.c */ |
| 2597 | HANDLE_OP_X_LONG_2ADDR(OP_AND_LONG_2ADDR, "and", &, 0) |
| 2598 | OP_END |
| 2599 | |
| 2600 | /* File: c/OP_OR_LONG_2ADDR.c */ |
| 2601 | HANDLE_OP_X_LONG_2ADDR(OP_OR_LONG_2ADDR, "or", |, 0) |
| 2602 | OP_END |
| 2603 | |
| 2604 | /* File: c/OP_XOR_LONG_2ADDR.c */ |
| 2605 | HANDLE_OP_X_LONG_2ADDR(OP_XOR_LONG_2ADDR, "xor", ^, 0) |
| 2606 | OP_END |
| 2607 | |
| 2608 | /* File: c/OP_SHL_LONG_2ADDR.c */ |
| 2609 | HANDLE_OP_SHX_LONG_2ADDR(OP_SHL_LONG_2ADDR, "shl", (s8), <<) |
| 2610 | OP_END |
| 2611 | |
| 2612 | /* File: c/OP_SHR_LONG_2ADDR.c */ |
| 2613 | HANDLE_OP_SHX_LONG_2ADDR(OP_SHR_LONG_2ADDR, "shr", (s8), >>) |
| 2614 | OP_END |
| 2615 | |
| 2616 | /* File: c/OP_USHR_LONG_2ADDR.c */ |
| 2617 | HANDLE_OP_SHX_LONG_2ADDR(OP_USHR_LONG_2ADDR, "ushr", (u8), >>) |
| 2618 | OP_END |
| 2619 | |
| 2620 | /* File: c/OP_ADD_FLOAT_2ADDR.c */ |
| 2621 | HANDLE_OP_X_FLOAT_2ADDR(OP_ADD_FLOAT_2ADDR, "add", +) |
| 2622 | OP_END |
| 2623 | |
| 2624 | /* File: c/OP_SUB_FLOAT_2ADDR.c */ |
| 2625 | HANDLE_OP_X_FLOAT_2ADDR(OP_SUB_FLOAT_2ADDR, "sub", -) |
| 2626 | OP_END |
| 2627 | |
| 2628 | /* File: c/OP_MUL_FLOAT_2ADDR.c */ |
| 2629 | HANDLE_OP_X_FLOAT_2ADDR(OP_MUL_FLOAT_2ADDR, "mul", *) |
| 2630 | OP_END |
| 2631 | |
| 2632 | /* File: c/OP_DIV_FLOAT_2ADDR.c */ |
| 2633 | HANDLE_OP_X_FLOAT_2ADDR(OP_DIV_FLOAT_2ADDR, "div", /) |
| 2634 | OP_END |
| 2635 | |
| 2636 | /* File: c/OP_REM_FLOAT_2ADDR.c */ |
| 2637 | HANDLE_OPCODE(OP_REM_FLOAT_2ADDR /*vA, vB*/) |
| 2638 | vdst = INST_A(inst); |
| 2639 | vsrc1 = INST_B(inst); |
| 2640 | ILOGV("|%s-float-2addr v%d,v%d", "mod", vdst, vsrc1); |
| 2641 | SET_REGISTER_FLOAT(vdst, |
| 2642 | fmodf(GET_REGISTER_FLOAT(vdst), GET_REGISTER_FLOAT(vsrc1))); |
| 2643 | FINISH(1); |
| 2644 | OP_END |
| 2645 | |
| 2646 | /* File: c/OP_ADD_DOUBLE_2ADDR.c */ |
| 2647 | HANDLE_OP_X_DOUBLE_2ADDR(OP_ADD_DOUBLE_2ADDR, "add", +) |
| 2648 | OP_END |
| 2649 | |
| 2650 | /* File: c/OP_SUB_DOUBLE_2ADDR.c */ |
| 2651 | HANDLE_OP_X_DOUBLE_2ADDR(OP_SUB_DOUBLE_2ADDR, "sub", -) |
| 2652 | OP_END |
| 2653 | |
| 2654 | /* File: c/OP_MUL_DOUBLE_2ADDR.c */ |
| 2655 | HANDLE_OP_X_DOUBLE_2ADDR(OP_MUL_DOUBLE_2ADDR, "mul", *) |
| 2656 | OP_END |
| 2657 | |
| 2658 | /* File: c/OP_DIV_DOUBLE_2ADDR.c */ |
| 2659 | HANDLE_OP_X_DOUBLE_2ADDR(OP_DIV_DOUBLE_2ADDR, "div", /) |
| 2660 | OP_END |
| 2661 | |
| 2662 | /* File: c/OP_REM_DOUBLE_2ADDR.c */ |
| 2663 | HANDLE_OPCODE(OP_REM_DOUBLE_2ADDR /*vA, vB*/) |
| 2664 | vdst = INST_A(inst); |
| 2665 | vsrc1 = INST_B(inst); |
| 2666 | ILOGV("|%s-double-2addr v%d,v%d", "mod", vdst, vsrc1); |
| 2667 | SET_REGISTER_DOUBLE(vdst, |
| 2668 | fmod(GET_REGISTER_DOUBLE(vdst), GET_REGISTER_DOUBLE(vsrc1))); |
| 2669 | FINISH(1); |
| 2670 | OP_END |
| 2671 | |
| 2672 | /* File: c/OP_ADD_INT_LIT16.c */ |
| 2673 | HANDLE_OP_X_INT_LIT16(OP_ADD_INT_LIT16, "add", +, 0) |
| 2674 | OP_END |
| 2675 | |
| 2676 | /* File: c/OP_RSUB_INT.c */ |
| 2677 | HANDLE_OPCODE(OP_RSUB_INT /*vA, vB, #+CCCC*/) |
| 2678 | { |
| 2679 | vdst = INST_A(inst); |
| 2680 | vsrc1 = INST_B(inst); |
| 2681 | vsrc2 = FETCH(1); |
| 2682 | ILOGV("|rsub-int v%d,v%d,#+0x%04x", vdst, vsrc1, vsrc2); |
| 2683 | SET_REGISTER(vdst, (s2) vsrc2 - (s4) GET_REGISTER(vsrc1)); |
| 2684 | } |
| 2685 | FINISH(2); |
| 2686 | OP_END |
| 2687 | |
| 2688 | /* File: c/OP_MUL_INT_LIT16.c */ |
| 2689 | HANDLE_OP_X_INT_LIT16(OP_MUL_INT_LIT16, "mul", *, 0) |
| 2690 | OP_END |
| 2691 | |
| 2692 | /* File: c/OP_DIV_INT_LIT16.c */ |
| 2693 | HANDLE_OP_X_INT_LIT16(OP_DIV_INT_LIT16, "div", /, 1) |
| 2694 | OP_END |
| 2695 | |
| 2696 | /* File: c/OP_REM_INT_LIT16.c */ |
| 2697 | HANDLE_OP_X_INT_LIT16(OP_REM_INT_LIT16, "rem", %, 2) |
| 2698 | OP_END |
| 2699 | |
| 2700 | /* File: c/OP_AND_INT_LIT16.c */ |
| 2701 | HANDLE_OP_X_INT_LIT16(OP_AND_INT_LIT16, "and", &, 0) |
| 2702 | OP_END |
| 2703 | |
| 2704 | /* File: c/OP_OR_INT_LIT16.c */ |
| 2705 | HANDLE_OP_X_INT_LIT16(OP_OR_INT_LIT16, "or", |, 0) |
| 2706 | OP_END |
| 2707 | |
| 2708 | /* File: c/OP_XOR_INT_LIT16.c */ |
| 2709 | HANDLE_OP_X_INT_LIT16(OP_XOR_INT_LIT16, "xor", ^, 0) |
| 2710 | OP_END |
| 2711 | |
| 2712 | /* File: c/OP_ADD_INT_LIT8.c */ |
| 2713 | HANDLE_OP_X_INT_LIT8(OP_ADD_INT_LIT8, "add", +, 0) |
| 2714 | OP_END |
| 2715 | |
| 2716 | /* File: c/OP_RSUB_INT_LIT8.c */ |
| 2717 | HANDLE_OPCODE(OP_RSUB_INT_LIT8 /*vAA, vBB, #+CC*/) |
| 2718 | { |
| 2719 | u2 litInfo; |
| 2720 | vdst = INST_AA(inst); |
| 2721 | litInfo = FETCH(1); |
| 2722 | vsrc1 = litInfo & 0xff; |
| 2723 | vsrc2 = litInfo >> 8; |
| 2724 | ILOGV("|%s-int/lit8 v%d,v%d,#+0x%02x", "rsub", vdst, vsrc1, vsrc2); |
| 2725 | SET_REGISTER(vdst, (s1) vsrc2 - (s4) GET_REGISTER(vsrc1)); |
| 2726 | } |
| 2727 | FINISH(2); |
| 2728 | OP_END |
| 2729 | |
| 2730 | /* File: c/OP_MUL_INT_LIT8.c */ |
| 2731 | HANDLE_OP_X_INT_LIT8(OP_MUL_INT_LIT8, "mul", *, 0) |
| 2732 | OP_END |
| 2733 | |
| 2734 | /* File: c/OP_DIV_INT_LIT8.c */ |
| 2735 | HANDLE_OP_X_INT_LIT8(OP_DIV_INT_LIT8, "div", /, 1) |
| 2736 | OP_END |
| 2737 | |
| 2738 | /* File: c/OP_REM_INT_LIT8.c */ |
| 2739 | HANDLE_OP_X_INT_LIT8(OP_REM_INT_LIT8, "rem", %, 2) |
| 2740 | OP_END |
| 2741 | |
| 2742 | /* File: c/OP_AND_INT_LIT8.c */ |
| 2743 | HANDLE_OP_X_INT_LIT8(OP_AND_INT_LIT8, "and", &, 0) |
| 2744 | OP_END |
| 2745 | |
| 2746 | /* File: c/OP_OR_INT_LIT8.c */ |
| 2747 | HANDLE_OP_X_INT_LIT8(OP_OR_INT_LIT8, "or", |, 0) |
| 2748 | OP_END |
| 2749 | |
| 2750 | /* File: c/OP_XOR_INT_LIT8.c */ |
| 2751 | HANDLE_OP_X_INT_LIT8(OP_XOR_INT_LIT8, "xor", ^, 0) |
| 2752 | OP_END |
| 2753 | |
| 2754 | /* File: c/OP_SHL_INT_LIT8.c */ |
| 2755 | HANDLE_OP_SHX_INT_LIT8(OP_SHL_INT_LIT8, "shl", (s4), <<) |
| 2756 | OP_END |
| 2757 | |
| 2758 | /* File: c/OP_SHR_INT_LIT8.c */ |
| 2759 | HANDLE_OP_SHX_INT_LIT8(OP_SHR_INT_LIT8, "shr", (s4), >>) |
| 2760 | OP_END |
| 2761 | |
| 2762 | /* File: c/OP_USHR_INT_LIT8.c */ |
| 2763 | HANDLE_OP_SHX_INT_LIT8(OP_USHR_INT_LIT8, "ushr", (u4), >>) |
| 2764 | OP_END |
| 2765 | |
| 2766 | /* File: c/OP_UNUSED_E3.c */ |
| 2767 | HANDLE_OPCODE(OP_UNUSED_E3) |
| 2768 | OP_END |
| 2769 | |
| 2770 | /* File: c/OP_UNUSED_E4.c */ |
| 2771 | HANDLE_OPCODE(OP_UNUSED_E4) |
| 2772 | OP_END |
| 2773 | |
| 2774 | /* File: c/OP_UNUSED_E5.c */ |
| 2775 | HANDLE_OPCODE(OP_UNUSED_E5) |
| 2776 | OP_END |
| 2777 | |
| 2778 | /* File: c/OP_UNUSED_E6.c */ |
| 2779 | HANDLE_OPCODE(OP_UNUSED_E6) |
| 2780 | OP_END |
| 2781 | |
| 2782 | /* File: c/OP_UNUSED_E7.c */ |
| 2783 | HANDLE_OPCODE(OP_UNUSED_E7) |
| 2784 | OP_END |
| 2785 | |
| 2786 | /* File: c/OP_UNUSED_E8.c */ |
| 2787 | HANDLE_OPCODE(OP_UNUSED_E8) |
| 2788 | OP_END |
| 2789 | |
| 2790 | /* File: c/OP_UNUSED_E9.c */ |
| 2791 | HANDLE_OPCODE(OP_UNUSED_E9) |
| 2792 | OP_END |
| 2793 | |
| 2794 | /* File: c/OP_UNUSED_EA.c */ |
| 2795 | HANDLE_OPCODE(OP_UNUSED_EA) |
| 2796 | OP_END |
| 2797 | |
| 2798 | /* File: c/OP_UNUSED_EB.c */ |
| 2799 | HANDLE_OPCODE(OP_UNUSED_EB) |
| 2800 | OP_END |
| 2801 | |
| 2802 | /* File: c/OP_UNUSED_EC.c */ |
| 2803 | HANDLE_OPCODE(OP_UNUSED_EC) |
| 2804 | OP_END |
| 2805 | |
| 2806 | /* File: c/OP_UNUSED_ED.c */ |
| 2807 | HANDLE_OPCODE(OP_UNUSED_ED) |
| 2808 | OP_END |
| 2809 | |
| 2810 | /* File: c/OP_EXECUTE_INLINE.c */ |
| 2811 | HANDLE_OPCODE(OP_EXECUTE_INLINE /*vB, {vD, vE, vF, vG}, inline@CCCC*/) |
| 2812 | { |
| 2813 | /* |
| 2814 | * This has the same form as other method calls, but we ignore |
| 2815 | * the 5th argument (vA). This is chiefly because the first four |
| 2816 | * arguments to a function on ARM are in registers. |
| 2817 | * |
| 2818 | * We only set the arguments that are actually used, leaving |
| 2819 | * the rest uninitialized. We're assuming that, if the method |
| 2820 | * needs them, they'll be specified in the call. |
| 2821 | * |
| 2822 | * This annoys gcc when optimizations are enabled, causing a |
| 2823 | * "may be used uninitialized" warning. We can quiet the warnings |
| 2824 | * for a slight penalty (5%: 373ns vs. 393ns on empty method). Note |
| 2825 | * that valgrind is perfectly happy with this arrangement, because |
| 2826 | * the uninitialiezd values are never actually used. |
| 2827 | */ |
| 2828 | u4 arg0, arg1, arg2, arg3; |
| 2829 | //arg0 = arg1 = arg2 = arg3 = 0; |
| 2830 | |
| 2831 | EXPORT_PC(); |
| 2832 | |
| 2833 | vsrc1 = INST_B(inst); /* #of args */ |
| 2834 | ref = FETCH(1); /* inline call "ref" */ |
| 2835 | vdst = FETCH(2); /* 0-4 register indices */ |
| 2836 | ILOGV("|execute-inline args=%d @%d {regs=0x%04x}", |
| 2837 | vsrc1, ref, vdst); |
| 2838 | |
| 2839 | assert((vdst >> 16) == 0); // 16-bit type -or- high 16 bits clear |
| 2840 | assert(vsrc1 <= 4); |
| 2841 | |
| 2842 | switch (vsrc1) { |
| 2843 | case 4: |
| 2844 | arg3 = GET_REGISTER(vdst >> 12); |
| 2845 | /* fall through */ |
| 2846 | case 3: |
| 2847 | arg2 = GET_REGISTER((vdst & 0x0f00) >> 8); |
| 2848 | /* fall through */ |
| 2849 | case 2: |
| 2850 | arg1 = GET_REGISTER((vdst & 0x00f0) >> 4); |
| 2851 | /* fall through */ |
| 2852 | case 1: |
| 2853 | arg0 = GET_REGISTER(vdst & 0x0f); |
| 2854 | /* fall through */ |
| 2855 | default: // case 0 |
| 2856 | ; |
| 2857 | } |
| 2858 | |
| 2859 | #if INTERP_TYPE == INTERP_DBG |
| 2860 | if (!dvmPerformInlineOp4Dbg(arg0, arg1, arg2, arg3, &retval, ref)) |
| 2861 | GOTO_exceptionThrown(); |
| 2862 | #else |
| 2863 | if (!dvmPerformInlineOp4Std(arg0, arg1, arg2, arg3, &retval, ref)) |
| 2864 | GOTO_exceptionThrown(); |
| 2865 | #endif |
| 2866 | } |
| 2867 | FINISH(3); |
| 2868 | OP_END |
| 2869 | |
| 2870 | /* File: c/OP_UNUSED_EF.c */ |
| 2871 | HANDLE_OPCODE(OP_UNUSED_EF) |
| 2872 | OP_END |
| 2873 | |
| 2874 | /* File: c/OP_INVOKE_DIRECT_EMPTY.c */ |
| 2875 | HANDLE_OPCODE(OP_INVOKE_DIRECT_EMPTY /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2876 | #if INTERP_TYPE != INTERP_DBG |
| 2877 | //LOGI("Ignoring empty\n"); |
| 2878 | FINISH(3); |
| 2879 | #else |
| 2880 | if (!gDvm.debuggerActive) { |
| 2881 | //LOGI("Skipping empty\n"); |
| 2882 | FINISH(3); // don't want it to show up in profiler output |
| 2883 | } else { |
| 2884 | //LOGI("Running empty\n"); |
| 2885 | /* fall through to OP_INVOKE_DIRECT */ |
| 2886 | GOTO_invoke(invokeDirect, false); |
| 2887 | } |
| 2888 | #endif |
| 2889 | OP_END |
| 2890 | |
| 2891 | /* File: c/OP_UNUSED_F1.c */ |
| 2892 | HANDLE_OPCODE(OP_UNUSED_F1) |
| 2893 | OP_END |
| 2894 | |
| 2895 | /* File: c/OP_IGET_QUICK.c */ |
| 2896 | HANDLE_IGET_X_QUICK(OP_IGET_QUICK, "", Int, ) |
| 2897 | OP_END |
| 2898 | |
| 2899 | /* File: c/OP_IGET_WIDE_QUICK.c */ |
| 2900 | HANDLE_IGET_X_QUICK(OP_IGET_WIDE_QUICK, "-wide", Long, _WIDE) |
| 2901 | OP_END |
| 2902 | |
| 2903 | /* File: c/OP_IGET_OBJECT_QUICK.c */ |
| 2904 | HANDLE_IGET_X_QUICK(OP_IGET_OBJECT_QUICK, "-object", Object, _AS_OBJECT) |
| 2905 | OP_END |
| 2906 | |
| 2907 | /* File: c/OP_IPUT_QUICK.c */ |
| 2908 | HANDLE_IPUT_X_QUICK(OP_IPUT_QUICK, "", Int, ) |
| 2909 | OP_END |
| 2910 | |
| 2911 | /* File: c/OP_IPUT_WIDE_QUICK.c */ |
| 2912 | HANDLE_IPUT_X_QUICK(OP_IPUT_WIDE_QUICK, "-wide", Long, _WIDE) |
| 2913 | OP_END |
| 2914 | |
| 2915 | /* File: c/OP_IPUT_OBJECT_QUICK.c */ |
| 2916 | HANDLE_IPUT_X_QUICK(OP_IPUT_OBJECT_QUICK, "-object", Object, _AS_OBJECT) |
| 2917 | OP_END |
| 2918 | |
| 2919 | /* File: c/OP_INVOKE_VIRTUAL_QUICK.c */ |
| 2920 | HANDLE_OPCODE(OP_INVOKE_VIRTUAL_QUICK /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2921 | GOTO_invoke(invokeVirtualQuick, false); |
| 2922 | OP_END |
| 2923 | |
| 2924 | /* File: c/OP_INVOKE_VIRTUAL_QUICK_RANGE.c */ |
| 2925 | HANDLE_OPCODE(OP_INVOKE_VIRTUAL_QUICK_RANGE/*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2926 | GOTO_invoke(invokeVirtualQuick, true); |
| 2927 | OP_END |
| 2928 | |
| 2929 | /* File: c/OP_INVOKE_SUPER_QUICK.c */ |
| 2930 | HANDLE_OPCODE(OP_INVOKE_SUPER_QUICK /*vB, {vD, vE, vF, vG, vA}, meth@CCCC*/) |
| 2931 | GOTO_invoke(invokeSuperQuick, false); |
| 2932 | OP_END |
| 2933 | |
| 2934 | /* File: c/OP_INVOKE_SUPER_QUICK_RANGE.c */ |
| 2935 | HANDLE_OPCODE(OP_INVOKE_SUPER_QUICK_RANGE /*{vCCCC..v(CCCC+AA-1)}, meth@BBBB*/) |
| 2936 | GOTO_invoke(invokeSuperQuick, true); |
| 2937 | OP_END |
| 2938 | |
| 2939 | /* File: c/OP_UNUSED_FC.c */ |
| 2940 | HANDLE_OPCODE(OP_UNUSED_FC) |
| 2941 | OP_END |
| 2942 | |
| 2943 | /* File: c/OP_UNUSED_FD.c */ |
| 2944 | HANDLE_OPCODE(OP_UNUSED_FD) |
| 2945 | OP_END |
| 2946 | |
| 2947 | /* File: c/OP_UNUSED_FE.c */ |
| 2948 | HANDLE_OPCODE(OP_UNUSED_FE) |
| 2949 | OP_END |
| 2950 | |
| 2951 | /* File: c/OP_UNUSED_FF.c */ |
| 2952 | HANDLE_OPCODE(OP_UNUSED_FF) |
| 2953 | /* |
| 2954 | * In portable interp, most unused opcodes will fall through to here. |
| 2955 | */ |
| 2956 | LOGE("unknown opcode 0x%02x\n", INST_INST(inst)); |
| 2957 | dvmAbort(); |
| 2958 | FINISH(1); |
| 2959 | OP_END |
| 2960 | |
| 2961 | /* File: cstubs/entry.c */ |
| 2962 | /* |
| 2963 | * Handler function table, one entry per opcode. |
| 2964 | */ |
| 2965 | #undef H |
| 2966 | #define H(_op) dvmMterp_##_op |
| 2967 | DEFINE_GOTO_TABLE(gDvmMterpHandlers) |
| 2968 | |
| 2969 | #undef H |
| 2970 | #define H(_op) #_op |
| 2971 | DEFINE_GOTO_TABLE(gDvmMterpHandlerNames) |
| 2972 | |
| 2973 | #include <setjmp.h> |
| 2974 | |
| 2975 | /* |
| 2976 | * C mterp entry point. This just calls the various C fallbacks, making |
| 2977 | * this a slow but portable interpeter. |
| 2978 | * |
| 2979 | * This is only used for the "allstubs" variant. |
| 2980 | */ |
| 2981 | bool dvmMterpStdRun(MterpGlue* glue) |
| 2982 | { |
| 2983 | jmp_buf jmpBuf; |
| 2984 | int changeInterp; |
| 2985 | |
| 2986 | glue->bailPtr = &jmpBuf; |
| 2987 | |
| 2988 | /* |
| 2989 | * We want to return "changeInterp" as a boolean, but we can't return |
| 2990 | * zero through longjmp, so we return (boolean+1). |
| 2991 | */ |
| 2992 | changeInterp = setjmp(jmpBuf) -1; |
| 2993 | if (changeInterp >= 0) { |
| 2994 | Thread* threadSelf = dvmThreadSelf(); |
| 2995 | LOGVV("mterp threadid=%d returning %d\n", |
| 2996 | threadSelf->threadId, changeInterp); |
| 2997 | return changeInterp; |
| 2998 | } |
| 2999 | |
| 3000 | /* |
| 3001 | * We may not be starting at a point where we're executing instructions. |
| 3002 | * We need to pick up where the other interpreter left off. |
| 3003 | * |
| 3004 | * In some cases we need to call into a throw/return handler which |
| 3005 | * will do some processing and then either return to us (updating "glue") |
| 3006 | * or longjmp back out. |
| 3007 | */ |
| 3008 | switch (glue->entryPoint) { |
| 3009 | case kInterpEntryInstr: |
| 3010 | /* just start at the start */ |
| 3011 | break; |
| 3012 | case kInterpEntryReturn: |
| 3013 | dvmMterp_returnFromMethod(glue); |
| 3014 | break; |
| 3015 | case kInterpEntryThrow: |
| 3016 | dvmMterp_exceptionThrown(glue); |
| 3017 | break; |
| 3018 | default: |
| 3019 | dvmAbort(); |
| 3020 | } |
| 3021 | |
| 3022 | /* run until somebody longjmp()s out */ |
| 3023 | while (true) { |
| 3024 | typedef void (*Handler)(MterpGlue* glue); |
| 3025 | |
| 3026 | u2 inst = /*glue->*/pc[0]; |
| 3027 | Handler handler = (Handler) gDvmMterpHandlers[inst & 0xff]; |
| 3028 | LOGVV("handler %p %s\n", |
| 3029 | handler, (const char*) gDvmMterpHandlerNames[inst & 0xff]); |
| 3030 | (*handler)(glue); |
| 3031 | } |
| 3032 | } |
| 3033 | |
| 3034 | /* |
| 3035 | * C mterp exit point. Call here to bail out of the interpreter. |
| 3036 | */ |
| 3037 | void dvmMterpStdBail(MterpGlue* glue, bool changeInterp) |
| 3038 | { |
| 3039 | jmp_buf* pJmpBuf = glue->bailPtr; |
| 3040 | longjmp(*pJmpBuf, ((int)changeInterp)+1); |
| 3041 | } |
| 3042 | |
| 3043 | |
| 3044 | /* File: c/gotoTargets.c */ |
| 3045 | /* |
| 3046 | * C footer. This has some common code shared by the various targets. |
| 3047 | */ |
| 3048 | |
| 3049 | /* |
| 3050 | * Everything from here on is a "goto target". In the basic interpreter |
| 3051 | * we jump into these targets and then jump directly to the handler for |
| 3052 | * next instruction. Here, these are subroutines that return to the caller. |
| 3053 | */ |
| 3054 | |
| 3055 | GOTO_TARGET(filledNewArray, bool methodCallRange) |
| 3056 | { |
| 3057 | ClassObject* arrayClass; |
| 3058 | ArrayObject* newArray; |
| 3059 | u4* contents; |
| 3060 | char typeCh; |
| 3061 | int i; |
| 3062 | u4 arg5; |
| 3063 | |
| 3064 | EXPORT_PC(); |
| 3065 | |
| 3066 | ref = FETCH(1); /* class ref */ |
| 3067 | vdst = FETCH(2); /* first 4 regs -or- range base */ |
| 3068 | |
| 3069 | if (methodCallRange) { |
| 3070 | vsrc1 = INST_AA(inst); /* #of elements */ |
| 3071 | arg5 = -1; /* silence compiler warning */ |
| 3072 | ILOGV("|filled-new-array-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3073 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3074 | } else { |
| 3075 | arg5 = INST_A(inst); |
| 3076 | vsrc1 = INST_B(inst); /* #of elements */ |
| 3077 | ILOGV("|filled-new-array args=%d @0x%04x {regs=0x%04x %x}", |
| 3078 | vsrc1, ref, vdst, arg5); |
| 3079 | } |
| 3080 | |
| 3081 | /* |
| 3082 | * Resolve the array class. |
| 3083 | */ |
| 3084 | arrayClass = dvmDexGetResolvedClass(methodClassDex, ref); |
| 3085 | if (arrayClass == NULL) { |
| 3086 | arrayClass = dvmResolveClass(curMethod->clazz, ref, false); |
| 3087 | if (arrayClass == NULL) |
| 3088 | GOTO_exceptionThrown(); |
| 3089 | } |
| 3090 | /* |
| 3091 | if (!dvmIsArrayClass(arrayClass)) { |
| 3092 | dvmThrowException("Ljava/lang/RuntimeError;", |
| 3093 | "filled-new-array needs array class"); |
| 3094 | GOTO_exceptionThrown(); |
| 3095 | } |
| 3096 | */ |
| 3097 | /* verifier guarantees this is an array class */ |
| 3098 | assert(dvmIsArrayClass(arrayClass)); |
| 3099 | assert(dvmIsClassInitialized(arrayClass)); |
| 3100 | |
| 3101 | /* |
| 3102 | * Create an array of the specified type. |
| 3103 | */ |
| 3104 | LOGVV("+++ filled-new-array type is '%s'\n", arrayClass->descriptor); |
| 3105 | typeCh = arrayClass->descriptor[1]; |
| 3106 | if (typeCh == 'D' || typeCh == 'J') { |
| 3107 | /* category 2 primitives not allowed */ |
| 3108 | dvmThrowException("Ljava/lang/RuntimeError;", |
| 3109 | "bad filled array req"); |
| 3110 | GOTO_exceptionThrown(); |
| 3111 | } else if (typeCh != 'L' && typeCh != '[' && typeCh != 'I') { |
| 3112 | /* TODO: requires multiple "fill in" loops with different widths */ |
| 3113 | LOGE("non-int primitives not implemented\n"); |
| 3114 | dvmThrowException("Ljava/lang/InternalError;", |
| 3115 | "filled-new-array not implemented for anything but 'int'"); |
| 3116 | GOTO_exceptionThrown(); |
| 3117 | } |
| 3118 | |
| 3119 | newArray = dvmAllocArrayByClass(arrayClass, vsrc1, ALLOC_DONT_TRACK); |
| 3120 | if (newArray == NULL) |
| 3121 | GOTO_exceptionThrown(); |
| 3122 | |
| 3123 | /* |
| 3124 | * Fill in the elements. It's legal for vsrc1 to be zero. |
| 3125 | */ |
| 3126 | contents = (u4*) newArray->contents; |
| 3127 | if (methodCallRange) { |
| 3128 | for (i = 0; i < vsrc1; i++) |
| 3129 | contents[i] = GET_REGISTER(vdst+i); |
| 3130 | } else { |
| 3131 | assert(vsrc1 <= 5); |
| 3132 | if (vsrc1 == 5) { |
| 3133 | contents[4] = GET_REGISTER(arg5); |
| 3134 | vsrc1--; |
| 3135 | } |
| 3136 | for (i = 0; i < vsrc1; i++) { |
| 3137 | contents[i] = GET_REGISTER(vdst & 0x0f); |
| 3138 | vdst >>= 4; |
| 3139 | } |
| 3140 | } |
| 3141 | |
| 3142 | retval.l = newArray; |
| 3143 | } |
| 3144 | FINISH(3); |
| 3145 | GOTO_TARGET_END |
| 3146 | |
| 3147 | |
| 3148 | GOTO_TARGET(invokeVirtual, bool methodCallRange) |
| 3149 | { |
| 3150 | Method* baseMethod; |
| 3151 | Object* thisPtr; |
| 3152 | |
| 3153 | EXPORT_PC(); |
| 3154 | |
| 3155 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3156 | ref = FETCH(1); /* method ref */ |
| 3157 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3158 | |
| 3159 | /* |
| 3160 | * The object against which we are executing a method is always |
| 3161 | * in the first argument. |
| 3162 | */ |
| 3163 | if (methodCallRange) { |
| 3164 | assert(vsrc1 > 0); |
| 3165 | ILOGV("|invoke-virtual-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3166 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3167 | thisPtr = (Object*) GET_REGISTER(vdst); |
| 3168 | } else { |
| 3169 | assert((vsrc1>>4) > 0); |
| 3170 | ILOGV("|invoke-virtual args=%d @0x%04x {regs=0x%04x %x}", |
| 3171 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3172 | thisPtr = (Object*) GET_REGISTER(vdst & 0x0f); |
| 3173 | } |
| 3174 | |
| 3175 | if (!checkForNull(thisPtr)) |
| 3176 | GOTO_exceptionThrown(); |
| 3177 | |
| 3178 | /* |
| 3179 | * Resolve the method. This is the correct method for the static |
| 3180 | * type of the object. We also verify access permissions here. |
| 3181 | */ |
| 3182 | baseMethod = dvmDexGetResolvedMethod(methodClassDex, ref); |
| 3183 | if (baseMethod == NULL) { |
| 3184 | baseMethod = dvmResolveMethod(curMethod->clazz, ref,METHOD_VIRTUAL); |
| 3185 | if (baseMethod == NULL) { |
| 3186 | ILOGV("+ unknown method or access denied\n"); |
| 3187 | GOTO_exceptionThrown(); |
| 3188 | } |
| 3189 | } |
| 3190 | |
| 3191 | /* |
| 3192 | * Combine the object we found with the vtable offset in the |
| 3193 | * method. |
| 3194 | */ |
| 3195 | assert(baseMethod->methodIndex < thisPtr->clazz->vtableCount); |
| 3196 | methodToCall = thisPtr->clazz->vtable[baseMethod->methodIndex]; |
| 3197 | |
| 3198 | #if 0 |
| 3199 | if (dvmIsAbstractMethod(methodToCall)) { |
| 3200 | /* |
| 3201 | * This can happen if you create two classes, Base and Sub, where |
| 3202 | * Sub is a sub-class of Base. Declare a protected abstract |
| 3203 | * method foo() in Base, and invoke foo() from a method in Base. |
| 3204 | * Base is an "abstract base class" and is never instantiated |
| 3205 | * directly. Now, Override foo() in Sub, and use Sub. This |
| 3206 | * Works fine unless Sub stops providing an implementation of |
| 3207 | * the method. |
| 3208 | */ |
| 3209 | dvmThrowException("Ljava/lang/AbstractMethodError;", |
| 3210 | "abstract method not implemented"); |
| 3211 | GOTO_exceptionThrown(); |
| 3212 | } |
| 3213 | #else |
| 3214 | assert(!dvmIsAbstractMethod(methodToCall) || |
| 3215 | methodToCall->nativeFunc != NULL); |
| 3216 | #endif |
| 3217 | |
| 3218 | LOGVV("+++ base=%s.%s virtual[%d]=%s.%s\n", |
| 3219 | baseMethod->clazz->descriptor, baseMethod->name, |
| 3220 | (u4) baseMethod->methodIndex, |
| 3221 | methodToCall->clazz->descriptor, methodToCall->name); |
| 3222 | assert(methodToCall != NULL); |
| 3223 | |
| 3224 | #if 0 |
| 3225 | if (vsrc1 != methodToCall->insSize) { |
| 3226 | LOGW("WRONG METHOD: base=%s.%s virtual[%d]=%s.%s\n", |
| 3227 | baseMethod->clazz->descriptor, baseMethod->name, |
| 3228 | (u4) baseMethod->methodIndex, |
| 3229 | methodToCall->clazz->descriptor, methodToCall->name); |
| 3230 | //dvmDumpClass(baseMethod->clazz); |
| 3231 | //dvmDumpClass(methodToCall->clazz); |
| 3232 | dvmDumpAllClasses(0); |
| 3233 | } |
| 3234 | #endif |
| 3235 | |
| 3236 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3237 | } |
| 3238 | GOTO_TARGET_END |
| 3239 | |
| 3240 | GOTO_TARGET(invokeSuper, bool methodCallRange) |
| 3241 | { |
| 3242 | Method* baseMethod; |
| 3243 | u2 thisReg; |
| 3244 | |
| 3245 | EXPORT_PC(); |
| 3246 | |
| 3247 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3248 | ref = FETCH(1); /* method ref */ |
| 3249 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3250 | |
| 3251 | if (methodCallRange) { |
| 3252 | ILOGV("|invoke-super-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3253 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3254 | thisReg = vdst; |
| 3255 | } else { |
| 3256 | ILOGV("|invoke-super args=%d @0x%04x {regs=0x%04x %x}", |
| 3257 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3258 | thisReg = vdst & 0x0f; |
| 3259 | } |
| 3260 | /* impossible in well-formed code, but we must check nevertheless */ |
| 3261 | if (!checkForNull((Object*) GET_REGISTER(thisReg))) |
| 3262 | GOTO_exceptionThrown(); |
| 3263 | |
| 3264 | /* |
| 3265 | * Resolve the method. This is the correct method for the static |
| 3266 | * type of the object. We also verify access permissions here. |
| 3267 | * The first arg to dvmResolveMethod() is just the referring class |
| 3268 | * (used for class loaders and such), so we don't want to pass |
| 3269 | * the superclass into the resolution call. |
| 3270 | */ |
| 3271 | baseMethod = dvmDexGetResolvedMethod(methodClassDex, ref); |
| 3272 | if (baseMethod == NULL) { |
| 3273 | baseMethod = dvmResolveMethod(curMethod->clazz, ref,METHOD_VIRTUAL); |
| 3274 | if (baseMethod == NULL) { |
| 3275 | ILOGV("+ unknown method or access denied\n"); |
| 3276 | GOTO_exceptionThrown(); |
| 3277 | } |
| 3278 | } |
| 3279 | |
| 3280 | /* |
| 3281 | * Combine the object we found with the vtable offset in the |
| 3282 | * method's class. |
| 3283 | * |
| 3284 | * We're using the current method's class' superclass, not the |
| 3285 | * superclass of "this". This is because we might be executing |
| 3286 | * in a method inherited from a superclass, and we want to run |
| 3287 | * in that class' superclass. |
| 3288 | */ |
| 3289 | if (baseMethod->methodIndex >= curMethod->clazz->super->vtableCount) { |
| 3290 | /* |
| 3291 | * Method does not exist in the superclass. Could happen if |
| 3292 | * superclass gets updated. |
| 3293 | */ |
| 3294 | dvmThrowException("Ljava/lang/NoSuchMethodError;", |
| 3295 | baseMethod->name); |
| 3296 | GOTO_exceptionThrown(); |
| 3297 | } |
| 3298 | methodToCall = curMethod->clazz->super->vtable[baseMethod->methodIndex]; |
| 3299 | #if 0 |
| 3300 | if (dvmIsAbstractMethod(methodToCall)) { |
| 3301 | dvmThrowException("Ljava/lang/AbstractMethodError;", |
| 3302 | "abstract method not implemented"); |
| 3303 | GOTO_exceptionThrown(); |
| 3304 | } |
| 3305 | #else |
| 3306 | assert(!dvmIsAbstractMethod(methodToCall) || |
| 3307 | methodToCall->nativeFunc != NULL); |
| 3308 | #endif |
| 3309 | LOGVV("+++ base=%s.%s super-virtual=%s.%s\n", |
| 3310 | baseMethod->clazz->descriptor, baseMethod->name, |
| 3311 | methodToCall->clazz->descriptor, methodToCall->name); |
| 3312 | assert(methodToCall != NULL); |
| 3313 | |
| 3314 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3315 | } |
| 3316 | GOTO_TARGET_END |
| 3317 | |
| 3318 | GOTO_TARGET(invokeInterface, bool methodCallRange) |
| 3319 | { |
| 3320 | Object* thisPtr; |
| 3321 | ClassObject* thisClass; |
| 3322 | |
| 3323 | EXPORT_PC(); |
| 3324 | |
| 3325 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3326 | ref = FETCH(1); /* method ref */ |
| 3327 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3328 | |
| 3329 | /* |
| 3330 | * The object against which we are executing a method is always |
| 3331 | * in the first argument. |
| 3332 | */ |
| 3333 | if (methodCallRange) { |
| 3334 | assert(vsrc1 > 0); |
| 3335 | ILOGV("|invoke-interface-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3336 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3337 | thisPtr = (Object*) GET_REGISTER(vdst); |
| 3338 | } else { |
| 3339 | assert((vsrc1>>4) > 0); |
| 3340 | ILOGV("|invoke-interface args=%d @0x%04x {regs=0x%04x %x}", |
| 3341 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3342 | thisPtr = (Object*) GET_REGISTER(vdst & 0x0f); |
| 3343 | } |
| 3344 | if (!checkForNull(thisPtr)) |
| 3345 | GOTO_exceptionThrown(); |
| 3346 | |
| 3347 | thisClass = thisPtr->clazz; |
| 3348 | |
| 3349 | /* |
| 3350 | * Given a class and a method index, find the Method* with the |
| 3351 | * actual code we want to execute. |
| 3352 | */ |
| 3353 | methodToCall = dvmFindInterfaceMethodInCache(thisClass, ref, curMethod, |
| 3354 | methodClassDex); |
| 3355 | if (methodToCall == NULL) { |
| 3356 | assert(dvmCheckException(self)); |
| 3357 | GOTO_exceptionThrown(); |
| 3358 | } |
| 3359 | |
| 3360 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3361 | } |
| 3362 | GOTO_TARGET_END |
| 3363 | |
| 3364 | GOTO_TARGET(invokeDirect, bool methodCallRange) |
| 3365 | { |
| 3366 | u2 thisReg; |
| 3367 | |
| 3368 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3369 | ref = FETCH(1); /* method ref */ |
| 3370 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3371 | |
| 3372 | EXPORT_PC(); |
| 3373 | |
| 3374 | if (methodCallRange) { |
| 3375 | ILOGV("|invoke-direct-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3376 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3377 | thisReg = vdst; |
| 3378 | } else { |
| 3379 | ILOGV("|invoke-direct args=%d @0x%04x {regs=0x%04x %x}", |
| 3380 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3381 | thisReg = vdst & 0x0f; |
| 3382 | } |
| 3383 | if (!checkForNull((Object*) GET_REGISTER(thisReg))) |
| 3384 | GOTO_exceptionThrown(); |
| 3385 | |
| 3386 | methodToCall = dvmDexGetResolvedMethod(methodClassDex, ref); |
| 3387 | if (methodToCall == NULL) { |
| 3388 | methodToCall = dvmResolveMethod(curMethod->clazz, ref, |
| 3389 | METHOD_DIRECT); |
| 3390 | if (methodToCall == NULL) { |
| 3391 | ILOGV("+ unknown direct method\n"); // should be impossible |
| 3392 | GOTO_exceptionThrown(); |
| 3393 | } |
| 3394 | } |
| 3395 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3396 | } |
| 3397 | GOTO_TARGET_END |
| 3398 | |
| 3399 | GOTO_TARGET(invokeStatic, bool methodCallRange) |
| 3400 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3401 | ref = FETCH(1); /* method ref */ |
| 3402 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3403 | |
| 3404 | EXPORT_PC(); |
| 3405 | |
| 3406 | if (methodCallRange) |
| 3407 | ILOGV("|invoke-static-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3408 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3409 | else |
| 3410 | ILOGV("|invoke-static args=%d @0x%04x {regs=0x%04x %x}", |
| 3411 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3412 | |
| 3413 | methodToCall = dvmDexGetResolvedMethod(methodClassDex, ref); |
| 3414 | if (methodToCall == NULL) { |
| 3415 | methodToCall = dvmResolveMethod(curMethod->clazz, ref, METHOD_STATIC); |
| 3416 | if (methodToCall == NULL) { |
| 3417 | ILOGV("+ unknown method\n"); |
| 3418 | GOTO_exceptionThrown(); |
| 3419 | } |
| 3420 | } |
| 3421 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3422 | GOTO_TARGET_END |
| 3423 | |
| 3424 | GOTO_TARGET(invokeVirtualQuick, bool methodCallRange) |
| 3425 | { |
| 3426 | Object* thisPtr; |
| 3427 | |
| 3428 | EXPORT_PC(); |
| 3429 | |
| 3430 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3431 | ref = FETCH(1); /* vtable index */ |
| 3432 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3433 | |
| 3434 | /* |
| 3435 | * The object against which we are executing a method is always |
| 3436 | * in the first argument. |
| 3437 | */ |
| 3438 | if (methodCallRange) { |
| 3439 | assert(vsrc1 > 0); |
| 3440 | ILOGV("|invoke-virtual-quick-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3441 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3442 | thisPtr = (Object*) GET_REGISTER(vdst); |
| 3443 | } else { |
| 3444 | assert((vsrc1>>4) > 0); |
| 3445 | ILOGV("|invoke-virtual-quick args=%d @0x%04x {regs=0x%04x %x}", |
| 3446 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3447 | thisPtr = (Object*) GET_REGISTER(vdst & 0x0f); |
| 3448 | } |
| 3449 | |
| 3450 | if (!checkForNull(thisPtr)) |
| 3451 | GOTO_exceptionThrown(); |
| 3452 | |
| 3453 | /* |
| 3454 | * Combine the object we found with the vtable offset in the |
| 3455 | * method. |
| 3456 | */ |
| 3457 | assert(ref < thisPtr->clazz->vtableCount); |
| 3458 | methodToCall = thisPtr->clazz->vtable[ref]; |
| 3459 | |
| 3460 | #if 0 |
| 3461 | if (dvmIsAbstractMethod(methodToCall)) { |
| 3462 | dvmThrowException("Ljava/lang/AbstractMethodError;", |
| 3463 | "abstract method not implemented"); |
| 3464 | GOTO_exceptionThrown(); |
| 3465 | } |
| 3466 | #else |
| 3467 | assert(!dvmIsAbstractMethod(methodToCall) || |
| 3468 | methodToCall->nativeFunc != NULL); |
| 3469 | #endif |
| 3470 | |
| 3471 | LOGVV("+++ virtual[%d]=%s.%s\n", |
| 3472 | ref, methodToCall->clazz->descriptor, methodToCall->name); |
| 3473 | assert(methodToCall != NULL); |
| 3474 | |
| 3475 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3476 | } |
| 3477 | GOTO_TARGET_END |
| 3478 | |
| 3479 | GOTO_TARGET(invokeSuperQuick, bool methodCallRange) |
| 3480 | { |
| 3481 | u2 thisReg; |
| 3482 | |
| 3483 | EXPORT_PC(); |
| 3484 | |
| 3485 | vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */ |
| 3486 | ref = FETCH(1); /* vtable index */ |
| 3487 | vdst = FETCH(2); /* 4 regs -or- first reg */ |
| 3488 | |
| 3489 | if (methodCallRange) { |
| 3490 | ILOGV("|invoke-super-quick-range args=%d @0x%04x {regs=v%d-v%d}", |
| 3491 | vsrc1, ref, vdst, vdst+vsrc1-1); |
| 3492 | thisReg = vdst; |
| 3493 | } else { |
| 3494 | ILOGV("|invoke-super-quick args=%d @0x%04x {regs=0x%04x %x}", |
| 3495 | vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f); |
| 3496 | thisReg = vdst & 0x0f; |
| 3497 | } |
| 3498 | /* impossible in well-formed code, but we must check nevertheless */ |
| 3499 | if (!checkForNull((Object*) GET_REGISTER(thisReg))) |
| 3500 | GOTO_exceptionThrown(); |
| 3501 | |
| 3502 | #if 0 /* impossible in optimized + verified code */ |
| 3503 | if (ref >= curMethod->clazz->super->vtableCount) { |
| 3504 | dvmThrowException("Ljava/lang/NoSuchMethodError;", NULL); |
| 3505 | GOTO_exceptionThrown(); |
| 3506 | } |
| 3507 | #else |
| 3508 | assert(ref < curMethod->clazz->super->vtableCount); |
| 3509 | #endif |
| 3510 | |
| 3511 | /* |
| 3512 | * Combine the object we found with the vtable offset in the |
| 3513 | * method's class. |
| 3514 | * |
| 3515 | * We're using the current method's class' superclass, not the |
| 3516 | * superclass of "this". This is because we might be executing |
| 3517 | * in a method inherited from a superclass, and we want to run |
| 3518 | * in the method's class' superclass. |
| 3519 | */ |
| 3520 | methodToCall = curMethod->clazz->super->vtable[ref]; |
| 3521 | |
| 3522 | #if 0 |
| 3523 | if (dvmIsAbstractMethod(methodToCall)) { |
| 3524 | dvmThrowException("Ljava/lang/AbstractMethodError;", |
| 3525 | "abstract method not implemented"); |
| 3526 | GOTO_exceptionThrown(); |
| 3527 | } |
| 3528 | #else |
| 3529 | assert(!dvmIsAbstractMethod(methodToCall) || |
| 3530 | methodToCall->nativeFunc != NULL); |
| 3531 | #endif |
| 3532 | LOGVV("+++ super-virtual[%d]=%s.%s\n", |
| 3533 | ref, methodToCall->clazz->descriptor, methodToCall->name); |
| 3534 | assert(methodToCall != NULL); |
| 3535 | |
| 3536 | GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst); |
| 3537 | } |
| 3538 | GOTO_TARGET_END |
| 3539 | |
| 3540 | |
| 3541 | |
| 3542 | /* |
| 3543 | * General handling for return-void, return, and return-wide. Put the |
| 3544 | * return value in "retval" before jumping here. |
| 3545 | */ |
| 3546 | GOTO_TARGET(returnFromMethod) |
| 3547 | { |
| 3548 | StackSaveArea* saveArea; |
| 3549 | |
| 3550 | /* |
| 3551 | * We must do this BEFORE we pop the previous stack frame off, so |
| 3552 | * that the GC can see the return value (if any) in the local vars. |
| 3553 | * |
| 3554 | * Since this is now an interpreter switch point, we must do it before |
| 3555 | * we do anything at all. |
| 3556 | */ |
| 3557 | PERIODIC_CHECKS(kInterpEntryReturn, 0); |
| 3558 | |
| 3559 | ILOGV("> retval=0x%llx (leaving %s.%s %s)", |
| 3560 | retval.j, curMethod->clazz->descriptor, curMethod->name, |
| 3561 | curMethod->signature); |
| 3562 | //DUMP_REGS(curMethod, fp); |
| 3563 | |
| 3564 | saveArea = SAVEAREA_FROM_FP(fp); |
| 3565 | |
| 3566 | #ifdef EASY_GDB |
| 3567 | debugSaveArea = saveArea; |
| 3568 | #endif |
| 3569 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER) |
| 3570 | TRACE_METHOD_EXIT(self, curMethod); |
| 3571 | #endif |
| 3572 | |
| 3573 | /* back up to previous frame and see if we hit a break */ |
| 3574 | fp = saveArea->prevFrame; |
| 3575 | assert(fp != NULL); |
| 3576 | if (dvmIsBreakFrame(fp)) { |
| 3577 | /* bail without popping the method frame from stack */ |
| 3578 | LOGVV("+++ returned into break frame\n"); |
| 3579 | GOTO_bail(); |
| 3580 | } |
| 3581 | |
| 3582 | /* update thread FP, and reset local variables */ |
| 3583 | self->curFrame = fp; |
| 3584 | curMethod = SAVEAREA_FROM_FP(fp)->method; |
| 3585 | //methodClass = curMethod->clazz; |
| 3586 | methodClassDex = curMethod->clazz->pDvmDex; |
| 3587 | pc = saveArea->savedPc; |
| 3588 | ILOGD("> (return to %s.%s %s)", curMethod->clazz->descriptor, |
| 3589 | curMethod->name, curMethod->signature); |
| 3590 | |
| 3591 | /* use FINISH on the caller's invoke instruction */ |
| 3592 | //u2 invokeInstr = INST_INST(FETCH(0)); |
| 3593 | if (true /*invokeInstr >= OP_INVOKE_VIRTUAL && |
| 3594 | invokeInstr <= OP_INVOKE_INTERFACE*/) |
| 3595 | { |
| 3596 | FINISH(3); |
| 3597 | } else { |
| 3598 | //LOGE("Unknown invoke instr %02x at %d\n", |
| 3599 | // invokeInstr, (int) (pc - curMethod->insns)); |
| 3600 | assert(false); |
| 3601 | } |
| 3602 | } |
| 3603 | GOTO_TARGET_END |
| 3604 | |
| 3605 | |
| 3606 | /* |
| 3607 | * Jump here when the code throws an exception. |
| 3608 | * |
| 3609 | * By the time we get here, the Throwable has been created and the stack |
| 3610 | * trace has been saved off. |
| 3611 | */ |
| 3612 | GOTO_TARGET(exceptionThrown) |
| 3613 | { |
| 3614 | Object* exception; |
| 3615 | int catchRelPc; |
| 3616 | |
| 3617 | /* |
| 3618 | * Since this is now an interpreter switch point, we must do it before |
| 3619 | * we do anything at all. |
| 3620 | */ |
| 3621 | PERIODIC_CHECKS(kInterpEntryThrow, 0); |
| 3622 | |
| 3623 | /* |
| 3624 | * We save off the exception and clear the exception status. While |
| 3625 | * processing the exception we might need to load some Throwable |
| 3626 | * classes, and we don't want class loader exceptions to get |
| 3627 | * confused with this one. |
| 3628 | */ |
| 3629 | assert(dvmCheckException(self)); |
| 3630 | exception = dvmGetException(self); |
| 3631 | dvmAddTrackedAlloc(exception, self); |
| 3632 | dvmClearException(self); |
| 3633 | |
| 3634 | LOGV("Handling exception %s at %s:%d\n", |
| 3635 | exception->clazz->descriptor, curMethod->name, |
| 3636 | dvmLineNumFromPC(curMethod, pc - curMethod->insns)); |
| 3637 | |
| 3638 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER) |
| 3639 | /* |
| 3640 | * Tell the debugger about it. |
| 3641 | * |
| 3642 | * TODO: if the exception was thrown by interpreted code, control |
| 3643 | * fell through native, and then back to us, we will report the |
| 3644 | * exception at the point of the throw and again here. We can avoid |
| 3645 | * this by not reporting exceptions when we jump here directly from |
| 3646 | * the native call code above, but then we won't report exceptions |
| 3647 | * that were thrown *from* the JNI code (as opposed to *through* it). |
| 3648 | * |
| 3649 | * The correct solution is probably to ignore from-native exceptions |
| 3650 | * here, and have the JNI exception code do the reporting to the |
| 3651 | * debugger. |
| 3652 | */ |
| 3653 | if (gDvm.debuggerActive) { |
| 3654 | void* catchFrame; |
| 3655 | catchRelPc = dvmFindCatchBlock(self, pc - curMethod->insns, |
| 3656 | exception, true, &catchFrame); |
| 3657 | dvmDbgPostException(fp, pc - curMethod->insns, catchFrame, |
| 3658 | catchRelPc, exception); |
| 3659 | } |
| 3660 | #endif |
| 3661 | |
| 3662 | /* |
| 3663 | * We need to unroll to the catch block or the nearest "break" |
| 3664 | * frame. |
| 3665 | * |
| 3666 | * A break frame could indicate that we have reached an intermediate |
| 3667 | * native call, or have gone off the top of the stack and the thread |
| 3668 | * needs to exit. Either way, we return from here, leaving the |
| 3669 | * exception raised. |
| 3670 | * |
| 3671 | * If we do find a catch block, we want to transfer execution to |
| 3672 | * that point. |
| 3673 | */ |
| 3674 | catchRelPc = dvmFindCatchBlock(self, pc - curMethod->insns, |
| 3675 | exception, false, (void*)&fp); |
| 3676 | |
| 3677 | /* |
| 3678 | * Restore the stack bounds after an overflow. This isn't going to |
| 3679 | * be correct in all circumstances, e.g. if JNI code devours the |
| 3680 | * exception this won't happen until some other exception gets |
| 3681 | * thrown. If the code keeps pushing the stack bounds we'll end |
| 3682 | * up aborting the VM. |
| 3683 | * |
| 3684 | * Note we want to do this *after* the call to dvmFindCatchBlock, |
| 3685 | * because that may need extra stack space to resolve exception |
| 3686 | * classes (e.g. through a class loader). |
| 3687 | */ |
| 3688 | if (self->stackOverflowed) |
| 3689 | dvmCleanupStackOverflow(self); |
| 3690 | |
| 3691 | if (catchRelPc < 0) { |
| 3692 | /* falling through to JNI code or off the bottom of the stack */ |
| 3693 | #if DVM_SHOW_EXCEPTION >= 2 |
| 3694 | LOGD("Exception %s from %s:%d not caught locally\n", |
| 3695 | exception->clazz->descriptor, dvmGetMethodSourceFile(curMethod), |
| 3696 | dvmLineNumFromPC(curMethod, pc - curMethod->insns)); |
| 3697 | #endif |
| 3698 | dvmSetException(self, exception); |
| 3699 | dvmReleaseTrackedAlloc(exception, self); |
| 3700 | GOTO_bail(); |
| 3701 | } |
| 3702 | |
| 3703 | #if DVM_SHOW_EXCEPTION >= 3 |
| 3704 | { |
| 3705 | const Method* catchMethod = SAVEAREA_FROM_FP(fp)->method; |
| 3706 | LOGD("Exception %s thrown from %s:%d to %s:%d\n", |
| 3707 | exception->clazz->descriptor, dvmGetMethodSourceFile(curMethod), |
| 3708 | dvmLineNumFromPC(curMethod, pc - curMethod->insns), |
| 3709 | dvmGetMethodSourceFile(catchMethod), |
| 3710 | dvmLineNumFromPC(catchMethod, catchRelPc)); |
| 3711 | } |
| 3712 | #endif |
| 3713 | |
| 3714 | /* |
| 3715 | * Adjust local variables to match self->curFrame and the |
| 3716 | * updated PC. |
| 3717 | */ |
| 3718 | //fp = (u4*) self->curFrame; |
| 3719 | curMethod = SAVEAREA_FROM_FP(fp)->method; |
| 3720 | //methodClass = curMethod->clazz; |
| 3721 | methodClassDex = curMethod->clazz->pDvmDex; |
| 3722 | pc = curMethod->insns + catchRelPc; |
| 3723 | ILOGV("> pc <-- %s.%s %s", curMethod->clazz->descriptor, |
| 3724 | curMethod->name, curMethod->signature); |
| 3725 | DUMP_REGS(curMethod, fp, false); // show all regs |
| 3726 | |
| 3727 | /* |
| 3728 | * Restore the exception if the handler wants it. |
| 3729 | * |
| 3730 | * The Dalvik spec mandates that, if an exception handler wants to |
| 3731 | * do something with the exception, the first instruction executed |
| 3732 | * must be "move-exception". We can pass the exception along |
| 3733 | * through the thread struct, and let the move-exception instruction |
| 3734 | * clear it for us. |
| 3735 | * |
| 3736 | * If the handler doesn't call move-exception, we don't want to |
| 3737 | * finish here with an exception still pending. |
| 3738 | */ |
| 3739 | if (INST_INST(FETCH(0)) == OP_MOVE_EXCEPTION) |
| 3740 | dvmSetException(self, exception); |
| 3741 | |
| 3742 | dvmReleaseTrackedAlloc(exception, self); |
| 3743 | FINISH(0); |
| 3744 | } |
| 3745 | GOTO_TARGET_END |
| 3746 | |
| 3747 | |
| 3748 | /* |
| 3749 | * General handling for invoke-{virtual,super,direct,static,interface}, |
| 3750 | * including "quick" variants. |
| 3751 | * |
| 3752 | * Set "methodToCall" to the Method we're calling, and "methodCallRange" |
| 3753 | * depending on whether this is a "/range" instruction. |
| 3754 | * |
| 3755 | * For a range call: |
| 3756 | * "vsrc1" holds the argument count (8 bits) |
| 3757 | * "vdst" holds the first argument in the range |
| 3758 | * For a non-range call: |
| 3759 | * "vsrc1" holds the argument count (4 bits) and the 5th argument index |
| 3760 | * "vdst" holds four 4-bit register indices |
| 3761 | * |
| 3762 | * The caller must EXPORT_PC before jumping here, because any method |
| 3763 | * call can throw a stack overflow exception. |
| 3764 | */ |
| 3765 | GOTO_TARGET(invokeMethod, bool methodCallRange, const Method* _methodToCall, |
| 3766 | u2 count, u2 regs) |
| 3767 | { |
| 3768 | STUB_HACK(vsrc1 = count; vdst = regs; methodToCall = _methodToCall;); |
| 3769 | |
| 3770 | //printf("range=%d call=%p count=%d regs=0x%04x\n", |
| 3771 | // methodCallRange, methodToCall, count, regs); |
| 3772 | //printf(" --> %s.%s %s\n", methodToCall->clazz->descriptor, |
| 3773 | // methodToCall->name, methodToCall->signature); |
| 3774 | |
| 3775 | u4* outs; |
| 3776 | int i; |
| 3777 | |
| 3778 | /* |
| 3779 | * Copy args. This may corrupt vsrc1/vdst. |
| 3780 | */ |
| 3781 | if (methodCallRange) { |
| 3782 | // could use memcpy or a "Duff's device"; most functions have |
| 3783 | // so few args it won't matter much |
| 3784 | assert(vsrc1 <= curMethod->outsSize); |
| 3785 | assert(vsrc1 == methodToCall->insSize); |
| 3786 | outs = OUTS_FROM_FP(fp, vsrc1); |
| 3787 | for (i = 0; i < vsrc1; i++) |
| 3788 | outs[i] = GET_REGISTER(vdst+i); |
| 3789 | } else { |
| 3790 | u4 count = vsrc1 >> 4; |
| 3791 | |
| 3792 | assert(count <= curMethod->outsSize); |
| 3793 | assert(count == methodToCall->insSize); |
| 3794 | assert(count <= 5); |
| 3795 | |
| 3796 | outs = OUTS_FROM_FP(fp, count); |
| 3797 | #if 0 |
| 3798 | if (count == 5) { |
| 3799 | outs[4] = GET_REGISTER(vsrc1 & 0x0f); |
| 3800 | count--; |
| 3801 | } |
| 3802 | for (i = 0; i < (int) count; i++) { |
| 3803 | outs[i] = GET_REGISTER(vdst & 0x0f); |
| 3804 | vdst >>= 4; |
| 3805 | } |
| 3806 | #else |
| 3807 | // This version executes fewer instructions but is larger |
| 3808 | // overall. Seems to be a teensy bit faster. |
| 3809 | assert((vdst >> 16) == 0); // 16 bits -or- high 16 bits clear |
| 3810 | switch (count) { |
| 3811 | case 5: |
| 3812 | outs[4] = GET_REGISTER(vsrc1 & 0x0f); |
| 3813 | case 4: |
| 3814 | outs[3] = GET_REGISTER(vdst >> 12); |
| 3815 | case 3: |
| 3816 | outs[2] = GET_REGISTER((vdst & 0x0f00) >> 8); |
| 3817 | case 2: |
| 3818 | outs[1] = GET_REGISTER((vdst & 0x00f0) >> 4); |
| 3819 | case 1: |
| 3820 | outs[0] = GET_REGISTER(vdst & 0x0f); |
| 3821 | default: |
| 3822 | ; |
| 3823 | } |
| 3824 | #endif |
| 3825 | } |
| 3826 | } |
| 3827 | |
| 3828 | /* |
| 3829 | * (This was originally a "goto" target; I've kept it separate from the |
| 3830 | * stuff above in case we want to refactor things again.) |
| 3831 | * |
| 3832 | * At this point, we have the arguments stored in the "outs" area of |
| 3833 | * the current method's stack frame, and the method to call in |
| 3834 | * "methodToCall". Push a new stack frame. |
| 3835 | */ |
| 3836 | { |
| 3837 | StackSaveArea* newSaveArea; |
| 3838 | u4* newFp; |
| 3839 | |
| 3840 | ILOGV("> %s%s.%s %s", |
| 3841 | dvmIsNativeMethod(methodToCall) ? "(NATIVE) " : "", |
| 3842 | methodToCall->clazz->descriptor, methodToCall->name, |
| 3843 | methodToCall->signature); |
| 3844 | |
| 3845 | newFp = (u4*) SAVEAREA_FROM_FP(fp) - methodToCall->registersSize; |
| 3846 | newSaveArea = SAVEAREA_FROM_FP(newFp); |
| 3847 | |
| 3848 | /* verify that we have enough space */ |
| 3849 | if (true) { |
| 3850 | u1* bottom; |
| 3851 | bottom = (u1*) newSaveArea - methodToCall->outsSize * sizeof(u4); |
| 3852 | if (bottom < self->interpStackEnd) { |
| 3853 | /* stack overflow */ |
| 3854 | LOGV("Stack overflow on method call (start=%p end=%p newBot=%p size=%d '%s')\n", |
| 3855 | self->interpStackStart, self->interpStackEnd, bottom, |
| 3856 | self->interpStackSize, methodToCall->name); |
| 3857 | dvmHandleStackOverflow(self); |
| 3858 | assert(dvmCheckException(self)); |
| 3859 | GOTO_exceptionThrown(); |
| 3860 | } |
| 3861 | //LOGD("+++ fp=%p newFp=%p newSave=%p bottom=%p\n", |
| 3862 | // fp, newFp, newSaveArea, bottom); |
| 3863 | } |
| 3864 | |
| 3865 | #ifdef LOG_INSTR |
| 3866 | if (methodToCall->registersSize > methodToCall->insSize) { |
| 3867 | /* |
| 3868 | * This makes valgrind quiet when we print registers that |
| 3869 | * haven't been initialized. Turn it off when the debug |
| 3870 | * messages are disabled -- we want valgrind to report any |
| 3871 | * used-before-initialized issues. |
| 3872 | */ |
| 3873 | memset(newFp, 0xcc, |
| 3874 | (methodToCall->registersSize - methodToCall->insSize) * 4); |
| 3875 | } |
| 3876 | #endif |
| 3877 | |
| 3878 | #ifdef EASY_GDB |
| 3879 | newSaveArea->prevSave = SAVEAREA_FROM_FP(fp); |
| 3880 | #endif |
| 3881 | newSaveArea->prevFrame = fp; |
| 3882 | newSaveArea->savedPc = pc; |
| 3883 | newSaveArea->method = methodToCall; |
| 3884 | |
| 3885 | if (!dvmIsNativeMethod(methodToCall)) { |
| 3886 | /* |
| 3887 | * "Call" interpreted code. Reposition the PC, update the |
| 3888 | * frame pointer and other local state, and continue. |
| 3889 | */ |
| 3890 | curMethod = methodToCall; |
| 3891 | methodClassDex = curMethod->clazz->pDvmDex; |
| 3892 | pc = methodToCall->insns; |
| 3893 | fp = self->curFrame = newFp; |
| 3894 | #ifdef EASY_GDB |
| 3895 | debugSaveArea = SAVEAREA_FROM_FP(newFp); |
| 3896 | #endif |
| 3897 | #if INTERP_TYPE == INTERP_DBG |
| 3898 | debugIsMethodEntry = true; // profiling, debugging |
| 3899 | #endif |
| 3900 | ILOGD("> pc <-- %s.%s %s", curMethod->clazz->descriptor, |
| 3901 | curMethod->name, curMethod->signature); |
| 3902 | DUMP_REGS(curMethod, fp, true); // show input args |
| 3903 | FINISH(0); // jump to method start |
| 3904 | } else { |
| 3905 | /* set this up for JNI locals, even if not a JNI native */ |
| 3906 | newSaveArea->xtra.localRefTop = self->jniLocalRefTable.nextEntry; |
| 3907 | |
| 3908 | self->curFrame = newFp; |
| 3909 | |
| 3910 | DUMP_REGS(methodToCall, newFp, true); // show input args |
| 3911 | |
| 3912 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER) |
| 3913 | if (gDvm.debuggerActive) { |
| 3914 | dvmDbgPostLocationEvent(methodToCall, -1, |
| 3915 | dvmGetThisPtr(curMethod, fp), DBG_METHOD_ENTRY); |
| 3916 | } |
| 3917 | #endif |
| 3918 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER) |
| 3919 | TRACE_METHOD_ENTER(self, methodToCall); |
| 3920 | #endif |
| 3921 | |
| 3922 | ILOGD("> native <-- %s.%s %s", methodToCall->clazz->descriptor, |
| 3923 | methodToCall->name, methodToCall->signature); |
| 3924 | |
| 3925 | /* |
| 3926 | * Jump through native call bridge. Because we leave no |
| 3927 | * space for locals on native calls, "newFp" points directly |
| 3928 | * to the method arguments. |
| 3929 | */ |
| 3930 | (*methodToCall->nativeFunc)(newFp, &retval, methodToCall, self); |
| 3931 | |
| 3932 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER) |
| 3933 | if (gDvm.debuggerActive) { |
| 3934 | dvmDbgPostLocationEvent(methodToCall, -1, |
| 3935 | dvmGetThisPtr(curMethod, fp), DBG_METHOD_EXIT); |
| 3936 | } |
| 3937 | #endif |
| 3938 | #if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER) |
| 3939 | TRACE_METHOD_EXIT(self, methodToCall); |
| 3940 | #endif |
| 3941 | |
| 3942 | /* pop frame off */ |
| 3943 | dvmPopJniLocals(self, newSaveArea); |
| 3944 | self->curFrame = fp; |
| 3945 | |
| 3946 | /* |
| 3947 | * If the native code threw an exception, or interpreted code |
| 3948 | * invoked by the native call threw one and nobody has cleared |
| 3949 | * it, jump to our local exception handling. |
| 3950 | */ |
| 3951 | if (dvmCheckException(self)) { |
| 3952 | LOGV("Exception thrown by/below native code\n"); |
| 3953 | GOTO_exceptionThrown(); |
| 3954 | } |
| 3955 | |
| 3956 | ILOGD("> retval=0x%llx (leaving native)", retval.j); |
| 3957 | ILOGD("> (return from native %s.%s to %s.%s %s)", |
| 3958 | methodToCall->clazz->descriptor, methodToCall->name, |
| 3959 | curMethod->clazz->descriptor, curMethod->name, |
| 3960 | curMethod->signature); |
| 3961 | |
| 3962 | //u2 invokeInstr = INST_INST(FETCH(0)); |
| 3963 | if (true /*invokeInstr >= OP_INVOKE_VIRTUAL && |
| 3964 | invokeInstr <= OP_INVOKE_INTERFACE*/) |
| 3965 | { |
| 3966 | FINISH(3); |
| 3967 | } else { |
| 3968 | //LOGE("Unknown invoke instr %02x at %d\n", |
| 3969 | // invokeInstr, (int) (pc - curMethod->insns)); |
| 3970 | assert(false); |
| 3971 | } |
| 3972 | } |
| 3973 | } |
| 3974 | assert(false); // should not get here |
| 3975 | GOTO_TARGET_END |
| 3976 | |
| 3977 | |
| 3978 | /* File: cstubs/enddefs.c */ |
| 3979 | |
| 3980 | /* undefine "magic" name remapping */ |
| 3981 | #undef retval |
| 3982 | #undef pc |
| 3983 | #undef fp |
| 3984 | #undef curMethod |
| 3985 | #undef methodClassDex |
| 3986 | #undef self |
| 3987 | #undef debugTrackedRefStart |
| 3988 | |