Threadsafe patches
[p5sagit/p5-mst-13.2.git] / bytecode.pl
index 7d9b223..f847298 100644 (file)
@@ -9,11 +9,11 @@ my %alias_to = (
     U8 => [qw(char)],
 );
 
-my @optype= qw(OP UNOP BINOP LOGOP 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).
-my @specialsv = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no);
+my @specialsv = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no pWARN_ALL pWARN_NONE);
 
 my (%alias_from, $from, $tos);
 while (($from, $tos) = each %alias_to) {
@@ -47,7 +47,7 @@ package B::Asmdata;
 use Exporter;
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name);
-use vars qw(%insn_data @insn_name @optype @specialsv_name);
+our(%insn_data, @insn_name, @optype, @specialsv_name);
 
 EOT
 print ASMDATA_PM <<"EOT";
@@ -82,7 +82,7 @@ print BYTERUN_C $c_header, <<'EOT';
 #include "bytecode.h"
 
 
-static int optype_size[] = {
+static const int optype_size[] = {
 EOT
 my $i = 0;
 for ($i = 0; $i < @optype - 1; $i++) {
@@ -92,12 +92,8 @@ printf BYTERUN_C "    sizeof(%s)\n", $optype[$i], $i;
 print BYTERUN_C <<'EOT';
 };
 
-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 void **bytecode_obj_list = Null(void**);
 static I32 bytecode_obj_list_fill = -1;
 
 void *
@@ -105,9 +101,9 @@ bset_obj_store(pTHXo_ void *obj, I32 ix)
 {
     if (ix > bytecode_obj_list_fill) {
        if (bytecode_obj_list_fill == -1)
-           New(666, bytecode_obj_list, ix + 1, void*);
+           New(666, bytecode_obj_list, ix + 32, void*);
        else
-           Renew(bytecode_obj_list, ix + 1, void*);
+           Renew(bytecode_obj_list, ix + 32, void*);
        bytecode_obj_list_fill = ix;
     }
     bytecode_obj_list[ix] = obj;
@@ -115,11 +111,20 @@ bset_obj_store(pTHXo_ void *obj, I32 ix)
 }
 
 void
-byterun(pTHXo_ struct bytestream bs)
+byterun(pTHXo)
 {
     dTHR;
     int insn;
-
+    SV *bytecode_sv;
+    XPV bytecode_pv;
+    SV *specialsv_list[6];
+    ENTER;
+    SAVEVPTR(bytecode_obj_list);
+    SAVEI32(bytecode_obj_list_fill);
+    bytecode_obj_list = Null(void**);
+    bytecode_obj_list_fill = -1;
+
+    BYTECODE_HEADER_CHECK;     /* croak if incorrect platform */
 EOT
 
 for (my $i = 0; $i < @specialsv; $i++) {
@@ -198,7 +203,7 @@ EOT
 #
 open(BYTERUN_H, ">ext/ByteLoader/byterun.h") or die "ext/ByteLoader/byterun.h: $!";
 print BYTERUN_H $c_header, <<'EOT';
-struct bytestream {
+struct bytestream { /* XXX: not currently used - too slow */
     void *data;
     int (*pfgetc)(void *);
     int (*pfread)(char *, size_t, size_t, void *);
@@ -234,15 +239,7 @@ for ($i = 0; $i < @optype - 1; $i++) {
 printf BYTERUN_H "    OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
 
 print BYTERUN_H <<'EOT';
-extern void byterun(pTHXo_ struct bytestream bs);
-
-#define INIT_SPECIALSV_LIST STMT_START { \
-EOT
-for ($i = 0; $i < @specialsv; $i++) {
-    print BYTERUN_H "\tPL_specialsv_list[$i] = $specialsv[$i]; \\\n";
-}
-print BYTERUN_H <<'EOT';
-    } STMT_END
+extern void byterun(pTHXo);
 EOT
 
 #
@@ -339,11 +336,11 @@ 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
-xcv_flags      CvFLAGS(bytecode_sv)                    U8
+xcv_flags      CvFLAGS(bytecode_sv)                    U16
 av_extend      bytecode_sv                             SSize_t         x
 av_push                bytecode_sv                             svindex         x
 xav_fill       AvFILLp(bytecode_sv)                    SSize_t
@@ -366,7 +363,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
@@ -393,19 +390,22 @@ 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
 curpad         PL_curpad                               svindex         x
+push_begin     PL_beginav                              svindex         x
+push_init      PL_initav                               svindex         x
+push_end       PL_endav                                svindex         x