blob: e0523c858822827686411d1bee3c54008fafcb0f [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
2 * In the C mterp stubs, "goto" is a function call followed immediately
3 * by a return.
4 */
5
6#define GOTO_TARGET_DECL(_target, ...)
7
8#define GOTO_TARGET(_target, ...) _target:
9
10#define GOTO_TARGET_END
11
12/* ugh */
13#define STUB_HACK(x)
buzbee9a3147c2011-03-02 15:43:48 -080014#define JIT_STUB_HACK(x)
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080015
16/*
17 * Instruction framing. For a switch-oriented implementation this is
18 * case/break, for a threaded implementation it's a goto label and an
19 * instruction fetch/computed goto.
20 *
21 * Assumes the existence of "const u2* pc" and (for threaded operation)
22 * "u2 inst".
23 */
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080024# define H(_op) &&op_##_op
25# define HANDLE_OPCODE(_op) op_##_op:
26# define FINISH(_offset) { \
27 ADJUST_PC(_offset); \
28 inst = FETCH(0); \
buzbee9a3147c2011-03-02 15:43:48 -080029 if (self->interpBreak.ctl.subMode) { \
30 dvmCheckBefore(pc, fp, self); \
31 } \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080032 goto *handlerTable[INST_INST(inst)]; \
33 }
Andy McFadden96516932009-10-28 17:39:02 -070034# define FINISH_BKPT(_opcode) { \
35 goto *handlerTable[_opcode]; \
36 }
jeffhao71eee1f2011-01-04 14:18:54 -080037# define DISPATCH_EXTENDED(_opcode) { \
38 goto *handlerTable[0x100 + _opcode]; \
39 }
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080040
41#define OP_END
42
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080043/*
44 * The "goto" targets just turn into goto statements. The "arguments" are
45 * passed through local variables.
46 */
47
48#define GOTO_exceptionThrown() goto exceptionThrown;
49
50#define GOTO_returnFromMethod() goto returnFromMethod;
51
jeffhao71eee1f2011-01-04 14:18:54 -080052#define GOTO_invoke(_target, _methodCallRange, _jumboFormat) \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080053 do { \
54 methodCallRange = _methodCallRange; \
jeffhao71eee1f2011-01-04 14:18:54 -080055 jumboFormat = _jumboFormat; \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080056 goto _target; \
57 } while(false)
58
59/* for this, the "args" are already in the locals */
60#define GOTO_invokeMethod(_methodCallRange, _methodToCall, _vsrc1, _vdst) goto invokeMethod;
61
62#define GOTO_bail() goto bail;
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080063
64/*
65 * Periodically check for thread suspension.
66 *
67 * While we're at it, see if a debugger has attached or the profiler has
68 * started. If so, switch to a different "goto" table.
69 */
buzbee9a3147c2011-03-02 15:43:48 -080070#define PERIODIC_CHECKS(_pcadj) { \
The Android Open Source Project99409882009-03-18 22:20:24 -070071 if (dvmCheckSuspendQuick(self)) { \
72 EXPORT_PC(); /* need for precise GC */ \
73 dvmCheckSuspendPending(self); \
74 } \
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080075 }