changeset 22:ab67945df0f0

fix goto codesegment
author anatofuz
date Thu, 01 Nov 2018 20:30:24 +0900
parents 371731d020ce
children 005049773e61
files src/core/cbc-interp.cbc
diffstat 1 files changed, 62 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/cbc-interp.cbc	Tue Oct 30 20:14:34 2018 +0900
+++ b/src/core/cbc-interp.cbc	Thu Nov 01 20:30:24 2018 +0900
@@ -20,9 +20,9 @@
  * the OP needs (return register + argument registers. The pc will point to the first place after
  * the current op, i.e. the first 16 bit register number. We add the requested number to that and
  * use the result as index into the reg_base array which stores the frame's locals. */
-#define GET_REG(pc, idx,i)    i->reg_base[check_reg(tc, i->reg_base, *((MVMuint16 *)(pc + idx)))]
+#define GET_REG(pc, idx,i)    (i->reg_base[check_reg(i->tc, i->reg_base, *((MVMuint16 *)(pc + idx)))])
 #else
-#define GET_REG(pc, idx,i)    i->reg_base[*((MVMuint16 *)(pc + idx))]
+#define GET_REG(pc, idx,i)    (i->reg_base[*((MVMuint16 *)(pc + idx))])
 #endif
 #if MVM_GC_DEBUG == 2
 MVM_STATIC_INLINE MVMuint16 check_lex(MVMThreadContext *tc, MVMFrame *f, MVMuint16 idx) {
@@ -33,9 +33,9 @@
         MVM_ASSERT_NOT_FROMSPACE(tc, f->env[idx].o);
     return idx;
 }
-#define GET_LEX(pc, idx, f) f->env[check_lex(tc, f, *((MVMuint16 *)(pc + idx)))]
+#define GET_LEX(pc, idx, f,i) f->env[check_lex(i->tc, f, *((MVMuint16 *)(pc + idx)))]
 #else
-#define GET_LEX(pc, idx, f) f->env[*((MVMuint16 *)(pc + idx))]
+#define GET_LEX(pc, idx, f,i) f->env[*((MVMuint16 *)(pc + idx))]
 #endif
 #define GET_I16(pc, idx)    *((MVMint16 *)(pc + idx))
 #define GET_UI16(pc, idx)   *((MVMuint16 *)(pc + idx))
@@ -68,6 +68,7 @@
 }
 __code cbc_const_i32(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "const_iX NYI");
+   goto cbc_const_i64(i);
 }
 __code cbc_const_i64(INTERP i){
     GET_REG(i->cur_op, 0,i).i64 = MVM_BC_get_I64(i->cur_op, 2);
@@ -76,6 +77,7 @@
 }
 __code cbc_const_n32(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "const_n32 NYI");
+   goto cbc_const_n64(i);
 }
 __code cbc_const_n64(INTERP i){
     GET_REG(i->cur_op, 0,i).n64 = MVM_BC_get_N64(i->cur_op, 2);
@@ -283,7 +285,7 @@
         ? f->spesh_cand->lexical_types
         : f->static_info->body.lexical_types;
     if (lexical_types[idx] == MVM_reg_obj) {
-        MVMRegister found = GET_LEX(i->cur_op, 2, f);
+        MVMRegister found = GET_LEX(i->cur_op, 2, f,i);
         MVMObject *value = found.o == NULL
             ? MVM_frame_vivify_lexical(i->tc, f, idx)
             : found.o;
@@ -292,7 +294,7 @@
             MVM_spesh_log_type(i->tc, value);
     }
     else {
-        GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f);
+        GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f,i);
     }
     i->cur_op += 6;
     goto NEXT(i);
@@ -313,11 +315,11 @@
 #if MVM_GC_DEGUG
         MVM_ASSERT_NOT_FROMSPACE(i->tc, GET_REG(i->cur_op, 4,i).o);
 #endif
