changeset 21:371731d020ce

fix DISPATCH macro
author anatofuz
date Tue, 30 Oct 2018 20:14:34 +0900
parents ae67093f0e62
children ab67945df0f0
files src/core/cbc-interp.cbc src/core/oplables-cbc-codes.h
diffstat 2 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/cbc-interp.cbc	Tue Oct 30 18:40:24 2018 +0900
+++ b/src/core/cbc-interp.cbc	Tue Oct 30 20:14:34 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) goto CODES[op];
+#define DISPATCH(op) {goto (CODES[op])(i);}
 #define OP(name) OP_ ## name
 #define NEXT(i) CODES[NEXT_OP(i)](i)
 #else
@@ -446,7 +446,7 @@
     MVM_args_set_result_int(i->tc, GET_REG(i->cur_op, 0,i).i64,
         MVM_RETURN_CALLER_FRAME);
     if (MVM_frame_try_return(i->tc) == 0)
-        goto return_label(i);
+        goto cbc_return_label(i);
     goto NEXT(i);
 }
 __code cbc_return_n(INTERP i){
@@ -455,7 +455,7 @@
     MVM_args_set_result_num(i->tc, GET_REG(i->cur_op, 0,i).n64,
         MVM_RETURN_CALLER_FRAME);
     if (MVM_frame_try_return(i->tc) == 0)
-        goto return_label(i);
+        goto cbc_return_label(i);
     goto NEXT(i);
 }
 __code cbc_return_s(INTERP i){
@@ -464,7 +464,7 @@
     MVM_args_set_result_str(i->tc, GET_REG(i->cur_op, 0,i).s,
         MVM_RETURN_CALLER_FRAME);
     if (MVM_frame_try_return(i->tc) == 0)
-        goto return_label(i);
+        goto cbc_return_label(i);
     goto NEXT(i);
 }
 __code cbc_return_o(INTERP i){
@@ -479,7 +479,7 @@
     }
     MVM_args_set_result_obj(i->tc, value, MVM_RETURN_CALLER_FRAME);
     if (MVM_frame_try_return(i->tc) == 0)
-        goto return_label(i);
+        goto cbc_return_label(i);
     goto NEXT(i);
 }
 __code cbc_return(INTERP i){
@@ -487,7 +487,7 @@
         MVM_spesh_log_return_type(i->tc, NULL);
     MVM_args_assert_void_return_ok(i->tc, MVM_RETURN_CALLER_FRAME);
     if (MVM_frame_try_return(i->tc) == 0)
-        goto return_label(i);
+        goto cbc_return_label(i);
     goto NEXT(i);
 }
 __code cbc_eq_i(INTERP i){
@@ -6198,7 +6198,7 @@
     MVM_jit_enter_code(i->tc,i->cu, i->tc->cur_frame->spesh_cand->jitcode);
     if (!i->tc->cur_frame) {
         /* somehow unwound our top frame */
-        goto return_label(i);
+        goto cbc_return_label(i);
     }
     goto NEXT(i);
             }
@@ -6407,8 +6407,8 @@
 __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);
+    MVMExtOpRecord *record = &i->cu->body.extops[i->op - MVM_OP_EXT_BASE];
+    record->func(i->tc, i->cur_op);
     if (op_before == i->cur_op)
         i->cur_op += record->operand_bytes;
     goto NEXT(i);
@@ -6441,13 +6441,13 @@
 
     /* Enter runloop. */
     runloop: {
-        MVMuint16 op;
+        //MVMuint16 op;
 
 #if MVM_TRACING
         if (tracing_enabled) {
             char *trace_line;
-            trace_line = MVM_exception_backtrace_line(tc, tc->cur_frame, 0, cur_op);
-            fprintf(stderr, "Op %d%s\n", (int)*((MVMuint16 *)cur_op), trace_line);
+            trace_line = MVM_exception_backtrace_line(tc, tc->cur_frame, 0, i->cur_op);
+            fprintf(stderr, "Op %d%s\n", (int)*((MVMuint16 *)i->cur_op), trace_line);
             /* slow tracing is slow. Feel free to speed it. */
             MVM_free(trace_line);
         }
@@ -6455,8 +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(i)) {
-        }
+        DISPATCH(NEXT_OP(i))
     }
 
 }
--- a/src/core/oplables-cbc-codes.h	Tue Oct 30 18:40:24 2018 +0900
+++ b/src/core/oplables-cbc-codes.h	Tue Oct 30 20:14:34 2018 +0900
@@ -887,6 +887,12 @@
 __code cbc_breakpoint(INTERP);
 __code cbc_op_call_extop(INTERP);
 
+
+__code cbc_return_label(INTERP);
+
+
+
+
  __code (* CODES[])(INTERP) = {
    cbc_no_op,
    cbc_const_i8,
@@ -1756,3 +1762,6 @@
    cbc_breakpoint,
    cbc_op_call_extop,
 };
+
+
+