| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
Cf. RT #110208.
- Remove missing unused variables: op.c, regcomp.c
- Silence -Wformat type error: sv.c
- Cast first part of (,) expression as (void): gv.c
|
|
|
|
| |
so that stringification will be able to use it, too.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
newATTRSUB requires the sub name to be passed to it wrapped up in
a const op.
Commit 8756617677dbd allowed it to accept a GV that way, since
S_maybe_add_coresub (in gv.c) needed to pass it an existing GV not in
the symbol table yet (to simplify code elsewhere).
This had the inadvertent side-effect of making the GV read-only, since
that’s what the check function for const ops does.
Even if we were to call this a feature, it wouldn’t make sense as
implemented, as GVs for non-ampable (&-able) subs like *CORE::chdir
were not being made read-only.
This commit adds a new flag to newATTRSUB, to allow a GV to be passed
as the o parameter, instead of an op. While this may look as though
it’s undoing the simplification in commit 8756617677dbd by adding
more code, the new code is still conceptually simpler and more
straightforward.
Since newATTRSUB is in the API, I had to add a new _flags variant.
(How did newATTRSUB get into the API to begin with?)
In adding a test, I also discovered that ‘used once’ warnings
were applying to these subs, which is obviously wrong. Commit
8756617677dbd caused that, too, as it was relying on the side-effect
of newATTRSUB doing a GV lookup.
This fixes that, too, by turning on the multi flag in
S_maybe_add_coresub.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The same applies to %-.
This is something I broke when merging is_magical_gv with
gv_fetchpvn_flags.
gv_fetchpvn_flags must make sure its *+ glob is present in the symbol
table when it loads Tie::Hash::NamedCapture. If it adds it afterwards
it will clobber another *+ that Tie::Hash::NamedCapture has autovivi-
fied and tied in the mean time.
|
|
|
|
|
|
|
|
|
| |
This is something I broke when merging is_magical_gv with
gv_fetchpvn_flags.
gv_fetchpvn_flags must make sure its *! glob is present in the sym-
bol table it loads Errno. If it adds it afterwards it will clobber
another *! that Errno has autovivified and tied in the mean time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Mentioning $& in a program slows everything down, because it force
regular expressions to do a pre-match copy.
It used to happen for any symbol named &, e.g., @& and %&. This was
changed in commit b4a9608f339, but that commit did not take into
account that the code path in question is only followed on creation of
the *& glob.
It should still be applying magic to $&, even if it is not setting
PL_sawampersand. The other place in gv_fetchpvn_flags that magical-
ises scalars (which currently handles %- %+ %! $] and @ISA), should
also turn on PL_sawampersand for $&.
All of the above applies to $' and $` as well.
|
|
|
|
|
| |
Commit 8756617677 did not take into account that newSVOP steals a ref-
erence count.
|
|
|
|
|
|
|
|
|
|
|
| |
It was working around the fact that newATTRSUB expects to be able to
look up the GV by name.
And for speed, it was going through hoops to try to avoid creating
extra SVs holding the name unnecessarily.
By tweaking newATTRSUB to accept a GV instead of a name, we can sim-
plify not only S_maybe_add_coresub but all its callers, too.
|
|
|
|
|
| |
In two instances, I actually modified to code to avoid %s for a
constant string, as it should be faster that way.
|
|
|
|
| |
It wasn’t close enough for diag.t to see it.
|
|
|
|
|
|
|
| |
Instead of using FEATURE_IS_ENABLED("say"), etc., now use
FEATURE_SAY_IS_ENABLED instead. These new macros, in feature.h, also
check feature bundle hints in PL_hints, so we can start using those
hints. Two commits ago, feature.pm started setting them.
|
|
|
|
| |
This will make it possible to create macros for each.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds the array_base feature to feature.pm
Perl_feature_is_enabled has been modified to use PL_curcop, rather
than PL_hintgv, so it can work with run-time hints as well.
(PL_curcop holds the current state op at run time, and &PL_compiling
at compile time, so it works for both.) The hints in $^H are not
stored in the same place at compile time and run time, so the FEATURE_IS_ENABLED macro has been modified to check first whether
PL_curop == &PL_compiling.
Since array_base is on by default with no hint for it in %^H, it is
a ‘negative’ feature, whose entry in %^H turns it off. feature.pm
has been modified to support such negative features. The new FEATURE_IS_ENABLED_d can check whether such default features
are enabled.
This does make things less efficient, as every version declaration
now loads feature.pm to disable all features (including turning off
array_base, which entails adding an entry to %^H) before loading the
new bundle. I have plans to make this more efficient.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Consider an arithmetic assignment operation of the form
$left += $right
A segfault was occuring in the case where $right is an overloaded object
but $left is not; and where $right does not override "+=" but does
provide a 'nomethod' override. Internally, Perl_amagic_call was
attempting to clone $left as if it were an overloaded object, causing the
segfault. This commit fixes the segfault by only cloning the left
operand when the left operand is the overloaded one.
|
|
|
|
|
|
|
|
|
|
| |
The code in gv.c for loading a tie module automatically
(S_require_tie_mod) was only loading the module if its stash did not
exist or if a particular method (usually TIEHASH) could not be found.
But it was triggering autoloading, such that a universal AUTOLOAD
method would allow it to ‘find’ the method it was looking for, even if
it did not exist. So autovivifying the package somehow (e.g., by men-
tioning one of its symbols) could prevent the module from loading.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This type of thing isn’t officially supported, but perl shouldn’t be
freeing unallocated memory (the 9th octet of a freed HEK) as a result:
$::{whatever} = __PACKAGE__;
*{"whatever"};
A string stored in the symbol table like that is actually a subroutine
stub. ‘sub foo($)’ is stored as '$' in the "foo" slot to save space.
gv_init_pvn (formerly known as gv_init) checks SvPOK first thing,
assuming, if it is set, that it can reuse SvPVX as the CV’s prototype,
without reallocating or copying it. That works most of the time.
For COW strings (such as those returned by __PACKAGE__), SvPVX points
to the hek_key field (the 9th octet) of a shared HEK. When the CV is
freed, it ends up trying to do Safefree(that_hek + 8) effectively,
which is bad.
|
|
|
|
| |
This function doesn’t take that flag. It wasn’t doing anything.
|
|
|
|
|
|
| |
When an optimised constant is promoted to a CV, the name’s length can
be passed straight to newCONSTSUB_flags, as it now has a length param-
eter which it passes to newXS_len_flags.
|
|
|
|
|
| |
This function was added after 5.14.0, so it is not too late to
change it. It is currently unused.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
gv_efullname4 produces undef if the GV points to no stash, instead of
using __ANON__, as it does when the stash has no name.
Instead of going through hoops to try and work around it elsewhere, fix
gv_efullname4.
This means that
$x = *$io;
$x .= "whate’er";
no longer produces an uninitialized warning. (The warning was rather
strange, as defined() returned true.)
This commit also gives the glob the name $__ANONIO__ (yes, with a dol-
lar sign). It may seem a little strange, but there is precedent in
other autovivified globs, such as those open() produces when it cannot
determine the variable name (e.g, open $t->{fh}).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit reimplements $[ using PL_check hooks, custom pp func-
tions and ties.
Outside of its compile-time use, $[ is now parsed as a simple varia-
ble, so function calls like foo($[) are permitted, which was not the
case with the former implementation removed by e1dccc0. I consider
that a bug fix.
The ‘That use of $[ is unsupported’ errors are out of necessity
deferred to run-time and implemented by a tied $[.
Indices between 0 and the array base are now treated consistently, as
are indices between a negative array base and zero. That, too, is
a bug fix.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In 5.6.0, XS autoloading worked. $AUTOLOAD would be set, as with
a Perl sub.
Commit ed850460 (5.6.1) allowed ‘sub AUTOLOAD;’ to prevent autoload
inheritance. But the code to check for that mistakenly equated an
XSUB with a forward declaration. So XS autoloading simply did not
work any more.
Then someone found it didn’t work and introduced it as a ‘new’ feature
in 5.8.0, with commit adb5a9ae. For efficiency’s sake, instead of
joining the package name and sub name together, only to have the XSUB
do the same, it set the CvSTASH and SvPVX fields of the SV.
SvPVX was already being used for the sub’s prototype, so 8fa6a409
(just recently) made the autoloaded sub name and the prototype play
along nicely together, with a few fix-up commits (05b525f4, 3d5f9785
and 74ee33f2).
It was only after that that I find out that $AUTOLOAD used to be set
for XSUBs. See the discussion at these two links
http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=4E9468E8.8050206@cpan.org
https://rt.perl.org/rt3/Ticket/Display.html?id=72708
This commit restores the original behaviour of setting $AUTOLOAD for
XSUBs, while retaining the CvSTASH+SvPVX method as well, as it has
been documented for a while.
Steffen Müller’s AUTOLOAD tests that I committed recently (120b7a08)
needed to be adjusted a bit. The test count was off, which was my
fault (I *thought* I had checked that.) The test XSUB was using
get_sv("AUTOLOAD"), which ended up fetching the caller’s $AUTOLOAD.
It was also using SvPV_set on an undefined scalar, which does not turn
the SvPOK flag on.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Did you know that a subroutine’s prototype can be modified with s///?
Don’t look:
*AUTOLOAD = *Internals'SvREFCNT;
my $f = "Just another "; eval{main->$f};
print prototype AUTOLOAD;
$f =~ s/Just another /Perl hacker,\n/;
print prototype AUTOLOAD;
You did look, didn’t you? You must admit that’s creepy.
The problem goes back to this:
commit adb5a9ae91a0bed93d396bb0abda99831f9e2e6f
Author: Doug MacEachern <dougm@covalent.net>
Date: Sat Jan 6 01:30:05 2001 -0800
[patch] xsub AUTOLOAD fix/optimization
Message-ID: <Pine.LNX.4.10.10101060924280.24460-100000@mojo.covalent.net>
Allow AUTOLOAD to be an xsub and allow such xsubs
to avoid use of $AUTOLOAD.
p4raw-id: //depot/perl@8362
which includes this:
+ if (CvXSUB(cv)) {
+ /* rather than lookup/init $AUTOLOAD here
+ * only to have the XSUB do another lookup for $AUTOLOAD
+ * and split that value on the last '::',
+ * pass along the same data via some unused fields in the CV
+ */
+ CvSTASH(cv) = stash;
+ SvPVX(cv) = (char *)name; /* cast to loose constness warning */
+ SvCUR(cv) = len;
+ return gv;
+ }
That ‘unused’ field is not unused. It’s where the prototype is
stored. So, not only is it clobbering the prototype, it’s also leak-
ing it by assigning over the top of SvPVX. Furthermore, it’s blindly
assigning someone else’s string, which could be freed before it’s
even used.
Since it has been documented for a long time that SvPVX contains the
name of the AUTOLOADed sub, and since the use of SvPVX for prototypes
is documented nowhere, we have to preserve the former.
So this commit makes the prototype and the sub name share the same
buffer, in a manner resembling that which CvFILE used before I changed
it with bad4ae38.
There are two new internal macros, CvPROTO and CvPROTOLEN for retriev-
ing the prototype.
|
| |
|
|
|
|
| |
This avoids creating a lot of temporary SVs.
|
|
|
|
|
|
| |
Suprisingly, gcc figured out that these were never used uninitialised
when I had the body of this function as part of gv_fetchpvn_flags, but
now it has trouble recognising that fact.
|
| |
|
|
|
|
|
|
|
|
| |
This makes perl -E '$::{example} = "\x{30cb}"; say prototype example;'
store and fetch the correctly flagged prototype.
With this, all TODO tests in gv.t pass; The next commit will deal
with making the parsing of prototypes nul-clean.
|
|
|
|
|
|
|
| |
In this code path, name_cursor could be uninitialised if
gv_fetchpvn_flags is called with GV_NOTQUAL|GV_ADDWARN. Whenever it
is initialised, it is the same as name_end by the time this part
of the function is reached.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Not really useful yet, since named methods aren't correctly
flagged; that is to access a \x{30cb} method, you'd need
to do something like Obj->${\"\x{30cb}"}.
Committer’s note: I’m also including one piece of the ‘gv.c and
pp_ctl.c warnings’ patch so that the newly-added tests in this
commit pass.
|
| |
|
| |
|
|
|
|
| |
As with the previous commit, no Perl-level visible changes.
|
|
|
|
|
|
|
| |
Since gv_fetchmeth_pvn is primarily used from within gv.c,
and not much of anything is passing in the flag yet, this has
no visible changes on the Perl level; So tests remain
entirely in XS::APItest for the time being.
|
| |
|
|
|
|
| |
This also uncomments the UTF-8 tests in XS::APItest.
|
| |
|
|
|
|
|
| |
Since multi is a boolean (even though it’s typed as an int), there is
no need to have a separate parameter. We can just use a flag bit.
|
|
|
|
|
|
|
|
|
| |
Now that a glob can be initialized and fetched in UTF-8,
the next commit will introduce some changes in toke.c to
actually test this.
Committer’s note: To keep tests passing I had to incorporate
the toke.c:S_pending_ident changes in the same patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
passed the UTF8 flag.
newCONSTSUB is still unclean however, so constant subs are
still generated under a wrong name.
gv_fullname4 is also UTF-8 aware now; While that should've gotten
it's own commit and tests, it's not possible to test the
UTF-8 part without the gv_init changes, and it's not possible
to test the gv_init changes without gv_fullname4.
Chicken and egg, as it were. So let's compromise and
wait for the relevant tests once globs can be intiialized as
UTF-8 from the Perl level without XS magic.
|
| |
|
|
|
|
|
|
|
|
| |
method is a boolean flag (typed I32, but used as a boolean) added by
commit 54310121b442.
These new gv_autoload_* functions have a flags parameter, so there’s
no reason for this extra effective bool. We can just use a flag bit.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 4 was added in commit 54310121b442 (inseparable changes during
5.003/4 developement), presumably the ‘Don't look up &AUTOLOAD in @ISA
when calling plain function’ part.
Before that, gv_autoload had three arguments, so the 4 indicated the
new version (with the method argument).
Since these new functions don’t all have four arguments, and since
they have a new naming convention, there is not reason for the 4.
|
| |
|
| |
|