X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=bytecode.pl;h=93157392339d8dcc0c3149f64696d1ab5820555e;hb=d8f6a7325d6b2ec46e8cdc1ec4b5e1ad4a86abd0;hp=93216048a3937aff4c713d72b2b1c9950226d4a3;hpb=059a8bb71dff4eb7a6ca47bbe766a3e1c7c58020;p=p5sagit%2Fp5-mst-13.2.git diff --git a/bytecode.pl b/bytecode.pl index 9321604..9315739 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -44,6 +44,9 @@ unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata. open(ASMDATA_PM, ">ext/B/B/Asmdata.pm") or die "ext/B/B/Asmdata.pm: $!"; print ASMDATA_PM $perl_header, <<'EOT'; package B::Asmdata; + +our $VERSION = '1.00'; + use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name); @@ -71,13 +74,6 @@ print BYTERUN_C $c_header, <<'EOT'; #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" @@ -93,7 +89,7 @@ print BYTERUN_C <<'EOT'; }; void * -bset_obj_store(pTHXo_ struct byteloader_state *bstate, void *obj, I32 ix) +bset_obj_store(pTHX_ struct byteloader_state *bstate, void *obj, I32 ix) { if (ix > bstate->bs_obj_list_fill) { Renew(bstate->bs_obj_list, ix + 32, void*); @@ -104,9 +100,8 @@ bset_obj_store(pTHXo_ struct byteloader_state *bstate, void *obj, I32 ix) } void -byterun(pTHXo_ register struct byteloader_state *bstate) +byterun(pTHX_ register struct byteloader_state *bstate) { - dTHR; register int insn; U32 ix; SV *specialsv_list[6]; @@ -117,7 +112,7 @@ byterun(pTHXo_ register struct byteloader_state *bstate) EOT -for (my $i = 0; $i < @specialsv; $i++) { +for my $i ( 0 .. $#specialsv ) { print BYTERUN_C " specialsv_list[$i] = $specialsv[$i];\n"; } @@ -210,14 +205,14 @@ struct byteloader_state { int bl_getc(struct byteloader_fdata *); int bl_read(struct byteloader_fdata *, char *, size_t, size_t); -extern void byterun(pTHXo_ struct byteloader_state *); +extern void byterun(pTHX_ struct byteloader_state *); enum { EOT my $add_enum_value = 0; my $max_insn; -for ($i = 0; $i < @insn_name; $i++) { +for $i ( 0 .. $#insn_name ) { $insn = uc($insn_name[$i]); if (defined($insn)) { $max_insn = $i; @@ -262,11 +257,53 @@ B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode =head1 SYNOPSIS - use Asmdata; + use B::Asmdata qw(%insn_data @insn_name @optype @specialsv_name); =head1 DESCRIPTION -See F. +Provides information about Perl ops in order to generate bytecode via +a bunch of exported variables. Its mostly used by B::Assembler and +B::Disassembler. + +=over 4 + +=item %insn_data + + my($bytecode_num, $put_sub, $get_meth) = @$insn_data{$op_name}; + +For a given $op_name (for example, 'cop_label', 'sv_flags', etc...) +you get an array ref containing the bytecode number of the op, a +reference to the subroutine used to 'PUT', and the name of the method +used to 'GET'. + +=for _private +Add more detail about what $put_sub and $get_meth are and how to use them. + +=item @insn_name + + my $op_name = $insn_name[$bytecode_num]; + +A simple mapping of the bytecode number to the name of the op. +Suitable for using with %insn_data like so: + + my $op_info = $insn_data{$insn_name[$bytecode_num]}; + +=item @optype + + my $op_type = $optype[$op_type_num]; + +A simple mapping of the op type number to its type (like 'COP' or 'BINOP'). + +=item @specialsv_name + + 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. +This array maps that number back to the name of the SV (like 'Nullsv' +or '&PL_sv_undef'). + +=back =head1 AUTHOR @@ -317,11 +354,11 @@ xlv_type LvTYPE(bstate->bs_sv) char xbm_useful BmUSEFUL(bstate->bs_sv) I32 xbm_previous BmPREVIOUS(bstate->bs_sv) U16 xbm_rare BmRARE(bstate->bs_sv) U8 -xfm_lines FmLINES(bstate->bs_sv) I32 -xio_lines IoLINES(bstate->bs_sv) long -xio_page IoPAGE(bstate->bs_sv) long -xio_page_len IoPAGE_LEN(bstate->bs_sv) long -xio_lines_left IoLINES_LEFT(bstate->bs_sv) long +xfm_lines FmLINES(bstate->bs_sv) IV +xio_lines IoLINES(bstate->bs_sv) IV +xio_page IoPAGE(bstate->bs_sv) IV +xio_page_len IoPAGE_LEN(bstate->bs_sv) IV +xio_lines_left IoLINES_LEFT(bstate->bs_sv) IV xio_top_name IoTOP_NAME(bstate->bs_sv) pvcontents xio_top_gv *(SV**)&IoTOP_GV(bstate->bs_sv) svindex xio_fmt_name IoFMT_NAME(bstate->bs_sv) pvcontents @@ -380,7 +417,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_children cLISTOP->op_children U32 op_pmreplroot cPMOP->op_pmreplroot opindex op_pmreplrootgv *(SV**)&cPMOP->op_pmreplroot svindex op_pmreplstart cPMOP->op_pmreplstart opindex