X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/27da23d53ccce622bc51822f59df8def79b4df95..178eff928e12522422417310bee9331fccc184cf:/bytecode.pl diff --git a/bytecode.pl b/bytecode.pl index 59069b3..4da765a 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -14,7 +14,8 @@ 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 pWARN_ALL pWARN_NONE); +my @specialsv = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no + (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD); my (%alias_from, $from, $tos); while (($from, $tos) = each %alias_to) { @@ -22,7 +23,8 @@ while (($from, $tos) = each %alias_to) { } my $c_header = <<'EOT'; -/* +/* -*- buffer-read-only: t -*- + * * Copyright (c) 1996-1999 Malcolm Beattie * * You may distribute under the terms of either the GNU General Public @@ -88,7 +90,10 @@ for ($i = 0; $i < @optype - 1; $i++) { printf BYTERUN_C " sizeof(%s),\n", $optype[$i], $i; } printf BYTERUN_C " sizeof(%s)\n", $optype[$i], $i; -print BYTERUN_C <<'EOT'; + +my $size = @specialsv; + +print BYTERUN_C <<"EOT"; }; void * @@ -108,10 +113,10 @@ byterun(pTHX_ register struct byteloader_state *bstate) dVAR; register int insn; U32 ix; - SV *specialsv_list[6]; + SV *specialsv_list[$size]; BYTECODE_HEADER_CHECK; /* croak if incorrect platform */ - New(666, bstate->bs_obj_list, 32, void*); /* set op objlist */ + 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; @@ -195,6 +200,8 @@ print BYTERUN_C <<'EOT'; } return 0; } + +/* ex: set ro: */ EOT # @@ -209,13 +216,18 @@ struct byteloader_fdata { int idx; }; +struct byteloader_pv_state { + char *pvx; + XPV xpv; +}; + struct byteloader_state { struct byteloader_fdata *bs_fdata; SV *bs_sv; void **bs_obj_list; int bs_obj_list_fill; int bs_ix; - XPV bs_pv; + struct byteloader_pv_state bs_pv; int bs_iv_overflows; }; @@ -251,6 +263,8 @@ for ($i = 0; $i < @optype - 1; $i++) { } printf BYTERUN_H " OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i; +print BYTERUN_H "/* ex: set ro: */\n"; + # # Finish off insn_data and create array initialisers in Asmdata.pm # @@ -315,7 +329,7 @@ A simple mapping of the op type number to its type (like 'COP' or 'BINOP'). my $sv_name = $specialsv_name[$sv_index]; Certain SV types are considered 'special'. They're represented by -B::SPECIAL and are refered to by a number from the specialsv_list. +B::SPECIAL and are referred to by a number from the specialsv_list. This array maps that number back to the name of the SV (like 'Nullsv' or '&PL_sv_undef'). @@ -326,6 +340,8 @@ or '&PL_sv_undef'). Malcolm Beattie, C =cut + +# ex: set ro: EOT @@ -354,7 +370,7 @@ ldsv bstate->bs_sv svindex ldop PL_op opindex stsv bstate->bs_sv U32 s stop PL_op U32 s -stpv bstate->bs_pv.xpv_pv U32 x +stpv bstate->bs_pv.pvx U32 x ldspecsv bstate->bs_sv U8 x ldspecsvx bstate->bs_sv U8 x newsv bstate->bs_sv U8 x @@ -363,8 +379,8 @@ newop PL_op U8 x newopx PL_op U16 x newopn PL_op U8 x newpv none PV -pv_cur bstate->bs_pv.xpv_cur STRLEN -pv_free bstate->bs_pv none x +pv_cur bstate->bs_pv.xpv.xpv_cur STRLEN +pv_free bstate->bs_pv.pvx none x sv_upgrade bstate->bs_sv U8 x sv_refcnt SvREFCNT(bstate->bs_sv) U32 sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x @@ -412,10 +428,8 @@ av_pushx bstate->bs_sv svindex x av_push bstate->bs_sv svindex x xav_fill AvFILLp(bstate->bs_sv) SSize_t xav_max AvMAX(bstate->bs_sv) SSize_t -xav_flags AvFLAGS(bstate->bs_sv) U8 xhv_riter HvRITER(bstate->bs_sv) I32 -xhv_name HvNAME(bstate->bs_sv) pvindex -xhv_pmroot *(OP**)&HvPMROOT(bstate->bs_sv) opindex +xhv_name bstate->bs_sv pvindex x hv_store bstate->bs_sv svindex x sv_magic bstate->bs_sv char x mg_obj SvMAGIC(bstate->bs_sv)->mg_obj svindex @@ -423,7 +437,7 @@ mg_private SvMAGIC(bstate->bs_sv)->mg_private U16 mg_flags SvMAGIC(bstate->bs_sv)->mg_flags U8 mg_name SvMAGIC(bstate->bs_sv) pvcontents x mg_namex SvMAGIC(bstate->bs_sv) svindex x -xmg_stash bstate->bs_sv svindex X +xmg_stash bstate->bs_sv svindex x gv_fetchpv bstate->bs_sv strconst x gv_fetchpvx bstate->bs_sv strconst x gv_stashpv bstate->bs_sv strconst x @@ -483,10 +497,10 @@ cop_stash cCOP svindex x cop_filegv cCOP svindex x #endif cop_seq cCOP->cop_seq U32 -cop_arybase cCOP->cop_arybase I32 +cop_arybase cCOP I32 x cop_line cCOP->cop_line line_t cop_io cCOP->cop_io svindex -cop_warnings cCOP->cop_warnings svindex +cop_warnings cCOP svindex x main_start PL_main_start opindex main_root PL_main_root opindex main_cv *(SV**)&PL_main_cv svindex