| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
Make the function Perl_op_parent() only be present in perls built with
-DPERL_OP_PARENT. Previously the function was present in all builds, but
always returned NULL on non PERL_OP_PARENT builds.
|
|
|
|
|
| |
This experimental feature now has the intersection operator ("&") higher
precedence than the other binary operators.
|
|
|
|
| |
.. but keep available to extensions.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some questions and loose ends:
XXX gv.c:S_gv_magicalize - why are we using SSize_t for paren?
XXX mg.c:Perl_magic_set - need appopriate error handling for $)
XXX regcomp.c:S_reg - need to check if we do the right thing if parno
was not grokked
Perl_get_debug_opts should probably return something unsigned; not sure
if that's something we can change.
|
|
|
|
| |
Spotted by Daniel Dragan
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This was introduced by 9df874cdaa2f196cc11fbd7b82a85690c243eb9f
in changing the name of some static functions. I didn't realize at the
time that the function was defined in embed.fnc, as none of the others
are, and it was always called with the S_ prefix form. Nor did I notice
the compiler warnings.
It turns out that the base name of this function is the same as a public
function, so I've renamed it to have prefix 'S_my_'.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A function implements seeing if the space between any two characters is
a grapheme cluster break. Afer I wrote this, I realized that an array
lookup might be a better implementation, but the deadline for v5.22 was
too close to change it. I did see that my gcc optimized it down to
an array lookup.
This makes the implementation of \X go from being complicated to
trivial.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
4258cf903c752ec19a3aeee9b93020533d923e1a
91e945c051cfcdf499d5b43aa5ac0a5681cdd595
eb254f2672a985ec3c34810f624f36c18fc35fc7
c9a671b17a9c588469bcef958038daaaaf9cc88b
99fcdd4df47515fb0a62a046e622adec0871754d
ba511db061a88439acb528a66c780ab574bb4fb0
0d1cf11425608e9be019f27a3a4575bc71c49e6b
c2ea8a88f8537d00ba25ec8feb63ef5dc085ef2b
b5a6eedc2f49a90089cca896ee20f41e373fb4c9
30419b527d2c5a06cefe2db9183f59e2697c47fc
29b62199cd4c359dfc6b9d690341de40d105ca5f
be181dc9d91c84a2fe03912c993c8259fed92641
4de1bcfe1abdaba0a5da394ddea0cc6fd7e36c7b
6e915616c4ccb4f6cc3122c5d395765db96c0a2d
b2e3501558a1017eb529be0915c25d31671e7869
bfaa02d55f4ace1571e6fa9e5b47d5e3ac3cecc6
569f27e562618bdddcf4a9fc71612283a73747e9
4f89311dc8de87ddc9a302c6f2d2c844951bbd28
a307a0b0d83c509cc2adaad8cebb44260294bf36
6640aa2c3b93d7ac78e4e86983fe5948b3ca55f2
b74dc0b3c96390d8bf83d8c3ffc0c2c2d1f0a5d3
c3a8e5a5b4bb89a15de642c023dfd5cbc4678938
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
v5.21.7-83-geaab564 added sv_get_backrefs. v5.21.7-90-g8fbcb65
removed the one use of aTHX.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This function returns a string representation of the OP_MULTIDEREF op
(as used by the output of perl -Dt).
However, the stringification of a UNOP_AUX op is op-specific, and
hypothetical future UNOP_AUX-class ops will need their own functions.
So the current function name is misleading.
It should be safe to rename it, as it only been in since 5.21.7, and isn't
public.
|
|
|
|
|
| |
Future commits will want this function to be able to be used in more
than one core file.
|
|
|
|
|
| |
This is in preparation for the next commit. The function previously was
used only in DEBUGGING builds
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
The bulk of this macro is extremely rarely executed, so it makes sense
to optimize for space, as it is called from a fair number of places, and
move as much as possible to a single function.
For whatever it's worth, on my system with my typical compilation
options, including -O0, the savings was 19640 bytes in regexec.o, 4528
in utf8.o, at a cost of 1488 in locale.o.
|
|
|
|
|
|
|
| |
This function has the capability to do strict checking, with the
variable 'strict', but it is initialized based on another parameter's
value. This commit causes 'strict' to be passed in, so it is
independent of other parameters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-flags arg of both funcs is unused in all callers. Move the 0 to the funcs.
flags arg is from commit ce16c625ec in 2012
-all bad_type_gv calls are right before the end of the switch, the pushing
of 1st 3 args and call asm ops can be merged together, leaving the 1
string constant push as the only unique op between the 7 src code
callers of bad_type_gv, this requires reordering the args so the only
unique one is the last/right most one, reordering can't be done to
bad_type_pv because each following execution point after each bad_type_pv
is different, bad_type_pv's caller/s are not a switch statement
- commit 53e06cf030 probably overlooked the 2 PL_op_desc[type] places,
OP_DESC is a fancier superset of PL_op_desc[type], since calling
bad_type_pv only happens during a PP syntax error, that is not
performance critical, so replace PL_op_desc[type] with OP_DESC and
factor out OP to description string lookup, plus custom ops are very rare
so this shouldn't impact the error message seen by the user
VC2003 .text section of perl521.dll before 0xc9543 after 0xC9523
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These two operators were being translated into subst("","") and
tr("","") by the lexer. Then pmruntime in op.c would take apart the
resulting list op. Instead of constructing a list op only to take it
apart again, feed the replacement part to pmruntime separately. We
can achieve this by introducing a new token ('/') that the parser rec-
ognizes as introducing a replacement.
If we had followed this approach to begin with, then bug #123542 would
never have happened.
(Actually, it seems the parser did know about the replacement part to
begin with, but it changed in perl-5.8.0-4047-g131b3ad to fix some
overloading problems.)
|
|
|
|
| |
There are no longer any calls to these, so can be removed.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
OP_DESC is simpler and more general.
|
|
|
|
|
|
|
| |
Previously it would read and replace the previous item on the stack:
$ ./perl -le 'print "CORE::undef", prototype'
;\[$@%&*]
|
|
|
|
|
|
|
|
|
|
|
| |
This encapsulates the logic to extract the backrefs from a weak-referent.
Since sv_get_backrefs() can be used for a similar purposes as hv_backreferences_p()
we no longer need to export the later, and therefore this patch also reverts
ad2f46a793b4ade67d45ac0086ae62f6756c2752.
See perl #123473 for related discussion, and https://github.com/Sereal/Sereal/issues/73
for a practical example of why this API is required.
|
|
|
|
| |
The data is used only for STCLASS, and it's somewhat expensive to create.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This prints 42 as expected (foo initialises $x and bar reads it
via eval):
use 5.01;
sub foo {
state $x = 42;
sub bar {
eval 'print $x // "u", "\n"';
}
}
foo();
bar();
If you predeclare foo and vivify its glob,
use 5.01;
*foo; # vivifies the glob at compile time
sub foo;
sub foo {
state $x = 42;
sub bar {
eval 'print $x // "u", "\n"';
}
}
foo();
bar();
then the output is ‘u’, because $x is now undefined.
What’s happening is that ‘eval’ follows CvOUTSIDE pointers (each sub
points to its outer sub), searching each pad to find a lexical $x. In
the former case it succeeds. In the latter, bar’s CvOUTSIDE pointer
is pointing to the wrong thing, so the search fails and $x is treated
as global. You can see it’s global with this example, which prints
‘globular’:
use 5.01;
*foo; # vivifies the glob at compile time
sub foo;
sub foo {
state $x = 42;
sub bar {
eval 'print $x // "u", "\n"';
}
}
foo();
$main::x = "globular";
bar();
When a sub is compiled, a new CV is created at the outset and put in
PL_compcv. When the sub finishes compiling, the CV in PL_compcv is
installed in the sub’s typeglob (or as a subref in the stash if pos-
sible). If there is already a stub in a typeglob, since that stub
could be referenced elsewhere, we have to reuse that stub and transfer
the contents of PL_compcv to that stub.
If we have any subs inside it, those will now have CvOUTSIDE point-
ers pointing to the old PL_compcv that has been eviscerated. So
we go through the pad and fix up the outside pointers for any subs
found there.
Named subs don’t get stored in the pad like that, so the CvOUTSIDE
fix-up never happens. Hence the bug above.
The bug does not occur if the glob is not vivified before the sub def-
inition, because a stub declaration will skip creating a real CV if it
can. It can’t if there is a typeglob.
The solution, of course, is to store named subs in the outer sub’s
pad. We can skip this if the outer ‘sub’ is an eval or the main pro-
gram. These two types of CVs obviously don’t reuse existing stubs,
since they never get installed in the symbol table. Since named subs
have strong outside pointers, we have to store weak refs in the pad,
just as we do for formats.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This op is an optimisation for any series of one or more array or hash
lookups and dereferences, where the key/index is a simple constant or
package/lexical variable. If the first-level lookup is of a simple
array/hash variable or scalar ref, then that is included in the op too.
So all of the following are replaced with a single op:
$h{foo}
$a[$i]
$a[5][$k][$i]
$r->{$k}
local $a[0][$i]
exists $a[$i]{$k}
delete $h{foo}
while these aren't:
$a[0] already handled by OP_AELEMFAST
$a[$x+1] not a simple index
and these are partially replaced:
(expr)->[0]{$k} the bit following (expr) is replaced
$h{foo}[$x+1][0] the first and third lookups are each done with
a multideref op, while the $x+1 expression and
middle lookup are done by existing add, aelem etc
ops.
Up until now, aggregate dereferencing has been very heavyweight in ops; for
example, $r->[0]{$x} is compiled as:
gv[*r] s
rv2sv sKM/DREFAV,1
rv2av[t2] sKR/1
const[IV 0] s
aelem sKM/DREFHV,2
rv2hv sKR/1
gvsv[*x] s
helem vK/2
When executing this, in addition to the actual calls to av_fetch() and
hv_fetch(), there is a lot of overhead of pushing SVs on and off the
stack, and calling lots of little pp() functions from the runops loop
(each with its potential indirect branch miss).
The multideref op avoids that by running all the code in a loop in a
switch statement. It makes use of the new UNOP_AUX type to hold an array
of
typedef union {
PADOFFSET pad_offset;
SV *sv;
IV iv;
UV uv;
} UNOP_AUX_item;
In something like $a[7][$i]{foo}, the GVs or pad offsets for @a and $i are
stored as items in the array, along with a pointer to a const SV holding
'foo', and the UV 7 is stored directly. Along with this, some UVs are used
to store a sequence of actions (several actions are squeezed into a single
UV).
Then the main body of pp_multideref is a big while loop round a switch,
which reads actions and values from the AUX array. The two big branches in
the switch are ones that are affectively unrolled (/DREFAV, rv2av, aelem)
and (/DREFHV, rv2hv, helem) triplets. The other branches are various entry
points that handle retrieving the different types of initial value; for
example 'my %h; $h{foo}' needs to get %h from the pad, while '(expr)->{foo}'
needs to pop expr off the stack.
Note that there is a slight complication with /DEREF; in the example above
of $r->[0]{$x}, the aelem op is actually
aelem sKM/DREFHV,2
which means that the aelem, after having retrieved a (possibly undef)
value from the array, is responsible for autovivifying it into a hash,
ready for the next op. Similarly, the rv2sv that retrieves $r from the
typeglob is responsible for autovivifying it into an AV. This action
of doing the next op's work for it complicates matters somewhat. Within
pp_multideref, the autovivification action is instead included as the
first step of the current action.
In terms of benchmarking with Porting/bench.pl, a simple lexical
$a[$i][$j] shows a reduction of approx 40% in numbers of instructions
executed, while $r->[0][0][0] uses 54% fewer. The speed-up for hash
accesses is relatively more modest, since the actual hash lookup (i.e.
hv_fetch()) is more expensive than an array lookup. A lexical $h{foo}
uses 10% fewer, while $r->{foo}{bar}{baz} uses 34% fewer instructions.
Overall,
bench.pl --tests='/expr::(array|hash)/' ...
gives:
PRE POST
------ ------
Ir 100.00 145.00
Dr 100.00 165.30
Dw 100.00 175.74
COND 100.00 132.02
IND 100.00 171.11
COND_m 100.00 127.65
IND_m 100.00 203.90
with cache misses unchanged at 100%.
In general, the more lookups done, the bigger the proportionate saving.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the same as a UNOP, but with the addition of an op_aux field,
which points to an array of UNOP_AUX_item unions.
It is intended as a general escape mechanism for adding per-op-type extra
fields (or arrays of items) to UNOPs.
Its class character (for regen/opcodes etc) is '+'.
Currently there are no ops of this type; but shortly, OP_MULTIDEREF will
be added, which is the original motivation for this new op type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
distinct from SV. This should fix the CPAN modules that were failing
when the PadnameLVALUE flag was added, because it shared the same
bit as SVs_OBJECT and pad names were going through code paths not
designed to handle pad names.
Unfortunately, it will probably break other CPAN modules, but I think
this change is for the better, as it makes both pad names and SVs sim-
pler and makes pad names take less memory.
|
|
|
|
| |
This is in preparation for making PADNAME a separate type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In ck_method:
Scan for '/::. If found SUPER::, create OP_METHOD_SUPER op
with precomputed hash value for method name.
In B::*, added support for method_super
In pp_hot.c, pp_method_*:
S_method_common removed, code related to getting stash is
moved to S_opmethod_stash, other code is moved to
pp_method_* functions.
As a result, SUPER::func() calls speeded up by 50%.
|
|
|
|
|
|
| |
This is a more accurately named synonym for is_ascii_string(), which is
retained. The old name is misleading to someone programming for
non-ASCII platforms.
|
|
|
|
| |
It doesn’t need it.
|
|
|
|
|
|
| |
This is in preparation for making the retrieval more complex in future
commits than it is now. This is going into mg.c because the value is
magical.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Based on commit 73758d77 (by me), in commit 117af67d629 more things got
noreturn removed on MSVC. See also ML post
"(Hugmeir) Re: [perl.git] branch blead, updated. v5.21.0-377-gdc3bf40"
This caused a measurable increase in machine code size in 117af67d629 .
In commit 73758d77 , the reason there was no increase is
Perl_magic_regdatum_set is called only through a magic vtable. Optimizing
this to noreturn is forbidden unless the struct member type specifies it
(and it obviously doesn't, since this is the magic vtable).
The other not-noreturn on MSVC function, Perl_screaminstr, has no core
usage (its only reference is in the export table) or CPAN grep usage so
therefore it is being removed. It was made fatal in commit 9e3f0d16db .
before .text section of perl521.dll on VC 2003 32b, 0xc66a3 bytes, after
0xc6453
|
|
|
|
| |
This is explained in the added perldiag entry.
|