| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
VMS seems to have a 31 character limitation for external symbols. To be able to
fit into that, rename 'coerce_qwlist_to_paren_list' to
'munge_qwlist_to_paren_list'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These provided a non-public API for the hash and array code to donate free
memory direct to the SV head allocation routines, instead of returning it
to the malloc system with free().
I assume that on some older mallocs this could offer significant benefits.
However, my benchmarking on a modern malloc couldn't detect any significant
effect (positive or negative) on removing the code. Its (continued) presence,
however, has downsides
a: slightly more code complexity
b: slightly larger interpreter structure
c: in the steady state, if net creation of SVs is zero, 1 chunk of allocated
but unused memory will exist (per thread)
So I think it best to remove it.
|
|
|
|
|
|
|
|
|
|
| |
This makes a qw(...) list literal a distinct token type for the
parser, where previously it was munged into a "(",THING,")" sequence.
The change means that qw(...) can't accidentally supply parens to parts
of the grammar that want real parens. Due to many bits of code taking
advantage of that by "foreach my $x qw(...) {}", this patch also includes
a hack to coerce qw(...) to the old-style parenthesised THING, emitting
a deprecation warning along the way.
|
|
|
|
|
| |
This way c++ compilers like us again, as we don't do jumps that skip
initialisations anymore.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
From a suggestion from Ben Morrow.
The first argument used to be struct refcounted_he *, which exposed an
implementation detail - that the COP's labels are (now) stored in this way.
Google Code Search and an unpacked CPAN both fail to find any users of this
API, so the impact should be minimal.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
sv_reftype() mostly returns strings whose length is known at compile
time, so we can avoid a strlen() call if we return the length.
Additionally, the non-length interface is potentially buggy in the
face of class names which contain "\0", therefore providing a way
to obtain the true length allows us to avoid any trickyness.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
It used to be a static function, hence the location, and I failed to spot that
I needed to move it, when I edited it to be non-static.
Problem spotted by Jerry D. Hedden.
|
|
|
|
|
|
|
| |
Convert get_arena() to be static, as now its only user is Perl_more_bodies().
Perl_get_arena() was not in the public API, and neither Google codesearch
nor an upacked CPAN show anything to be using it.
|
|
|
|
| |
Also fix one value passed to the debugging *_printf() in the #else block.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 65bfe90c4b4ea5706a50067179e60d4e8de6807a.
While it made a few of the things I wanted possible, a couple of other things
one might need to do and I thought this change would enable don't actually
work. Thanks Zefram for pointing out my mistake.
Conflicts:
ext/XS-APItest/APItest.xs
op.c
|
|
|
|
|
|
|
|
|
|
|
| |
Rather than creating an AV and pushing the backref onto it,
store a single backref directly in the mg_obj or xhv_backreferences
slot.
If the backref is an AV, then we skip this optimisation (although I don't
think at the moment, that an AV would ever be pointed to by some backref
magic). So the test of whether the optimisation is is in effect is whether
the thing in the slot is an AV or not.
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 044d8c24fa9214cf0fe9c6fc8a44e03f3f5374d7.
Conflicts:
hv.c
That commit tried to simply the xhv_backreferences processing, but
was totally wrong and broke ordinary weak refs to hashes (see #76716).
|
|
|
|
| |
The previous return value where NULL meant OK is outside-the-norm.
|
|
|
|
|
|
|
|
|
|
|
| |
Also allows extensions, when delegating to Perl_peep, to specify what function
it should use when recursing into a part of the op tree.
The usecase for this are extensions like namespace::alias, which need to hook
into the peep to do their thing. With this change they can stop copying the
whole peep only to add tiny bits of new behaviour to it, allowing them to work
easier on a large variety of perls, without having to maintain one peep which
works on all of them (which is HARD!).
|
|
|
|
| |
C, of course, is happy enough without a function prototype.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This commit adds the new construct \o{} to express a character constant
by its octal ordinal value, along with ancillary tests and
documentation.
A function to handle this is added to util.c, and it is called from the
3 parsing places it could occur. The function is a candidate for
in-lining, though I doubt that it will ever be used frequently.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each CV usually has a pointer, CvGV(cv), back to the GV that corresponds
to the CV's name (or to *foo::__ANON__ for anon CVs). This pointer wasn't
reference counted, to avoid loops. This could leave it dangling if the GV
is deleted.
We fix this by:
For named subs, adding backref magic to the GV, so that when the GV is
freed, it can trigger processing the CV's CvGV field. This processing
consists of: if it looks like the freeing of the GV is about to trigger
freeing of the CV too, set it to NULL; otherwise make it point to
*foo::__ANON__ (and set CvAONON(cv)).
For anon subs, make CvGV a strong reference, i.e. increment the refcnt of
*foo::__ANON__. This doesn't cause a loop, since in this case the
__ANON__ glob doesn't point to the CV. This also avoids dangling pointers
if someone does an explicit 'delete $foo::{__ANON__}'.
Note that there was already some partial protection for CvGV with
commit f1c32fec87699aee2eeb638f44135f21217d2127. This worked by
anonymising any corresponding CV when freeing a stash or stash entry.
This had two drawbacks. First it didn't fix CVs that were anonmous or that
weren't currently pointed to by the GV (e.g. after local *foo), and
second, it caused *all* CVs to get anonymised during cleanup, even the
ones that would have been deleted shortly afterwards anyway. This commit
effectively removes that former commit, while reusing a bit of the
actual anonymising code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each CV usually has a pointer, CvSTASH, back to the stash that it was
complied in. This pointer isn't reference counted, to avoid loops. Which
can leave it dangling if the stash is deleted.
There is already protection for the similar GvSTASH field in GVs: the
stash has an array of backrefs, xhv_backreferences, pointing to the GVs
whose GvSTASHes point to it, and which is used to zero all the GvSTASH
fields should the stash be deleted.
All this patch does is also add the CVs with CvSTASH to that stash's
backref list too.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When deleting a stash, make the algorithm
GvSTASH($_) = NULL for (@xhv_backreferences);
delete xhv_backreferences;
free each stash entry;
Previously the algorithm was
hide xhv_backreferences as ordinary backref magic;
free each stash entry:
this may trigger a sv_del_backref() for each GV being freed
delete @xhv_backreferences
The new method is:
* more efficient: one scan through @xhv_backreferences rather than lots of
calls to sv_del_backref(), removing elements one by one;
* makes the code simpler; the 'hide xhv_backreferences as backref magic'
hack no longer needs to be done
* removes a bug whereby GVs that had a refcnt > 1 (the usual case) were
left with a GvSTASH pointing to the freed stash; it's now NULL instead. I
couldn't think of a test for this.
There are two drawbacks:
* If the GV gets freed at the same time as the stash, the freeing code
sees the GV with a GVSTASH of NULL rather than still pointing to the
stash.
* As far as I can see, the only difference this currently makes is that
mro_method_changed_in() is no longer called by sv_clear(), but since we're
blowing away the whole stash anyway, method resolution doesn't really
bother us any more.
At some point in the future I might set GvSTASH to %__ANON__ rather than
NULL.
|
|
|
|
|
| |
Replacing 4 copies of this debugging-only routine with 1 reduces source and
object code size.
|
|
|
|
|
|
|
| |
Pass in a boolean to S_sv_pos_u2b_forwards, which sets it to true if it
discovers that the UTF-8 offset is at (or after) the end of the string.
This can only happen if we don't already know the SV's length (in Unicode
characters), because if we know it, we always call S_sv_pos_u2b_midway().
|
| |
|
|
|
|
|
| |
This should help prevent people from thinking they can get cute with the
contents.
|
|
|
|
|
|
| |
Change S_sv_pos_u2b_forwards() to take a point to the (requested) UTF-8 offset,
and return the actual UTF-8 offset for the byte position returned. This ensures
that the cache is consistent with reality.
|
| |
|
|
|
|
|
| |
It was added for PERL_OBJECT support in commit 0cb9638,
which has been removed again with commit acfe0ab.
|
|
|
|
|
|
|
| |
my_stat() and my_lstat() call get magic on the stack arg, so create _flags()
variants that allow us to control this. (I can't just change the signature
or the mg_get() behaviour since my_[l]stat() are listed as being in the
public API, even though they're undocumented.)
|
|
|
|
|
| |
This reduces object code size, reducing CPU cache pressure on the non-exception
paths.
|
|
|
|
|
|
| |
This generates slightly smaller object code overall, which means that the "hot"
code (the non-overloaded paths through the ops) will be smaller, and hence more
likely to stay in the CPU cache.
|
|
|
|
|
| |
Convert the gimme argument to a flags argument, and add a flag bit to signal
that mortalization is not required. Only "BINMODE" needs this.
|
|
|
|
| |
This allows "GETC" to use it.
|
|
|
|
| |
This enables "BINMODE", "EOF" and "SYSSEEK" to use it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As discussed on p5p, ibcmp has different semantics from other cmp
functions in that it is a binary instead of ternary function. It is
less confusing then to have a name that implies true/false.
There are three functions affected: ibcmp, ibcmp_locale and ibcmp_utf8.
ibcmp is actually equivalent to foldNE, but for the same reason that things
like 'unless' and 'until' are cautioned against, I changed the functions
to foldEQ, so that the existing names, like ibcmp_utf8 are defined as
macros as being the complement of foldEQ.
This patch also changes the one file where turning ibcmp into a macro
causes problems. It changes it to use the new name. It also documents
for the first time ibcmp, ibcmp_locale and their new names.
|
| |
|
|
|
|
|
|
| |
This is achieved by introducing a new find_rundefsv() function in pad.c
This fixes [perl #75436].
|
|
|
|
| |
assert() that pads are never AvREAL().
|
|
|
|
|
|
|
|
|
|
|
|
| |
Effectively this leaves the cloned-into interpreter in a consistent state.
In the cloned-from interpreter, the SV targets of non-reference owning pointers
*are* referenced and managed by other pointers. SvREFCNT() == 0 SVs in the
cloned-into interpreter result from the non-reference owning pointers being
found and followed, but the reference owning and managing pointers not being
part of the subsection of interpreter state cloned over. Hence, this change
creates reference owning pointers to this SVs on the temps stack, which ensures
that they are correctly cleaned up, and don't "leak" until interpreter
destruction. (Which might be some time away, in a persistent process.)
|
|
|
|
|
|
|
|
|
|
| |
Track all SVs created by sv_dup() that have a 0 reference count. If they still
have a 0 reference count at the end of cloning, assign a reference to each to
the temps stack. As the temps stack is cleared at thread exit, SVs book keeping
will be correct and consistent before perl_destruct() makes its check for
leaked scalars.
Remove special case code for checking each @_ and the parent's temp stack.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As it allocates memory dynamically, add Perl_clone_params_del(). This will
allow CLONE_PARAMS to be expand in future in a source and binary compatible
fashion.
These implementations of Perl_clone_params_new()/Perl_clone_params_del() jump
through hoops to remain source and binary compatible, in particular, by not
assuming that the structure member is present and correctly initialised. Hence
they should be suitable for inclusion into Devel::PPPort.
Convert threads.xs to use them, resolving RT #73046.
|
| |
|
|
|
|
|
| |
Add a function Perl_hv_fill to perform the count. This will save 1 IV per hash,
and on some systems cause struct xpvhv to become cache aligned.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In most places, ops checked their args for overload *before* doing
mg_get(). This meant that, among other issues, tied vars that
returned overloaded objects wouldn't trigger calling the
overloaded method. (Actually, for tied and arrays and hashes, it
still often would since mg_get gets called beforehand in rvalue
context).
This patch does the following:
Makes sure get magic is called first.
Moves most of the overload code formerly included by macros at the
start of each pp function into the separate helper functions
Perl_try_amagic_bin, Perl_try_amagic_un, S_try_amagic_ftest,
with 3 new wrapper macros:
tryAMAGICbin_MG, tryAMAGICun_MG, tryAMAGICftest_MG.
This made the code 3800 bytes smaller.
Makes sure that FETCH is not called multiple times. Much of this
bit was helped by some earlier work from Father Chrysostomos.
Added new functions and macros sv_inc_nomg(), sv_dec_nomg(),
dPOPnv_nomg, dPOPXiirl_ul_nomg, dPOPTOPnnrl_nomg, dPOPTOPiirl_ul_nomg
dPOPTOPiirl_nomg, SvIV_please_nomg, SvNV_nomg (again, some of
these were based on Father Chrysostomos's work).
Fixed the list version of the repeat operator (x): it now only
calls overloaded methods for the scalar version:
(1,2,$overloaded) x 10
no longer erroneously calls
x_method($overloaded,10))
The only thing I haven't checked/fixed yet is overloading the
iterator operator, <>.
|
| |
|
| |
|