changeset 20:ae67093f0e62

fix code segment
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 30 Oct 2018 18:40:24 +0900
parents 073d6fd557dc
children 371731d020ce
files src/core/cbc-interp.cbc src/core/oplables-cbc-codes.h
diffstat 2 files changed, 16 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/cbc-interp.cbc	Thu Oct 25 14:40:22 2018 +0900
+++ b/src/core/cbc-interp.cbc	Tue Oct 30 18:40:24 2018 +0900
@@ -46,7 +46,7 @@
 #define NEXT_OP(i) (i->op = *(MVMuint16 *)(i->cur_op), i->cur_op += 2, i->op)
 
 #if MVM_CGOTO
-#define DISPATCH(op)
+#define DISPATCH(op) goto CODES[op];
 #define OP(name) OP_ ## name
 #define NEXT(i) CODES[NEXT_OP(i)](i)
 #else
@@ -6394,7 +6394,7 @@
     goto NEXT(i);
             }
 
-__code return_label (INTERP i){
+__code cbc_return_label (INTERP i){
     /* Need to clear these pointer pointers since they may be rooted
      * by some GC procedure. */
     i->tc->interp_cur_op         = NULL;
@@ -6403,6 +6403,17 @@
     i->tc->interp_cu             = NULL;
     MVM_barrier();
 }
+
+__code  cbc_op_call_extop (INTERP i) {
+    /* Bounds checking? Never heard of that. */
+    MVMuint8 *op_before = i->cur_op;
+    MVMExtOpRecord *record = &i->cu->body.extops[op - MVM_OP_EXT_BASE];
+    record->func(tc, i->cur_op);
+    if (op_before == i->cur_op)
+        i->cur_op += record->operand_bytes;
+    goto NEXT(i);
+}
+
 /* This is the interpreter run loop. We have one of these per thread. */
 void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContext *, void *), void *invoke_data) {
 #if MVM_CGOTO
@@ -6444,33 +6455,7 @@
 
         /* The ops should be in the same order here as in the oplist file, so
          * the compiler can can optimise the switch properly */
-        DISPATCH(NEXT_OP) {
-#if MVM_CGOTO
-            OP_CALL_EXTOP: {
-                /* Bounds checking? Never heard of that. */
-                MVMuint8 *op_before = i->cur_op;
-                MVMExtOpRecord *record = &i->cu->body.extops[op - MVM_OP_EXT_BASE];
-                record->func(tc, i->cur_op);
-                if (op_before == i->cur_op)
-                    i->cur_op += record->operand_bytes;
-                goto NEXT(i);
-            }
-#else
-            default: {
-                if (op >= MVM_OP_EXT_BASE
-                        && (op - MVM_OP_EXT_BASE) <i->cu->body.num_extops) {
-                    MVMuint8 *op_before = cur_op;
-                    MVMExtOpRecord *record =
-                            &cu->body.extops[op - MVM_OP_EXT_BASE];
-                    record->func(tc, cur_op);
-                    if (op_before == cur_op)
-                        cur_op += record->operand_bytes;
-                    goto NEXT(i);
-                }
-
-                MVM_panic(MVM_exitcode_invalidopcode, "Invalid opcode executed (corrupt bytecode stream?) opcode %u", op);
-            }
-#endif
+        DISPATCH(NEXT_OP(i)) {
         }
     }
 
--- a/src/core/oplables-cbc-codes.h	Thu Oct 25 14:40:22 2018 +0900
+++ b/src/core/oplables-cbc-codes.h	Tue Oct 30 18:40:24 2018 +0900
@@ -885,6 +885,7 @@
 __code cbc_ctw_check(INTERP);
 __code cbc_coverage_log(INTERP);
 __code cbc_breakpoint(INTERP);
+__code cbc_op_call_extop(INTERP);
 
  __code (* CODES[])(INTERP) = {
    cbc_no_op,
@@ -1753,4 +1754,5 @@
    cbc_ctw_check,
    cbc_coverage_log,
    cbc_breakpoint,
+   cbc_op_call_extop,
 };