This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
GvFILE() cannot be a pointer to the memory owned by the COP, because
[perl5.git] / ext / ByteLoader / byterun.c
index 595fd4e..3738ad5 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- buffer-read-only: t -*-
+ *
  *      Copyright (c) 1996-1999 Malcolm Beattie
  *
  *      You may distribute under the terms of either the GNU General Public
 #define NO_XSLOCKS
 #include "XSUB.h"
 
-#ifdef PERL_OBJECT
-#undef CALL_FPTR
-#define CALL_FPTR(fptr) (pPerl->*fptr)
-#undef PL_ppaddr
-#define PL_ppaddr (*get_ppaddr())
-#endif
-
 #include "byterun.h"
 #include "bytecode.h"
 
 
-static int optype_size[] = {
+static const int optype_size[] = {
     sizeof(OP),
     sizeof(UNOP),
     sizeof(BINOP),
@@ -40,38 +34,38 @@ static int optype_size[] = {
     sizeof(COP)
 };
 
-static SV *specialsv_list[4];
-
-static int bytecode_iv_overflows = 0;
-static SV *bytecode_sv;
-static XPV bytecode_pv;
-static void **bytecode_obj_list;
-static I32 bytecode_obj_list_fill = -1;
-
 void *
-bset_obj_store(pTHXo_ void *obj, I32 ix)
+bset_obj_store(pTHX_ struct byteloader_state *bstate, void *obj, I32 ix)
 {
-    if (ix > bytecode_obj_list_fill) {
-       if (bytecode_obj_list_fill == -1)
-           New(666, bytecode_obj_list, ix + 1, void*);
-       else
-           Renew(bytecode_obj_list, ix + 1, void*);
-       bytecode_obj_list_fill = ix;
+    if (ix > bstate->bs_obj_list_fill) {
+       Renew(bstate->bs_obj_list, ix + 32, void*);
+       bstate->bs_obj_list_fill = ix + 31;
     }
-    bytecode_obj_list[ix] = obj;
+    bstate->bs_obj_list[ix] = obj;
     return obj;
 }
 
-void
-byterun(pTHXo_ struct bytestream bs)
+int
+byterun(pTHX_ register struct byteloader_state *bstate)
 {
-    dTHR;
-    int insn;
+    dVAR;
+    register int insn;
+    U32 ix;
+    SV *specialsv_list[7];
+
+    BYTECODE_HEADER_CHECK;     /* croak if incorrect platform */
+    Newx(bstate->bs_obj_list, 32, void*); /* set op objlist */
+    bstate->bs_obj_list_fill = 31;
+    bstate->bs_obj_list[0] = NULL; /* first is always Null */
+    bstate->bs_ix = 1;
 
     specialsv_list[0] = Nullsv;
     specialsv_list[1] = &PL_sv_undef;
     specialsv_list[2] = &PL_sv_yes;
     specialsv_list[3] = &PL_sv_no;
+    specialsv_list[4] = (SV*)pWARN_ALL;
+    specialsv_list[5] = (SV*)pWARN_NONE;
+    specialsv_list[6] = (SV*)pWARN_STD;
 
     while ((insn = BGET_FGETC()) != EOF) {
        switch (insn) {
@@ -95,7 +89,7 @@ byterun(pTHXo_ struct bytestream bs)
            {
                svindex arg;
                BGET_svindex(arg);
-               bytecode_sv = arg;
+               bstate->bs_sv = arg;
                break;
            }
          case INSN_LDOP:               /* 2 */
@@ -109,7 +103,7 @@ byterun(pTHXo_ struct bytestream bs)
            {
                U32 arg;
                BGET_U32(arg);
-               BSET_OBJ_STORE(bytecode_sv, arg);
+               BSET_OBJ_STORE(bstate->bs_sv, arg);
                break;
            }
          case INSN_STOP:               /* 4 */
@@ -119,781 +113,1016 @@ byterun(pTHXo_ struct bytestream bs)
                BSET_OBJ_STORE(PL_op, arg);
                break;
            }
-         case INSN_LDSPECSV:           /* 5 */
+         case INSN_STPV:               /* 5 */
+           {
+               U32 arg;
+               BGET_U32(arg);
+               BSET_stpv(bstate->bs_pv.pvx, arg);
+               break;
+           }
+         case INSN_LDSPECSV:           /* 6 */
+           {
+               U8 arg;
+               BGET_U8(arg);
+               BSET_ldspecsv(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_LDSPECSVX:          /* 7 */
            {
                U8 arg;
                BGET_U8(arg);
-               BSET_ldspecsv(bytecode_sv, arg);
+               BSET_ldspecsvx(bstate->bs_sv, arg);
                break;
            }
-         case INSN_NEWSV:              /* 6 */
+         case INSN_NEWSV:              /* 8 */
            {
                U8 arg;
                BGET_U8(arg);
-               BSET_newsv(bytecode_sv, arg);
+               BSET_newsv(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_NEWSVX:             /* 9 */
+           {
+               U32 arg;
+               BGET_U32(arg);
+               BSET_newsvx(bstate->bs_sv, arg);
                break;
            }
-         case INSN_NEWOP:              /* 7 */
+         case INSN_NEWOP:              /* 11 */
            {
                U8 arg;
                BGET_U8(arg);
                BSET_newop(PL_op, arg);
                break;
            }
-         case INSN_NEWOPN:             /* 8 */
+         case INSN_NEWOPX:             /* 12 */
+           {
+               U16 arg;
+               BGET_U16(arg);
+               BSET_newopx(PL_op, arg);
+               break;
+           }
+         case INSN_NEWOPN:             /* 13 */
            {
                U8 arg;
                BGET_U8(arg);
                BSET_newopn(PL_op, arg);
                break;
            }
-         case INSN_NEWPV:              /* 9 */
+         case INSN_NEWPV:              /* 14 */
            {
                PV arg;
                BGET_PV(arg);
                break;
            }
-         case INSN_PV_CUR:             /* 11 */
+         case INSN_PV_CUR:             /* 15 */
            {
                STRLEN arg;
-               BGET_U32(arg);
-               bytecode_pv.xpv_cur = arg;
+               BGET_PADOFFSET(arg);
+               bstate->bs_pv.xpv.xpv_cur = arg;
                break;
            }
-         case INSN_PV_FREE:            /* 12 */
+         case INSN_PV_FREE:            /* 16 */
            {
-               BSET_pv_free(bytecode_pv);
+               BSET_pv_free(bstate->bs_pv.pvx);
                break;
            }
-         case INSN_SV_UPGRADE:         /* 13 */
+         case INSN_SV_UPGRADE:         /* 17 */
            {
-               char arg;
+               U8 arg;
                BGET_U8(arg);
-               BSET_sv_upgrade(bytecode_sv, arg);
+               BSET_sv_upgrade(bstate->bs_sv, arg);
                break;
            }
-         case INSN_SV_REFCNT:          /* 14 */
+         case INSN_SV_REFCNT:          /* 18 */
            {
                U32 arg;
                BGET_U32(arg);
-               SvREFCNT(bytecode_sv) = arg;
+               SvREFCNT(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_SV_REFCNT_ADD:              /* 15 */
+         case INSN_SV_REFCNT_ADD:              /* 19 */
            {
                I32 arg;
                BGET_I32(arg);
-               BSET_sv_refcnt_add(SvREFCNT(bytecode_sv), arg);
+               BSET_sv_refcnt_add(SvREFCNT(bstate->bs_sv), arg);
                break;
            }
-         case INSN_SV_FLAGS:           /* 16 */
+         case INSN_SV_FLAGS:           /* 20 */
            {
                U32 arg;
                BGET_U32(arg);
-               SvFLAGS(bytecode_sv) = arg;
+               SvFLAGS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XRV:                /* 17 */
+         case INSN_XRV:                /* 21 */
            {
                svindex arg;
                BGET_svindex(arg);
-               SvRV(bytecode_sv) = arg;
+               BSET_xrv(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XPV:                /* 18 */
+         case INSN_XPV:                /* 22 */
            {
-               BSET_xpv(bytecode_sv);
+               BSET_xpv(bstate->bs_sv);
                break;
            }
-         case INSN_XIV32:              /* 19 */
+         case INSN_XPV_CUR:            /* 23 */
            {
-               I32 arg;
-               BGET_I32(arg);
-               SvIVX(bytecode_sv) = arg;
+               STRLEN arg;
+               BGET_PADOFFSET(arg);
+               BSET_xpv_cur(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_XPV_LEN:            /* 24 */
+           {
+               STRLEN arg;
+               BGET_PADOFFSET(arg);
+               BSET_xpv_len(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XIV64:              /* 20 */
+         case INSN_XIV:                /* 25 */
            {
-               IV64 arg;
-               BGET_IV64(arg);
-               SvIVX(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               BSET_xiv(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XNV:                /* 21 */
+         case INSN_XNV:                /* 26 */
            {
                NV arg;
                BGET_NV(arg);
-               SvNVX(bytecode_sv) = arg;
+               BSET_xnv(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XLV_TARGOFF:                /* 22 */
+         case INSN_XLV_TARGOFF:                /* 27 */
            {
                STRLEN arg;
-               BGET_U32(arg);
-               LvTARGOFF(bytecode_sv) = arg;
+               BGET_PADOFFSET(arg);
+               LvTARGOFF(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XLV_TARGLEN:                /* 23 */
+         case INSN_XLV_TARGLEN:                /* 28 */
            {
                STRLEN arg;
-               BGET_U32(arg);
-               LvTARGLEN(bytecode_sv) = arg;
+               BGET_PADOFFSET(arg);
+               LvTARGLEN(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XLV_TARG:           /* 24 */
+         case INSN_XLV_TARG:           /* 29 */
            {
                svindex arg;
                BGET_svindex(arg);
-               LvTARG(bytecode_sv) = arg;
+               LvTARG(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XLV_TYPE:           /* 25 */
+         case INSN_XLV_TYPE:           /* 30 */
            {
                char arg;
                BGET_U8(arg);
-               LvTYPE(bytecode_sv) = arg;
+               LvTYPE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XBM_USEFUL:         /* 26 */
+         case INSN_XBM_USEFUL:         /* 31 */
            {
                I32 arg;
                BGET_I32(arg);
-               BmUSEFUL(bytecode_sv) = arg;
+               BmUSEFUL(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XBM_PREVIOUS:               /* 27 */
+         case INSN_XBM_PREVIOUS:               /* 32 */
            {
                U16 arg;
                BGET_U16(arg);
-               BmPREVIOUS(bytecode_sv) = arg;
+               BmPREVIOUS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XBM_RARE:           /* 28 */
+         case INSN_XBM_RARE:           /* 33 */
            {
                U8 arg;
                BGET_U8(arg);
-               BmRARE(bytecode_sv) = arg;
+               BmRARE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XFM_LINES:          /* 29 */
+         case INSN_XFM_LINES:          /* 34 */
            {
-               I32 arg;
-               BGET_I32(arg);
-               FmLINES(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               FmLINES(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_LINES:          /* 30 */
+         case INSN_XIO_LINES:          /* 36 */
            {
-               long arg;
-               BGET_I32(arg);
-               IoLINES(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               IoLINES(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_PAGE:           /* 31 */
+         case INSN_XIO_PAGE:           /* 37 */
            {
-               long arg;
-               BGET_I32(arg);
-               IoPAGE(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               IoPAGE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_PAGE_LEN:               /* 32 */
+         case INSN_XIO_PAGE_LEN:               /* 38 */
            {
-               long arg;
-               BGET_I32(arg);
-               IoPAGE_LEN(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               IoPAGE_LEN(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_LINES_LEFT:             /* 33 */
+         case INSN_XIO_LINES_LEFT:             /* 39 */
            {
-               long arg;
-               BGET_I32(arg);
-               IoLINES_LEFT(bytecode_sv) = arg;
+               IV arg;
+               BGET_IV(arg);
+               IoLINES_LEFT(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_TOP_NAME:               /* 34 */
+         case INSN_XIO_TOP_NAME:               /* 40 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               IoTOP_NAME(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               IoTOP_NAME(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_TOP_GV:         /* 36 */
+         case INSN_XIO_TOP_GV:         /* 41 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&IoTOP_GV(bytecode_sv) = arg;
+               *(SV**)&IoTOP_GV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_FMT_NAME:               /* 37 */
+         case INSN_XIO_FMT_NAME:               /* 42 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               IoFMT_NAME(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               IoFMT_NAME(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_FMT_GV:         /* 38 */
+         case INSN_XIO_FMT_GV:         /* 43 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&IoFMT_GV(bytecode_sv) = arg;
+               *(SV**)&IoFMT_GV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_BOTTOM_NAME:            /* 39 */
+         case INSN_XIO_BOTTOM_NAME:            /* 44 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               IoBOTTOM_NAME(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               IoBOTTOM_NAME(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_BOTTOM_GV:              /* 40 */
+         case INSN_XIO_BOTTOM_GV:              /* 45 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&IoBOTTOM_GV(bytecode_sv) = arg;
+               *(SV**)&IoBOTTOM_GV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_SUBPROCESS:             /* 41 */
+         case INSN_XIO_SUBPROCESS:             /* 46 */
            {
                short arg;
                BGET_U16(arg);
-               IoSUBPROCESS(bytecode_sv) = arg;
+               IoSUBPROCESS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_TYPE:           /* 42 */
+         case INSN_XIO_TYPE:           /* 47 */
            {
                char arg;
                BGET_U8(arg);
-               IoTYPE(bytecode_sv) = arg;
+               IoTYPE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XIO_FLAGS:          /* 43 */
+         case INSN_XIO_FLAGS:          /* 48 */
            {
                char arg;
                BGET_U8(arg);
-               IoFLAGS(bytecode_sv) = arg;
+               IoFLAGS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_STASH:          /* 44 */
+         case INSN_XCV_XSUBANY:                /* 49 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&CvSTASH(bytecode_sv) = arg;
+               *(SV**)&CvXSUBANY(bstate->bs_sv).any_ptr = arg;
                break;
            }
-         case INSN_XCV_START:          /* 45 */
+         case INSN_XCV_STASH:          /* 50 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&CvSTASH(bstate->bs_sv) = arg;
+               break;
+           }
+         case INSN_XCV_START:          /* 51 */
            {
                opindex arg;
                BGET_opindex(arg);
-               CvSTART(bytecode_sv) = arg;
+               CvSTART(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_ROOT:           /* 46 */
+         case INSN_XCV_ROOT:           /* 52 */
            {
                opindex arg;
                BGET_opindex(arg);
-               CvROOT(bytecode_sv) = arg;
+               CvROOT(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_GV:             /* 47 */
+         case INSN_XCV_GV:             /* 53 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&CvGV(bytecode_sv) = arg;
+               *(SV**)&CvGV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_FILE:           /* 48 */
+         case INSN_XCV_FILE:           /* 54 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               CvFILE(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               CvFILE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_DEPTH:          /* 49 */
+         case INSN_XCV_DEPTH:          /* 55 */
            {
                long arg;
-               BGET_I32(arg);
-               CvDEPTH(bytecode_sv) = arg;
+               BGET_long(arg);
+               CvDEPTH(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_PADLIST:                /* 50 */
+         case INSN_XCV_PADLIST:                /* 56 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&CvPADLIST(bytecode_sv) = arg;
+               *(SV**)&CvPADLIST(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_OUTSIDE:                /* 51 */
+         case INSN_XCV_OUTSIDE:                /* 57 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&CvOUTSIDE(bytecode_sv) = arg;
+               *(SV**)&CvOUTSIDE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XCV_FLAGS:          /* 52 */
+         case INSN_XCV_OUTSIDE_SEQ:            /* 58 */
            {
-               U8 arg;
-               BGET_U8(arg);
-               CvFLAGS(bytecode_sv) = arg;
+               U32 arg;
+               BGET_U32(arg);
+               CvOUTSIDE_SEQ(bstate->bs_sv) = arg;
+               break;
+           }
+         case INSN_XCV_FLAGS:          /* 59 */
+           {
+               U16 arg;
+               BGET_U16(arg);
+               CvFLAGS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_AV_EXTEND:          /* 53 */
+         case INSN_AV_EXTEND:          /* 60 */
            {
                SSize_t arg;
-               BGET_I32(arg);
-               BSET_av_extend(bytecode_sv, arg);
+               BGET_PADOFFSET(arg);
+               BSET_av_extend(bstate->bs_sv, arg);
                break;
            }
-         case INSN_AV_PUSH:            /* 54 */
+         case INSN_AV_PUSHX:           /* 61 */
            {
                svindex arg;
                BGET_svindex(arg);
-               BSET_av_push(bytecode_sv, arg);
+               BSET_av_pushx(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XAV_FILL:           /* 55 */
+         case INSN_AV_PUSH:            /* 62 */
            {
-               SSize_t arg;
-               BGET_I32(arg);
-               AvFILLp(bytecode_sv) = arg;
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_av_push(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XAV_MAX:            /* 56 */
+         case INSN_XAV_FILL:           /* 63 */
            {
                SSize_t arg;
-               BGET_I32(arg);
-               AvMAX(bytecode_sv) = arg;
+               BGET_PADOFFSET(arg);
+               AvFILLp(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XAV_FLAGS:          /* 57 */
+         case INSN_XAV_MAX:            /* 64 */
            {
-               U8 arg;
-               BGET_U8(arg);
-               AvFLAGS(bytecode_sv) = arg;
+               SSize_t arg;
+               BGET_PADOFFSET(arg);
+               AvMAX(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XHV_RITER:          /* 58 */
+         case INSN_XHV_RITER:          /* 65 */
            {
                I32 arg;
                BGET_I32(arg);
-               HvRITER(bytecode_sv) = arg;
+               HvRITER(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_XHV_NAME:           /* 59 */
+         case INSN_XHV_NAME:           /* 66 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               HvNAME(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               BSET_xhv_name(bstate->bs_sv, arg);
                break;
            }
-         case INSN_HV_STORE:           /* 60 */
+         case INSN_HV_STORE:           /* 67 */
            {
                svindex arg;
                BGET_svindex(arg);
-               BSET_hv_store(bytecode_sv, arg);
+               BSET_hv_store(bstate->bs_sv, arg);
                break;
            }
-         case INSN_SV_MAGIC:           /* 61 */
+         case INSN_SV_MAGIC:           /* 68 */
            {
                char arg;
                BGET_U8(arg);
-               BSET_sv_magic(bytecode_sv, arg);
+               BSET_sv_magic(bstate->bs_sv, arg);
                break;
            }
-         case INSN_MG_OBJ:             /* 62 */
+         case INSN_MG_OBJ:             /* 69 */
            {
                svindex arg;
                BGET_svindex(arg);
-               SvMAGIC(bytecode_sv)->mg_obj = arg;
+               SvMAGIC(bstate->bs_sv)->mg_obj = arg;
                break;
            }
-         case INSN_MG_PRIVATE:         /* 63 */
+         case INSN_MG_PRIVATE:         /* 70 */
            {
                U16 arg;
                BGET_U16(arg);
-               SvMAGIC(bytecode_sv)->mg_private = arg;
+               SvMAGIC(bstate->bs_sv)->mg_private = arg;
                break;
            }
-         case INSN_MG_FLAGS:           /* 64 */
+         case INSN_MG_FLAGS:           /* 71 */
            {
                U8 arg;
                BGET_U8(arg);
-               SvMAGIC(bytecode_sv)->mg_flags = arg;
+               SvMAGIC(bstate->bs_sv)->mg_flags = arg;
                break;
            }
-         case INSN_MG_PV:              /* 65 */
+         case INSN_MG_NAME:            /* 72 */
            {
                pvcontents arg;
                BGET_pvcontents(arg);
-               BSET_mg_pv(SvMAGIC(bytecode_sv), arg);
+               BSET_mg_name(SvMAGIC(bstate->bs_sv), arg);
                break;
            }
-         case INSN_XMG_STASH:          /* 66 */
+         case INSN_MG_NAMEX:           /* 73 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&SvSTASH(bytecode_sv) = arg;
+               BSET_mg_namex(SvMAGIC(bstate->bs_sv), arg);
+               break;
+           }
+         case INSN_XMG_STASH:          /* 74 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_xmg_stash(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_GV_FETCHPV:         /* 75 */
+           {
+               strconst arg;
+               BGET_strconst(arg);
+               BSET_gv_fetchpv(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_GV_FETCHPVX:                /* 76 */
+           {
+               strconst arg;
+               BGET_strconst(arg);
+               BSET_gv_fetchpvx(bstate->bs_sv, arg);
                break;
            }
-         case INSN_GV_FETCHPV:         /* 67 */
+         case INSN_GV_STASHPV:         /* 77 */
            {
                strconst arg;
                BGET_strconst(arg);
-               BSET_gv_fetchpv(bytecode_sv, arg);
+               BSET_gv_stashpv(bstate->bs_sv, arg);
                break;
            }
-         case INSN_GV_STASHPV:         /* 68 */
+         case INSN_GV_STASHPVX:                /* 78 */
            {
                strconst arg;
                BGET_strconst(arg);
-               BSET_gv_stashpv(bytecode_sv, arg);
+               BSET_gv_stashpvx(bstate->bs_sv, arg);
                break;
            }
-         case INSN_GP_SV:              /* 69 */
+         case INSN_GP_SV:              /* 79 */
            {
                svindex arg;
                BGET_svindex(arg);
-               GvSV(bytecode_sv) = arg;
+               GvSV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_REFCNT:          /* 70 */
+         case INSN_GP_REFCNT:          /* 80 */
            {
                U32 arg;
                BGET_U32(arg);
-               GvREFCNT(bytecode_sv) = arg;
+               GvREFCNT(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_REFCNT_ADD:              /* 71 */
+         case INSN_GP_REFCNT_ADD:              /* 81 */
            {
                I32 arg;
                BGET_I32(arg);
-               BSET_gp_refcnt_add(GvREFCNT(bytecode_sv), arg);
+               BSET_gp_refcnt_add(GvREFCNT(bstate->bs_sv), arg);
                break;
            }
-         case INSN_GP_AV:              /* 72 */
+         case INSN_GP_AV:              /* 82 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&GvAV(bytecode_sv) = arg;
+               *(SV**)&GvAV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_HV:              /* 73 */
+         case INSN_GP_HV:              /* 83 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&GvHV(bytecode_sv) = arg;
+               *(SV**)&GvHV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_CV:              /* 74 */
+         case INSN_GP_CV:              /* 84 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&GvCV(bytecode_sv) = arg;
+               *(SV**)&GvCV(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_FILE:            /* 75 */
+         case INSN_GP_FILE:            /* 85 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
-               GvFILE(bytecode_sv) = arg;
+               pvindex arg;
+               BGET_pvindex(arg);
+               BSET_gp_file(bstate->bs_sv, arg);
                break;
            }
-         case INSN_GP_IO:              /* 76 */
+         case INSN_GP_IO:              /* 86 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&GvIOp(bytecode_sv) = arg;
+               *(SV**)&GvIOp(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_FORM:            /* 77 */
+         case INSN_GP_FORM:            /* 87 */
            {
                svindex arg;
                BGET_svindex(arg);
-               *(SV**)&GvFORM(bytecode_sv) = arg;
+               *(SV**)&GvFORM(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_CVGEN:           /* 78 */
+         case INSN_GP_CVGEN:           /* 88 */
            {
                U32 arg;
                BGET_U32(arg);
-               GvCVGEN(bytecode_sv) = arg;
+               GvCVGEN(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_LINE:            /* 79 */
+         case INSN_GP_LINE:            /* 89 */
            {
                line_t arg;
-               BGET_U16(arg);
-               GvLINE(bytecode_sv) = arg;
+               BGET_U32(arg);
+               GvLINE(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_GP_SHARE:           /* 80 */
+         case INSN_GP_SHARE:           /* 90 */
            {
                svindex arg;
                BGET_svindex(arg);
-               BSET_gp_share(bytecode_sv, arg);
+               BSET_gp_share(bstate->bs_sv, arg);
                break;
            }
-         case INSN_XGV_FLAGS:          /* 81 */
+         case INSN_XGV_FLAGS:          /* 91 */
            {
                U8 arg;
                BGET_U8(arg);
-               GvFLAGS(bytecode_sv) = arg;
+               GvFLAGS(bstate->bs_sv) = arg;
                break;
            }
-         case INSN_OP_NEXT:            /* 82 */
+         case INSN_OP_NEXT:            /* 92 */
            {
                opindex arg;
                BGET_opindex(arg);
                PL_op->op_next = arg;
                break;
            }
-         case INSN_OP_SIBLING:         /* 83 */
+         case INSN_OP_SIBLING:         /* 93 */
            {
                opindex arg;
                BGET_opindex(arg);
                PL_op->op_sibling = arg;
                break;
            }
-         case INSN_OP_PPADDR:          /* 84 */
+         case INSN_OP_PPADDR:          /* 94 */
            {
                strconst arg;
                BGET_strconst(arg);
                BSET_op_ppaddr(PL_op->op_ppaddr, arg);
                break;
            }
-         case INSN_OP_TARG:            /* 85 */
+         case INSN_OP_TARG:            /* 95 */
            {
                PADOFFSET arg;
-               BGET_U32(arg);
+               BGET_PADOFFSET(arg);
                PL_op->op_targ = arg;
                break;
            }
-         case INSN_OP_TYPE:            /* 86 */
+         case INSN_OP_TYPE:            /* 96 */
            {
                OPCODE arg;
                BGET_U16(arg);
                BSET_op_type(PL_op, arg);
                break;
            }
-         case INSN_OP_SEQ:             /* 87 */
+         case INSN_OP_OPT:             /* 97 */
            {
-               U16 arg;
-               BGET_U16(arg);
-               PL_op->op_seq = arg;
+               U8 arg;
+               BGET_U8(arg);
+               PL_op->op_opt = arg;
                break;
            }
-         case INSN_OP_FLAGS:           /* 88 */
+         case INSN_OP_STATIC:          /* 98 */
+           {
+               U8 arg;
+               BGET_U8(arg);
+               PL_op->op_static = arg;
+               break;
+           }
+         case INSN_OP_FLAGS:           /* 99 */
            {
                U8 arg;
                BGET_U8(arg);
                PL_op->op_flags = arg;
                break;
            }
-         case INSN_OP_PRIVATE:         /* 89 */
+         case INSN_OP_PRIVATE:         /* 100 */
            {
                U8 arg;
                BGET_U8(arg);
                PL_op->op_private = arg;
                break;
            }
-         case INSN_OP_FIRST:           /* 90 */
+         case INSN_OP_FIRST:           /* 101 */
            {
                opindex arg;
                BGET_opindex(arg);
                cUNOP->op_first = arg;
                break;
            }
-         case INSN_OP_LAST:            /* 91 */
+         case INSN_OP_LAST:            /* 102 */
            {
                opindex arg;
                BGET_opindex(arg);
                cBINOP->op_last = arg;
                break;
            }
-         case INSN_OP_OTHER:           /* 92 */
+         case INSN_OP_OTHER:           /* 103 */
            {
                opindex arg;
                BGET_opindex(arg);
                cLOGOP->op_other = arg;
                break;
            }
-         case INSN_OP_CHILDREN:                /* 93 */
-           {
-               U32 arg;
-               BGET_U32(arg);
-               cLISTOP->op_children = arg;
-               break;
-           }
-         case INSN_OP_PMREPLROOT:              /* 94 */
+         case INSN_OP_PMREPLROOT:              /* 104 */
            {
                opindex arg;
                BGET_opindex(arg);
                cPMOP->op_pmreplroot = arg;
                break;
            }
-         case INSN_OP_PMREPLROOTGV:            /* 95 */
-           {
-               svindex arg;
-               BGET_svindex(arg);
-               *(SV**)&cPMOP->op_pmreplroot = arg;
-               break;
-           }
-         case INSN_OP_PMREPLSTART:             /* 96 */
+         case INSN_OP_PMREPLSTART:             /* 105 */
            {
                opindex arg;
                BGET_opindex(arg);
                cPMOP->op_pmreplstart = arg;
                break;
            }
-         case INSN_OP_PMNEXT:          /* 97 */
+         case INSN_OP_PMNEXT:          /* 106 */
            {
                opindex arg;
                BGET_opindex(arg);
                *(OP**)&cPMOP->op_pmnext = arg;
                break;
            }
-         case INSN_PREGCOMP:           /* 98 */
+#ifdef USE_ITHREADS
+         case INSN_OP_PMSTASHPV:               /* 107 */
+           {
+               pvindex arg;
+               BGET_pvindex(arg);
+               BSET_op_pmstashpv(cPMOP, arg);
+               break;
+           }
+         case INSN_OP_PMREPLROOTPO:            /* 108 */
+           {
+               PADOFFSET arg;
+               BGET_PADOFFSET(arg);
+               cPMOP->op_pmreplroot = (OP*)arg;
+               break;
+           }
+#else
+         case INSN_OP_PMSTASH:         /* 109 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&cPMOP->op_pmstash = arg;
+               break;
+           }
+         case INSN_OP_PMREPLROOTGV:            /* 110 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&cPMOP->op_pmreplroot = arg;
+               break;
+           }
+#endif
+         case INSN_PREGCOMP:           /* 111 */
            {
                pvcontents arg;
                BGET_pvcontents(arg);
                BSET_pregcomp(PL_op, arg);
                break;
            }
-         case INSN_OP_PMFLAGS:         /* 99 */
+         case INSN_OP_PMFLAGS:         /* 112 */
            {
                U16 arg;
                BGET_U16(arg);
                cPMOP->op_pmflags = arg;
                break;
            }
-         case INSN_OP_PMPERMFLAGS:             /* 100 */
+         case INSN_OP_PMPERMFLAGS:             /* 113 */
            {
                U16 arg;
                BGET_U16(arg);
                cPMOP->op_pmpermflags = arg;
                break;
            }
-         case INSN_OP_SV:              /* 101 */
+         case INSN_OP_PMDYNFLAGS:              /* 114 */
+           {
+               U8 arg;
+               BGET_U8(arg);
+               cPMOP->op_pmdynflags = arg;
+               break;
+           }
+         case INSN_OP_SV:              /* 115 */
            {
                svindex arg;
                BGET_svindex(arg);
                cSVOP->op_sv = arg;
                break;
            }
-         case INSN_OP_PADIX:           /* 102 */
+         case INSN_OP_PADIX:           /* 116 */
            {
                PADOFFSET arg;
-               BGET_U32(arg);
+               BGET_PADOFFSET(arg);
                cPADOP->op_padix = arg;
                break;
            }
-         case INSN_OP_PV:              /* 103 */
+         case INSN_OP_PV:              /* 117 */
            {
                pvcontents arg;
                BGET_pvcontents(arg);
                cPVOP->op_pv = arg;
                break;
            }
-         case INSN_OP_PV_TR:           /* 104 */
+         case INSN_OP_PV_TR:           /* 118 */
            {
                op_tr_array arg;
                BGET_op_tr_array(arg);
                cPVOP->op_pv = arg;
                break;
            }
-         case INSN_OP_REDOOP:          /* 105 */
+         case INSN_OP_REDOOP:          /* 119 */
            {
                opindex arg;
                BGET_opindex(arg);
                cLOOP->op_redoop = arg;
                break;
            }
-         case INSN_OP_NEXTOP:          /* 106 */
+         case INSN_OP_NEXTOP:          /* 120 */
            {
                opindex arg;
                BGET_opindex(arg);
                cLOOP->op_nextop = arg;
                break;
            }
-         case INSN_OP_LASTOP:          /* 107 */
+         case INSN_OP_LASTOP:          /* 121 */
            {
                opindex arg;
                BGET_opindex(arg);
                cLOOP->op_lastop = arg;
                break;
            }
-         case INSN_COP_LABEL:          /* 108 */
+         case INSN_COP_LABEL:          /* 122 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
+               pvindex arg;
+               BGET_pvindex(arg);
                cCOP->cop_label = arg;
                break;
            }
-         case INSN_COP_STASHPV:                /* 109 */
+#ifdef USE_ITHREADS
+         case INSN_COP_STASHPV:                /* 123 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
+               pvindex arg;
+               BGET_pvindex(arg);
                BSET_cop_stashpv(cCOP, arg);
                break;
            }
-         case INSN_COP_FILE:           /* 110 */
+         case INSN_COP_FILE:           /* 124 */
            {
-               pvcontents arg;
-               BGET_pvcontents(arg);
+               pvindex arg;
+               BGET_pvindex(arg);
                BSET_cop_file(cCOP, arg);
                break;
            }
-         case INSN_COP_SEQ:            /* 111 */
+#else
+         case INSN_COP_STASH:          /* 125 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_cop_stash(cCOP, arg);
+               break;
+           }
+         case INSN_COP_FILEGV:         /* 126 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_cop_filegv(cCOP, arg);
+               break;
+           }
+#endif
+         case INSN_COP_SEQ:            /* 127 */
            {
                U32 arg;
                BGET_U32(arg);
                cCOP->cop_seq = arg;
                break;
            }
-         case INSN_COP_ARYBASE:                /* 112 */
+         case INSN_COP_ARYBASE:                /* 128 */
            {
                I32 arg;
                BGET_I32(arg);
-               cCOP->cop_arybase = arg;
+               BSET_cop_arybase(cCOP, arg);
                break;
            }
-         case INSN_COP_LINE:           /* 113 */
+         case INSN_COP_LINE:           /* 129 */
            {
                line_t arg;
-               BGET_U16(arg);
-               BSET_cop_line(cCOP, arg);
+               BGET_U32(arg);
+               cCOP->cop_line = arg;
+               break;
+           }
+         case INSN_COP_IO:             /* 130 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               cCOP->cop_io = arg;
                break;
            }
-         case INSN_COP_WARNINGS:               /* 114 */
+         case INSN_COP_WARNINGS:               /* 131 */
            {
                svindex arg;
                BGET_svindex(arg);
-               cCOP->cop_warnings = arg;
+               BSET_cop_warnings(cCOP, arg);
                break;
            }
-         case INSN_MAIN_START:         /* 115 */
+         case INSN_MAIN_START:         /* 132 */
            {
                opindex arg;
                BGET_opindex(arg);
                PL_main_start = arg;
                break;
            }
-         case INSN_MAIN_ROOT:          /* 116 */
+         case INSN_MAIN_ROOT:          /* 133 */
            {
                opindex arg;
                BGET_opindex(arg);
                PL_main_root = arg;
                break;
            }
-         case INSN_CURPAD:             /* 117 */
+         case INSN_MAIN_CV:            /* 134 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&PL_main_cv = arg;
+               break;
+           }
+         case INSN_CURPAD:             /* 135 */
            {
                svindex arg;
                BGET_svindex(arg);
                BSET_curpad(PL_curpad, arg);
                break;
            }
+         case INSN_PUSH_BEGIN:         /* 136 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_push_begin(PL_beginav, arg);
+               break;
+           }
+         case INSN_PUSH_INIT:          /* 137 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_push_init(PL_initav, arg);
+               break;
+           }
+         case INSN_PUSH_END:           /* 138 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_push_end(PL_endav, arg);
+               break;
+           }
+         case INSN_CURSTASH:           /* 139 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&PL_curstash = arg;
+               break;
+           }
+         case INSN_DEFSTASH:           /* 140 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&PL_defstash = arg;
+               break;
+           }
+         case INSN_DATA:               /* 141 */
+           {
+               U8 arg;
+               BGET_U8(arg);
+               BSET_data(none, arg);
+               break;
+           }
+         case INSN_INCAV:              /* 142 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&GvAV(PL_incgv) = arg;
+               break;
+           }
+         case INSN_LOAD_GLOB:          /* 143 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               BSET_load_glob(none, arg);
+               break;
+           }
+#ifdef USE_ITHREADS
+         case INSN_REGEX_PADAV:                /* 144 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&PL_regex_padav = arg;
+               break;
+           }
+#endif
+         case INSN_DOWARN:             /* 145 */
+           {
+               U8 arg;
+               BGET_U8(arg);
+               PL_dowarn = arg;
+               break;
+           }
+         case INSN_COMPPAD_NAME:               /* 146 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&PL_comppad_name = arg;
+               break;
+           }
+         case INSN_XGV_STASH:          /* 147 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               *(SV**)&GvSTASH(bstate->bs_sv) = arg;
+               break;
+           }
+         case INSN_SIGNAL:             /* 148 */
+           {
+               strconst arg;
+               BGET_strconst(arg);
+               BSET_signal(bstate->bs_sv, arg);
+               break;
+           }
+         case INSN_FORMFEED:           /* 149 */
+           {
+               svindex arg;
+               BGET_svindex(arg);
+               PL_formfeed = arg;
+               break;
+           }
          default:
            Perl_croak(aTHX_ "Illegal bytecode instruction %d\n", insn);
            /* NOTREACHED */
        }
     }
+    return 0;
 }
+
+/* ex: set ro: */