| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is for two reasons:
• In S_my_kid, the attribute-handling code comes before the code that
marks the padop as being a state instead of a my, which it knows to
do based on the value of PL_parser->in_my. The attribute-handling
code begins by setting PL_parser->in_my to FALSE, preventing the
code that follows from doing its job.
So now PL_parser->in_my is read at the top of S_my_kid, before the
attribute code, with the statehood recorded in a boolean. Then the
code that marks the padop as being state checks that boolean
instead of in_my.
• A lexical variable declaration that has an attribute and is assigned
to in the same expression compiles to something similar to:
(attributes->import(... \$x ...), my $x) = 3;
where the list is actually in scalar context, returning the my $x
which is then assigned to (something that cannot be expressed
directly in Perl syntax). So Perl_ck_sassign needs to take that list
op into account when creating the ‘once’ op that actually makes
state assignment work. Up till now it was just looking for a padsv
on its LHS. This commit makes it check also for a list op whose last
item is a padsv.
|
|
|
|
|
|
|
|
|
|
| |
Quoting op.c:
/* /$x/ may cause an eval, since $x might be qr/(?{..})/ */
But the (?{..})’s compilation is only ever reached in the scope of
‘use re 'eval'’, so we can avoid setting PL_cv_has_eval (and the
slight overhead that entails) when that pragma is off.
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this patch:
$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = 1 or die}'
Found = in conditional, should be == at -e line 1.
Since the value of a constant may not be known at the time the program
is written, it should be perfectly acceptable to do a constant assign-
ment in a conditional.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
main::b in this example shows a null op that has the if() statement
attached to it.
$ perl -MO=Concise,a,b -e 'my $x;sub a {$x}; sub b{if($x){}0}'
main::a:
3 <1> leavesub[1 ref] K/REFC,1 ->(end)
- <@> lineseq KP ->3
1 <;> nextstate(main 2 -e:1) v ->2
2 <0> padsv[$x:FAKE:] ->3
main::b:
a <1> leavesub[1 ref] K/REFC,1 ->(end)
- <@> lineseq KP ->a
4 <;> nextstate(main 5 -e:1) v ->5
- <1> null vK/1 ->8
6 <|> and(other->7) vK/1 ->8
5 <0> padsv[$x:FAKE:] s ->6
- <@> scope vK ->-
7 <0> stub v ->8
8 <;> nextstate(main 5 -e:1) v ->9
9 <$> const[IV 0] s ->a
-e syntax OK
Perl_op_const_sv has:
if (type == OP_NEXTSTATE || type == OP_NULL || type == OP_PUSHMARK)
continue;
It traverses from the null to the const. The const’s op_next pointer
points to the leavesub, so it is taken to be a constant.
It returns to newATTRSUB, which turns on CvCONST without assigning a
constant value.
Later, cv_clone (called by pp_anoncode) calls op_const_sv again. The
latter returns the SV from the first PADSV it finds, which is the $x
in if($x).
This commit stops op_const_sv from skipping over null ops that
have children.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This bug has been present in non-threaded builds for a long time.
Change 38bb37b9aa introduced it to threaded builds.
$hash{...} makes its operand a shared-PV scalar if it is an OP_CONST.
But \"foo" is also an OP_CONST, as is anything generated with use
constant. This is the sort of thing that results:
$ perl5.8.5 -MO=Concise -e '$a{\"foo"}'
7 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
6 <2> helem vK/2 ->7
4 <1> rv2hv sKR/1 ->5
3 <$> gv(*a) s ->4
5 <$> const(PVIV "SCALAR(0x81b378)") s ->6
-e syntax OK
(My 5.8.5 installation is non-threaded.)
See the "SCALAR(0x81b378)" in there?
So this commit skips that optimisation if the key is ROK or if it is a
PVMG or higher.
|
| |
|
|
|
|
| |
as requested by Reini Urban [perl #78908]
|
|
|
|
|
| |
As mentioned in the RT ticket, ac56e7d did not take PERLDB_NOOPT
into account.
|
|
|
|
|
|
| |
Previously in a BEGIN block, require was behaving identically to use 5.12.0 -
ie erroneously executing the use feature ':5.12.0'; and use strict;
use warnings behaviour, which only use was documented to provide.
|
|
|
|
|
|
|
|
|
|
|
| |
Previously it was using cv_undef() to (partially) free the target CV (the
pre-existing stub), before donating it the padlist and outside pointers from
the source CV (the definition, just compiled), and then freeing up the remains
of the source CV.
Instead, explicitly exchange padlist and outside pointers, explicitly assign
other fields that need changing (file and stash), and assert that various
CvFLAGS are as we expect them.
|
|
|
|
|
| |
Provide a Perl_newSUB() function in mathoms.c for anyone referencing it by its
full name.
|
|
|
|
| |
This will allow the non-API function Perl_pad_undef to be inlined into it.
|
|
|
|
| |
Even if the xop description couldn't be fetched from PL_custom_op_descs.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the custom op registrations from two separate hashes to one hash
holding structure pointers, and add API functions to register ops and
look them up. This will make it easier to add new properties of custom
ops in the future. Copy entries across from the old hashes where
necessary, to preserve compatibility.
Add two new properties, in addition to the already-existing 'name' and
'description': 'class' and 'peep'. 'class' is one of the OA_*OP
constants, and allows B and other introspection mechanisms to work with
custom ops that aren't BASEOPs. 'peep' is a pointer to a function that
will be called for ops of this type from Perl_rpeep.
Adjust B.xs to take account of the new properties, and also to give
custom ops their registered name rather than simply 'custom'.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All built-in functions that operate directly on array or hash
containers now also accept hard references to arrays or hashes:
|----------------------------+---------------------------|
| Traditional syntax | Terse syntax |
|----------------------------+---------------------------|
| push @$arrayref, @stuff | push $arrayref, @stuff |
| unshift @$arrayref, @stuff | unshift $arrayref, @stuff |
| pop @$arrayref | pop $arrayref |
| shift @$arrayref | shift $arrayref |
| splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 |
| keys %$hashref | keys $hashref |
| keys @$arrayref | keys $arrayref |
| values %$hashref | values $hashref |
| values @$arrayref | values $arrayref |
| ($k,$v) = each %$hashref | ($k,$v) = each $hashref |
| ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref |
|----------------------------+---------------------------|
This allows these built-in functions to act on long dereferencing
chains or on the return value of subroutines without needing to wrap
them in C<@{}> or C<%{}>:
push @{$obj->tags}, $new_tag; # old way
push $obj->tags, $new_tag; # new way
for ( keys %{$hoh->{genres}{artists}} ) {...} # old way
for ( keys $hoh->{genres}{artists} ) {...} # new way
For C<push>, C<unshift> and C<splice>, the reference will auto-vivify
if it is not defined, just as if it were wrapped with C<@{}>.
Calling C<keys> or C<values> directly on a reference gives a
substantial performance improvement over explicit dereferencing.
For C<keys>, C<values>, C<each>, when overloaded dereferencing is
present, the overloaded dereference is used instead of dereferencing
the underlying reftype. Warnings are issued about assumptions made in
the following three ambiguous cases:
(a) If both %{} and @{} overloading exists, %{} is used
(b) If %{} overloading exists on a blessed arrayref, %{} is used
(c) If @{} overloading exists on a blessed hashref, @{} is used
|
|
|
|
|
| |
Commit c427f4d2d4575fbc8a5190932fe321136c7597b3 in 5.10.1 made sprintf()
ignore LC_NUMERIC for numeric constants.
|
|
|
|
|
|
| |
The function scope() goes into the API as op_scope(), and mod() goes
into the API as op_lvalue(). Both marked experimental, because their
behaviour is a little quirky and not trivially dequirkable.
|
|
|
|
|
|
| |
Now that CvSTASH requires backreference bookkeeping, stop people from
directly assigning to it (by using CvSTASH() as an lvalue), and instead
force them to use CvSTASH_set().
|
|
|
|
|
|
|
|
|
| |
Remove the line number parameter from newWHILEOP() and newFOROP()
functions. Instead, the line number for the impending COP is set by
parser code after constructing the ops. (In fact the parser was doing
this anyway in most cases.) This brings newWHILEOP() and newFOROP()
in line with the other op constructors, in that they do not concern
themselves with COPs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactoring of the grammar around statements. New production <barestmt>
encompasses a statement without label. It includes all statement types,
including declarations, with no unnecessary intermediate non-terminals.
It generates an op tree for the statement's content, with no leading
state op. The <fullstmt> production has just one rule, consisting of
optional label followed by <barestmt>. It puts a state op on the front
of the statement's content ops.
To support the regular statement op structure, the op sequence for for(;;)
loops no longer has a second state op between the initialisation and
the loop. Instead, the unstack op type is slightly adapted to achieve
the stack clearing without a state op.
The newFOROP() constructor function no longer generates a state op,
that now being the job of the <fullstmt> production. Consequently it
no longer takes a parameter stating what label is to go in the state op.
This brings it in line with the other op constructors.
|
|
|
|
|
|
|
|
|
|
| |
Stop *{} from returning globs with the SVf_FAKE flag on.
It removes three tests from t/op/gv.t (that I added) that test buggy
edge cases that can no longer occur.
It also modifies tests in t/io/defout.t to keep them passing. I am not
sure that test script serves any purpose any more.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The C<+> prototype is a special alternative to C<$> that will act like
C<\[@%]> when given a literal array or hash variable, but will otherwise
force scalar context on the argument. This is useful for functions which
should accept either a literal array or an array reference as the argument:
sub smartpush (+@) {
my $aref = shift;
die "Not an array or arrayref" unless ref $aref eq 'ARRAY';
push @$aref, @_;
}
When using the C<+> prototype, your function must check that the argument
is of an acceptable type.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Expose cop hint hashes as a type COPHH, with a cophh_* API which is a
macro layer over the refcounted_he_* API. The documentation for cophh_*
describes purely API-visible behaviour, whereas the refcounted_he_*
documentation describes the functions mainly in terms of the
implementation. Revise the cop_hints_* API, using the flags parameter
consistently and reimplementing in terms of cophh_*. Use the cophh_*
and cop_hints_* functions consistently where appropriate.
[Modified by the committer to update two calls to
Perl_refcounted_he_fetch recently added to newPMOP.]
|
| |
|
|
|
|
|
| |
lex_start() is added to the API, marked experimental, and documented.
It also gains a flags parameter for foreseeable future use.
|
|
|
|
|
|
|
|
| |
The only uses of lex_start that had the new_filter parameter false,
to make the new lexer context share source filters with the previous
lexer context, were uses with rsfp null, which therefore never invoked
source filters. Inheriting source filters from a logically unrelated
file seems like a silly idea anyway.
|
| |
|
|
|
|
|
| |
Also rename the underlying function to op_linklist, to match the other
API op functions.
|
|
|
|
|
|
| |
Put into the API op_append_elem, op_prepend_elem, and op_append_list. All
renamed from op_-less internal names. Parameter types for op_append_list
changed to match the rest of the op API and avoid some casting.
|
|
|
|
|
|
|
|
|
| |
Allowing BhkENTRY(bhk, start) to look up the bhk_start member defeats
much of the point of having a bhk_ prefix in the first place: if a
member is added later called (say) 'bhk_die', any invocation of
BhkENTRY(bhk, die) will expand to BhkENTRY(bhk, Perl_die) because of the
API macros. Requiring BhkENTRY(bhk, bhk_start), while tedious, is much
safer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New magic type PERL_MAGIC_checkcall attaches a function to a CV, which
will be called as the second half of the op checker for an entersub
op calling that CV. Default state, in the absence of this magic,
is to process the CV's prototype if it has one, or apply list context
to all the arguments if not. New API functions cv_get_call_checker()
and cv_set_call_checker() provide a clean interface to this facility,
hiding the internal use of magic.
Expose in the API the new functions rv2cv_op_cv(),
ck_entersub_args_list(), ck_entersub_args_proto(), and
ck_entersub_args_proto_or_list(), which are meaningful segments of
standard entersub op checking and are likely to be useful in plugged-in
call checker functions.
Expose new API function op_contextualize(), which is a public interface
to the internal scalar()/list()/scalarvoid() functions. This API is
likely to be required in most plugged-in call checker functions.
Incidentally add new function mg_free_type(), in the API, which will
remove magic of one type from an SV. (mg_free() removes all magic,
and there isn't anything else more selective.)
|
|
|
|
| |
This is left over from PERL_OBJECT (see beeff2, 16c915, and so on).
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make embed.pl fully responsible for generating prototypes and embedding macros
for pp_* and ck_* functions, placing them in embed.h and proto.h
opcode.pl no longer generates pp_proto.h
Remove the (effectively) duplicate explicit entries for (all but 2) ck_*
functions from embed.fnc
We can't actually remove pp_proto.h from the distribution *yet*, as
ExtUtils::MM_Unix and ExtUtils::MM_VMS have hardcoded lists of the installed
headers. Once this is resolved, we can.
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds recognition of these modifiers, with appropriate action
for d and l. u does nothing useful yet. This allows for the
interpolation of a regex into another one without losing the character
set semantics that it was compiled with, as for the first time, the
semantics is now specified in the stringification as one of these
modifiers.
To this end, it allocates an unused bit in the structures. The off-
sets change so as to not disturb other bits.
|
|
|
|
|
|
|
|
|
|
|
|
| |
$text =~ ( 1 ? /phoo/ : /bear/)
used to be constant-folded to
$text =~ /phoo/
This patch solves the problem by marking match and subst ops as
OPf_SPECIAL during constant folding, so the =~ operator can tell not
to take possession of it.
|
| |
|
|
|
|
|
| |
A good optimising compiler can already spot this, but removing dead code makes
it easier for the humans.
|
|
|
|
|
| |
The implementation of assertions was (mostly) removed in 584420f022db5722.
It turns out that b1233c72f2dabb53 didn't remove the last vestige of it.
|
|
|
|
|
|
| |
The later conditional setting of HINT_STRICT_REFS and of OPpENTERSUB_DB are
unaffected by any code triggered by cvop->op_type. Moving them together lets
the C compiler produce better code.
|
|
|
|
|
| |
This reveals that there is no need to set the variable prev when looping for
the !proto case.
|
|
|
|
|
|
| |
Prototype checking is currently 165 lines of code. The rest of the while loop
is 19, including comments. It's much easier to see how prototype checking fits
into the structure this way, *and* it avoids a repeated if check inside a loop.
|
| |
|
|
|
|
|
|
| |
ref_array_or_hash did not take aslice or hslice OPs into account; wrap
them in an anonlist so that smart matching has a reference as it
expects.
|
|
|
|
|
|
|
| |
Instead pass in a COP, as suggested by Ben Morrow. Also add length and flags
parameters, and remove the comment suggesting this change. The underlying
storage mechanism can honour length and UTF8/not, so there is no harm in
exposing this one level higher.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, in code such as
use constant DEBUG=>0;
sub GAK {
warn if DEBUG;
print "stuff\n";
}
the ops for C<warn if DEBUG;> would be folded to a null op (ex-const), but
the nextstate op would remain, resulting in a runtime op dispatch of nextstate,
nextstate, ...
The execution of a sequence of nexstate ops is indistinguishable from just the
last nextstate op, so teach the peephole optimiser to eliminate the first of a
pair of nextstate ops. (Except where the first carries a label, as labels
mustn't be eliminated by the optimiser, and label usage isn't conclusively
known at compile time.)
|
|
|
|
|
|
|
|
| |
New variable PL_rpeepp makes it possible for extensions to hook
the per-op-chain part of the peephole optimiser (which recurses into
side chains). The existing variable PL_peepp still allows hooking the
per-sub part of the peephole optimiser, maintaining perfect backward
compatibility.
|