-        MVM_ASSIGN_REF(i->tc, &(f->header), GET_LEX(i->cur_op, 0, f).o,
+        MVM_ASSIGN_REF(i->tc, &(f->header), GET_LEX(i->cur_op, 0, f,i).o,
             GET_REG(i->cur_op, 4,i).o);
     }
     else {
-        GET_LEX(i->cur_op, 0, f) = GET_REG(i->cur_op, 4,i);
+        GET_LEX(i->cur_op, 0, f,i) = GET_REG(i->cur_op, 4,i);
     }
     i->cur_op += 6;
     goto NEXT(i);
@@ -387,6 +389,7 @@
 }
 __code cbc_bindlex_ng(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "get/bindlex_ng NYI");
+    goto cbc_getdynlex(i);
 }
 __code cbc_getdynlex(INTERP i){
     GET_REG(i->cur_op, 0,i).o = MVM_frame_getdynlex(i->tc, GET_REG(i->cur_op, 2,i).s,
@@ -1120,7 +1123,7 @@
             }
 }
 __code cbc_param_op_o(INTERP i){
-            {
+           
     MVMuint16 arg_idx = GET_UI16(i->cur_op, 2);
     MVMArgInfo param = MVM_args_get_optional_pos_obj(i->tc, &i->tc->cur_frame->params, arg_idx);
     if (param.exists) {
@@ -1133,7 +1136,7 @@
         i->cur_op += 8;
     }
     goto NEXT(i);
-            }
+            
 }
 __code cbc_param_rn_i(INTERP i){
     GET_REG(i->cur_op, 0,i).i64 = MVM_args_get_named_int(i->tc, &i->tc->cur_frame->params,
@@ -1173,7 +1176,7 @@
         i->cur_op += 10;
     }
     goto NEXT(i);
-            }
+}
 __code cbc_param_on_n(INTERP i){
     MVMArgInfo param = MVM_args_get_named_num(i->tc, &i->tc->cur_frame->params,
         MVM_cu_string(i->tc,i->cu, GET_UI32(i->cur_op, 2)), MVM_ARG_OPTIONAL);
@@ -1185,7 +1188,7 @@
         i->cur_op += 10;
     }
     goto NEXT(i);
-            }
+}
 __code cbc_param_on_s(INTERP i){
     MVMArgInfo param = MVM_args_get_named_str(i->tc, &i->tc->cur_frame->params,
         MVM_cu_string(i->tc,i->cu, GET_UI32(i->cur_op, 2)), MVM_ARG_OPTIONAL);
@@ -1197,7 +1200,7 @@
         i->cur_op += 10;
     }
     goto NEXT(i);
-            }
+}
 __code cbc_param_on_o(INTERP i){
     MVMArgInfo param = MVM_args_get_named_obj(i->tc, &i->tc->cur_frame->params,
         MVM_cu_string(i->tc,i->cu, GET_UI32(i->cur_op, 2)), MVM_ARG_OPTIONAL);
@@ -1211,7 +1214,7 @@
         i->cur_op += 10;
     }
     goto NEXT(i);
-            }
+}
 __code cbc_param_sp(INTERP i){
     GET_REG(i->cur_op, 0,i).o = MVM_args_slurpy_positional(i->tc, &i->tc->cur_frame->params, GET_UI16(i->cur_op, 2));
     i->cur_op += 4;
@@ -1238,14 +1241,15 @@
 
     i->cur_op += 4;
     goto NEXT(i);
-            }
+}
 __code cbc_capturelex(INTERP i){
     MVM_frame_capturelex(i->tc, GET_REG(i->cur_op, 0,i).o);
     i->cur_op += 2;
     goto NEXT(i);
 }
 __code cbc_takeclosure(INTERP i){
-    GET_REG(i->cur_op, 0,i).o = MVM_frame_takeclosure(i->tc, GET_REG(i->cur_op, 2,i).o);
+    (i->reg_base[*((MVMuint16 *)(i->cur_op + 0))]).o = MVM_frame_takeclosure(i->tc, GET_REG(i->cur_op, 2,i).o);
+    //GET_REG(i->cur_op, 0,i).o = MVM_frame_takeclosure(i->tc, GET_REG(i->cur_op, 2,i).o);
     i->cur_op += 4;
     goto NEXT(i);
 }
