| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | /* |
| 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) |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 14 | #define JIT_STUB_HACK(x) |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 15 | |
| 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 Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 24 | # define H(_op) &&op_##_op |
| 25 | # define HANDLE_OPCODE(_op) op_##_op: |
| 26 | # define FINISH(_offset) { \ |
| 27 | ADJUST_PC(_offset); \ |
| 28 | inst = FETCH(0); \ |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 29 | if (self->interpBreak.ctl.subMode) { \ |
| 30 | dvmCheckBefore(pc, fp, self); \ |
| 31 | } \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 32 | goto *handlerTable[INST_INST(inst)]; \ |
| 33 | } |
| Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 34 | # define FINISH_BKPT(_opcode) { \ |
| 35 | goto *handlerTable[_opcode]; \ |
| 36 | } |
| jeffhao | 71eee1f | 2011-01-04 14:18:54 -0800 | [diff] [blame] | 37 | # define DISPATCH_EXTENDED(_opcode) { \ |
| 38 | goto *handlerTable[0x100 + _opcode]; \ |
| 39 | } |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 40 | |
| 41 | #define OP_END |
| 42 | |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 43 | /* |
| 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 | |
| jeffhao | 71eee1f | 2011-01-04 14:18:54 -0800 | [diff] [blame] | 52 | #define GOTO_invoke(_target, _methodCallRange, _jumboFormat) \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 53 | do { \ |
| 54 | methodCallRange = _methodCallRange; \ |
| jeffhao | 71eee1f | 2011-01-04 14:18:54 -0800 | [diff] [blame] | 55 | jumboFormat = _jumboFormat; \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 56 | 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 Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 63 | |
| 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 | */ |
| buzbee | 9a3147c | 2011-03-02 15:43:48 -0800 | [diff] [blame] | 70 | #define PERIODIC_CHECKS(_pcadj) { \ |
| The Android Open Source Project | 9940988 | 2009-03-18 22:20:24 -0700 | [diff] [blame] | 71 | if (dvmCheckSuspendQuick(self)) { \ |
| 72 | EXPORT_PC(); /* need for precise GC */ \ |
| 73 | dvmCheckSuspendPending(self); \ |
| 74 | } \ |
| The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 75 | } |