| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
This reverts commit 819b139db33e2022424694e381422766903d4f65.
This could be repapplied for 5.23.1, with modifications or
additional patches to solve the breakage discussed in RT 123580.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
gv_add_by_type was added in commit d5713896ec in 5.11.0 . Improve
gv_add_by_type by making it return the newly created SV*, instead of the
the GV *, which the caller must deref both the GV head to get svu and
then deref a slice into the GP, even though it already derefed svu and GP
right before, to figure out whether to call gv_add_by_type in the first
place. The original version of this patch had gv_add_by_type returning a
SV ** to ensure lvalue-ness but it was discovered it wasn't needed and not
smart.
-rename gv_add_by_type since it was removed from public api and its proto
changed
-remove null check since it is impossible to pass null through GvAVn(),
and unlikely with gv_AVadd, null segvs reliably crash in the rare case of
a problem
-instead of S_gv_init_svtype and gv_add_by_type using a tree of logic/
conditional jumps in asm, use a lookup table, GPe (e=enum or entry)
enums are identical to offsets into the GP struct, all of then fit under
0xFF, if the CC and CPU arch wants, CC can load the const once into a
register, then use the number for the 2nd deref, then use the number again
as an arg to gv_add_by_type, the low (&~0xf) or high (<<2) 2 bits in a
GPe can be used for something else in the future since GPe is pointer
aligned
-SVt_LAST triggers "panic: sv_upgrade to unknown type", so use that value
for entries of a GP which are not SV head *s and are invalid to pass as
an arg
-remove the tree of logic in S_gv_init_svtype, replace with a table
-S_gv_init_svtype is now tail call friendly and very small
-change the GV**n to be rvalues only, assigning to GV**n is probably a
memory leak
-fix 1 core GV**n as lvalue use
-GvSVn's unusual former definition is from commit 547f15c3f9 in 2005
and DEFSV as lvalue is gone in core as of commit 414bf5ae08 from 2008
since all the GV**n macros are now rvalues, this goes too
-PTRPTR2IDX and PTRSIZELOG2 could use better names
-in pp_rv2av dont declare strings like that VC linker won't dedup that, and
other parts of core also have "an ARRAY", perl521.dll previously had 2
"an ARRAY" and "a HASH" strings in it due to this
before VC 2003 32 perl521.dll .text 0xc8813 in machine code bytes after
.text 0xc8623
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
gv_fetchmeth_internal added, which receives method name
both as SV and const char. Now it calls hv_common instead
of hv_fetch.
gv_fetchmeth_pvn and gv_fetchmeth_sv are now just wrappers
for gv_fetchmeth_internal
Result: x2 speedup for gv_fetchmeth_sv new SV is a shared hash
BEFORE
PVN - 28.5 Mcalls/s
SV SHARED HASH - 26 Mcalls/s
AFTER
PVN - 29.4 Mcalls/s
SV SHARED HASH - 51 Mcalls/s
|
|
|
|
|
|
| |
This commit adds documentation of the bodyless-IV/NV hacks as well as
moving the offset calculation into a somewhat sensibly-named define
instead of cargo-culting the obscure logic in many different places.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The encoding pragma is deprecated, but in the meantime it causes spooky
action at a distance with other modules that it may be combined with.
In these modules, operations such as chr(), ord(), and utf8::upgrade()
will suddenly start doing the wrong thing.
The documentation for 'encoding' has said to call it after loading other
modules, but this may be impractical. This is especially bad with
anything that auto-loads at first use, like \N{} does now for charnames.
There is an issue with combining this with setting the variable
${^ENCODING} directly. The potential for conflicts has always been
there, and remains. This commit introduces a shadow hidden variable,
subservient to ${^ENCODING} (to preserve backwards compatibility) that
has lexical scope validity.
The pod for 'encoding' has been revamped to be more concise, clear, use
more idiomatic English, and to speak from a modern perspective.
|
|
|
|
|
|
| |
a623f8939 was arguably a little too eager. It’s purpose is to protect
vars whose modification can causes hangs and crashes. I don’t believe
that is the case for any magic vars.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the implicit close() fails, warn about it, mentioning $! in the
message. This is a default warning in the io category.
We do this in two spots, sv_clear and gp_free. While sv_clear would
be sufficient to get the warning emitted, the warning won’t contain
the name of the handle when called from there, because lone IO thing-
ies are nameless. Doing it also when a GV’s glob pointer is freed--as
long as the IO thingy in there has a reference count of 1--allows the
name to be included in the message, because we still have the glob,
which is where the name is stored.
The result:
$ ./miniperl -Ilib -e 'open fh, ">/Volumes/Disk Image/foo"; print fh "x"x1000, "\n" for 1..50; undef *fh'
Warning: unable to close filehandle fh properly: No space left on device at -e line 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
CvRESERVED is a placeholder, it will be replaced with a sentinal value
from future revised BOOTCHECK API.
CvPADLIST_set was helpful during development of this patch, so keep it
around for now.
PoisonPADLIST's magic value is from PERL_POISON 0xEF pattern. Some
PoisonPADLIST locations will get code from future BOOTCHECK API.
Make padlist_dup a NN function to avoid overhead of calling it for XSUBs
during closing.
Perl_cv_undef_flags's else if (CvISXSUB(&cvbody)) is to avoid whitespace
changes.
Filed as perl [#123059].
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of turning off the flag only when we need to turn it off
(when there is a hek, which is the only time it should be on), just
turn it off unconditionally.
This gets Scope::Upper working once more.
While it is arguably the module’s fault, it’s still a good idea to
make cvgv_set robust. CvNAMED should never be on after calling it,
regardless of the previous state of the CV.
|
|
|
|
|
|
| |
We already take care of possible utf8ness in the format string. There
is no need to turn on the flag afterwards. This double utf8 check has
been present since ecad31f018.
|
|
|
|
|
|
| |
by suggesting the declaration of a lexical variable, but without
removing the ‘Global symbol’ part, since much code no doubt depends
on its presence.
|
|
|
|
|
| |
I’m not sure that it’s even possible for a CV with a name hek to reach
this code path, but if that happens this avoids reifying the GV.
|
|
|
|
| |
Takes more code, but I think the new code is clearer....
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch changes ‘sub foo {...}’ declarations to store subroutine
references in the stash, to save memory.
Typeglobs still notionally exist. Accessing CvGV(cv) will reify them.
Hence, currently the savings are lost when a sub call is compiled.
$ ./miniperl -e 'sub foo{} BEGIN { warn $::{foo} } foo(); BEGIN { warn $::{foo} }'
CODE(0x7f8ef082ad98) at -e line 1.
*main::foo at -e line 1.
This optimisation is skipped if the subroutine declaration contains a
package separator.
Concerning the changes in caller.t, this code:
sub foo { print +(caller(0))[3],"\n" }
my $fooref = delete $::{foo};
$fooref -> ();
used to crash in 5.7.3 or thereabouts. It was fixed by 16658 (aka
07b8c804e8) to produce ‘(unknown)’ instead. Then in 5.13.3 it was
changed (by 803f274) to produce ‘main::__ANON__’ instead. So the
tests are really checking that we don’t get a crash. I think it is
acceptable that it has now changed to ‘main::foo’.
|
|
|
|
|
| |
From now on, the presence of a name hek implies a GV. Any access to
CvGV will cause that implicit GV to be reified.
|
|
|
|
|
| |
This flag will signify that lexical subs should not have package names
associated with them in error messages, etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Wrap gv_stashpvn_internal() with a routine which caches
what it does, and rework gv_stashsv() and gv_stashpvn()
to use the cached codepath.
Also rework the documentation of gv_stashsv() and gv_stashpvn()
that the gv_stashsv() is prefered as there is a mechanism to cache
the hash value associated with the name which requires an SV
to passed in as an argument for caching purposes.
Note this is a reworked version of sybers original patch.
|
|
|
|
|
|
|
| |
S_stashpvn was not added to embed.fnc properly, and is named contrary
to general expectations of the Perl internals.
This fixes that, there should be no other functional differences.
|
|
|
|
|
|
|
| |
Sub declaration can reuse an existing stub. So it is possible to define
a package sub using a stub that was originally lexical. Hence,
leave_scope needs to take into account that a my-sub may not have a
name hek any more.
|
| |
|
| |
|
|
|
|
|
|
| |
The previous commit copied the PL_stashcache handling code from
S_method_common() to gv_stashpvn(), so now we can call that function
directly rather than doing it ourselves.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
perl has a stash name lookup cache, which is currently just used for
looking up up class names in Some::Class->method calls. This means
that a lookup of the class name 'A::B::C' gets reduced from doing
several stash lookups (e.g. $::{'A::'}{'B::'}{'C::'}) to a single
cache lookup (e.g. $PL_stashcache{'A::B::C::'}, so to speak).
Make gv_stashpvn() use this cache too, which means that all package
name lookups benefit, not just class method calls. Among other things,
this also indirectly affects bless operations both from Perl (OP_BLESS)
and XS.
|
| |
|
|
|
|
|
|
|
|
| |
You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT
or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference.
(g++ does not do the "post-annotation" form of "unused".)
The version code has some of these issues, reported upstream.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after return/croak/die/exit, return/break are pointless
(break is not a terminator/separator, it's a goto)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(the initializations will be skipped since the flow will bypass
the start of the block); in some easy cases simply hoist the declarations
out of the block and move them earlier
Note 1: Since after this patch the core is not yet -Wunreachable-code
clean, not enabling that via cflags.SH, one needs to -Accflags=... it.
Note 2: At least with the older gcc 4.4.7 there are far too many
"unreachable code" warnings, which seem to go away with gcc 4.8,
maybe better flow control analysis. Therefore, the warning should
eventually be enabled only for modernish gccs (what about clang and
Intel cc?)
|
|
|
|
|
|
|
| |
This reverts commit 8c2b19724d117cecfa186d044abdbf766372c679.
I don't understand - smoke-me came back happy with three
separate reports... oh well, some other time.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- after croak/die/exit (or return), break (or return!) are pointless
(break is not a terminator/separator, it's a promise of a jump)
- after goto, another goto (!) is pointless
- in some cases (usually function ends) introduce explicit NOT_REACHED
to make the noreturn nature clearer (do not do this everywhere, though,
since that would mean adding NOT_REACHED after every croak)
- for the added NOT_REACHED also add /* NOTREACHED */ since
NOT_REACHED is for gcc (and VC), while the comment is for linters
- declaring variables in switch blocks is just too fragile:
it kind of works for narrowing the scope (which is nice),
but breaks the moment there are initializations for the variables
(they will be skipped!); in some easy cases simply hoist the declarations
out of the block and move them earlier
There are still a few places left.
|
|
|
|
| |
This silences a chunk of warnings under -Wformat
|
|
|
|
|
|
|
|
|
|
|
| |
Unlike other pod handling routines, autodoc requires the line following
an =head1 to be non-empty for its text to be included in the paragraph
started by the heading. If you fail to do this, silently the text will
be omitted from perlapi. I went through the source code, and where it
was apparent that the text was supposed to be in perlapi, deleted the
empty line so it would be, with some revisions to make more sense.
I added =cuts where I thought it best for the text to not be included.
|
|
|
|
|
|
|
| |
Used by linters (static checkers), and also good for human readers.
Even though "FALL THROUGH" seems to be the most common, e.g BSD lint
manual only knows "FALLTHROUGH" (or "FALLTHRU").
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix suspicious (*) switch cases found by Coverity by
annotating with either "/* FALLTHROUGH */" or adding a break;
The FALLTHROUGH was much more common, but the break turned
out to be the right choice in three spots. All changes tested
to work.
(*) suspicious = case1 + code + case2, and neither flow control
(like break) nor fallthrough annotation between code and case2.
Fix for Coverity perl5 CIDs 28977..28989, 45353.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since the HvAUX structure is just tacked onto the end of the HvARRAY()
struct, code like this can do bad things:
aux = HvAUX();
... something that might split hv ...
aux->foo = ...; /* SEGV! */
So I've visually audited core for places where HbAUX() is saved and then
re-used, and re-initialised the var if it looks like HvARRAY() could
have changed in the meantime.
I've been very conservative about what might be unsafe. For example,
destructors or __WARN__ handlers could call perl code that modifies the
hash.
|
|
|
|
|
|
|
|
|
|
|
| |
My recent commit 3d147ac29d12abdb to "speed up (non)overloaded derefs"
introduced a potential SEGV. In Perl_Gv_AMupdate(), the 'aux' variable is
set to HvAUX(hv). My patch used the value of the variable later on in the
function, but it turns out that by then, S_hsplit() may have been called,
and thus HvARRAY (and HvAUX()) may have been reallocated.
Issue first spotted by Andreas' awesome BBC service, and diagnosed by
Nicholas Clark.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Consider a class that has some minimal overloading added - e.g. to give
pretty stringification of objects - but which *doesn't* overload
dereference methods such as '@[]'. '%[]' etc.
In this case, simple dereferencing, such as $obj->[0] or $obj->{foo}
becomes much slower than if the object was blessed into a non-overloaded
class.
This is because every time a dereferencing is performed in pp_rv2av for
example, the "normal" code path has to go through the full checking of:
* is the stash into which the referent is blessed overloaded? If so,
* retrieve the overload magic from the stash;
* check whether the overload method cache has been invalidated and if so
rebuild it;
* check whether we are in the scope of 'no overloading', and if so
is the current method disabled in this scope?
* Is there a '@{}' or whatever (or 'nomethod') method in the cache?
If not, then process the ref as normal.
That's a lot of extra overhead to decide that an overloaded method doesn't
in fact need to be called.
This commit adds a new flag to the newish xhv_aux_flags field,
HvAUXf_NO_DEREF, which signals that the overloading of this stash
contains no deref (nor 'nomethod') overloaded methods. Thus a quick check
for this flag in the common case allows us to short-circuit all the above
checks except the first one.
Before this commit, a simple $obj->[0] was about 40-50% slower if the
class it was blessed into was overloaded (but didn't have deref methods);
after the commit, the slowdown is 0-10%. (These timings are very
approximate, given the vagaries of nano benchmarks.)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Currently the SVf_IsCOW flag doesn't have any meaning for HVs,
except that it is used in the specific case of gv_check() to temporarily
mark a stash as being scanned. Since stashes will have the HV_AUX fields,
we can use a flags bit in the new xhv_aux_flags field instead.
This then potentially frees up the SVf_IsCOW for use as a new general flag
bit for *all* HVs (including non-stash ones).
|
|
|
|
|
|
|
|
|
|
| |
gv.c(1455) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
gv.c(1586) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
gv.c(2122) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
toke.c(12423) : warning C4244: '=' : conversion from 'I32' to 'char', possible loss of data
win32.c(3017) : warning C4022: 'SetHandleInformation' : pointer mismatch for actual parameter 1
win32.c(2971) : warning C4101: 'old_h' : unreferenced local variable
win32.c(2967) : warning C4101: 'oldfd' : unreferenced local variable
|
|
|
|
|
| |
flags param was poorly designed and didn't have a formal api. Replace it
with the bool it really is. See #115736 for details.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit aae438050a20 (5.17.4) broke ->SUPER::foo with AUTOLOAD by look-
ing up AUTOLOAD from the current package, rather than the current
package’s superclass.
Instead of keeping track of whether it was doing a SUPER lookup via a
::SUPER prefix on the package name, that commit changed method lookup
to pass a GV_SUPER flag around (to fix another bug) and to pass the
current stash, rather than __PACKAGE__::SUPER. But it did not update
gv_autoload_pvn to pass that flag through to gv_fetchmeth_pvn when
actually looking up the method.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PUSHSTACKi() calls SWITCHSTACK(), which sets PL_stack_sp and sp like this:
sp = PL_stack_sp = PL_stack_base + AvFILLp(t)
Hence after PUSHSTACKi() both are identical, so use of SPAGAIN or PUTBACK
to assign one to the other is redundant.
The use of SPAGAIN in encoding.xs and via.xs was added with commit
24f59afc531955e5 (April 2002) which added the use of PUSHSTACKi(). It feels
like cargo-cult.
The use of PUTBACK in Perl_amagic_call() predates the introduction of nested
stacks and PUSHSTACKi() in commit e336de0d01f30cc4 (April 1998). It dates from
perl 5.000, but it's not clear that it was ever needed, as the code in
question looked like this, and nothing could have moved the stack between
the dSP and PUTBACK:
dSP;
BINOP myop;
SV* res;
Zero(&myop, 1, BINOP);
myop.op_last = (OP *) &myop;
myop.op_next = Nullop;
myop.op_flags = OPf_KNOW|OPf_STACKED;
ENTER;
SAVESPTR(op);
op = (OP *) &myop;
PUTBACK;
The PUTBACK and SPAGAIN in Perl_require_pv() were added by commit
d3acc0f7e5197310 (June 1998) which also added the PUSHSTACKi(). They have
both been redundant since they were added.
|
|
|
|
|
|
| |
Core subs are already accounted for by method lookup, so vivifying
them does not change what gets inherited. Hence, there is no need
to flush caches here.
|