@@ -1433,7 +1437,7 @@
     }
     i->cur_op += 6;
     goto NEXT(i);
-            }
+}
 __code cbc_captureposarg_s(INTERP i){
     MVMObject *obj = GET_REG(i->cur_op, 2,i).o;
     if (IS_CONCRETE(obj) && REPR(obj)->ID == MVM_REPR_ID_MVMCallCapture) {
@@ -1446,7 +1450,7 @@
     }
     i->cur_op += 6;
     goto NEXT(i);
-            }
+}
 __code cbc_captureposprimspec(INTERP i){
     MVMObject *obj = GET_REG(i->cur_op, 2,i).o;
     MVMint64   j   = GET_REG(i->cur_op, 4,i).i64;
@@ -1481,7 +1485,7 @@
     }
     i->cur_op += 6;
     goto NEXT(i);
-            }
+}
 __code cbc_captureexistsnamed(INTERP i){
     MVMObject *obj = GET_REG(i->cur_op, 2,i).o;
     if (IS_CONCRETE(obj) && REPR(obj)->ID == MVM_REPR_ID_MVMCallCapture) {
@@ -1494,7 +1498,7 @@
     }
     i->cur_op += 6;
     goto NEXT(i);
-            }
+}
 __code cbc_capturehasnameds(INTERP i){
     MVMObject *obj = GET_REG(i->cur_op, 2,i).o;
     if (IS_CONCRETE(obj) && REPR(obj)->ID == MVM_REPR_ID_MVMCallCapture) {
@@ -1508,7 +1512,7 @@
     }
     i->cur_op += 4;
     goto NEXT(i);
-            }
+}
 __code cbc_invokewithcapture(INTERP i){
     static MVMObject *cobj;
     cobj = GET_REG(i->cur_op, 4,i).o;
@@ -1532,12 +1536,12 @@
             MVM_ASSIGN_REF(i->tc, &(i->tc->cur_frame->header),
                 e->invoked_call_capture, cobj);
         }
-        goto NEXT(i);
     }
     else {
         MVM_exception_throw_adhoc(i->tc, "invokewithcapture needs a MVMCallCapture");
     }
-            }
+	goto NEXT(i);
+}
 __code cbc_multicacheadd(INTERP i){
     GET_REG(i->cur_op, 0,i).o = MVM_multi_cache_add(i->tc, GET_REG(i->cur_op, 2,i).o,
         GET_REG(i->cur_op, 4,i).o, GET_REG(i->cur_op, 6,i).o);
@@ -3881,6 +3885,7 @@
 }
 __code cbc_encodefromcodes(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "NYI");
+    goto cbc_print(i);
 }
 __code cbc_print(INTERP i){
     MVM_string_print(i->tc, GET_REG(i->cur_op, 0,i).s);
@@ -3970,7 +3975,8 @@
     MVMint64 exit_code = GET_REG(i->cur_op, 0,i).i64;
     MVM_io_flush_standard_handles(i->tc);
     exit(exit_code);
-            }
+    goto NEXT(i);
+}
 __code cbc_cwd(INTERP i){
     GET_REG(i->cur_op, 0,i).s = MVM_dir_cwd(i->tc);
     i->cur_op += 2;
@@ -3998,7 +4004,7 @@
     MVM_dll_free(i->tc, name);
     i->cur_op += 2;
     goto NEXT(i);
-            }
+}
 __code cbc_findsym(INTERP i){
     MVMString *lib = GET_REG(i->cur_op, 2,i).s;
     MVMString *sym = GET_REG(i->cur_op, 4,i).s;
@@ -4009,12 +4015,12 @@
     GET_REG(i->cur_op, 0,i).o = obj;
     i->cur_op += 6;
     goto NEXT(i);
-            }
+}
 __code cbc_dropsym(INTERP i){
     MVM_dll_drop_symbol(i->tc, GET_REG(i->cur_op, 0,i).o);
     i->cur_op += 2;
     goto NEXT(i);
-            }
+}
 __code cbc_loadext(INTERP i){
     MVMString *lib = GET_REG(i->cur_op, 0,i).s;
     MVMString *ext = GET_REG(i->cur_op, 2,i).s;
@@ -4939,6 +4945,7 @@
 }
 __code cbc_encodenorm(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "NYI");
