| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
|
| |
This new function inverts a Unicode property. A regular inversion
doesn't work because it operates on the whole of the code space, and
Unicode property inversions don't invert above-Unicode code points.
This does for inversion lists, what an earlier commit did for swashes.
This function is currently not called by anyone.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When smartmatch is about to start, to avoid calling get-magic (e.g.,
FETCH methods) more than once, it copies any argument that has
get-magic.
Tainting uses get-magic to taint the expression. Calling mg_get(sv)
on a tainted scalar causes PL_tainted to be set, causing any scalars
modified by sv_setsv_flags to be tainted. That means that tainting
magic gets copied from one scalar to another.
So when smartmatch tries to copy the variable to avoid repeated calls
to magic, it still copies taint magic to the new variable.
For $scalar ~~ @array (or ~~ [...]), S_do_smartmatch calls itself
recursively for each element of @array, with $scalar (on the suppos-
edly non-magical copy of $scalar) on the left and the element on
the right.
In that recursive call, it again does the get-magic check and copies
the argument. Since the copied of a tainted variable on the LHS is
magical, it gets copied again. Since the first copy is a mortal
(marked TEMP) with a refcount of one, the second copy steal its
string buffer.
The outer call to S_do_smartmatch then proceeds with the second ele-
ment of @array, without realising that its copy of $scalar has lost
its string buffer and is now undefined.
So these produce incorrect results under -T (where $^X is ‘perl’):
$^X =~ ["whatever", undef] # matches
$^X =~ ["whatever", "perl"] # fails
This problem did not start occurring until this commit:
commit 8985fe98dcc5c0af2fadeac15dfbc13f553ee7fc
Author: David Mitchell <davem@iabyn.com>
Date: Thu Dec 30 10:32:44 2010 +0000
Better handling of magic methods freeing the SV
mg_get used to increase the refcount unconditionally, pushing it on to
the mortals stack. So the magical copy would have had a refcount of
2, preventing its string buffer from being stolen. Now it has a ref-
erence count of 1.
This commit solves it by adding a new parameter to S_do_smartmatch
telling it that the variable has already been copied and does not even
need to be checked. The $scalar~~@array case sets that parameter for
the recursive calls. That avoids the whole string-stealing problem
*and* avoids extra unnecessary SVs.
|
|
|
|
|
|
|
|
|
|
| |
The non-constant folding parts of fold_constants are moved into
separate functions. op_integerize handles converting ops to integer
(and special case of OP_NEGATE), op_std_init handling some standard
functionality (forced scalar context and allocating the TARGET).
Both functions are called where fold_constants is called (but we might
want to make that a bit some selective and use op_std_init in other
places).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This resolves perl bug #97978.
Many built-in variables, like $], are actually created on the fly
when first accessed. Perl likes to pretend that these variables have
always existed, so it autovivifies the *] glob even in rvalue context
(e.g., defined *{"]"}, close "]").
The list of variables that were autovivified was maintained separ-
ately (in is_gv_magical_sv) from the code that actually creates
them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it
*wasn’t* being maintained, and there were new variables that never
got added to is_gv_magical_sv and one deleted variable that was
never removed.
There are only two pieces of code that call is_gv_magical_sv, both in
pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions
like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}).
In both cases, the glob is immediately autovivified if
is_gv_magical_sv returns true.
So this commit eliminates the extra maintenance burden by extirpat-
ing is_gv_magical_sv altogether, and replacing it with a new flag to
gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a
magical one.
It does make defined(*{"frobbly"}) slightly slower, in that it creates
a temporary glob and then frees it when it sees nothing magical has
been done with it. But this case is rare enough it should not matter.
At least I got rid of the bugginess.
|
|
|
|
|
|
|
|
|
|
|
|
| |
For functions that take handles as arguments, this code will need to
call static functions in op.c, like is_handle_constructor.
While we could make is_handle_constructor into a non-static function
and call it from gv.c, that seems backwards, as it would result in a
lot of op-manipulation code in the middle of gv.c.
So this commit creates a new function in op.c, called coresub_op,
which is only called from gv.c, from the &CORE::sub code.
|
|
|
|
|
|
|
|
|
|
| |
Subs in the CORE package with a (_) prototype will use this.
This accepts a CV and a sequence number, so that one can
use it to find the $_ in the caller’s scope. It only uses
the topmost call of a subroutine that is being called recur-
sively, so it’s not really a general-purpose function. But
it suffices for &CORE::abs and friends.
|
|
|
|
|
|
|
|
| |
scalarvoid.
Why: The in place assignment is not just an optimisation but has
significant different behaviour and thus doesn't belong in the
peephole optimiser. Also the optree changes are unified and simpler.
|
|
|
|
|
|
|
|
|
| |
This reverts commit e52d58aa5bea245b66786b4c9029e849a2be69d3.
I don’t quite know how I managed it, but I really screw up
this time! Two completely unrelated commits ended up getting
merged into one, so, to avoid confusion down the road, I’m
reverting it, only to reapply it shortly....
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
unpack is the only op that takes an implicit $_ for its second argu-
ment. (For others it’s the first.)
Instead of special-casing unpack with its own ck_ routine, we can sim-
ply modify the logic in ck_fun to apply OA_DEFGV to the first optional
argument, not just the first argument.
Currently OA_DEFGV is not set in PL_opargs[OP_UNPACK], which means the
automatically-generated prototype is ($;$), instead of ($_).
This commit sets the flag on the op, changes it to use ck_fun
directly, and updates ck_fun and the prototype-generation code accord-
ingly. I couldn’t put this in multiple commits, as the changes are
interdependent.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit b8c38f0a2a65 refactored pp_prototype by moving much of its
code to a new function in op.c, called core_prototype. This served
two purposes: (1) to allow the code to be simplified, which required
the use of static functions in op.c, and (2) to allow the &CORE::subs
feature to share the same code.
But some code was moved to core_prototype which, in hindsight, did not
need to be moved, such as the ‘Can’t find an opnumber’ message.
This commit moves that code back to pp_prototype, resulting in a sim-
pler (and possibly faster, at least for &CORE::subs) core_prototype.
|
|
|
|
|
|
|
| |
Since it has to calculate it, it might as well provide it, so callers
do not have to go through that while(i < MAXO) loop yet again.
(The &CORE::foo feature will use this.)
|
| |
|
|
|
|
|
|
|
| |
After mod was renamed to op_lvalue, this stub was added temporarily
to provide a smoother transition for the compilers. The compiler
maintainer is happy with its extirpation at this stage. See
ticket #78908.
|
|
|
|
|
|
|
|
|
|
|
|
| |
checking/finalization now being done by the peephole optimizer.
This function takes the optree after it is finished building. It
takes over some of the checking and final conversions which are currently being
done by the peephole optimizer.
Add the moment this is an unnecessary extra step after the peephole optimizer, but with
a separate code generation step, the current peephole optimizer can't exists and
this function will take over all its essential compile time functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit moves the code for generating core prototypes into a sepa-
rate function, core_prototype, in op.c. This serves two porpoises:
• It allows the lock and tie exceptional cases to be incorporated into
the main prototype=generation code, which requires the use of a
static function in op.c.
• It allows other parts of the core (e.g., the upcoming \&CORE::foo
feature) to use the same code.
The docs for it are in a section boringly entitled ‘Functions in
op.c’, for lack of a better name. This, I believe, is the only op.c
function that is in perlintern currently, so it’s hard to see what to
name a section that will, at least for now, contain nothing else.
|
|
|
|
|
| |
PERL_IMPLICIT_SYS only builds on Win32.
Correct embed.fnc to reflect the reality.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
OK, now I understand what’s happening.
If there is a public macro (PUSHSUB) that contains a call to a pri-
vate function (was_lvalue_sub), that function has to be exported, so
that non-core code can call it. But if it is marked X, there is no
was_lvalue_sub shorthand macro visible to non-core code, so when the
PUSHSUB macro is expanded in such code, the was_lvalue_sub(...) bit
becomes a call to the function literally named was_lvalue_sub, as
opposed to Perl_lvalue_sub (and is compiled that way on forgiving
platforms). Making it A makes that macro available to non-core code,
but also implies that it is available for direct use by extensions,
which is not the case with was_lvalue_sub.
So, this commit makes it X again, but spells it out in PUSHSUB, so
there is no need for the function’s macro to be available when
PUSHSUB is expanded.
Hence, there is no need for the was_lvalue_sub macro to exist, so this
commit also removes it.
See also these three commits:
c73b0699db
7b70e81778
777d901444
|
| |
|
|
|
|
|
|
|
| |
Move several pad functions into the core API. Document the pad
functions more consistently for perlapi. Fix the interface issues
around delimitation of lexical variable names, providing _pvn, _pvs,
_pv, and _sv forms of pad_add_name and pad_findmy.
|
|
|
|
|
|
| |
7b70e8177801df4e142684870ce037d584f72e7b was my (wrong) suggestion,
and it made the symbol only visible when PERL_CORE was defined,
which it isn't in List::Util.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this commit, this code would fail:
$foo = "foo";
sub foo :lvalue{ return index "foo","o" }
sub bar :lvalue { foo }
$x = bar;
(It would fail for ‘return $]’ as well. Whether it’s a PADTMP or a
read-only scalar makes no difference.)
foo would think it was being called in true lvalue context, because
the entersub op that called it (in bar) was marked that way, bar being
an lvalue sub as well.
The PUSHSUB macro in cop.h needed to be modified to account for
dynamic, or indetermine, context (i.e., indeterminable at compile
time). This happens when an entersub op is an argument to return or
the last statement in a subroutine. In those cases it has to propa-
gate the context from the caller.
So what we now do is this: Both lvalue and in-args flags are turned on
for an entersub op when op_lvalue is called with OP_LEAVESUBLV as the
type. Then PUSHSUB copies into the context stack only those flags
that are set both on the current entersub op and in the context stack
for the previous sub call.
|
|
|
|
|
| |
These functions are internal only with names beginning with underscore.
I hadn't realized that their definitions could be restricted.
|
| |
|
|
|
|
|
| |
This is in preparation for them to be called from another file. Note
that they are still protected by an #ifdef in embed.fnc.
|
|
|
|
|
|
| |
The names now begin with an underscore to emphasize that they are
for internal use only. This is in preparation for making them
accessible beyond regcomp.c.
|
|
|
|
| |
This adds inversion, cloning, and set subtraction
|
|
|
|
|
| |
This element is restricted to either 0 or 1. The comments detail
how its use enables an inversion list to be efficiently inverted.
|
|
|
|
|
| |
Future changes will make the length no longer the same as SvCUR,
so create an element to hold the correct length
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This hasn't been used since 626725768b7b17463e9ec7b92e2da37105036252
Author: Nicholas Clark <nick@ccl4.org>
Date: Thu May 26 22:29:40 2011 -0600
regcomp.c: Fix memory leak regression
here was a remaining memory leak in the new inversion lists data
structure under threading. This solves it by changing the
implementation to use a SVpPV instead of doing our own memory
management. Then the already existing code for handling SVs
returns the memory when done.
|
|
|
|
|
|
| |
The invlist_destroy function was misleading, as it has changed to
just decrement the reference count, which may or may not lead to
immediate destruction
|
|
|
|
|
|
|
| |
These are static functions so no external effect. Revise the calling
sequence of two functions so that they can know enough to free
memory if appropriate of the other parameters. This hides from the
callers the need for tracking when to free memory.
|
|
|
|
| |
This is just a refactoring. There should be no functional changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extract most of the body of pp_ncmp() (numeric compare) into a separate
function, do_ncmp(), then make the following ops use it:
pp_ncmp
pp_lt
pp_le
pp_eq
pp_ne
pp_ge
pp_gt
This removes a lot of similar or duplicated code, most of which is
dedicated to handling the various combinations of IV verses UV verses NV
verses NaN.
The various ops first check for, and directly process, the simple and common
case of both args being SvIOK_notUV(), and pass the processing on to
do_ncmp() otherwise. Benchmarking seems to indicate (but with a lot of
noise) that the SvIOK_notUV case is slightly faster than before, and the
do_ncmp() branch slightly slower.
|
|
|
|
|
|
|
|
|
|
| |
Add flags param to op_lvalue, so that the caller can ask it not to
croak when encountering an unmodifiable op (upcoming).
This is in preparation for making the \$ prototype accept any lvalue.
There is no mathom, as the changes that this will support
are by no means suitable for maint.
|
|
|
|
|
|
|
|
| |
There was a remaining memory leak in the new inversion lists data
structure under threading. This solves it by changing the
implementation to use a SVpPV instead of doing our own memory
management. Then the already existing code for handling SVs
returns the memory when done.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move body of hfreeentries()' central loop into a new function,
hfree_next_entry(); leaving hfreeentries() as a simple loop that calls
hfree_next_entry() until there are no entries left.
This will in future allow sv_clear() to free a hash iteratively rather
than recursively.
Similarly, turn hv_free_ent() into a thin wrapper around a new function,
hv_free_ent_ret(), which doesn't free HeVAL(), but rather just returns the
SV instead.
|
|
|
|
|
|
|
|
|
|
| |
And also to_uni_fold().
The flag allows retrieving either simple or full folds.
The interface is subject to change, so these are marked experimental
and their names begin with underscore. The old versions are turned
into macros calling the new versions with the correct extra parameter.
|
|
|
|
| |
See ticket #80626.
|
| |
|
|
|
|
|
| |
These two functions now have identical code, so merge them, but use
a macro in case they ever need to diverge again.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A side-effect of change 3185893b8dec1062 was to force av in S_incpush() to be
NULL, whilst other flag variables were still set as if it were non-NULL, for
certain cases, only when compiled with -DPERL_IS_MINIPERL
The "obvious" fix is to also set all the flag variables to 0 under
-DPERL_IS_MINIPERL, to make everything consistent. However, this confuses (at
least) the local version of gcc, which issues warnings about passing a NULL
value (av, known always to be NULL) as a not-NULL parameter, despite the fact
that all the relevant calls are inside blocks which are actually dead code,
due to the if() conditions being const variables set to 0 under
-DPERL_IS_MINIPERL.
So to avoid future bug reports about compiler warnings, the least worst thing
to do seems to be to use #ifndef to use the pre-processor to eliminate the
dead code, and related variables.
|
|
|
|
|
|
| |
A pointer to the list of multi-char folds in an ANYOF node is now passed
to the routines that set the bit map. This is in preparation for those
routines to add to the list
|
|
|
|
|
| |
This is just an inline shorthand when a single code point is all that is
needed. A macro could have been used instead, but this just seemed nicer.
|
|
|
|
| |
A future commit uses this same code, so put it into a common place.
|
|
|
|
|
|
|
|
|
|
| |
Previously this used a home-grown definition of an identifier start,
stemming from a bug in some early Unicode versions. This led to some
problems, fixed by #74022.
But the home-grown solution did not track Unicode, and allowed for
characters, like marks, to begin words when they shouldn't. This change
brings this macro into compliance with Unicode going-forward.
|
|
|
|
|
| |
The parameter doesn't do anything yet. The old version becomes a macro
calling the new version with 0 as the flags.
|
| |
|