blob: e84d8d02a6d675c4185989dac786a0d5c4c6aa4b [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
2 * This file was generated automatically by gen-mterp.py for 'x86'.
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
Ben Chengba4fc8b2009-06-01 13:00:29 -070029#include "mterp/common/FindInterface.h"
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080030
31/*
32 * Configuration defines. These affect the C implementations, i.e. the
33 * portable interpreter(s) and C stubs.
34 *
35 * Some defines are controlled by the Makefile, e.g.:
36 * WITH_PROFILER
37 * WITH_DEBUGGER
38 * WITH_INSTR_CHECKS
39 * WITH_TRACKREF_CHECKS
40 * EASY_GDB
41 * NDEBUG
42 *
43 * If THREADED_INTERP is not defined, we use a classic "while true / switch"
44 * interpreter. If it is defined, then the tail end of each instruction
45 * handler fetches the next instruction and jumps directly to the handler.
46 * This increases the size of the "Std" interpreter by about 10%, but
47 * provides a speedup of about the same magnitude.
48 *
49 * There's a "hybrid" approach that uses a goto table instead of a switch
50 * statement, avoiding the "is the opcode in range" tests required for switch.
51 * The performance is close to the threaded version, and without the 10%
52 * size increase, but the benchmark results are off enough that it's not
53 * worth adding as a third option.
54 */
55#define THREADED_INTERP /* threaded vs. while-loop interpreter */
56
The Android Open Source Project99409882009-03-18 22:20:24 -070057#ifdef WITH_INSTR_CHECKS /* instruction-level paranoia (slow!) */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080058# define CHECK_BRANCH_OFFSETS
59# define CHECK_REGISTER_INDICES
60#endif
61
62/*
63 * ARM EABI requires 64-bit alignment for access to 64-bit data types. We
64 * can't just use pointers to copy 64-bit values out of our interpreted
65 * register set, because gcc will generate ldrd/strd.
66 *
67 * The __UNION version copies data in and out of a union. The __MEMCPY
68 * version uses a memcpy() call to do the transfer; gcc is smart enough to
69 * not actually call memcpy(). The __UNION version is very bad on ARM;
70 * it only uses one more instruction than __MEMCPY, but for some reason
71 * gcc thinks it needs separate storage for every instance of the union.
72 * On top of that, it feels the need to zero them out at the start of the
73 * method. Net result is we zero out ~700 bytes of stack space at the top
74 * of the interpreter using ARM STM instructions.
75 */
76#if defined(__ARM_EABI__)
77//# define NO_UNALIGN_64__UNION
78# define NO_UNALIGN_64__MEMCPY
79#endif
80
81//#define LOG_INSTR /* verbose debugging */
82/* set and adjust ANDROID_LOG_TAGS='*:i jdwp:i dalvikvm:i dalvikvmi:i' */
83
84/*
85 * Keep a tally of accesses to fields. Currently only works if full DEX
86 * optimization is disabled.
87 */
88#ifdef PROFILE_FIELD_ACCESS
89# define UPDATE_FIELD_GET(_field) { (_field)->gets++; }
90# define UPDATE_FIELD_PUT(_field) { (_field)->puts++; }
91#else
92# define UPDATE_FIELD_GET(_field) ((void)0)
93# define UPDATE_FIELD_PUT(_field) ((void)0)
94#endif
95
96/*
The Android Open Source Project99409882009-03-18 22:20:24 -070097 * Export another copy of the PC on every instruction; this is largely
98 * redundant with EXPORT_PC and the debugger code. This value can be
99 * compared against what we have stored on the stack with EXPORT_PC to
100 * help ensure that we aren't missing any export calls.
101 */
102#if WITH_EXTRA_GC_CHECKS > 1
103# define EXPORT_EXTRA_PC() (self->currentPc2 = pc)
104#else
105# define EXPORT_EXTRA_PC()
106#endif
107
108/*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800109 * Adjust the program counter. "_offset" is a signed int, in 16-bit units.
110 *
111 * Assumes the existence of "const u2* pc" and "const u2* curMethod->insns".
112 *
113 * We don't advance the program counter until we finish an instruction or
114 * branch, because we do want to have to unroll the PC if there's an
115 * exception.
116 */
117#ifdef CHECK_BRANCH_OFFSETS
118# define ADJUST_PC(_offset) do { \
119 int myoff = _offset; /* deref only once */ \
120 if (pc + myoff < curMethod->insns || \
121 pc + myoff >= curMethod->insns + dvmGetMethodInsnsSize(curMethod)) \
122 { \
123 char* desc; \
124 desc = dexProtoCopyMethodDescriptor(&curMethod->prototype); \
125 LOGE("Invalid branch %d at 0x%04x in %s.%s %s\n", \
126 myoff, (int) (pc - curMethod->insns), \
127 curMethod->clazz->descriptor, curMethod->name, desc); \
128 free(desc); \
129 dvmAbort(); \
130 } \
131 pc += myoff; \
The Android Open Source Project99409882009-03-18 22:20:24 -0700132 EXPORT_EXTRA_PC(); \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800133 } while (false)
134#else
The Android Open Source Project99409882009-03-18 22:20:24 -0700135# define ADJUST_PC(_offset) do { \
136 pc += _offset; \
137 EXPORT_EXTRA_PC(); \
138 } while (false)
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800139#endif
140
141/*
142 * If enabled, log instructions as we execute them.
143 */
144#ifdef LOG_INSTR
145# define ILOGD(...) ILOG(LOG_DEBUG, __VA_ARGS__)
146# define ILOGV(...) ILOG(LOG_VERBOSE, __VA_ARGS__)
147# define ILOG(_level, ...) do { \
148 char debugStrBuf[128]; \
149 snprintf(debugStrBuf, sizeof(debugStrBuf), __VA_ARGS__); \
150 if (curMethod != NULL) \
151 LOG(_level, LOG_TAG"i", "%-2d|%04x%s\n", \
152 self->threadId, (int)(pc - curMethod->insns), debugStrBuf); \
153 else \
154 LOG(_level, LOG_TAG"i", "%-2d|####%s\n", \
155 self->threadId, debugStrBuf); \
156 } while(false)
157void dvmDumpRegs(const Method* method, const u4* framePtr, bool inOnly);
158# define DUMP_REGS(_meth, _frame, _inOnly) dvmDumpRegs(_meth, _frame, _inOnly)
159static const char kSpacing[] = " ";
160#else
161# define ILOGD(...) ((void)0)
162# define ILOGV(...) ((void)0)
163# define DUMP_REGS(_meth, _frame, _inOnly) ((void)0)
164#endif
165
166/* get a long from an array of u4 */
167static inline s8 getLongFromArray(const u4* ptr, int idx)
168{
169#if defined(NO_UNALIGN_64__UNION)
170 union { s8 ll; u4 parts[2]; } conv;
171
172 ptr += idx;
173 conv.parts[0] = ptr[0];
174 conv.parts[1] = ptr[1];
175 return conv.ll;
176#elif defined(NO_UNALIGN_64__MEMCPY)
177 s8 val;
178 memcpy(&val, &ptr[idx], 8);
179 return val;
180#else
181 return *((s8*) &ptr[idx]);
182#endif
183}
184
185/* store a long into an array of u4 */
186static inline void putLongToArray(u4* ptr, int idx, s8 val)
187{
188#if defined(NO_UNALIGN_64__UNION)
189 union { s8 ll; u4 parts[2]; } conv;
190
191 ptr += idx;
192 conv.ll = val;
193 ptr[0] = conv.parts[0];
194 ptr[1] = conv.parts[1];
195#elif defined(NO_UNALIGN_64__MEMCPY)
196 memcpy(&ptr[idx], &val, 8);
197#else
198 *((s8*) &ptr[idx]) = val;
199#endif
200}
201
202/* get a double from an array of u4 */
203static inline double getDoubleFromArray(const u4* ptr, int idx)
204{
205#if defined(NO_UNALIGN_64__UNION)
206 union { double d; u4 parts[2]; } conv;
207
208 ptr += idx;
209 conv.parts[0] = ptr[0];
210 conv.parts[1] = ptr[1];
211 return conv.d;
212#elif defined(NO_UNALIGN_64__MEMCPY)
213 double dval;
214 memcpy(&dval, &ptr[idx], 8);
215 return dval;
216#else
217 return *((double*) &ptr[idx]);
218#endif
219}
220
221/* store a double into an array of u4 */
222static inline void putDoubleToArray(u4* ptr, int idx, double dval)
223{
224#if defined(NO_UNALIGN_64__UNION)
225 union { double d; u4 parts[2]; } conv;
226
227 ptr += idx;
228 conv.d = dval;
229 ptr[0] = conv.parts[0];
230 ptr[1] = conv.parts[1];
231#elif defined(NO_UNALIGN_64__MEMCPY)
232 memcpy(&ptr[idx], &dval, 8);
233#else
234 *((double*) &ptr[idx]) = dval;
235#endif
236}
237
238/*
239 * If enabled, validate the register number on every access. Otherwise,
240 * just do an array access.
241 *
242 * Assumes the existence of "u4* fp".
243 *
244 * "_idx" may be referenced more than once.
245 */
246#ifdef CHECK_REGISTER_INDICES
247# define GET_REGISTER(_idx) \
248 ( (_idx) < curMethod->registersSize ? \
249 (fp[(_idx)]) : (assert(!"bad reg"),1969) )
250# define SET_REGISTER(_idx, _val) \
251 ( (_idx) < curMethod->registersSize ? \
252 (fp[(_idx)] = (u4)(_val)) : (assert(!"bad reg"),1969) )
253# define GET_REGISTER_AS_OBJECT(_idx) ((Object *)GET_REGISTER(_idx))
254# define SET_REGISTER_AS_OBJECT(_idx, _val) SET_REGISTER(_idx, (s4)_val)
255# define GET_REGISTER_INT(_idx) ((s4) GET_REGISTER(_idx))
256# define SET_REGISTER_INT(_idx, _val) SET_REGISTER(_idx, (s4)_val)
257# define GET_REGISTER_WIDE(_idx) \
258 ( (_idx) < curMethod->registersSize-1 ? \
259 getLongFromArray(fp, (_idx)) : (assert(!"bad reg"),1969) )
260# define SET_REGISTER_WIDE(_idx, _val) \
261 ( (_idx) < curMethod->registersSize-1 ? \
262 putLongToArray(fp, (_idx), (_val)) : (assert(!"bad reg"),1969) )
263# define GET_REGISTER_FLOAT(_idx) \
264 ( (_idx) < curMethod->registersSize ? \
265 (*((float*) &fp[(_idx)])) : (assert(!"bad reg"),1969.0f) )
266# define SET_REGISTER_FLOAT(_idx, _val) \
267 ( (_idx) < curMethod->registersSize ? \
268 (*((float*) &fp[(_idx)]) = (_val)) : (assert(!"bad reg"),1969.0f) )
269# define GET_REGISTER_DOUBLE(_idx) \
270 ( (_idx) < curMethod->registersSize-1 ? \
271 getDoubleFromArray(fp, (_idx)) : (assert(!"bad reg"),1969.0) )
272# define SET_REGISTER_DOUBLE(_idx, _val) \
273 ( (_idx) < curMethod->registersSize-1 ? \
274 putDoubleToArray(fp, (_idx), (_val)) : (assert(!"bad reg"),1969.0) )
275#else
276# define GET_REGISTER(_idx) (fp[(_idx)])
277# define SET_REGISTER(_idx, _val) (fp[(_idx)] = (_val))
278# define GET_REGISTER_AS_OBJECT(_idx) ((Object*) fp[(_idx)])
279# define SET_REGISTER_AS_OBJECT(_idx, _val) (fp[(_idx)] = (u4)(_val))
280# define GET_REGISTER_INT(_idx) ((s4)GET_REGISTER(_idx))
281# define SET_REGISTER_INT(_idx, _val) SET_REGISTER(_idx, (s4)_val)
282# define GET_REGISTER_WIDE(_idx) getLongFromArray(fp, (_idx))
283# define SET_REGISTER_WIDE(_idx, _val) putLongToArray(fp, (_idx), (_val))
284# define GET_REGISTER_FLOAT(_idx) (*((float*) &fp[(_idx)]))
285# define SET_REGISTER_FLOAT(_idx, _val) (*((float*) &fp[(_idx)]) = (_val))
286# define GET_REGISTER_DOUBLE(_idx) getDoubleFromArray(fp, (_idx))
287# define SET_REGISTER_DOUBLE(_idx, _val) putDoubleToArray(fp, (_idx), (_val))
288#endif
289
290/*
291 * Get 16 bits from the specified offset of the program counter. We always
292 * want to load 16 bits at a time from the instruction stream -- it's more
293 * efficient than 8 and won't have the alignment problems that 32 might.
294 *
295 * Assumes existence of "const u2* pc".
296 */
297#define FETCH(_offset) (pc[(_offset)])
298
299/*
300 * Extract instruction byte from 16-bit fetch (_inst is a u2).
301 */
302#define INST_INST(_inst) ((_inst) & 0xff)
303
304/*
Andy McFadden96516932009-10-28 17:39:02 -0700305 * Replace the opcode (used when handling breakpoints). _opcode is a u1.
306 */
307#define INST_REPLACE_OP(_inst, _opcode) (((_inst) & 0xff00) | _opcode)
308
309/*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800310 * Extract the "vA, vB" 4-bit registers from the instruction word (_inst is u2).
311 */
312#define INST_A(_inst) (((_inst) >> 8) & 0x0f)
313#define INST_B(_inst) ((_inst) >> 12)
314
315/*
316 * Get the 8-bit "vAA" 8-bit register index from the instruction word.
317 * (_inst is u2)
318 */
319#define INST_AA(_inst) ((_inst) >> 8)
320
321/*
322 * The current PC must be available to Throwable constructors, e.g.
323 * those created by dvmThrowException(), so that the exception stack
324 * trace can be generated correctly. If we don't do this, the offset
325 * within the current method won't be shown correctly. See the notes
326 * in Exception.c.
327 *
The Android Open Source Project99409882009-03-18 22:20:24 -0700328 * This is also used to determine the address for precise GC.
329 *
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800330 * Assumes existence of "u4* fp" and "const u2* pc".
331 */
332#define EXPORT_PC() (SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc)
333
334/*
335 * Determine if we need to switch to a different interpreter. "_current"
336 * is either INTERP_STD or INTERP_DBG. It should be fixed for a given
337 * interpreter generation file, which should remove the outer conditional
338 * from the following.
339 *
340 * If we're building without debug and profiling support, we never switch.
341 */
342#if defined(WITH_PROFILER) || defined(WITH_DEBUGGER)
Ben Chengba4fc8b2009-06-01 13:00:29 -0700343#if defined(WITH_JIT)
344# define NEED_INTERP_SWITCH(_current) ( \
345 (_current == INTERP_STD) ? \
346 dvmJitDebuggerOrProfilerActive(interpState->jitState) : \
347 !dvmJitDebuggerOrProfilerActive(interpState->jitState) )
348#else
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800349# define NEED_INTERP_SWITCH(_current) ( \
350 (_current == INTERP_STD) ? \
351 dvmDebuggerOrProfilerActive() : !dvmDebuggerOrProfilerActive() )
Ben Chengba4fc8b2009-06-01 13:00:29 -0700352#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800353#else
354# define NEED_INTERP_SWITCH(_current) (false)
355#endif
356
357/*
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800358 * Check to see if "obj" is NULL. If so, throw an exception. Assumes the
359 * pc has already been exported to the stack.
360 *
361 * Perform additional checks on debug builds.
362 *
363 * Use this to check for NULL when the instruction handler calls into
364 * something that could throw an exception (so we have already called
365 * EXPORT_PC at the top).
366 */
367static inline bool checkForNull(Object* obj)
368{
369 if (obj == NULL) {
370 dvmThrowException("Ljava/lang/NullPointerException;", NULL);
371 return false;
372 }
373#ifdef WITH_EXTRA_OBJECT_VALIDATION
374 if (!dvmIsValidObject(obj)) {
375 LOGE("Invalid object %p\n", obj);
376 dvmAbort();
377 }
378#endif
379#ifndef NDEBUG
380 if (obj->clazz == NULL || ((u4) obj->clazz) <= 65536) {
381 /* probable heap corruption */
382 LOGE("Invalid object class %p (in %p)\n", obj->clazz, obj);
383 dvmAbort();
384 }
385#endif
386 return true;
387}
388
389/*
390 * Check to see if "obj" is NULL. If so, export the PC into the stack
391 * frame and throw an exception.
392 *
393 * Perform additional checks on debug builds.
394 *
395 * Use this to check for NULL when the instruction handler doesn't do
396 * anything else that can throw an exception.
397 */
398static inline bool checkForNullExportPC(Object* obj, u4* fp, const u2* pc)
399{
400 if (obj == NULL) {
401 EXPORT_PC();
402 dvmThrowException("Ljava/lang/NullPointerException;", NULL);
403 return false;
404 }
405#ifdef WITH_EXTRA_OBJECT_VALIDATION
406 if (!dvmIsValidObject(obj)) {
407 LOGE("Invalid object %p\n", obj);
408 dvmAbort();
409 }
410#endif
411#ifndef NDEBUG
412 if (obj->clazz == NULL || ((u4) obj->clazz) <= 65536) {
413 /* probable heap corruption */
414 LOGE("Invalid object class %p (in %p)\n", obj->clazz, obj);
415 dvmAbort();
416 }
417#endif
418 return true;
419}
420
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800421/* File: cstubs/stubdefs.c */
422/* this is a standard (no debug support) interpreter */
423#define INTERP_TYPE INTERP_STD
424#define CHECK_DEBUG_AND_PROF() ((void)0)
425# define CHECK_TRACKED_REFS() ((void)0)
426
427/*
428 * In the C mterp stubs, "goto" is a function call followed immediately
429 * by a return.
430 */
431
432#define GOTO_TARGET_DECL(_target, ...) \
433 void dvmMterp_##_target(MterpGlue* glue, ## __VA_ARGS__);
434
435#define GOTO_TARGET(_target, ...) \
436 void dvmMterp_##_target(MterpGlue* glue, ## __VA_ARGS__) { \
437 u2 ref, vsrc1, vsrc2, vdst; \
438 u2 inst = FETCH(0); \
439 const Method* methodToCall; \
440 StackSaveArea* debugSaveArea;
441
442#define GOTO_TARGET_END }
443
444/*
445 * Redefine what used to be local variable accesses into MterpGlue struct
446 * references. (These are undefined down in "footer.c".)
447 */
448#define retval glue->retval
449#define pc glue->pc
450#define fp glue->fp
451#define curMethod glue->method
452#define methodClassDex glue->methodClassDex
453#define self glue->self
454#define debugTrackedRefStart glue->debugTrackedRefStart
455
456/* ugh */
457#define STUB_HACK(x) x
458
459
460/*
461 * Opcode handler framing macros. Here, each opcode is a separate function
462 * that takes a "glue" argument and returns void. We can't declare
463 * these "static" because they may be called from an assembly stub.
464 */
465#define HANDLE_OPCODE(_op) \
466 void dvmMterp_##_op(MterpGlue* glue) { \
467 u2 ref, vsrc1, vsrc2, vdst; \
468 u2 inst = FETCH(0);
469
470#define OP_END }
471
472/*
473 * Like the "portable" FINISH, but don't reload "inst", and return to caller
474 * when done.
475 */
476#define FINISH(_offset) { \
477 ADJUST_PC(_offset); \
478 CHECK_DEBUG_AND_PROF(); \
479 CHECK_TRACKED_REFS(); \
480 return; \
481 }
482
483
484/*
485 * The "goto label" statements turn into function calls followed by
486 * return statements. Some of the functions take arguments, which in the
487 * portable interpreter are handled by assigning values to globals.
488 */
489
490#define GOTO_exceptionThrown() \
491 do { \
492 dvmMterp_exceptionThrown(glue); \
493 return; \
494 } while(false)
495
496#define GOTO_returnFromMethod() \
497 do { \
498 dvmMterp_returnFromMethod(glue); \
499 return; \
500 } while(false)
501
502#define GOTO_invoke(_target, _methodCallRange) \
503 do { \
504 dvmMterp_##_target(glue, _methodCallRange); \
505 return; \
506 } while(false)
507
508#define GOTO_invokeMethod(_methodCallRange, _methodToCall, _vsrc1, _vdst) \
509 do { \
510 dvmMterp_invokeMethod(glue, _methodCallRange, _methodToCall, \
511 _vsrc1, _vdst); \
512 return; \
513 } while(false)
514
515/*
516 * As a special case, "goto bail" turns into a longjmp. Use "bail_switch"
517 * if we need to switch to the other interpreter upon our return.
518 */
519#define GOTO_bail() \
520 dvmMterpStdBail(glue, false);
521#define GOTO_bail_switch() \
522 dvmMterpStdBail(glue, true);
523
524/*
525 * Periodically check for thread suspension.
526 *
527 * While we're at it, see if a debugger has attached or the profiler has
528 * started. If so, switch to a different "goto" table.
529 */
530#define PERIODIC_CHECKS(_entryPoint, _pcadj) { \
The Android Open Source Project99409882009-03-18 22:20:24 -0700531 if (dvmCheckSuspendQuick(self)) { \
532 EXPORT_PC(); /* need for precise GC */ \
533 dvmCheckSuspendPending(self); \
534 } \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800535 if (NEED_INTERP_SWITCH(INTERP_TYPE)) { \
536 ADJUST_PC(_pcadj); \
537 glue->entryPoint = _entryPoint; \
538 LOGVV("threadid=%d: switch to STD ep=%d adj=%d\n", \
Andy McFadden080ca4a2009-08-05 13:20:16 -0700539 self->threadId, (_entryPoint), (_pcadj)); \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -0800540 GOTO_bail_switch(); \
541 } \
542 }
543
544
545/* File: c/opcommon.c */
546/* forward declarations of goto targets */
547GOTO_TARGET_DECL(filledNewArray, bool methodCallRange);
548GOTO_TARGET_DECL(invokeVirtual, bool methodCallRange);
549GOTO_TARGET_DECL(invokeSuper, bool methodCallRange);
550GOTO_TARGET_DECL(invokeInterface, bool methodCallRange);
551GOTO_TARGET_DECL(invokeDirect, bool methodCallRange);
552GOTO_TARGET_DECL(invokeStatic, bool methodCallRange);
553GOTO_TARGET_DECL(invokeVirtualQuick, bool methodCallRange);
554GOTO_TARGET_DECL(invokeSuperQuick, bool methodCallRange);
555GOTO_TARGET_DECL(invokeMethod, bool methodCallRange, const Method* methodToCall,
556 u2 count, u2 regs);
557GOTO_TARGET_DECL(returnFromMethod);
558GOTO_TARGET_DECL(exceptionThrown);
559
560/*
561 * ===========================================================================
562 *
563 * What follows are opcode definitions shared between multiple opcodes with
564 * minor substitutions handled by the C pre-processor. These should probably
565 * use the mterp substitution mechanism instead, with the code here moved
566 * into common fragment files (like the asm "binop.S"), although it's hard
567 * to give up the C preprocessor in favor of the much simpler text subst.
568 *
569 * ===========================================================================
570 */
571
572#define HANDLE_NUMCONV(_opcode, _opname, _fromtype, _totype) \
573 HANDLE_OPCODE(_opcode /*vA, vB*/) \
574 vdst = INST_A(inst); \
575 vsrc1 = INST_B(inst); \
576 ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \
577 SET_REGISTER##_totype(vdst, \
578 GET_REGISTER##_fromtype(vsrc1)); \
579 FINISH(1);
580
581#define HANDLE_FLOAT_TO_INT(_opcode, _opname, _fromvtype, _fromrtype, \
582 _tovtype, _tortype) \
583 HANDLE_OPCODE(_opcode /*vA, vB*/) \
584 { \
585 /* spec defines specific handling for +/- inf and NaN values */ \
586 _fromvtype val; \
587 _tovtype intMin, intMax, result; \
588 vdst = INST_A(inst); \
589 vsrc1 = INST_B(inst); \
590 ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \
591 val = GET_REGISTER##_fromrtype(vsrc1); \
592 intMin = (_tovtype) 1 << (sizeof(_tovtype) * 8 -1); \
593 intMax = ~intMin; \
594 result = (_tovtype) val; \
595 if (val >= intMax) /* +inf */ \
596 result = intMax; \
597 else if (val <= intMin) /* -inf */ \
598 result = intMin; \
599 else if (val != val) /* NaN */ \
600 result = 0; \
601 else \
602 result = (_tovtype) val; \
603 SET_REGISTER##_tortype(vdst, result); \
604 } \
605 FINISH(1);
606
607#define HANDLE_INT_TO_SMALL(_opcode, _opname, _type) \
608 HANDLE_OPCODE(_opcode /*vA, vB*/) \
609 vdst = INST_A(inst); \
610 vsrc1 = INST_B(inst); \
611 ILOGV("|int-to-%s v%d,v%d", (_opname), vdst, vsrc1); \
612 SET_REGISTER(vdst, (_type) GET_REGISTER(vsrc1)); \
613 FINISH(1);
614
615/* NOTE: the comparison result is always a signed 4-byte integer */
616#define HANDLE_OP_CMPX(_opcode, _opname, _varType, _type, _nanVal) \
617 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
618 { \
619 int result; \
620 u2 regs; \
621 _varType val1, val2; \
622 vdst = INST_AA(inst); \
623 regs = FETCH(1); \
624 vsrc1 = regs & 0xff; \
625 vsrc2 = regs >> 8; \
626 ILOGV("|cmp%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
627 val1 = GET_REGISTER##_type(vsrc1); \
628 val2 = GET_REGISTER##_type(vsrc2); \
629 if (val1 == val2) \
630 result = 0; \
631 else if (val1 < val2) \
632 result = -1; \
633 else if (val1 > val2) \
634 result = 1; \
635 else \
636 result = (_nanVal); \
637 ILOGV("+ result=%d\n", result); \
638 SET_REGISTER(vdst, result); \
639 } \
640 FINISH(2);
641
642#define HANDLE_OP_IF_XX(_opcode, _opname, _cmp) \
643 HANDLE_OPCODE(_opcode /*vA, vB, +CCCC*/) \
644 vsrc1 = INST_A(inst); \
645 vsrc2 = INST_B(inst); \
646 if ((s4) GET_REGISTER(vsrc1) _cmp (s4) GET_REGISTER(vsrc2)) { \
647 int branchOffset = (s2)FETCH(1); /* sign-extended */ \
648 ILOGV("|if-%s v%d,v%d,+0x%04x", (_opname), vsrc1, vsrc2, \
649 branchOffset); \
650 ILOGV("> branch taken"); \
651 if (branchOffset < 0) \
652 PERIODIC_CHECKS(kInterpEntryInstr, branchOffset); \
653 FINISH(branchOffset); \
654 } else { \
655 ILOGV("|if-%s v%d,v%d,-", (_opname), vsrc1, vsrc2); \
656 FINISH(2); \
657 }
658
659#define HANDLE_OP_IF_XXZ(_opcode, _opname, _cmp) \
660 HANDLE_OPCODE(_opcode /*vAA, +BBBB*/) \
661 vsrc1 = INST_AA(inst); \
662 if ((s4) GET_REGISTER(vsrc1) _cmp 0) { \
663 int branchOffset = (s2)FETCH(1); /* sign-extended */ \
664 ILOGV("|if-%s v%d,+0x%04x", (_opname), vsrc1, branchOffset); \
665 ILOGV("> branch taken"); \
666 if (branchOffset < 0) \
667 PERIODIC_CHECKS(kInterpEntryInstr, branchOffset); \
668 FINISH(branchOffset); \
669 } else { \
670 ILOGV("|if-%s v%d,-", (_opname), vsrc1); \
671 FINISH(2); \
672 }
673
674#define HANDLE_UNOP(_opcode, _opname, _pfx, _sfx, _type) \
675 HANDLE_OPCODE(_opcode /*vA, vB*/) \
676 vdst = INST_A(inst); \
677 vsrc1 = INST_B(inst); \
678 ILOGV("|%s v%d,v%d", (_opname), vdst, vsrc1); \
679 SET_REGISTER##_type(vdst, _pfx GET_REGISTER##_type(vsrc1) _sfx); \
680 FINISH(1);
681
682#define HANDLE_OP_X_INT(_opcode, _opname, _op, _chkdiv) \
683 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
684 { \
685 u2 srcRegs; \
686 vdst = INST_AA(inst); \
687 srcRegs = FETCH(1); \
688 vsrc1 = srcRegs & 0xff; \
689 vsrc2 = srcRegs >> 8; \
690 ILOGV("|%s-int v%d,v%d", (_opname), vdst, vsrc1); \
691 if (_chkdiv != 0) { \
692 s4 firstVal, secondVal, result; \
693 firstVal = GET_REGISTER(vsrc1); \
694 secondVal = GET_REGISTER(vsrc2); \
695 if (secondVal == 0) { \
696 EXPORT_PC(); \
697 dvmThrowException("Ljava/lang/ArithmeticException;", \
698 "divide by zero"); \
699 GOTO_exceptionThrown(); \
700 } \
701 if ((u4)firstVal == 0x80000000 && secondVal == -1) { \
702 if (_chkdiv == 1) \
703 result = firstVal; /* division */ \
704 else \
705 result = 0; /* remainder */ \
706 } else { \
707 result = firstVal _op secondVal; \
708 } \
709 SET_REGISTER(vdst, result); \
710 } else { \
711 /* non-div/rem case */ \
712 SET_REGISTER(vdst, \
713 (s4) GET_REGISTER(vsrc1) _op (s4) GET_REGISTER(vsrc2)); \
714 } \
715 } \
716 FINISH(2);
717
718#define HANDLE_OP_SHX_INT(_opcode, _opname, _cast, _op) \
719 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
720 { \
721 u2 srcRegs; \
722 vdst = INST_AA(inst); \
723 srcRegs = FETCH(1); \
724 vsrc1 = srcRegs & 0xff; \
725 vsrc2 = srcRegs >> 8; \
726 ILOGV("|%s-int v%d,v%d", (_opname), vdst, vsrc1); \
727 SET_REGISTER(vdst, \
728 _cast GET_REGISTER(vsrc1) _op (GET_REGISTER(vsrc2) & 0x1f)); \
729 } \
730 FINISH(2);
731
732#define HANDLE_OP_X_INT_LIT16(_opcode, _opname, _op, _chkdiv) \
733 HANDLE_OPCODE(_opcode /*vA, vB, #+CCCC*/) \
734 vdst = INST_A(inst); \
735 vsrc1 = INST_B(inst); \
736 vsrc2 = FETCH(1); \
737 ILOGV("|%s-int/lit16 v%d,v%d,#+0x%04x", \
738 (_opname), vdst, vsrc1, vsrc2); \
739 if (_chkdiv != 0) { \
740 s4 firstVal, result; \
741 firstVal = GET_REGISTER(vsrc1); \
742 if ((s2) vsrc2 == 0) { \
743 EXPORT_PC(); \
744 dvmThrowException("Ljava/lang/ArithmeticException;", \
745 "divide by zero"); \
746 GOTO_exceptionThrown(); \
747 } \
748 if ((u4)firstVal == 0x80000000 && ((s2) vsrc2) == -1) { \
749 /* won't generate /lit16 instr for this; check anyway */ \
750 if (_chkdiv == 1) \
751 result = firstVal; /* division */ \
752 else \
753 result = 0; /* remainder */ \
754 } else { \
755 result = firstVal _op (s2) vsrc2; \
756 } \
757 SET_REGISTER(vdst, result); \
758 } else { \
759 /* non-div/rem case */ \
760 SET_REGISTER(vdst, GET_REGISTER(vsrc1) _op (s2) vsrc2); \
761 } \
762 FINISH(2);
763
764#define HANDLE_OP_X_INT_LIT8(_opcode, _opname, _op, _chkdiv) \
765 HANDLE_OPCODE(_opcode /*vAA, vBB, #+CC*/) \
766 { \
767 u2 litInfo; \
768 vdst = INST_AA(inst); \
769 litInfo = FETCH(1); \
770 vsrc1 = litInfo & 0xff; \
771 vsrc2 = litInfo >> 8; /* constant */ \
772 ILOGV("|%s-int/lit8 v%d,v%d,#+0x%02x", \
773 (_opname), vdst, vsrc1, vsrc2); \
774 if (_chkdiv != 0) { \
775 s4 firstVal, result; \
776 firstVal = GET_REGISTER(vsrc1); \
777 if ((s1) vsrc2 == 0) { \
778 EXPORT_PC(); \
779 dvmThrowException("Ljava/lang/ArithmeticException;", \
780 "divide by zero"); \
781 GOTO_exceptionThrown(); \
782 } \
783 if ((u4)firstVal == 0x80000000 && ((s1) vsrc2) == -1) { \
784 if (_chkdiv == 1) \
785 result = firstVal; /* division */ \
786 else \
787 result = 0; /* remainder */ \
788 } else { \
789 result = firstVal _op ((s1) vsrc2); \
790 } \
791 SET_REGISTER(vdst, result); \
792 } else { \
793 SET_REGISTER(vdst, \
794 (s4) GET_REGISTER(vsrc1) _op (s1) vsrc2); \
795 } \
796 } \
797 FINISH(2);
798
799#define HANDLE_OP_SHX_INT_LIT8(_opcode, _opname, _cast, _op) \
800 HANDLE_OPCODE(_opcode /*vAA, vBB, #+CC*/) \
801 { \
802 u2 litInfo; \
803 vdst = INST_AA(inst); \
804 litInfo = FETCH(1); \
805 vsrc1 = litInfo & 0xff; \
806 vsrc2 = litInfo >> 8; /* constant */ \
807 ILOGV("|%s-int/lit8 v%d,v%d,#+0x%02x", \
808 (_opname), vdst, vsrc1, vsrc2); \
809 SET_REGISTER(vdst, \
810 _cast GET_REGISTER(vsrc1) _op (vsrc2 & 0x1f)); \
811 } \
812 FINISH(2);
813
814#define HANDLE_OP_X_INT_2ADDR(_opcode, _opname, _op, _chkdiv) \
815 HANDLE_OPCODE(_opcode /*vA, vB*/) \
816 vdst = INST_A(inst); \
817 vsrc1 = INST_B(inst); \
818 ILOGV("|%s-int-2addr v%d,v%d", (_opname), vdst, vsrc1); \
819 if (_chkdiv != 0) { \
820 s4 firstVal, secondVal, result; \
821 firstVal = GET_REGISTER(vdst); \
822 secondVal = GET_REGISTER(vsrc1); \
823 if (secondVal == 0) { \
824 EXPORT_PC(); \
825 dvmThrowException("Ljava/lang/ArithmeticException;", \
826 "divide by zero"); \
827 GOTO_exceptionThrown(); \
828 } \
829 if ((u4)firstVal == 0x80000000 && secondVal == -1) { \
830 if (_chkdiv == 1) \
831 result = firstVal; /* division */ \
832 else \
833 result = 0; /* remainder */ \
834 } else { \
835 result = firstVal _op secondVal; \
836 } \
837 SET_REGISTER(vdst, result); \
838 } else { \
839 SET_REGISTER(vdst, \
840 (s4) GET_REGISTER(vdst) _op (s4) GET_REGISTER(vsrc1)); \
841 } \
842 FINISH(1);
843
844#define HANDLE_OP_SHX_INT_2ADDR(_opcode, _opname, _cast, _op) \
845 HANDLE_OPCODE(_opcode /*vA, vB*/) \
846 vdst = INST_A(inst); \
847 vsrc1 = INST_B(inst); \
848 ILOGV("|%s-int-2addr v%d,v%d", (_opname), vdst, vsrc1); \
849 SET_REGISTER(vdst, \
850 _cast GET_REGISTER(vdst) _op (GET_REGISTER(vsrc1) & 0x1f)); \
851 FINISH(1);
852
853#define HANDLE_OP_X_LONG(_opcode, _opname, _op, _chkdiv) \
854 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
855 { \
856 u2 srcRegs; \
857 vdst = INST_AA(inst); \
858 srcRegs = FETCH(1); \
859 vsrc1 = srcRegs & 0xff; \
860 vsrc2 = srcRegs >> 8; \
861 ILOGV("|%s-long v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
862 if (_chkdiv != 0) { \
863 s8 firstVal, secondVal, result; \
864 firstVal = GET_REGISTER_WIDE(vsrc1); \
865 secondVal = GET_REGISTER_WIDE(vsrc2); \
866 if (secondVal == 0LL) { \
867 EXPORT_PC(); \
868 dvmThrowException("Ljava/lang/ArithmeticException;", \
869 "divide by zero"); \
870 GOTO_exceptionThrown(); \
871 } \
872 if ((u8)firstVal == 0x8000000000000000ULL && \
873 secondVal == -1LL) \
874 { \
875 if (_chkdiv == 1) \
876 result = firstVal; /* division */ \
877 else \
878 result = 0; /* remainder */ \
879 } else { \
880 result = firstVal _op secondVal; \
881 } \
882 SET_REGISTER_WIDE(vdst, result); \
883 } else { \
884 SET_REGISTER_WIDE(vdst, \
885 (s8) GET_REGISTER_WIDE(vsrc1) _op (s8) GET_REGISTER_WIDE(vsrc2)); \
886 } \
887 } \
888 FINISH(2);
889
890#define HANDLE_OP_SHX_LONG(_opcode, _opname, _cast, _op) \
891 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
892 { \
893 u2 srcRegs; \
894 vdst = INST_AA(inst); \
895 srcRegs = FETCH(1); \
896 vsrc1 = srcRegs & 0xff; \
897 vsrc2 = srcRegs >> 8; \
898 ILOGV("|%s-long v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
899 SET_REGISTER_WIDE(vdst, \
900 _cast GET_REGISTER_WIDE(vsrc1) _op (GET_REGISTER(vsrc2) & 0x3f)); \
901 } \
902 FINISH(2);
903
904#define HANDLE_OP_X_LONG_2ADDR(_opcode, _opname, _op, _chkdiv) \
905 HANDLE_OPCODE(_opcode /*vA, vB*/) \
906 vdst = INST_A(inst); \
907 vsrc1 = INST_B(inst); \
908 ILOGV("|%s-long-2addr v%d,v%d", (_opname), vdst, vsrc1); \
909 if (_chkdiv != 0) { \
910 s8 firstVal, secondVal, result; \
911 firstVal = GET_REGISTER_WIDE(vdst); \
912 secondVal = GET_REGISTER_WIDE(vsrc1); \
913 if (secondVal == 0LL) { \
914 EXPORT_PC(); \
915 dvmThrowException("Ljava/lang/ArithmeticException;", \
916 "divide by zero"); \
917 GOTO_exceptionThrown(); \
918 } \
919 if ((u8)firstVal == 0x8000000000000000ULL && \
920 secondVal == -1LL) \
921 { \
922 if (_chkdiv == 1) \
923 result = firstVal; /* division */ \
924 else \
925 result = 0; /* remainder */ \
926 } else { \
927 result = firstVal _op secondVal; \
928 } \
929 SET_REGISTER_WIDE(vdst, result); \
930 } else { \
931 SET_REGISTER_WIDE(vdst, \
932 (s8) GET_REGISTER_WIDE(vdst) _op (s8)GET_REGISTER_WIDE(vsrc1));\
933 } \
934 FINISH(1);
935
936#define HANDLE_OP_SHX_LONG_2ADDR(_opcode, _opname, _cast, _op) \
937 HANDLE_OPCODE(_opcode /*vA, vB*/) \
938 vdst = INST_A(inst); \
939 vsrc1 = INST_B(inst); \
940 ILOGV("|%s-long-2addr v%d,v%d", (_opname), vdst, vsrc1); \
941 SET_REGISTER_WIDE(vdst, \
942 _cast GET_REGISTER_WIDE(vdst) _op (GET_REGISTER(vsrc1) & 0x3f)); \
943 FINISH(1);
944
945#define HANDLE_OP_X_FLOAT(_opcode, _opname, _op) \
946 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
947 { \
948 u2 srcRegs; \
949 vdst = INST_AA(inst); \
950 srcRegs = FETCH(1); \
951 vsrc1 = srcRegs & 0xff; \
952 vsrc2 = srcRegs >> 8; \
953 ILOGV("|%s-float v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
954 SET_REGISTER_FLOAT(vdst, \
955 GET_REGISTER_FLOAT(vsrc1) _op GET_REGISTER_FLOAT(vsrc2)); \
956 } \
957 FINISH(2);
958
959#define HANDLE_OP_X_DOUBLE(_opcode, _opname, _op) \
960 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
961 { \
962 u2 srcRegs; \
963 vdst = INST_AA(inst); \
964 srcRegs = FETCH(1); \
965 vsrc1 = srcRegs & 0xff; \
966 vsrc2 = srcRegs >> 8; \
967 ILOGV("|%s-double v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
968 SET_REGISTER_DOUBLE(vdst, \
969 GET_REGISTER_DOUBLE(vsrc1) _op GET_REGISTER_DOUBLE(vsrc2)); \
970 } \
971 FINISH(2);
972
973#define HANDLE_OP_X_FLOAT_2ADDR(_opcode, _opname, _op) \
974 HANDLE_OPCODE(_opcode /*vA, vB*/) \
975 vdst = INST_A(inst); \
976 vsrc1 = INST_B(inst); \
977 ILOGV("|%s-float-2addr v%d,v%d", (_opname), vdst, vsrc1); \
978 SET_REGISTER_FLOAT(vdst, \
979 GET_REGISTER_FLOAT(vdst) _op GET_REGISTER_FLOAT(vsrc1)); \
980 FINISH(1);
981
982#define HANDLE_OP_X_DOUBLE_2ADDR(_opcode, _opname, _op) \
983 HANDLE_OPCODE(_opcode /*vA, vB*/) \
984 vdst = INST_A(inst); \
985 vsrc1 = INST_B(inst); \
986 ILOGV("|%s-double-2addr v%d,v%d", (_opname), vdst, vsrc1); \
987 SET_REGISTER_DOUBLE(vdst, \
988 GET_REGISTER_DOUBLE(vdst) _op GET_REGISTER_DOUBLE(vsrc1)); \
989 FINISH(1);
990
991#define HANDLE_OP_AGET(_opcode, _opname, _type, _regsize) \
992 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
993 { \
994 ArrayObject* arrayObj; \
995 u2 arrayInfo; \
996 EXPORT_PC(); \
997 vdst = INST_AA(inst); \
998 arrayInfo = FETCH(1); \
999 vsrc1 = arrayInfo & 0xff; /* array ptr */ \
1000 vsrc2 = arrayInfo >> 8; /* index */ \
1001 ILOGV("|aget%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
1002 arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); \
1003 if (!checkForNull((Object*) arrayObj)) \
1004 GOTO_exceptionThrown(); \
1005 if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
1006 LOGV("Invalid array access: %p %d (len=%d)\n", \
1007 arrayObj, vsrc2, arrayObj->length); \
1008 dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", \
1009 NULL); \
1010 GOTO_exceptionThrown(); \
1011 } \
1012 SET_REGISTER##_regsize(vdst, \
1013 ((_type*) arrayObj->contents)[GET_REGISTER(vsrc2)]); \
1014 ILOGV("+ AGET[%d]=0x%x", GET_REGISTER(vsrc2), GET_REGISTER(vdst)); \
1015 } \
1016 FINISH(2);
1017
1018#define HANDLE_OP_APUT(_opcode, _opname, _type, _regsize) \
1019 HANDLE_OPCODE(_opcode /*vAA, vBB, vCC*/) \
1020 { \
1021 ArrayObject* arrayObj; \
1022 u2 arrayInfo; \
1023 EXPORT_PC(); \
1024 vdst = INST_AA(inst); /* AA: source value */ \
1025 arrayInfo = FETCH(1); \
1026 vsrc1 = arrayInfo & 0xff; /* BB: array ptr */ \
1027 vsrc2 = arrayInfo >> 8; /* CC: index */ \
1028 ILOGV("|aput%s v%d,v%d,v%d", (_opname), vdst, vsrc1, vsrc2); \
1029 arrayObj = (ArrayObject*) GET_REGISTER(vsrc1); \
1030 if (!checkForNull((Object*) arrayObj)) \
1031 GOTO_exceptionThrown(); \
1032 if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
1033 dvmThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", \
1034 NULL); \
1035 GOTO_exceptionThrown(); \
1036 } \
1037 ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
1038 ((_type*) arrayObj->contents)[GET_REGISTER(vsrc2)] = \
1039 GET_REGISTER##_regsize(vdst); \
1040 } \
1041 FINISH(2);
1042
1043/*
1044 * It's possible to get a bad value out of a field with sub-32-bit stores
1045 * because the -quick versions always operate on 32 bits. Consider:
1046 * short foo = -1 (sets a 32-bit register to 0xffffffff)
1047 * iput-quick foo (writes all 32 bits to the field)
1048 * short bar = 1 (sets a 32-bit register to 0x00000001)
1049 * iput-short (writes the low 16 bits to the field)
1050 * iget-quick foo (reads all 32 bits from the field, yielding 0xffff0001)
1051 * This can only happen when optimized and non-optimized code has interleaved
1052 * access to the same field. This is unlikely but possible.
1053 *
1054 * The easiest way to fix this is to always read/write 32 bits at a time. On
1055 * a device with a 16-bit data bus this is sub-optimal. (The alternative
1056 * approach is to have sub-int versions of iget-quick, but now we're wasting
1057 * Dalvik instruction space and making it less likely that handler code will
1058 * already be in the CPU i-cache.)
1059 */
1060#define HANDLE_IGET_X(_opcode, _opname, _ftype, _regsize) \
1061 HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \
1062 { \
1063 InstField* ifield; \
1064 Object* obj; \
1065 EXPORT_PC(); \
1066 vdst = INST_A(inst); \
1067 vsrc1 = INST_B(inst); /* object ptr */ \
1068 ref = FETCH(1); /* field ref */ \
1069 ILOGV("|iget%s v%d,v%d,field@0x%04x", (_opname), vdst, vsrc1, ref); \
1070 obj = (Object*) GET_REGISTER(vsrc1); \
1071 if (!checkForNull(obj)) \
1072 GOTO_exceptionThrown(); \
1073 ifield = (InstField*) dvmDexGetResolvedField(methodClassDex, ref); \
1074 if (ifield == NULL) { \
1075 ifield = dvmResolveInstField(curMethod->clazz, ref); \
1076 if (ifield == NULL) \
1077 GOTO_exceptionThrown(); \
1078 } \
1079 SET_REGISTER##_regsize(vdst, \
1080 dvmGetField##_ftype(obj, ifield->byteOffset)); \
1081 ILOGV("+ IGET '%s'=0x%08llx", ifield->field.name, \
1082 (u8) GET_REGISTER##_regsize(vdst)); \
1083 UPDATE_FIELD_GET(&ifield->field); \
1084 } \
1085 FINISH(2);
1086
1087#define HANDLE_IGET_X_QUICK(_opcode, _opname, _ftype, _regsize) \
1088 HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \
1089 { \
1090 Object* obj; \
1091 vdst = INST_A(inst); \
1092 vsrc1 = INST_B(inst); /* object ptr */ \
1093 ref = FETCH(1); /* field offset */ \
1094 ILOGV("|iget%s-quick v%d,v%d,field@+%u", \
1095 (_opname), vdst, vsrc1, ref); \
1096 obj = (Object*) GET_REGISTER(vsrc1); \
1097 if (!checkForNullExportPC(obj, fp, pc)) \
1098 GOTO_exceptionThrown(); \
1099 SET_REGISTER##_regsize(vdst, dvmGetField##_ftype(obj, ref)); \
1100 ILOGV("+ IGETQ %d=0x%08llx", ref, \
1101 (u8) GET_REGISTER##_regsize(vdst)); \
1102 } \
1103 FINISH(2);
1104
1105#define HANDLE_IPUT_X(_opcode, _opname, _ftype, _regsize) \
1106 HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \
1107 { \
1108 InstField* ifield; \
1109 Object* obj; \
1110 EXPORT_PC(); \
1111 vdst = INST_A(inst); \
1112 vsrc1 = INST_B(inst); /* object ptr */ \
1113 ref = FETCH(1); /* field ref */ \
1114 ILOGV("|iput%s v%d,v%d,field@0x%04x", (_opname), vdst, vsrc1, ref); \
1115 obj = (Object*) GET_REGISTER(vsrc1); \
1116 if (!checkForNull(obj)) \
1117 GOTO_exceptionThrown(); \
1118 ifield = (InstField*) dvmDexGetResolvedField(methodClassDex, ref); \
1119 if (ifield == NULL) { \
1120 ifield = dvmResolveInstField(curMethod->clazz, ref); \
1121 if (ifield == NULL) \
1122 GOTO_exceptionThrown(); \
1123 } \
1124 dvmSetField##_ftype(obj, ifield->byteOffset, \
1125 GET_REGISTER##_regsize(vdst)); \
1126 ILOGV("+ IPUT '%s'=0x%08llx", ifield->field.name, \
1127 (u8) GET_REGISTER##_regsize(vdst)); \
1128 UPDATE_FIELD_PUT(&ifield->field); \
1129 } \
1130 FINISH(2);
1131
1132#define HANDLE_IPUT_X_QUICK(_opcode, _opname, _ftype, _regsize) \
1133 HANDLE_OPCODE(_opcode /*vA, vB, field@CCCC*/) \
1134 { \
1135 Object* obj; \
1136 vdst = INST_A(inst); \
1137 vsrc1 = INST_B(inst); /* object ptr */ \
1138 ref = FETCH(1); /* field offset */ \
1139 ILOGV("|iput%s-quick v%d,v%d,field@0x%04x", \
1140 (_opname), vdst, vsrc1, ref); \
1141 obj = (Object*) GET_REGISTER(vsrc1); \
1142 if (!checkForNullExportPC(obj, fp, pc)) \
1143 GOTO_exceptionThrown(); \
1144 dvmSetField##_ftype(obj, ref, GET_REGISTER##_regsize(vdst)); \
1145 ILOGV("+ IPUTQ %d=0x%08llx", ref, \
1146 (u8) GET_REGISTER##_regsize(vdst)); \
1147 } \
1148 FINISH(2);
1149
1150#define HANDLE_SGET_X(_opcode, _opname, _ftype, _regsize) \
1151 HANDLE_OPCODE(_opcode /*vAA, field@BBBB*/) \
1152 { \
1153 StaticField* sfield; \
1154 vdst = INST_AA(inst); \
1155 ref = FETCH(1); /* field ref */ \
1156 ILOGV("|sget%s v%d,sfield@0x%04x", (_opname), vdst, ref); \
1157 sfield = (StaticField*)dvmDexGetResolvedField(methodClassDex, ref); \
1158 if (sfield == NULL) { \
1159 EXPORT_PC(); \
1160 sfield = dvmResolveStaticField(curMethod->clazz, ref); \
1161 if (sfield == NULL) \
1162 GOTO_exceptionThrown(); \
1163 } \
1164 SET_REGISTER##_regsize(vdst, dvmGetStaticField##_ftype(sfield)); \
1165 ILOGV("+ SGET '%s'=0x%08llx", \
1166 sfield->field.name, (u8)GET_REGISTER##_regsize(vdst)); \
1167 UPDATE_FIELD_GET(&sfield->field); \
1168 } \
1169 FINISH(2);
1170
1171#define HANDLE_SPUT_X(_opcode, _opname, _ftype, _regsize) \
1172 HANDLE_OPCODE(_opcode /*vAA, field@BBBB*/) \
1173 { \
1174 StaticField* sfield; \
1175 vdst = INST_AA(inst); \
1176 ref = FETCH(1); /* field ref */ \
1177 ILOGV("|sput%s v%d,sfield@0x%04x", (_opname), vdst, ref); \
1178 sfield = (StaticField*)dvmDexGetResolvedField(methodClassDex, ref); \
1179 if (sfield == NULL) { \
1180 EXPORT_PC(); \
1181 sfield = dvmResolveStaticField(curMethod->clazz, ref); \
1182 if (sfield == NULL) \
1183 GOTO_exceptionThrown(); \
1184 } \
1185 dvmSetStaticField##_ftype(sfield, GET_REGISTER##_regsize(vdst)); \
1186 ILOGV("+ SPUT '%s'=0x%08llx", \
1187 sfield->field.name, (u8)GET_REGISTER##_regsize(vdst)); \
1188 UPDATE_FIELD_PUT(&sfield->field); \
1189 } \
1190 FINISH(2);
1191
1192
Andy McFaddenb0a05412009-11-19 10:23:41 -08001193/* File: c/OP_EXECUTE_INLINE_RANGE.c */
1194HANDLE_OPCODE(OP_EXECUTE_INLINE_RANGE /*{vCCCC..v(CCCC+AA-1)}, inline@BBBB*/)
1195 {
1196 u4 arg0, arg1, arg2, arg3;
1197 arg0 = arg1 = arg2 = arg3 = 0; /* placate gcc */
1198
1199 EXPORT_PC();
1200
1201 vsrc1 = INST_AA(inst); /* #of args */
1202 ref = FETCH(1); /* inline call "ref" */
1203 vdst = FETCH(2); /* range base */
1204 ILOGV("|execute-inline-range args=%d @%d {regs=v%d-v%d}",
1205 vsrc1, ref, vdst, vdst+vsrc1-1);
1206
1207 assert((vdst >> 16) == 0); // 16-bit type -or- high 16 bits clear
1208 assert(vsrc1 <= 4);
1209
1210 switch (vsrc1) {
1211 case 4:
1212 arg3 = GET_REGISTER(vdst+3);
1213 /* fall through */
1214 case 3:
1215 arg2 = GET_REGISTER(vdst+2);
1216 /* fall through */
1217 case 2:
1218 arg1 = GET_REGISTER(vdst+1);
1219 /* fall through */
1220 case 1:
1221 arg0 = GET_REGISTER(vdst+0);
1222 /* fall through */
1223 default: // case 0
1224 ;
1225 }
1226
1227#if INTERP_TYPE == INTERP_DBG
1228 if (!dvmPerformInlineOp4Dbg(arg0, arg1, arg2, arg3, &retval, ref))
1229 GOTO_exceptionThrown();
1230#else
1231 if (!dvmPerformInlineOp4Std(arg0, arg1, arg2, arg3, &retval, ref))
1232 GOTO_exceptionThrown();
1233#endif
1234 }
1235 FINISH(3);
1236OP_END
1237
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001238/* File: c/gotoTargets.c */
1239/*
1240 * C footer. This has some common code shared by the various targets.
1241 */
1242
1243/*
1244 * Everything from here on is a "goto target". In the basic interpreter
1245 * we jump into these targets and then jump directly to the handler for
1246 * next instruction. Here, these are subroutines that return to the caller.
1247 */
1248
1249GOTO_TARGET(filledNewArray, bool methodCallRange)
1250 {
1251 ClassObject* arrayClass;
1252 ArrayObject* newArray;
1253 u4* contents;
1254 char typeCh;
1255 int i;
1256 u4 arg5;
1257
1258 EXPORT_PC();
1259
1260 ref = FETCH(1); /* class ref */
1261 vdst = FETCH(2); /* first 4 regs -or- range base */
1262
1263 if (methodCallRange) {
1264 vsrc1 = INST_AA(inst); /* #of elements */
1265 arg5 = -1; /* silence compiler warning */
1266 ILOGV("|filled-new-array-range args=%d @0x%04x {regs=v%d-v%d}",
1267 vsrc1, ref, vdst, vdst+vsrc1-1);
1268 } else {
1269 arg5 = INST_A(inst);
1270 vsrc1 = INST_B(inst); /* #of elements */
1271 ILOGV("|filled-new-array args=%d @0x%04x {regs=0x%04x %x}",
1272 vsrc1, ref, vdst, arg5);
1273 }
1274
1275 /*
1276 * Resolve the array class.
1277 */
1278 arrayClass = dvmDexGetResolvedClass(methodClassDex, ref);
1279 if (arrayClass == NULL) {
1280 arrayClass = dvmResolveClass(curMethod->clazz, ref, false);
1281 if (arrayClass == NULL)
1282 GOTO_exceptionThrown();
1283 }
1284 /*
1285 if (!dvmIsArrayClass(arrayClass)) {
1286 dvmThrowException("Ljava/lang/RuntimeError;",
1287 "filled-new-array needs array class");
1288 GOTO_exceptionThrown();
1289 }
1290 */
1291 /* verifier guarantees this is an array class */
1292 assert(dvmIsArrayClass(arrayClass));
1293 assert(dvmIsClassInitialized(arrayClass));
1294
1295 /*
1296 * Create an array of the specified type.
1297 */
1298 LOGVV("+++ filled-new-array type is '%s'\n", arrayClass->descriptor);
1299 typeCh = arrayClass->descriptor[1];
1300 if (typeCh == 'D' || typeCh == 'J') {
1301 /* category 2 primitives not allowed */
1302 dvmThrowException("Ljava/lang/RuntimeError;",
1303 "bad filled array req");
1304 GOTO_exceptionThrown();
1305 } else if (typeCh != 'L' && typeCh != '[' && typeCh != 'I') {
1306 /* TODO: requires multiple "fill in" loops with different widths */
1307 LOGE("non-int primitives not implemented\n");
1308 dvmThrowException("Ljava/lang/InternalError;",
1309 "filled-new-array not implemented for anything but 'int'");
1310 GOTO_exceptionThrown();
1311 }
1312
1313 newArray = dvmAllocArrayByClass(arrayClass, vsrc1, ALLOC_DONT_TRACK);
1314 if (newArray == NULL)
1315 GOTO_exceptionThrown();
1316
1317 /*
1318 * Fill in the elements. It's legal for vsrc1 to be zero.
1319 */
1320 contents = (u4*) newArray->contents;
1321 if (methodCallRange) {
1322 for (i = 0; i < vsrc1; i++)
1323 contents[i] = GET_REGISTER(vdst+i);
1324 } else {
1325 assert(vsrc1 <= 5);
1326 if (vsrc1 == 5) {
1327 contents[4] = GET_REGISTER(arg5);
1328 vsrc1--;
1329 }
1330 for (i = 0; i < vsrc1; i++) {
1331 contents[i] = GET_REGISTER(vdst & 0x0f);
1332 vdst >>= 4;
1333 }
1334 }
1335
1336 retval.l = newArray;
1337 }
1338 FINISH(3);
1339GOTO_TARGET_END
1340
1341
1342GOTO_TARGET(invokeVirtual, bool methodCallRange)
1343 {
1344 Method* baseMethod;
1345 Object* thisPtr;
1346
1347 EXPORT_PC();
1348
1349 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1350 ref = FETCH(1); /* method ref */
1351 vdst = FETCH(2); /* 4 regs -or- first reg */
1352
1353 /*
1354 * The object against which we are executing a method is always
1355 * in the first argument.
1356 */
1357 if (methodCallRange) {
1358 assert(vsrc1 > 0);
1359 ILOGV("|invoke-virtual-range args=%d @0x%04x {regs=v%d-v%d}",
1360 vsrc1, ref, vdst, vdst+vsrc1-1);
1361 thisPtr = (Object*) GET_REGISTER(vdst);
1362 } else {
1363 assert((vsrc1>>4) > 0);
1364 ILOGV("|invoke-virtual args=%d @0x%04x {regs=0x%04x %x}",
1365 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1366 thisPtr = (Object*) GET_REGISTER(vdst & 0x0f);
1367 }
1368
1369 if (!checkForNull(thisPtr))
1370 GOTO_exceptionThrown();
1371
1372 /*
1373 * Resolve the method. This is the correct method for the static
1374 * type of the object. We also verify access permissions here.
1375 */
1376 baseMethod = dvmDexGetResolvedMethod(methodClassDex, ref);
1377 if (baseMethod == NULL) {
1378 baseMethod = dvmResolveMethod(curMethod->clazz, ref,METHOD_VIRTUAL);
1379 if (baseMethod == NULL) {
1380 ILOGV("+ unknown method or access denied\n");
1381 GOTO_exceptionThrown();
1382 }
1383 }
1384
1385 /*
1386 * Combine the object we found with the vtable offset in the
1387 * method.
1388 */
1389 assert(baseMethod->methodIndex < thisPtr->clazz->vtableCount);
1390 methodToCall = thisPtr->clazz->vtable[baseMethod->methodIndex];
1391
1392#if 0
1393 if (dvmIsAbstractMethod(methodToCall)) {
1394 /*
1395 * This can happen if you create two classes, Base and Sub, where
1396 * Sub is a sub-class of Base. Declare a protected abstract
1397 * method foo() in Base, and invoke foo() from a method in Base.
1398 * Base is an "abstract base class" and is never instantiated
1399 * directly. Now, Override foo() in Sub, and use Sub. This
1400 * Works fine unless Sub stops providing an implementation of
1401 * the method.
1402 */
1403 dvmThrowException("Ljava/lang/AbstractMethodError;",
1404 "abstract method not implemented");
1405 GOTO_exceptionThrown();
1406 }
1407#else
1408 assert(!dvmIsAbstractMethod(methodToCall) ||
1409 methodToCall->nativeFunc != NULL);
1410#endif
1411
1412 LOGVV("+++ base=%s.%s virtual[%d]=%s.%s\n",
1413 baseMethod->clazz->descriptor, baseMethod->name,
1414 (u4) baseMethod->methodIndex,
1415 methodToCall->clazz->descriptor, methodToCall->name);
1416 assert(methodToCall != NULL);
1417
1418#if 0
1419 if (vsrc1 != methodToCall->insSize) {
1420 LOGW("WRONG METHOD: base=%s.%s virtual[%d]=%s.%s\n",
1421 baseMethod->clazz->descriptor, baseMethod->name,
1422 (u4) baseMethod->methodIndex,
1423 methodToCall->clazz->descriptor, methodToCall->name);
1424 //dvmDumpClass(baseMethod->clazz);
1425 //dvmDumpClass(methodToCall->clazz);
1426 dvmDumpAllClasses(0);
1427 }
1428#endif
1429
1430 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1431 }
1432GOTO_TARGET_END
1433
1434GOTO_TARGET(invokeSuper, bool methodCallRange)
1435 {
1436 Method* baseMethod;
1437 u2 thisReg;
1438
1439 EXPORT_PC();
1440
1441 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1442 ref = FETCH(1); /* method ref */
1443 vdst = FETCH(2); /* 4 regs -or- first reg */
1444
1445 if (methodCallRange) {
1446 ILOGV("|invoke-super-range args=%d @0x%04x {regs=v%d-v%d}",
1447 vsrc1, ref, vdst, vdst+vsrc1-1);
1448 thisReg = vdst;
1449 } else {
1450 ILOGV("|invoke-super args=%d @0x%04x {regs=0x%04x %x}",
1451 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1452 thisReg = vdst & 0x0f;
1453 }
1454 /* impossible in well-formed code, but we must check nevertheless */
1455 if (!checkForNull((Object*) GET_REGISTER(thisReg)))
1456 GOTO_exceptionThrown();
1457
1458 /*
1459 * Resolve the method. This is the correct method for the static
1460 * type of the object. We also verify access permissions here.
1461 * The first arg to dvmResolveMethod() is just the referring class
1462 * (used for class loaders and such), so we don't want to pass
1463 * the superclass into the resolution call.
1464 */
1465 baseMethod = dvmDexGetResolvedMethod(methodClassDex, ref);
1466 if (baseMethod == NULL) {
1467 baseMethod = dvmResolveMethod(curMethod->clazz, ref,METHOD_VIRTUAL);
1468 if (baseMethod == NULL) {
1469 ILOGV("+ unknown method or access denied\n");
1470 GOTO_exceptionThrown();
1471 }
1472 }
1473
1474 /*
1475 * Combine the object we found with the vtable offset in the
1476 * method's class.
1477 *
1478 * We're using the current method's class' superclass, not the
1479 * superclass of "this". This is because we might be executing
1480 * in a method inherited from a superclass, and we want to run
1481 * in that class' superclass.
1482 */
1483 if (baseMethod->methodIndex >= curMethod->clazz->super->vtableCount) {
1484 /*
1485 * Method does not exist in the superclass. Could happen if
1486 * superclass gets updated.
1487 */
1488 dvmThrowException("Ljava/lang/NoSuchMethodError;",
1489 baseMethod->name);
1490 GOTO_exceptionThrown();
1491 }
1492 methodToCall = curMethod->clazz->super->vtable[baseMethod->methodIndex];
1493#if 0
1494 if (dvmIsAbstractMethod(methodToCall)) {
1495 dvmThrowException("Ljava/lang/AbstractMethodError;",
1496 "abstract method not implemented");
1497 GOTO_exceptionThrown();
1498 }
1499#else
1500 assert(!dvmIsAbstractMethod(methodToCall) ||
1501 methodToCall->nativeFunc != NULL);
1502#endif
1503 LOGVV("+++ base=%s.%s super-virtual=%s.%s\n",
1504 baseMethod->clazz->descriptor, baseMethod->name,
1505 methodToCall->clazz->descriptor, methodToCall->name);
1506 assert(methodToCall != NULL);
1507
1508 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1509 }
1510GOTO_TARGET_END
1511
1512GOTO_TARGET(invokeInterface, bool methodCallRange)
1513 {
1514 Object* thisPtr;
1515 ClassObject* thisClass;
1516
1517 EXPORT_PC();
1518
1519 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1520 ref = FETCH(1); /* method ref */
1521 vdst = FETCH(2); /* 4 regs -or- first reg */
1522
1523 /*
1524 * The object against which we are executing a method is always
1525 * in the first argument.
1526 */
1527 if (methodCallRange) {
1528 assert(vsrc1 > 0);
1529 ILOGV("|invoke-interface-range args=%d @0x%04x {regs=v%d-v%d}",
1530 vsrc1, ref, vdst, vdst+vsrc1-1);
1531 thisPtr = (Object*) GET_REGISTER(vdst);
1532 } else {
1533 assert((vsrc1>>4) > 0);
1534 ILOGV("|invoke-interface args=%d @0x%04x {regs=0x%04x %x}",
1535 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1536 thisPtr = (Object*) GET_REGISTER(vdst & 0x0f);
1537 }
1538 if (!checkForNull(thisPtr))
1539 GOTO_exceptionThrown();
1540
1541 thisClass = thisPtr->clazz;
1542
1543 /*
1544 * Given a class and a method index, find the Method* with the
1545 * actual code we want to execute.
1546 */
1547 methodToCall = dvmFindInterfaceMethodInCache(thisClass, ref, curMethod,
1548 methodClassDex);
1549 if (methodToCall == NULL) {
1550 assert(dvmCheckException(self));
1551 GOTO_exceptionThrown();
1552 }
1553
1554 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1555 }
1556GOTO_TARGET_END
1557
1558GOTO_TARGET(invokeDirect, bool methodCallRange)
1559 {
1560 u2 thisReg;
1561
1562 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1563 ref = FETCH(1); /* method ref */
1564 vdst = FETCH(2); /* 4 regs -or- first reg */
1565
1566 EXPORT_PC();
1567
1568 if (methodCallRange) {
1569 ILOGV("|invoke-direct-range args=%d @0x%04x {regs=v%d-v%d}",
1570 vsrc1, ref, vdst, vdst+vsrc1-1);
1571 thisReg = vdst;
1572 } else {
1573 ILOGV("|invoke-direct args=%d @0x%04x {regs=0x%04x %x}",
1574 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1575 thisReg = vdst & 0x0f;
1576 }
1577 if (!checkForNull((Object*) GET_REGISTER(thisReg)))
1578 GOTO_exceptionThrown();
1579
1580 methodToCall = dvmDexGetResolvedMethod(methodClassDex, ref);
1581 if (methodToCall == NULL) {
1582 methodToCall = dvmResolveMethod(curMethod->clazz, ref,
1583 METHOD_DIRECT);
1584 if (methodToCall == NULL) {
1585 ILOGV("+ unknown direct method\n"); // should be impossible
1586 GOTO_exceptionThrown();
1587 }
1588 }
1589 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1590 }
1591GOTO_TARGET_END
1592
1593GOTO_TARGET(invokeStatic, bool methodCallRange)
1594 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1595 ref = FETCH(1); /* method ref */
1596 vdst = FETCH(2); /* 4 regs -or- first reg */
1597
1598 EXPORT_PC();
1599
1600 if (methodCallRange)
1601 ILOGV("|invoke-static-range args=%d @0x%04x {regs=v%d-v%d}",
1602 vsrc1, ref, vdst, vdst+vsrc1-1);
1603 else
1604 ILOGV("|invoke-static args=%d @0x%04x {regs=0x%04x %x}",
1605 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1606
1607 methodToCall = dvmDexGetResolvedMethod(methodClassDex, ref);
1608 if (methodToCall == NULL) {
1609 methodToCall = dvmResolveMethod(curMethod->clazz, ref, METHOD_STATIC);
1610 if (methodToCall == NULL) {
1611 ILOGV("+ unknown method\n");
1612 GOTO_exceptionThrown();
1613 }
1614 }
1615 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1616GOTO_TARGET_END
1617
1618GOTO_TARGET(invokeVirtualQuick, bool methodCallRange)
1619 {
1620 Object* thisPtr;
1621
1622 EXPORT_PC();
1623
1624 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1625 ref = FETCH(1); /* vtable index */
1626 vdst = FETCH(2); /* 4 regs -or- first reg */
1627
1628 /*
1629 * The object against which we are executing a method is always
1630 * in the first argument.
1631 */
1632 if (methodCallRange) {
1633 assert(vsrc1 > 0);
1634 ILOGV("|invoke-virtual-quick-range args=%d @0x%04x {regs=v%d-v%d}",
1635 vsrc1, ref, vdst, vdst+vsrc1-1);
1636 thisPtr = (Object*) GET_REGISTER(vdst);
1637 } else {
1638 assert((vsrc1>>4) > 0);
1639 ILOGV("|invoke-virtual-quick args=%d @0x%04x {regs=0x%04x %x}",
1640 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1641 thisPtr = (Object*) GET_REGISTER(vdst & 0x0f);
1642 }
1643
1644 if (!checkForNull(thisPtr))
1645 GOTO_exceptionThrown();
1646
1647 /*
1648 * Combine the object we found with the vtable offset in the
1649 * method.
1650 */
1651 assert(ref < thisPtr->clazz->vtableCount);
1652 methodToCall = thisPtr->clazz->vtable[ref];
1653
1654#if 0
1655 if (dvmIsAbstractMethod(methodToCall)) {
1656 dvmThrowException("Ljava/lang/AbstractMethodError;",
1657 "abstract method not implemented");
1658 GOTO_exceptionThrown();
1659 }
1660#else
1661 assert(!dvmIsAbstractMethod(methodToCall) ||
1662 methodToCall->nativeFunc != NULL);
1663#endif
1664
1665 LOGVV("+++ virtual[%d]=%s.%s\n",
1666 ref, methodToCall->clazz->descriptor, methodToCall->name);
1667 assert(methodToCall != NULL);
1668
1669 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1670 }
1671GOTO_TARGET_END
1672
1673GOTO_TARGET(invokeSuperQuick, bool methodCallRange)
1674 {
1675 u2 thisReg;
1676
1677 EXPORT_PC();
1678
1679 vsrc1 = INST_AA(inst); /* AA (count) or BA (count + arg 5) */
1680 ref = FETCH(1); /* vtable index */
1681 vdst = FETCH(2); /* 4 regs -or- first reg */
1682
1683 if (methodCallRange) {
1684 ILOGV("|invoke-super-quick-range args=%d @0x%04x {regs=v%d-v%d}",
1685 vsrc1, ref, vdst, vdst+vsrc1-1);
1686 thisReg = vdst;
1687 } else {
1688 ILOGV("|invoke-super-quick args=%d @0x%04x {regs=0x%04x %x}",
1689 vsrc1 >> 4, ref, vdst, vsrc1 & 0x0f);
1690 thisReg = vdst & 0x0f;
1691 }
1692 /* impossible in well-formed code, but we must check nevertheless */
1693 if (!checkForNull((Object*) GET_REGISTER(thisReg)))
1694 GOTO_exceptionThrown();
1695
1696#if 0 /* impossible in optimized + verified code */
1697 if (ref >= curMethod->clazz->super->vtableCount) {
1698 dvmThrowException("Ljava/lang/NoSuchMethodError;", NULL);
1699 GOTO_exceptionThrown();
1700 }
1701#else
1702 assert(ref < curMethod->clazz->super->vtableCount);
1703#endif
1704
1705 /*
1706 * Combine the object we found with the vtable offset in the
1707 * method's class.
1708 *
1709 * We're using the current method's class' superclass, not the
1710 * superclass of "this". This is because we might be executing
1711 * in a method inherited from a superclass, and we want to run
1712 * in the method's class' superclass.
1713 */
1714 methodToCall = curMethod->clazz->super->vtable[ref];
1715
1716#if 0
1717 if (dvmIsAbstractMethod(methodToCall)) {
1718 dvmThrowException("Ljava/lang/AbstractMethodError;",
1719 "abstract method not implemented");
1720 GOTO_exceptionThrown();
1721 }
1722#else
1723 assert(!dvmIsAbstractMethod(methodToCall) ||
1724 methodToCall->nativeFunc != NULL);
1725#endif
1726 LOGVV("+++ super-virtual[%d]=%s.%s\n",
1727 ref, methodToCall->clazz->descriptor, methodToCall->name);
1728 assert(methodToCall != NULL);
1729
1730 GOTO_invokeMethod(methodCallRange, methodToCall, vsrc1, vdst);
1731 }
1732GOTO_TARGET_END
1733
1734
1735
1736 /*
1737 * General handling for return-void, return, and return-wide. Put the
1738 * return value in "retval" before jumping here.
1739 */
1740GOTO_TARGET(returnFromMethod)
1741 {
1742 StackSaveArea* saveArea;
1743
1744 /*
1745 * We must do this BEFORE we pop the previous stack frame off, so
1746 * that the GC can see the return value (if any) in the local vars.
1747 *
1748 * Since this is now an interpreter switch point, we must do it before
1749 * we do anything at all.
1750 */
1751 PERIODIC_CHECKS(kInterpEntryReturn, 0);
1752
1753 ILOGV("> retval=0x%llx (leaving %s.%s %s)",
1754 retval.j, curMethod->clazz->descriptor, curMethod->name,
Mike Lockwood85745e12009-07-08 12:39:37 -04001755 curMethod->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001756 //DUMP_REGS(curMethod, fp);
1757
1758 saveArea = SAVEAREA_FROM_FP(fp);
1759
1760#ifdef EASY_GDB
1761 debugSaveArea = saveArea;
1762#endif
1763#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER)
1764 TRACE_METHOD_EXIT(self, curMethod);
1765#endif
1766
1767 /* back up to previous frame and see if we hit a break */
1768 fp = saveArea->prevFrame;
1769 assert(fp != NULL);
1770 if (dvmIsBreakFrame(fp)) {
1771 /* bail without popping the method frame from stack */
1772 LOGVV("+++ returned into break frame\n");
Bill Buzbeed7269912009-11-10 14:31:32 -08001773#if defined(WITH_JIT)
1774 /* Let the Jit know the return is terminating normally */
1775 CHECK_JIT();
1776#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001777 GOTO_bail();
1778 }
1779
1780 /* update thread FP, and reset local variables */
1781 self->curFrame = fp;
1782 curMethod = SAVEAREA_FROM_FP(fp)->method;
1783 //methodClass = curMethod->clazz;
1784 methodClassDex = curMethod->clazz->pDvmDex;
1785 pc = saveArea->savedPc;
1786 ILOGD("> (return to %s.%s %s)", curMethod->clazz->descriptor,
Mike Lockwood85745e12009-07-08 12:39:37 -04001787 curMethod->name, curMethod->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001788
1789 /* use FINISH on the caller's invoke instruction */
1790 //u2 invokeInstr = INST_INST(FETCH(0));
1791 if (true /*invokeInstr >= OP_INVOKE_VIRTUAL &&
1792 invokeInstr <= OP_INVOKE_INTERFACE*/)
1793 {
1794 FINISH(3);
1795 } else {
1796 //LOGE("Unknown invoke instr %02x at %d\n",
1797 // invokeInstr, (int) (pc - curMethod->insns));
1798 assert(false);
1799 }
1800 }
1801GOTO_TARGET_END
1802
1803
1804 /*
1805 * Jump here when the code throws an exception.
1806 *
1807 * By the time we get here, the Throwable has been created and the stack
1808 * trace has been saved off.
1809 */
1810GOTO_TARGET(exceptionThrown)
1811 {
1812 Object* exception;
1813 int catchRelPc;
1814
1815 /*
1816 * Since this is now an interpreter switch point, we must do it before
1817 * we do anything at all.
1818 */
1819 PERIODIC_CHECKS(kInterpEntryThrow, 0);
1820
Ben Cheng79d173c2009-09-29 16:12:51 -07001821#if defined(WITH_JIT)
1822 // Something threw during trace selection - abort the current trace
Bill Buzbeed7269912009-11-10 14:31:32 -08001823 dvmJitAbortTraceSelect(interpState);
Ben Cheng79d173c2009-09-29 16:12:51 -07001824#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001825 /*
1826 * We save off the exception and clear the exception status. While
1827 * processing the exception we might need to load some Throwable
1828 * classes, and we don't want class loader exceptions to get
1829 * confused with this one.
1830 */
1831 assert(dvmCheckException(self));
1832 exception = dvmGetException(self);
1833 dvmAddTrackedAlloc(exception, self);
1834 dvmClearException(self);
1835
1836 LOGV("Handling exception %s at %s:%d\n",
1837 exception->clazz->descriptor, curMethod->name,
1838 dvmLineNumFromPC(curMethod, pc - curMethod->insns));
1839
1840#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER)
1841 /*
1842 * Tell the debugger about it.
1843 *
1844 * TODO: if the exception was thrown by interpreted code, control
1845 * fell through native, and then back to us, we will report the
1846 * exception at the point of the throw and again here. We can avoid
1847 * this by not reporting exceptions when we jump here directly from
1848 * the native call code above, but then we won't report exceptions
1849 * that were thrown *from* the JNI code (as opposed to *through* it).
1850 *
1851 * The correct solution is probably to ignore from-native exceptions
1852 * here, and have the JNI exception code do the reporting to the
1853 * debugger.
1854 */
1855 if (gDvm.debuggerActive) {
1856 void* catchFrame;
1857 catchRelPc = dvmFindCatchBlock(self, pc - curMethod->insns,
1858 exception, true, &catchFrame);
1859 dvmDbgPostException(fp, pc - curMethod->insns, catchFrame,
1860 catchRelPc, exception);
1861 }
1862#endif
1863
1864 /*
1865 * We need to unroll to the catch block or the nearest "break"
1866 * frame.
1867 *
1868 * A break frame could indicate that we have reached an intermediate
1869 * native call, or have gone off the top of the stack and the thread
1870 * needs to exit. Either way, we return from here, leaving the
1871 * exception raised.
1872 *
1873 * If we do find a catch block, we want to transfer execution to
1874 * that point.
1875 */
1876 catchRelPc = dvmFindCatchBlock(self, pc - curMethod->insns,
1877 exception, false, (void*)&fp);
1878
1879 /*
1880 * Restore the stack bounds after an overflow. This isn't going to
1881 * be correct in all circumstances, e.g. if JNI code devours the
1882 * exception this won't happen until some other exception gets
1883 * thrown. If the code keeps pushing the stack bounds we'll end
1884 * up aborting the VM.
1885 *
1886 * Note we want to do this *after* the call to dvmFindCatchBlock,
1887 * because that may need extra stack space to resolve exception
1888 * classes (e.g. through a class loader).
1889 */
1890 if (self->stackOverflowed)
1891 dvmCleanupStackOverflow(self);
1892
1893 if (catchRelPc < 0) {
1894 /* falling through to JNI code or off the bottom of the stack */
1895#if DVM_SHOW_EXCEPTION >= 2
1896 LOGD("Exception %s from %s:%d not caught locally\n",
1897 exception->clazz->descriptor, dvmGetMethodSourceFile(curMethod),
1898 dvmLineNumFromPC(curMethod, pc - curMethod->insns));
1899#endif
1900 dvmSetException(self, exception);
1901 dvmReleaseTrackedAlloc(exception, self);
1902 GOTO_bail();
1903 }
1904
1905#if DVM_SHOW_EXCEPTION >= 3
1906 {
1907 const Method* catchMethod = SAVEAREA_FROM_FP(fp)->method;
1908 LOGD("Exception %s thrown from %s:%d to %s:%d\n",
1909 exception->clazz->descriptor, dvmGetMethodSourceFile(curMethod),
1910 dvmLineNumFromPC(curMethod, pc - curMethod->insns),
1911 dvmGetMethodSourceFile(catchMethod),
1912 dvmLineNumFromPC(catchMethod, catchRelPc));
1913 }
1914#endif
1915
1916 /*
1917 * Adjust local variables to match self->curFrame and the
1918 * updated PC.
1919 */
1920 //fp = (u4*) self->curFrame;
1921 curMethod = SAVEAREA_FROM_FP(fp)->method;
1922 //methodClass = curMethod->clazz;
1923 methodClassDex = curMethod->clazz->pDvmDex;
1924 pc = curMethod->insns + catchRelPc;
1925 ILOGV("> pc <-- %s.%s %s", curMethod->clazz->descriptor,
Mike Lockwood85745e12009-07-08 12:39:37 -04001926 curMethod->name, curMethod->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001927 DUMP_REGS(curMethod, fp, false); // show all regs
1928
1929 /*
1930 * Restore the exception if the handler wants it.
1931 *
1932 * The Dalvik spec mandates that, if an exception handler wants to
1933 * do something with the exception, the first instruction executed
1934 * must be "move-exception". We can pass the exception along
1935 * through the thread struct, and let the move-exception instruction
1936 * clear it for us.
1937 *
1938 * If the handler doesn't call move-exception, we don't want to
1939 * finish here with an exception still pending.
1940 */
1941 if (INST_INST(FETCH(0)) == OP_MOVE_EXCEPTION)
1942 dvmSetException(self, exception);
1943
1944 dvmReleaseTrackedAlloc(exception, self);
1945 FINISH(0);
1946 }
1947GOTO_TARGET_END
1948
1949
1950 /*
1951 * General handling for invoke-{virtual,super,direct,static,interface},
1952 * including "quick" variants.
1953 *
1954 * Set "methodToCall" to the Method we're calling, and "methodCallRange"
1955 * depending on whether this is a "/range" instruction.
1956 *
1957 * For a range call:
1958 * "vsrc1" holds the argument count (8 bits)
1959 * "vdst" holds the first argument in the range
1960 * For a non-range call:
1961 * "vsrc1" holds the argument count (4 bits) and the 5th argument index
1962 * "vdst" holds four 4-bit register indices
1963 *
1964 * The caller must EXPORT_PC before jumping here, because any method
1965 * call can throw a stack overflow exception.
1966 */
1967GOTO_TARGET(invokeMethod, bool methodCallRange, const Method* _methodToCall,
1968 u2 count, u2 regs)
1969 {
1970 STUB_HACK(vsrc1 = count; vdst = regs; methodToCall = _methodToCall;);
1971
1972 //printf("range=%d call=%p count=%d regs=0x%04x\n",
1973 // methodCallRange, methodToCall, count, regs);
1974 //printf(" --> %s.%s %s\n", methodToCall->clazz->descriptor,
Mike Lockwood85745e12009-07-08 12:39:37 -04001975 // methodToCall->name, methodToCall->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001976
1977 u4* outs;
1978 int i;
1979
1980 /*
1981 * Copy args. This may corrupt vsrc1/vdst.
1982 */
1983 if (methodCallRange) {
1984 // could use memcpy or a "Duff's device"; most functions have
1985 // so few args it won't matter much
1986 assert(vsrc1 <= curMethod->outsSize);
1987 assert(vsrc1 == methodToCall->insSize);
1988 outs = OUTS_FROM_FP(fp, vsrc1);
1989 for (i = 0; i < vsrc1; i++)
1990 outs[i] = GET_REGISTER(vdst+i);
1991 } else {
1992 u4 count = vsrc1 >> 4;
1993
1994 assert(count <= curMethod->outsSize);
1995 assert(count == methodToCall->insSize);
1996 assert(count <= 5);
1997
1998 outs = OUTS_FROM_FP(fp, count);
1999#if 0
2000 if (count == 5) {
2001 outs[4] = GET_REGISTER(vsrc1 & 0x0f);
2002 count--;
2003 }
2004 for (i = 0; i < (int) count; i++) {
2005 outs[i] = GET_REGISTER(vdst & 0x0f);
2006 vdst >>= 4;
2007 }
2008#else
2009 // This version executes fewer instructions but is larger
2010 // overall. Seems to be a teensy bit faster.
2011 assert((vdst >> 16) == 0); // 16 bits -or- high 16 bits clear
2012 switch (count) {
2013 case 5:
2014 outs[4] = GET_REGISTER(vsrc1 & 0x0f);
2015 case 4:
2016 outs[3] = GET_REGISTER(vdst >> 12);
2017 case 3:
2018 outs[2] = GET_REGISTER((vdst & 0x0f00) >> 8);
2019 case 2:
2020 outs[1] = GET_REGISTER((vdst & 0x00f0) >> 4);
2021 case 1:
2022 outs[0] = GET_REGISTER(vdst & 0x0f);
2023 default:
2024 ;
2025 }
2026#endif
2027 }
2028 }
2029
2030 /*
2031 * (This was originally a "goto" target; I've kept it separate from the
2032 * stuff above in case we want to refactor things again.)
2033 *
2034 * At this point, we have the arguments stored in the "outs" area of
2035 * the current method's stack frame, and the method to call in
2036 * "methodToCall". Push a new stack frame.
2037 */
2038 {
2039 StackSaveArea* newSaveArea;
2040 u4* newFp;
2041
2042 ILOGV("> %s%s.%s %s",
2043 dvmIsNativeMethod(methodToCall) ? "(NATIVE) " : "",
2044 methodToCall->clazz->descriptor, methodToCall->name,
Mike Lockwood85745e12009-07-08 12:39:37 -04002045 methodToCall->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002046
2047 newFp = (u4*) SAVEAREA_FROM_FP(fp) - methodToCall->registersSize;
2048 newSaveArea = SAVEAREA_FROM_FP(newFp);
2049
2050 /* verify that we have enough space */
2051 if (true) {
2052 u1* bottom;
2053 bottom = (u1*) newSaveArea - methodToCall->outsSize * sizeof(u4);
2054 if (bottom < self->interpStackEnd) {
2055 /* stack overflow */
Andy McFadden6ed1a0f2009-09-10 15:34:19 -07002056 LOGV("Stack overflow on method call (start=%p end=%p newBot=%p(%d) size=%d '%s')\n",
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002057 self->interpStackStart, self->interpStackEnd, bottom,
Andy McFadden6ed1a0f2009-09-10 15:34:19 -07002058 (u1*) fp - bottom, self->interpStackSize,
2059 methodToCall->name);
2060 dvmHandleStackOverflow(self, methodToCall);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002061 assert(dvmCheckException(self));
2062 GOTO_exceptionThrown();
2063 }
2064 //LOGD("+++ fp=%p newFp=%p newSave=%p bottom=%p\n",
2065 // fp, newFp, newSaveArea, bottom);
2066 }
2067
2068#ifdef LOG_INSTR
2069 if (methodToCall->registersSize > methodToCall->insSize) {
2070 /*
2071 * This makes valgrind quiet when we print registers that
2072 * haven't been initialized. Turn it off when the debug
2073 * messages are disabled -- we want valgrind to report any
2074 * used-before-initialized issues.
2075 */
2076 memset(newFp, 0xcc,
2077 (methodToCall->registersSize - methodToCall->insSize) * 4);
2078 }
2079#endif
2080
2081#ifdef EASY_GDB
2082 newSaveArea->prevSave = SAVEAREA_FROM_FP(fp);
2083#endif
2084 newSaveArea->prevFrame = fp;
2085 newSaveArea->savedPc = pc;
Ben Chengba4fc8b2009-06-01 13:00:29 -07002086#if defined(WITH_JIT)
2087 newSaveArea->returnAddr = 0;
2088#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002089 newSaveArea->method = methodToCall;
2090
2091 if (!dvmIsNativeMethod(methodToCall)) {
2092 /*
2093 * "Call" interpreted code. Reposition the PC, update the
2094 * frame pointer and other local state, and continue.
2095 */
2096 curMethod = methodToCall;
2097 methodClassDex = curMethod->clazz->pDvmDex;
2098 pc = methodToCall->insns;
2099 fp = self->curFrame = newFp;
2100#ifdef EASY_GDB
2101 debugSaveArea = SAVEAREA_FROM_FP(newFp);
2102#endif
2103#if INTERP_TYPE == INTERP_DBG
2104 debugIsMethodEntry = true; // profiling, debugging
2105#endif
2106 ILOGD("> pc <-- %s.%s %s", curMethod->clazz->descriptor,
Mike Lockwood85745e12009-07-08 12:39:37 -04002107 curMethod->name, curMethod->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002108 DUMP_REGS(curMethod, fp, true); // show input args
2109 FINISH(0); // jump to method start
2110 } else {
2111 /* set this up for JNI locals, even if not a JNI native */
Andy McFaddend5ab7262009-08-25 07:19:34 -07002112#ifdef USE_INDIRECT_REF
2113 newSaveArea->xtra.localRefCookie = self->jniLocalRefTable.segmentState.all;
2114#else
2115 newSaveArea->xtra.localRefCookie = self->jniLocalRefTable.nextEntry;
2116#endif
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002117
2118 self->curFrame = newFp;
2119
2120 DUMP_REGS(methodToCall, newFp, true); // show input args
2121
2122#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER)
2123 if (gDvm.debuggerActive) {
2124 dvmDbgPostLocationEvent(methodToCall, -1,
2125 dvmGetThisPtr(curMethod, fp), DBG_METHOD_ENTRY);
2126 }
2127#endif
2128#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER)
2129 TRACE_METHOD_ENTER(self, methodToCall);
2130#endif
2131
2132 ILOGD("> native <-- %s.%s %s", methodToCall->clazz->descriptor,
Mike Lockwood85745e12009-07-08 12:39:37 -04002133 methodToCall->name, methodToCall->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002134
Bill Buzbeed7269912009-11-10 14:31:32 -08002135#if defined(WITH_JIT)
2136 /* Allow the Jit to end any pending trace building */
2137 CHECK_JIT();
2138#endif
2139
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002140 /*
2141 * Jump through native call bridge. Because we leave no
2142 * space for locals on native calls, "newFp" points directly
2143 * to the method arguments.
2144 */
2145 (*methodToCall->nativeFunc)(newFp, &retval, methodToCall, self);
2146
2147#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_DEBUGGER)
2148 if (gDvm.debuggerActive) {
2149 dvmDbgPostLocationEvent(methodToCall, -1,
2150 dvmGetThisPtr(curMethod, fp), DBG_METHOD_EXIT);
2151 }
2152#endif
2153#if (INTERP_TYPE == INTERP_DBG) && defined(WITH_PROFILER)
2154 TRACE_METHOD_EXIT(self, methodToCall);
2155#endif
2156
2157 /* pop frame off */
2158 dvmPopJniLocals(self, newSaveArea);
2159 self->curFrame = fp;
2160
2161 /*
2162 * If the native code threw an exception, or interpreted code
2163 * invoked by the native call threw one and nobody has cleared
2164 * it, jump to our local exception handling.
2165 */
2166 if (dvmCheckException(self)) {
2167 LOGV("Exception thrown by/below native code\n");
2168 GOTO_exceptionThrown();
2169 }
2170
2171 ILOGD("> retval=0x%llx (leaving native)", retval.j);
2172 ILOGD("> (return from native %s.%s to %s.%s %s)",
2173 methodToCall->clazz->descriptor, methodToCall->name,
2174 curMethod->clazz->descriptor, curMethod->name,
Mike Lockwood85745e12009-07-08 12:39:37 -04002175 curMethod->shorty);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002176
2177 //u2 invokeInstr = INST_INST(FETCH(0));
2178 if (true /*invokeInstr >= OP_INVOKE_VIRTUAL &&
2179 invokeInstr <= OP_INVOKE_INTERFACE*/)
2180 {
2181 FINISH(3);
2182 } else {
2183 //LOGE("Unknown invoke instr %02x at %d\n",
2184 // invokeInstr, (int) (pc - curMethod->insns));
2185 assert(false);
2186 }
2187 }
2188 }
2189 assert(false); // should not get here
2190GOTO_TARGET_END
2191
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08002192/* File: cstubs/enddefs.c */
2193
2194/* undefine "magic" name remapping */
2195#undef retval
2196#undef pc
2197#undef fp
2198#undef curMethod
2199#undef methodClassDex
2200#undef self
2201#undef debugTrackedRefStart
2202