leak in change#4694 spotted by Larry
[p5sagit/p5-mst-13.2.git] / bytecode.pl
index 93457ea..00df48b 100644 (file)
@@ -9,7 +9,7 @@ my %alias_to = (
     U8 => [qw(char)],
 );
 
-my @optype= qw(OP UNOP BINOP LOGOP CONDOP LISTOP PMOP SVOP GVOP PVOP LOOP COP);
+my @optype= qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP);
 
 # Nullsv *must* come first in the following so that the condition
 # ($$sv == 0) can continue to be used to test (sv == Nullsv).
@@ -65,11 +65,23 @@ EOT
 open(BYTERUN_C, ">ext/ByteLoader/byterun.c") or die "ext/ByteLoader/byterun.c: $!";
 print BYTERUN_C $c_header, <<'EOT';
 
+#define PERL_NO_GET_CONTEXT
 #include "EXTERN.h"
 #include "perl.h"
+#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[] = {
 EOT
 my $i = 0;
@@ -89,7 +101,7 @@ static void **bytecode_obj_list;
 static I32 bytecode_obj_list_fill = -1;
 
 void *
-bset_obj_store(void *obj, I32 ix)
+bset_obj_store(pTHXo_ void *obj, I32 ix)
 {
     if (ix > bytecode_obj_list_fill) {
        if (bytecode_obj_list_fill == -1)
@@ -102,7 +114,8 @@ bset_obj_store(void *obj, I32 ix)
     return obj;
 }
 
-void byterun(struct bytestream bs)
+void
+byterun(pTHXo_ struct bytestream bs)
 {
     dTHR;
     int insn;
@@ -173,7 +186,7 @@ EOT
 #
 print BYTERUN_C <<'EOT';
          default:
-           croak("Illegal bytecode instruction %d\n", insn);
+           Perl_croak(aTHX_ "Illegal bytecode instruction %d\n", insn);
            /* NOTREACHED */
        }
     }
