X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=bytecode.pl;h=fc16f176157eb75d61f37554906f5e0cc70c36c3;hb=46187eeb6d9336144ec364973ed57177c89816cf;hp=4b00e14b9a11e2961260e143de31cf4075bbb1a1;hpb=117dada22e1a48990acd498dee229f361feda1fa;p=p5sagit%2Fp5-mst-13.2.git diff --git a/bytecode.pl b/bytecode.pl index 4b00e14..fc16f17 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,7 +100,7 @@ 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) { register int insn; U32 ix; @@ -116,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"; } @@ -209,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; @@ -261,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 @@ -300,7 +338,7 @@ newopn PL_op U8 x newpv none PV pv_cur bstate->bs_pv.xpv_cur STRLEN pv_free bstate->bs_pv none x -sv_upgrade bstate->bs_sv char x +sv_upgrade bstate->bs_sv U8 x sv_refcnt SvREFCNT(bstate->bs_sv) U32 sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x sv_flags SvFLAGS(bstate->bs_sv) U32 @@ -316,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