From: Dave Mitchell Date: Fri, 4 May 2007 22:18:42 +0000 (+0000) Subject: move some more variables into the PL_parser struct: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f06b58485d86282d0dbf47ffb2a797860a8346a7;p=p5sagit%2Fp5-mst-13.2.git move some more variables into the PL_parser struct: PL_bufptr PL_oldbufptr PL_oldoldbufptr PL_linestart PL_bufend PL_last_uni PL_last_lop PL_last_lop_op p4raw-id: //depot/perl@31147 --- diff --git a/embedvar.h b/embedvar.h index 7f64f8e..c458948 100644 --- a/embedvar.h +++ b/embedvar.h @@ -154,8 +154,6 @@ #define PL_bitcount (vTHX->Ibitcount) #define PL_body_arenas (vTHX->Ibody_arenas) #define PL_body_roots (vTHX->Ibody_roots) -#define PL_bufend (vTHX->Ibufend) -#define PL_bufptr (vTHX->Ibufptr) #define PL_checkav (vTHX->Icheckav) #define PL_checkav_save (vTHX->Icheckav_save) #define PL_clocktick (vTHX->Iclocktick) @@ -228,20 +226,16 @@ #define PL_inplace (vTHX->Iinplace) #define PL_isarev (vTHX->Iisarev) #define PL_known_layers (vTHX->Iknown_layers) -#define PL_last_lop (vTHX->Ilast_lop) -#define PL_last_lop_op (vTHX->Ilast_lop_op) #define PL_last_swash_hv (vTHX->Ilast_swash_hv) #define PL_last_swash_key (vTHX->Ilast_swash_key) #define PL_last_swash_klen (vTHX->Ilast_swash_klen) #define PL_last_swash_slen (vTHX->Ilast_swash_slen) #define PL_last_swash_tmps (vTHX->Ilast_swash_tmps) -#define PL_last_uni (vTHX->Ilast_uni) #define PL_lastfd (vTHX->Ilastfd) #define PL_laststatval (vTHX->Ilaststatval) #define PL_laststype (vTHX->Ilaststype) #define PL_lex_state (vTHX->Ilex_state) #define PL_lineary (vTHX->Ilineary) -#define PL_linestart (vTHX->Ilinestart) #define PL_localpatches (vTHX->Ilocalpatches) #define PL_lockhook (vTHX->Ilockhook) #define PL_madskills (vTHX->Imadskills) @@ -276,9 +270,7 @@ #define PL_numeric_name (vTHX->Inumeric_name) #define PL_numeric_radix_sv (vTHX->Inumeric_radix_sv) #define PL_numeric_standard (vTHX->Inumeric_standard) -#define PL_oldbufptr (vTHX->Ioldbufptr) #define PL_oldname (vTHX->Ioldname) -#define PL_oldoldbufptr (vTHX->Ioldoldbufptr) #define PL_op_mask (vTHX->Iop_mask) #define PL_origalen (vTHX->Iorigalen) #define PL_origargc (vTHX->Iorigargc) @@ -417,8 +409,6 @@ #define PL_Ibitcount PL_bitcount #define PL_Ibody_arenas PL_body_arenas #define PL_Ibody_roots PL_body_roots -#define PL_Ibufend PL_bufend -#define PL_Ibufptr PL_bufptr #define PL_Icheckav PL_checkav #define PL_Icheckav_save PL_checkav_save #define PL_Iclocktick PL_clocktick @@ -491,20 +481,16 @@ #define PL_Iinplace PL_inplace #define PL_Iisarev PL_isarev #define PL_Iknown_layers PL_known_layers -#define PL_Ilast_lop PL_last_lop -#define PL_Ilast_lop_op PL_last_lop_op #define PL_Ilast_swash_hv PL_last_swash_hv #define PL_Ilast_swash_key PL_last_swash_key #define PL_Ilast_swash_klen PL_last_swash_klen #define PL_Ilast_swash_slen PL_last_swash_slen #define PL_Ilast_swash_tmps PL_last_swash_tmps -#define PL_Ilast_uni PL_last_uni #define PL_Ilastfd PL_lastfd #define PL_Ilaststatval PL_laststatval #define PL_Ilaststype PL_laststype #define PL_Ilex_state PL_lex_state #define PL_Ilineary PL_lineary -#define PL_Ilinestart PL_linestart #define PL_Ilocalpatches PL_localpatches #define PL_Ilockhook PL_lockhook #define PL_Imadskills PL_madskills @@ -539,9 +525,7 @@ #define PL_Inumeric_name PL_numeric_name #define PL_Inumeric_radix_sv PL_numeric_radix_sv #define PL_Inumeric_standard PL_numeric_standard -#define PL_Ioldbufptr PL_oldbufptr #define PL_Ioldname PL_oldname -#define PL_Ioldoldbufptr PL_oldoldbufptr #define PL_Iop_mask PL_op_mask #define PL_Iorigalen PL_origalen #define PL_Iorigargc PL_origargc diff --git a/intrpvar.h b/intrpvar.h index 543acd0..5799966 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -189,8 +189,6 @@ PERLVAR(ICmd, char *) /* stuff to free from do_aexec, vfork safe */ PERLVAR(Ipreambleav, AV *) PERLVAR(Imess_sv, SV *) PERLVAR(Iors_sv, SV *) /* output record separator $\ */ - /* Space for one more U16 here without increasing the structure size */ -PERLVAR(Ilast_lop_op, OPCODE) /* last list operator */ PERLVAR(Iin_my, U16) /* we're compiling a "my" (or "our") declaration */ PERLVARI(Ilaststype, U16, OP_STAT) PERLVARI(Ilaststatval, int, -1) @@ -241,8 +239,6 @@ PERLVARI(Iin_clean_all, bool, FALSE) /* from sv.c */ PERLVAR(Inomemok, bool) /* let malloc context handle nomem */ PERLVARI(Isavebegin, bool, FALSE) /* save BEGINs for compiler */ -PERLVAR(Ilinestart, char *) /* beg. of most recently read line */ - PERLVAR(Iuid, Uid_t) /* current real user id */ PERLVAR(Ieuid, Uid_t) /* current effective user id */ PERLVAR(Igid, Gid_t) /* current real group id */ @@ -299,11 +295,6 @@ PERLVARA(Inexttype,5, I32) /* type of next token */ PERLVAR(Inexttoke, I32) #endif -PERLVAR(Ibufptr, char *) -PERLVAR(Ioldbufptr, char *) -PERLVAR(Ioldoldbufptr, char *) -PERLVAR(Ibufend, char *) - PERLVAR(Ilex_state, U8) /* next token is determined */ PERLVAR(Ierror_count, U8) /* how many errors so far, max 10 */ PERLVARI(Icv_has_eval, bool, FALSE) /* PL_compcv includes an entereval or similar */ @@ -322,8 +313,6 @@ PERLVAR(Ipadix, I32) /* max used index in current "register" pad */ PERLVAR(Ipadix_floor, I32) /* how low may inner block reset padix */ PERLVAR(Ipad_reset_pending, I32) /* reset pad on next attempted alloc */ -PERLVAR(Ilast_uni, char *) /* position of last named-unary op */ -PERLVAR(Ilast_lop, char *) /* position of last list operator */ PERLVAR(Iin_my_stash, HV *) /* declared class of this "my" declaration */ PERLVAR(Ihints, U32) /* pragma-tic compile-time flags */ diff --git a/op.c b/op.c index 1c793e3..2f043c0 100644 --- a/op.c +++ b/op.c @@ -2260,10 +2260,11 @@ Perl_localize(pTHX_ OP *o, I32 lex) NOOP; #endif else { - if ( PL_bufptr > PL_oldbufptr && PL_bufptr[-1] == ',' + if ( PL_parser->bufptr > PL_parser->oldbufptr + && PL_parser->bufptr[-1] == ',' && ckWARN(WARN_PARENTHESIS)) { - char *s = PL_bufptr; + char *s = PL_parser->bufptr; bool sigil = FALSE; /* some heuristics to detect a potential error */ diff --git a/parser.h b/parser.h index 847e50a..2dfcfa7 100644 --- a/parser.h +++ b/parser.h @@ -51,6 +51,7 @@ typedef struct yy_parser { OP *lex_op; /* extra info to pass back on op */ SV *lex_repl; /* runtime replacement from s/// */ U16 lex_inwhat; /* what kind of quoting are we in */ + OPCODE last_lop_op; /* last list operator */ I32 lex_starts; /* how many interps done on level */ SV *lex_stuff; /* runtime pattern from m// or s/// */ I32 multi_start; /* 1st line of multi-line string */ @@ -61,6 +62,13 @@ typedef struct yy_parser { SUBLEXINFO sublex_info; SV *linestr; /* current chunk of src text */ line_t copline; /* current line number */ + char *bufptr; + char *oldbufptr; + char *oldoldbufptr; + char *bufend; + char *linestart; /* beginning of most recently read line */ + char *last_uni; /* position of last named-unary op */ + char *last_lop; /* position of last list operator */ #ifdef PERL_MAD SV *endwhite; diff --git a/perl.h b/perl.h index 1ffdba7..1220de1 100644 --- a/perl.h +++ b/perl.h @@ -3287,8 +3287,8 @@ struct _sublex_info { U8 super_state; /* lexer state to save */ U16 sub_inwhat; /* "lex_inwhat" to use */ OP *sub_op; /* "lex_op" to use */ - char *super_bufptr; /* PL_bufptr that was */ - char *super_bufend; /* PL_bufend that was */ + char *super_bufptr; /* PL_parser->bufptr that was */ + char *super_bufend; /* PL_parser->bufend that was */ }; #include "parser.h" diff --git a/perlapi.h b/perlapi.h index 8070abb..0106cdd 100644 --- a/perlapi.h +++ b/perlapi.h @@ -184,10 +184,6 @@ END_EXTERN_C #define PL_body_arenas (*Perl_Ibody_arenas_ptr(aTHX)) #undef PL_body_roots #define PL_body_roots (*Perl_Ibody_roots_ptr(aTHX)) -#undef PL_bufend -#define PL_bufend (*Perl_Ibufend_ptr(aTHX)) -#undef PL_bufptr -#define PL_bufptr (*Perl_Ibufptr_ptr(aTHX)) #undef PL_checkav #define PL_checkav (*Perl_Icheckav_ptr(aTHX)) #undef PL_checkav_save @@ -332,10 +328,6 @@ END_EXTERN_C #define PL_isarev (*Perl_Iisarev_ptr(aTHX)) #undef PL_known_layers #define PL_known_layers (*Perl_Iknown_layers_ptr(aTHX)) -#undef PL_last_lop -#define PL_last_lop (*Perl_Ilast_lop_ptr(aTHX)) -#undef PL_last_lop_op -#define PL_last_lop_op (*Perl_Ilast_lop_op_ptr(aTHX)) #undef PL_last_swash_hv #define PL_last_swash_hv (*Perl_Ilast_swash_hv_ptr(aTHX)) #undef PL_last_swash_key @@ -346,8 +338,6 @@ END_EXTERN_C #define PL_last_swash_slen (*Perl_Ilast_swash_slen_ptr(aTHX)) #undef PL_last_swash_tmps #define PL_last_swash_tmps (*Perl_Ilast_swash_tmps_ptr(aTHX)) -#undef PL_last_uni -#define PL_last_uni (*Perl_Ilast_uni_ptr(aTHX)) #undef PL_lastfd #define PL_lastfd (*Perl_Ilastfd_ptr(aTHX)) #undef PL_laststatval @@ -358,8 +348,6 @@ END_EXTERN_C #define PL_lex_state (*Perl_Ilex_state_ptr(aTHX)) #undef PL_lineary #define PL_lineary (*Perl_Ilineary_ptr(aTHX)) -#undef PL_linestart -#define PL_linestart (*Perl_Ilinestart_ptr(aTHX)) #undef PL_localpatches #define PL_localpatches (*Perl_Ilocalpatches_ptr(aTHX)) #undef PL_lockhook @@ -428,12 +416,8 @@ END_EXTERN_C #define PL_numeric_radix_sv (*Perl_Inumeric_radix_sv_ptr(aTHX)) #undef PL_numeric_standard #define PL_numeric_standard (*Perl_Inumeric_standard_ptr(aTHX)) -#undef PL_oldbufptr -#define PL_oldbufptr (*Perl_Ioldbufptr_ptr(aTHX)) #undef PL_oldname #define PL_oldname (*Perl_Ioldname_ptr(aTHX)) -#undef PL_oldoldbufptr -#define PL_oldoldbufptr (*Perl_Ioldoldbufptr_ptr(aTHX)) #undef PL_op_mask #define PL_op_mask (*Perl_Iop_mask_ptr(aTHX)) #undef PL_origalen diff --git a/sv.c b/sv.c index d989731..f05f4cd 100644 --- a/sv.c +++ b/sv.c @@ -9574,7 +9574,29 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param) parser->linestr = sv_dup_inc(proto->linestr, param); parser->expect = proto->expect; parser->copline = proto->copline; + parser->last_lop_op = proto->last_lop_op; + parser->linestr = sv_dup_inc(proto->linestr, param); + + { + char *ols = SvPVX(proto->linestr); + char *ls = SvPVX(parser->linestr); + + parser->bufptr = ls + (proto->bufptr >= ols ? + proto->bufptr - ols : 0); + parser->oldbufptr = ls + (proto->oldbufptr >= ols ? + proto->oldbufptr - ols : 0); + parser->oldoldbufptr= ls + (proto->oldoldbufptr >= ols ? + proto->oldoldbufptr - ols : 0); + parser->linestart = ls + (proto->linestart >= ols ? + proto->linestart - ols : 0); + parser->last_uni = ls + (proto->last_uni >= ols ? + proto->last_uni - ols : 0); + parser->last_lop = ls + (proto->last_lop >= ols ? + proto->last_lop - ols : 0); + + parser->bufend = ls + SvCUR(parser->linestr); + } #ifdef PERL_MAD parser->endwhite = proto->endwhite; @@ -11239,29 +11261,12 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_nexttoke = proto_perl->Inexttoke; #endif - if (proto_perl->Iparser) { - i = proto_perl->Ibufptr - SvPVX_const(proto_perl->Iparser->linestr); - PL_bufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - i = proto_perl->Ioldbufptr - SvPVX_const(proto_perl->Iparser->linestr); - PL_oldbufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - i = proto_perl->Ioldoldbufptr - SvPVX_const(proto_perl->Iparser->linestr); - PL_oldoldbufptr = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - i = proto_perl->Ilinestart - SvPVX_const(proto_perl->Iparser->linestr); - PL_linestart = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - PL_bufend = SvPVX(PL_parser->linestr) + SvCUR(PL_parser->linestr); - i = proto_perl->Ilast_uni - SvPVX_const(proto_perl->Iparser->linestr); - PL_last_uni = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - i = proto_perl->Ilast_lop - SvPVX_const(proto_perl->Iparser->linestr); - PL_last_lop = SvPVX(PL_parser->linestr) + (i < 0 ? 0 : i); - } - PL_multi_end = proto_perl->Imulti_end; PL_error_count = proto_perl->Ierror_count; PL_subline = proto_perl->Isubline; PL_subname = sv_dup_inc(proto_perl->Isubname, param); - PL_last_lop_op = proto_perl->Ilast_lop_op; PL_in_my = proto_perl->Iin_my; PL_in_my_stash = hv_dup(proto_perl->Iin_my_stash, param); #ifdef FCRYPT diff --git a/toke.c b/toke.c index aa2ec2d..3e10445 100644 --- a/toke.c +++ b/toke.c @@ -52,7 +52,14 @@ #define PL_linestr (PL_parser->linestr) #define PL_expect (PL_parser->expect) #define PL_copline (PL_parser->copline) - +#define PL_bufptr (PL_parser->bufptr) +#define PL_oldbufptr (PL_parser->oldbufptr) +#define PL_oldoldbufptr (PL_parser->oldoldbufptr) +#define PL_linestart (PL_parser->linestart) +#define PL_bufend (PL_parser->bufend) +#define PL_last_uni (PL_parser->last_uni) +#define PL_last_lop (PL_parser->last_lop) +#define PL_last_lop_op (PL_parser->last_lop_op) #ifdef PERL_MAD # define PL_endwhite (PL_parser->endwhite) @@ -673,13 +680,6 @@ Perl_lex_start(pTHX_ SV *line) } #endif SAVECOPLINE(PL_curcop); - SAVEPPTR(PL_bufptr); - SAVEPPTR(PL_bufend); - SAVEPPTR(PL_oldbufptr); - SAVEPPTR(PL_oldoldbufptr); - SAVEPPTR(PL_last_lop); - SAVEPPTR(PL_last_uni); - SAVEPPTR(PL_linestart); SAVEDESTRUCTOR_X(restore_rsfp, PL_rsfp); parser->copline = NOLINE; @@ -709,9 +709,12 @@ Perl_lex_start(pTHX_ SV *line) SvREFCNT_inc_simple_void_NN(line); parser->linestr = line; } - PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = SvPVX(parser->linestr); - PL_bufend = PL_bufptr + SvCUR(parser->linestr); - PL_last_lop = PL_last_uni = NULL; + parser->oldoldbufptr = + parser->oldbufptr = + parser->bufptr = + parser->linestart = SvPVX(parser->linestr); + parser->bufend = parser->bufptr + SvCUR(parser->linestr); + parser->last_lop = parser->last_uni = NULL; PL_rsfp = 0; }