@@ -187,15 +200,14 @@ open(BYTERUN_H, ">ext/ByteLoader/byterun.h") or die "ext/ByteLoader/byterun.h: $
 print BYTERUN_H $c_header, <<'EOT';
 struct bytestream {
     void *data;
-    int (*fgetc)(void *);
-    int (*fread)(char *, size_t, size_t, void *);
-    void (*freadpv)(U32, void *, XPV *);
+    int (*pfgetc)(void *);
+    int (*pfread)(char *, size_t, size_t, void *);
+    void (*pfreadpv)(U32, void *, XPV *);
 };
 
 enum {
 EOT
 
-my $i = 0;
 my $add_enum_value = 0;
 my $max_insn;
 for ($i = 0; $i < @insn_name; $i++) {
@@ -220,22 +232,10 @@ for ($i = 0; $i < @optype - 1; $i++) {
     printf BYTERUN_H "    OPt_%s,\t\t/* %d */\n", $optype[$i], $i;
 }
 printf BYTERUN_H "    OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
-print BYTERUN_H <<'EOT';
-EXT int PL_optype_size[]
-#ifdef DOINIT
-= {
-EOT
-for ($i = 0; $i < @optype - 1; $i++) {
-    printf BYTERUN_H "    sizeof(%s),\n", $optype[$i], $i;
-}
-printf BYTERUN_H "    sizeof(%s)\n}\n", $optype[$i], $i;
-print BYTERUN_H <<'EOT';
-#endif /* DOINIT */
-;
-
-EOT
 
 print BYTERUN_H <<'EOT';
+extern void byterun(pTHXo_ struct bytestream bs);
+
 #define INIT_SPECIALSV_LIST STMT_START { \
 EOT
 for ($i = 0; $i < @specialsv; $i++) {
@@ -313,7 +313,7 @@ xrv         SvRV(bytecode_sv)                       svindex
 xpv            bytecode_sv                             none            x
 xiv32          SvIVX(bytecode_sv)                      I32
 xiv64          SvIVX(bytecode_sv)                      IV64
-xnv            SvNVX(bytecode_sv)                      double
+xnv            SvNVX(bytecode_sv)                      NV
 xlv_targoff    LvTARGOFF(bytecode_sv)                  STRLEN
 xlv_targlen    LvTARGLEN(bytecode_sv)                  STRLEN
 xlv_targ       LvTARG(bytecode_sv)                     svindex
@@ -339,7 +339,7 @@ xcv_stash   *(SV**)&CvSTASH(bytecode_sv)            svindex
 xcv_start      CvSTART(bytecode_sv)                    opindex
 xcv_root       CvROOT(bytecode_sv)                     opindex
 xcv_gv         *(SV**)&CvGV(bytecode_sv)               svindex
-xcv_filegv     *(SV**)&CvFILEGV(bytecode_sv)           svindex
+xcv_file       CvFILE(bytecode_sv)                     pvcontents
 xcv_depth      CvDEPTH(bytecode_sv)                    long
 xcv_padlist    *(SV**)&CvPADLIST(bytecode_sv)          svindex
 xcv_outside    *(SV**)&CvOUTSIDE(bytecode_sv)          svindex
@@ -366,7 +366,7 @@ gp_refcnt_add       GvREFCNT(bytecode_sv)                   I32             x
 gp_av          *(SV**)&GvAV(bytecode_sv)               svindex
 gp_hv          *(SV**)&GvHV(bytecode_sv)               svindex
 gp_cv          *(SV**)&GvCV(bytecode_sv)               svindex
-gp_filegv      *(SV**)&GvFILEGV(bytecode_sv)           svindex
+gp_file                GvFILE(bytecode_sv)                     pvcontents
 gp_io          *(SV**)&GvIOp(bytecode_sv)              svindex
 gp_form                *(SV**)&GvFORM(bytecode_sv)             svindex
 gp_cvgen       GvCVGEN(bytecode_sv)                    U32
@@ -384,8 +384,6 @@ op_private  PL_op->op_private                       U8
 op_first       cUNOP->op_first                         opindex
 op_last                cBINOP->op_last                         opindex
 op_other       cLOGOP->op_other                        opindex
-op_true                cCONDOP->op_true                        opindex
-op_false       cCONDOP->op_false                       opindex
 op_children    cLISTOP->op_children                    U32
 op_pmreplroot  cPMOP->op_pmreplroot                    opindex
 op_pmreplrootgv        *(SV**)&cPMOP->op_pmreplroot            svindex
@@ -395,18 +393,18 @@ pregcomp  PL_op                                   pvcontents      x
 op_pmflags     cPMOP->op_pmflags                       U16
 op_pmpermflags cPMOP->op_pmpermflags                   U16
 op_sv          cSVOP->op_sv                            svindex
-op_gv          *(SV**)&cGVOP->op_gv                    svindex
+op_padix       cPADOP->op_padix                        PADOFFSET
 op_pv          cPVOP->op_pv                            pvcontents
 op_pv_tr       cPVOP->op_pv                            op_tr_array
 op_redoop      cLOOP->op_redoop                        opindex
 op_nextop      cLOOP->op_nextop                        opindex
 op_lastop      cLOOP->op_lastop                        opindex
 cop_label      cCOP->cop_label                         pvcontents
-cop_stash      *(SV**)&cCOP->cop_stash                 svindex
-cop_filegv     *(SV**)&cCOP->cop_filegv                svindex
+cop_stashpv    cCOP                                    pvcontents      x
+cop_file       cCOP                                    pvcontents      x
 cop_seq                cCOP->cop_seq                           U32
 cop_arybase    cCOP->cop_arybase                       I32
-cop_line       cCOP->cop_line                          line_t
+cop_line       cCOP                                    line_t          x
 cop_warnings   cCOP->cop_warnings                      svindex
 main_start     PL_main_start                           opindex
 main_root      PL_main_root                            opindex