+	goto cbc_normalizecodes(i);
 }
 __code cbc_normalizecodes(INTERP i){
     MVM_unicode_normalize_codepoints(i->tc, GET_REG(i->cur_op, 0,i).o, GET_REG(i->cur_op, 4,i).o,
@@ -5800,7 +5807,7 @@
         f = f->outer;
         outers--;
     }
-    found = GET_LEX(i->cur_op, 2, f);
+    found = GET_LEX(i->cur_op, 2, f,i);
     GET_REG(i->cur_op, 0,i).o = found.o == NULL
         ? MVM_frame_vivify_lexical(i->tc, f, idx)
         : found.o;
@@ -5817,7 +5824,7 @@
         f = f->outer;
         outers--;
     }
-    GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f);
+    GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f,i);
     i->cur_op += 6;
     goto NEXT(i);
             }
@@ -6154,7 +6161,7 @@
         f = f->outer;
         outers--;
     }
-    found = GET_LEX(i->cur_op, 2, f);
+    found = GET_LEX(i->cur_op, 2, f,i);
     GET_REG(i->cur_op, 0,i).o = found.o == NULL
         ? MVM_frame_vivify_lexical(i->tc, f, idx)
         : found.o;
@@ -6171,7 +6178,7 @@
         f = f->outer;
         outers--;
     }
-    GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f);
+    GET_REG(i->cur_op, 0,i) = GET_LEX(i->cur_op, 2, f,i);
     i->cur_op += 8;
     goto NEXT(i);
             }
@@ -6309,66 +6316,87 @@
 }
 __code cbc_DEPRECATED_12(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The getregref_* ops were removed in MoarVM 2017.01.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_13(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The continuationclone op was removed in MoarVM 2017.01.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_14(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The asyncwritestr op was removed in MoarVM 2017.05.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_15(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The asyncwritestrto op was removed in MoarVM 2017.05.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_16(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The asyncreadchars op was removed in MoarVM 2017.05.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_17(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The setencoding op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_18(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The write_fhs op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_19(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The say_fhs op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_21(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The readlinechomp_fh op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_22(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The readall_fh op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_23(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The read_fhs op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_24(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The setinputlinesep op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_25(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The setinputlineseps op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_27(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The slurp op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_28(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The spew op was removed in MoarVM 2017.06.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_29(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The spawn op was removed in MoarVM 2017.07.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_30(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The shell op was removed in MoarVM 2017.07.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_31(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The syncpipe op was removed in MoarVM 2017.07.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_32(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The close_fhi op was removed in MoarVM 2017.07.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_33(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The newlexotic op was removed in MoarVM 2017.08.");
+    goto NEXT(i);
 }
 __code cbc_DEPRECATED_34(INTERP i){
     MVM_exception_throw_adhoc(i->tc, "The lexoticresult op was removed in MoarVM 2017.08.");
+    goto NEXT(i);
 }
 __code cbc_coverage_log(INTERP i){
     MVMString *filename = MVM_cu_string(i->tc,i->cu, GET_UI32(i->cur_op, 0));
@@ -6402,6 +6430,7 @@
     i->tc->interp_reg_base       = NULL;
     i->tc->interp_cu             = NULL;
     MVM_barrier();
+    goto NEXT(i);
 }
 
 __code  cbc_op_call_extop (INTERP i) {
@@ -6455,7 +6484,8 @@
 
         /* 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))
+	goto (CODES[(i->op = *(MVMuint16 *)(i->cur_op), i->cur_op += 2, i->op)])(i);
     }
 
 }