comparison src/core/interp.c @ 46:e3cd4e21b560

add --cbc option
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 08 Dec 2018 22:57:55 +0900
parents 2cf249471370
children 585f22dcc6aa
comparison
equal deleted inserted replaced
45:6e8bd93cbb96 46:e3cd4e21b560
40 #define GET_UI16(pc, idx) *((MVMuint16 *)(pc + idx)) 40 #define GET_UI16(pc, idx) *((MVMuint16 *)(pc + idx))
41 #define GET_I32(pc, idx) *((MVMint32 *)(pc + idx)) 41 #define GET_I32(pc, idx) *((MVMint32 *)(pc + idx))
42 #define GET_UI32(pc, idx) *((MVMuint32 *)(pc + idx)) 42 #define GET_UI32(pc, idx) *((MVMuint32 *)(pc + idx))
43 #define GET_N32(pc, idx) *((MVMnum32 *)(pc + idx)) 43 #define GET_N32(pc, idx) *((MVMnum32 *)(pc + idx))
44 44
45 #define NEXT_OP (op = *(MVMuint16 *)(cur_op), cur_op += 2, op) 45 #define ddd(x) (op_count++>343724?printf("count=%d op=%d\n", op_count, *(MVMuint16 *)cur_op):0)
46
47 #define NEXT_OP (ddd(0), op = *(MVMuint16 *)(cur_op), cur_op += 2, op)
46 48
47 #if MVM_CGOTO 49 #if MVM_CGOTO
48 #define DISPATCH(op) 50 #define DISPATCH(op)
49 #define OP(name) OP_ ## name 51 #define OP(name) OP_ ## name
50 #define NEXT *LABELS[NEXT_OP] 52 #define NEXT *LABELS[NEXT_OP]
53 #define OP(name) case MVM_OP_ ## name 55 #define OP(name) case MVM_OP_ ## name
54 #define NEXT runloop 56 #define NEXT runloop
55 #endif 57 #endif
56 58
57 static int tracing_enabled = 0; 59 static int tracing_enabled = 0;
60
61 int use_cbc = 0;
62 extern void MVM_interp_run_cbc(MVMThreadContext *tc);
63 typedef struct interp {
64 MVMuint16 op;
65 MVMuint8 *cur_op;
66 MVMuint8 *bytecode_start;
67 MVMRegister *reg_base;
68 MVMCompUnit *cu;
69 MVMCallsite *cur_callsite;
70 MVMThreadContext *tc;
71 } INTER,*INTERP;
72
58 73
59 /* This is the interpreter run loop. We have one of these per thread. */ 74 /* This is the interpreter run loop. We have one of these per thread. */
60 void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContext *, void *), void *invoke_data) { 75 void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContext *, void *), void *invoke_data) {
61 #if MVM_CGOTO 76 #if MVM_CGOTO
62 #include "oplabels.h" 77 #include "oplabels.h"
93 initial_invoke(tc, invoke_data); 108 initial_invoke(tc, invoke_data);
94 109
95 /* Set jump point, for if we arrive back in the interpreter from an 110 /* Set jump point, for if we arrive back in the interpreter from an
96 * exception thrown from C code. */ 111 * exception thrown from C code. */
97 setjmp(tc->interp_jump); 112 setjmp(tc->interp_jump);
113
114 if (use_cbc) {
115 MVM_interp_run_cbc(tc);
116 return;
117 }
98 118
99 /* Enter runloop. */ 119 /* Enter runloop. */
100 runloop: { 120 runloop: {
101 MVMuint16 op; 121 MVMuint16 op;
102 122