summaryrefslogtreecommitdiff
path: root/bytecode.pl
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-08-22 13:36:44 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-08-22 13:36:44 +0000
commit059a8bb71dff4eb7a6ca47bbe766a3e1c7c58020 (patch)
tree9d22fbfcafc8c55cc7133507c464803748550696 /bytecode.pl
parent10d9c778f985d5d6d434ffb325e0b7b1d8369cb5 (diff)
downloadperl-059a8bb71dff4eb7a6ca47bbe766a3e1c7c58020.tar.gz
Bytecompiler patches from Benjamin Stuhl.
p4raw-id: //depot/perl@6763
Diffstat (limited to 'bytecode.pl')
-rw-r--r--bytecode.pl227
1 files changed, 113 insertions, 114 deletions
diff --git a/bytecode.pl b/bytecode.pl
index d1e1c708c0..93216048a3 100644
--- a/bytecode.pl
+++ b/bytecode.pl
@@ -13,7 +13,7 @@ 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) {
@@ -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,33 +92,28 @@ 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 I32 bytecode_obj_list_fill = -1;
-
void *
-bset_obj_store(pTHXo_ void *obj, I32 ix)
+bset_obj_store(pTHXo_ struct byteloader_state *bstate, void *obj, I32 ix)
{
- if (ix > bytecode_obj_list_fill) {
- if (bytecode_obj_list_fill == -1)
- New(666, bytecode_obj_list, ix + 1, void*);
- else
- Renew(bytecode_obj_list, ix + 1, void*);
- bytecode_obj_list_fill = ix;
+ if (ix > bstate->bs_obj_list_fill) {
+ Renew(bstate->bs_obj_list, ix + 32, void*);
+ bstate->bs_obj_list_fill = ix + 31;
}
- bytecode_obj_list[ix] = obj;
+ bstate->bs_obj_list[ix] = obj;
return obj;
}
void
-byterun(pTHXo_ struct bytestream bs)
+byterun(pTHXo_ register struct byteloader_state *bstate)
{
dTHR;
- int insn;
+ register int insn;
+ U32 ix;
+ SV *specialsv_list[6];
+
+ BYTECODE_HEADER_CHECK; /* croak if incorrect platform */
+ New(666, bstate->bs_obj_list, 32, void*); /* set op objlist */
+ bstate->bs_obj_list_fill = 31;
EOT
@@ -198,13 +193,25 @@ EOT
#
open(BYTERUN_H, ">ext/ByteLoader/byterun.h") or die "ext/ByteLoader/byterun.h: $!";
print BYTERUN_H $c_header, <<'EOT';
-struct bytestream {
- void *data;
- int (*pfgetc)(void *);
- int (*pfread)(char *, size_t, size_t, void *);
- void (*pfreadpv)(U32, void *, XPV *);
+struct byteloader_fdata {
+ SV *datasv;
+ int next_out;
+ int idx;
};
+struct byteloader_state {
+ struct byteloader_fdata *bs_fdata;
+ SV *bs_sv;
+ void **bs_obj_list;
+ int bs_obj_list_fill;
+ XPV bs_pv;
+ int bs_iv_overflows;
+};
+
+int bl_getc(struct byteloader_fdata *);
+int bl_read(struct byteloader_fdata *, char *, size_t, size_t);
+extern void byterun(pTHXo_ struct byteloader_state *);
+
enum {
EOT
@@ -233,18 +240,6 @@ 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
-EOT
-
#
# Finish off insn_data and create array initialisers in Asmdata.pm
#
@@ -294,85 +289,86 @@ nop none none
#opcode lvalue argtype flags
#
ret none none x
-ldsv bytecode_sv svindex
+ldsv bstate->bs_sv svindex
ldop PL_op opindex
-stsv bytecode_sv U32 s
+stsv bstate->bs_sv U32 s
stop PL_op U32 s
-ldspecsv bytecode_sv U8 x
-newsv bytecode_sv U8 x
+stpv bstate->bs_pv.xpv_pv U32 x
+ldspecsv bstate->bs_sv U8 x
+newsv bstate->bs_sv U8 x
newop PL_op U8 x
newopn PL_op U8 x
newpv none PV
-pv_cur bytecode_pv.xpv_cur STRLEN
-pv_free bytecode_pv none x
-sv_upgrade bytecode_sv char x
-sv_refcnt SvREFCNT(bytecode_sv) U32
-sv_refcnt_add SvREFCNT(bytecode_sv) I32 x
-sv_flags SvFLAGS(bytecode_sv) U32
-xrv SvRV(bytecode_sv) svindex
-xpv bytecode_sv none x
-xiv32 SvIVX(bytecode_sv) I32
-xiv64 SvIVX(bytecode_sv) IV64
-xnv SvNVX(bytecode_sv) NV
-xlv_targoff LvTARGOFF(bytecode_sv) STRLEN
-xlv_targlen LvTARGLEN(bytecode_sv) STRLEN
-xlv_targ LvTARG(bytecode_sv) svindex
-xlv_type LvTYPE(bytecode_sv) char
-xbm_useful BmUSEFUL(bytecode_sv) I32
-xbm_previous BmPREVIOUS(bytecode_sv) U16
-xbm_rare BmRARE(bytecode_sv) U8
-xfm_lines FmLINES(bytecode_sv) I32
-xio_lines IoLINES(bytecode_sv) long
-xio_page IoPAGE(bytecode_sv) long
-xio_page_len IoPAGE_LEN(bytecode_sv) long
-xio_lines_left IoLINES_LEFT(bytecode_sv) long
-xio_top_name IoTOP_NAME(bytecode_sv) pvcontents
-xio_top_gv *(SV**)&IoTOP_GV(bytecode_sv) svindex
-xio_fmt_name IoFMT_NAME(bytecode_sv) pvcontents
-xio_fmt_gv *(SV**)&IoFMT_GV(bytecode_sv) svindex
-xio_bottom_name IoBOTTOM_NAME(bytecode_sv) pvcontents
-xio_bottom_gv *(SV**)&IoBOTTOM_GV(bytecode_sv) svindex
-xio_subprocess IoSUBPROCESS(bytecode_sv) short
-xio_type IoTYPE(bytecode_sv) char
-xio_flags IoFLAGS(bytecode_sv) char
-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_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) U16
-av_extend bytecode_sv SSize_t x
-av_push bytecode_sv svindex x
-xav_fill AvFILLp(bytecode_sv) SSize_t
-xav_max AvMAX(bytecode_sv) SSize_t
-xav_flags AvFLAGS(bytecode_sv) U8
-xhv_riter HvRITER(bytecode_sv) I32
-xhv_name HvNAME(bytecode_sv) pvcontents
-hv_store bytecode_sv svindex x
-sv_magic bytecode_sv char x
-mg_obj SvMAGIC(bytecode_sv)->mg_obj svindex
-mg_private SvMAGIC(bytecode_sv)->mg_private U16
-mg_flags SvMAGIC(bytecode_sv)->mg_flags U8
-mg_pv SvMAGIC(bytecode_sv) pvcontents x
-xmg_stash *(SV**)&SvSTASH(bytecode_sv) svindex
-gv_fetchpv bytecode_sv strconst x
-gv_stashpv bytecode_sv strconst x
-gp_sv GvSV(bytecode_sv) svindex
-gp_refcnt GvREFCNT(bytecode_sv) U32
-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_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
-gp_line GvLINE(bytecode_sv) line_t
-gp_share bytecode_sv svindex x
-xgv_flags GvFLAGS(bytecode_sv) U8
+pv_cur bstate->bs_pv.xpv_cur STRLEN
+pv_free bstate->bs_pv none x
+sv_upgrade bstate->bs_sv char x
+sv_refcnt SvREFCNT(bstate->bs_sv) U32
+sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x
+sv_flags SvFLAGS(bstate->bs_sv) U32
+xrv SvRV(bstate->bs_sv) svindex
+xpv bstate->bs_sv none x
+xiv32 SvIVX(bstate->bs_sv) I32
+xiv64 SvIVX(bstate->bs_sv) IV64
+xnv SvNVX(bstate->bs_sv) NV
+xlv_targoff LvTARGOFF(bstate->bs_sv) STRLEN
+xlv_targlen LvTARGLEN(bstate->bs_sv) STRLEN
+xlv_targ LvTARG(bstate->bs_sv) svindex
+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
+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
+xio_fmt_gv *(SV**)&IoFMT_GV(bstate->bs_sv) svindex
+xio_bottom_name IoBOTTOM_NAME(bstate->bs_sv) pvcontents
+xio_bottom_gv *(SV**)&IoBOTTOM_GV(bstate->bs_sv) svindex
+xio_subprocess IoSUBPROCESS(bstate->bs_sv) short
+xio_type IoTYPE(bstate->bs_sv) char
+xio_flags IoFLAGS(bstate->bs_sv) char
+xcv_stash *(SV**)&CvSTASH(bstate->bs_sv) svindex
+xcv_start CvSTART(bstate->bs_sv) opindex
+xcv_root CvROOT(bstate->bs_sv) opindex
+xcv_gv *(SV**)&CvGV(bstate->bs_sv) svindex
+xcv_file CvFILE(bstate->bs_sv) pvindex
+xcv_depth CvDEPTH(bstate->bs_sv) long
+xcv_padlist *(SV**)&CvPADLIST(bstate->bs_sv) svindex
+xcv_outside *(SV**)&CvOUTSIDE(bstate->bs_sv) svindex
+xcv_flags CvFLAGS(bstate->bs_sv) U16
+av_extend bstate->bs_sv SSize_t 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) pvcontents
+hv_store bstate->bs_sv svindex x
+sv_magic bstate->bs_sv char x
+mg_obj SvMAGIC(bstate->bs_sv)->mg_obj svindex
+mg_private SvMAGIC(bstate->bs_sv)->mg_private U16
+mg_flags SvMAGIC(bstate->bs_sv)->mg_flags U8
+mg_pv SvMAGIC(bstate->bs_sv) pvcontents x
+xmg_stash *(SV**)&SvSTASH(bstate->bs_sv) svindex
+gv_fetchpv bstate->bs_sv strconst x
+gv_stashpv bstate->bs_sv strconst x
+gp_sv GvSV(bstate->bs_sv) svindex
+gp_refcnt GvREFCNT(bstate->bs_sv) U32
+gp_refcnt_add GvREFCNT(bstate->bs_sv) I32 x
+gp_av *(SV**)&GvAV(bstate->bs_sv) svindex
+gp_hv *(SV**)&GvHV(bstate->bs_sv) svindex
+gp_cv *(SV**)&GvCV(bstate->bs_sv) svindex
+gp_file GvFILE(bstate->bs_sv) pvindex
+gp_io *(SV**)&GvIOp(bstate->bs_sv) svindex
+gp_form *(SV**)&GvFORM(bstate->bs_sv) svindex
+gp_cvgen GvCVGEN(bstate->bs_sv) U32
+gp_line GvLINE(bstate->bs_sv) line_t
+gp_share bstate->bs_sv svindex x
+xgv_flags GvFLAGS(bstate->bs_sv) U8
op_next PL_op->op_next opindex
op_sibling PL_op->op_sibling opindex
op_ppaddr PL_op->op_ppaddr strconst x
@@ -399,9 +395,9 @@ 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_stashpv cCOP pvcontents x
-cop_file cCOP pvcontents x
+cop_label cCOP->cop_label pvindex
+cop_stashpv cCOP pvindex x
+cop_file cCOP pvindex x
cop_seq cCOP->cop_seq U32
cop_arybase cCOP->cop_arybase I32
cop_line cCOP line_t x
@@ -409,3 +405,6 @@ 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