| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
System select (select with 4 arguments) does not allow any of its
first three arguments to be read-only unless they are undef or
empty strings.
It does not work properly for read-only copy-on-write empty strings,
because it passes all copy-on-write through sv_force_normal under the
expectation that they will shortly be modified. It should not be
doing that for read-only empty strings.
|
|
|
|
|
|
|
|
|
| |
When elements of @_ refer to nonexistent hash or array elements, then
the magic scalar in $_[0] delegates all set/get actions to the element
in represents, vivifying it if needed.
tie/tied/untie, however, were not delegating to the element, but were
tying the the magical ‘deferred element’ scalar itself.
|
|
|
|
| |
The Strerror macro is defined properly to handle either case here.
|
| |
|
|
|
|
|
|
| |
This is unreachable. It only happens in pp_leavewrite when IoTOP_GV(io)
is null, but the code leading up to it makes sure that IoTOP_GV(io) is not
null. If it is still null, it jumps past the error with ‘goto forget_top’.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code dealt rather inconsistently with uids and gids. Some
places assumed that they could be safely stored in UVs, others
in IVs, others in ints; All of them should've been using the
macros from config.h instead. Similarly, code that created
SVs or pushed values into the stack was also making incorrect
assumptions -- As a point of reference, only pp_stat did the
right thing:
#if Uid_t_size > IVSIZE
mPUSHn(PL_statcache.st_uid);
#else
# if Uid_t_sign <= 0
mPUSHi(PL_statcache.st_uid);
# else
mPUSHu(PL_statcache.st_uid);
# endif
#endif
The other places were potential bugs, and some were even causing
warnings in some unusual OSs, like haiku or qnx.
This commit ammends the situation by introducing four new macros,
SvUID(), sv_setuid(), SvGID(), and sv_setgid(), and using them
where needed.
|
|
|
|
|
|
|
|
|
|
|
| |
This means that there are always macros or functions for ntohl, ntohs,
htonl and htons available, so eliminate use of HAS_NTOHL etc, and
unconditionally compile the code that it was protecting. However, as code
on CPAN is using these guard macros, define all of them in perl.h
(Technically the 4 are not quite no-ops, as they truncate their values to
32 or 16 bits, to be consistent with the implementations for platforms which
need re-ordering.)
|
|
|
|
| |
and fix the test that's meant to detect this bug.
|
|
|
|
| |
This parameter is no longer used. Its value is always 0.
|
|
|
|
|
|
| |
If Glob.xs just uses the address of PL_op as its iterator key all the
time (when called via PL_globhook too, not just via a glob override),
the code is simpler.
|
|
|
|
|
|
|
|
| |
This magic second argument is undocumented and unused on CPAN and in
the core (as of the last few commits).
It could also get in the way of making glob truly overridable in the
future (e.g., allowing File::Glob to take a list).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove a large amount of machine code (~4KB for me) from funcs that use
ERRSV making Perl faster and smaller by preventing multiple evaluation.
ERRSV is a macro that contains GvSVn which eventually conditionally calls
Perl_gv_add_by_type. If a SvTRUE or any other multiple evaluation macro
is used on ERRSV, the expansion will, in asm have dozens of calls to
Perl_gv_add_by_type one for each test/deref of the SV in SvTRUE. A less
severe problem exists when multiple funcs (sv_set*) in a row call, each
with ERRSV as an arg. Its recalculated then, Perl_gv_add_by_type and all.
I think ERRSV macro got the func call in commit f5fa9033b8, Perl RT #70862.
Prior to that commit it would be pure derefs I think. Saving the SV* is
still better than looking into interp->gv->gp to get the SV * after each
func call.
I received no responses to
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195724.html
explaining when the SV is replaced in PL_errgv, so took a conservative
view and assumed callbacks (with Perl stack/ENTER/LEAVE/eval_*/call_*)
can change it. I also assume ERRSV will never return null, this allows a
more efficiently version of SvTRUE to be used.
In Perl_newATTRSUB_flags a wasteful copy to C stack operation with the
string was removed, and a croak_notcontext to remove push instructions to
the stack. I was not sure about the interaction between ERRSV and message
sv, I didn't change it to a more efficient (instruction wise, speed, idk)
format string combining of the not safe string and ERRSV in the croak call.
If such an optimization is done, a compiler potentially will put the not
safe string on the first, unconditionally, then check PL_in_eval, and
then jump to the croak call site, or eval ERRSV, push the SV on the C stack
then push the format string "%"SVf"%s". The C stack allocated const char
array came from commit e1ec3a884f .
In Perl_eval_pv, croak_on_error was checked first to not eval ERRSV unless
necessery. I was not sure about the side effects of using a more efficient
croak_sv instead of Perl_croak (null chars, utf8, etc) so I left a comment.
nocontext used to save an push instruction on implicit sys perl.
In S_doeval, don't open a new block to avoid large whitespace changes.
The NULL assignment should optimize away unless accidental usage of errsv
in the future happens through a code change. There might be a bug here from
commit ecad31f018 since previous a char * was derefed to check for null
char, but ERRSV will never be null, so "Unknown error\n" branch will never
be taken.
For pp_sys.c, in pp_die a new block was opened to not eval ERRSV if
"well-formed exception supplied". The else if else if else blocks all used
ERRSV, so a "SV * errsv = NULL;" and a eval in the conditional with comma
op thing wouldn't work (maybe it would, see toke.c comments later in this
message). pp_warn, I have no comments.
In S_compile_runtime_code, a croak_sv question comes up same as in
Perl_eval_pv.
In S_new_constant, a eval in the conditional is done to avoid evaling
ERRSV if PL_in_eval short circuits. Same thing in Perl_yyerror_pvn.
Perl__core_swash_init I have no comments.
In the future, a SvEMPTYSTRING macro should be considered (not fully
thought out by me) to replace the SvTRUEs with something smaller and
faster when dealing with ERRSV. _nomg is another thing to think about.
In S_init_main_stash there is an opportunity to prevent an extra ERRSV
between "sv_grow(ERRSV, 240);" and "CLEAR_ERRSV();" that was too complicated
for me to optimize.
before perl517.dll
.text 0xc2f77
.rdata 0x212dc
.data 0x3948
after perl517.dll
.text 0xc20d7
.rdata 0x212dc
.data 0x3948
Numbers are from VC 2003 x86 32 bit.
|
|
|
|
|
|
|
| |
EPOC was a family of operating systems developed by Psion for mobile
devices. It was the predecessor of Symbian.
The port was last updated in April 2002.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As discussed in ticket #114820, instead of using READONLY+FAKE to mark
a copy-on-write string, we should make it a separate flag.
There are many modules in CPAN (and 1 in core, Compress::Raw::Zlib)
that assume that SvREADONLY means read-only. Only one CPAN module,
POSIX::pselect will definitely be broken by this. Others may need to
be tweaked. But I believe this is for the better.
It causes all tests except ext/Devel-Peek/t/Peek.t (which needs a tiny
tweak still) to pass under PERL_OLD_COPY_ON_WRITE, which is a prereq-
uisite for any new COW scheme that creates COWs under the same cir-
cumstances.
|
|
|
|
|
|
|
|
|
|
|
| |
Remove the context/pTHX from Perl_croak_no_modify and Perl_croak_xs_usage.
For croak_no_modify, it now has no parameters (and always has been
no return), and on some compilers will now be optimized to a conditional
jump. For Perl_croak_xs_usage one push asm opcode is removed at the caller.
For both funcs, their footprint in their callers (which probably are hot
code) is smaller, which means a tiny bit more room in the cache. My text
section went from 0xC1A2F to 0xC198F after apply this. Also see
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195233.html .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
By defining NO_TAINT_SUPPORT, all the various checks that perl does for
tainting become no-ops. It's not an entirely complete change: it doesn't
attempt to remove the taint-related interpreter variables, but instead
virtually eliminates access to it.
Why, you ask? Because it appears to speed up perl's run-time
significantly by avoiding various "are we running under taint" checks
and the like.
This change is not in a state to go into blead yet. The actual way I
implemented it might raise some (valid) objections. Basically, I
replaced all uses of the global taint variables (but not PL_taint_warn!)
with an extra layer of get/set macros (TAINT_get/TAINTING_get).
Furthermore, the change is not complete:
- PL_taint_warn would likely deserve the same treatment.
- Obviously, tests fail. We have tests for -t/-T
- Right now, I added a Perl warn() on startup when -t/-T are detected
but the perl was not compiled support it. It might be argued that it
should be silently ignored! Needs some thinking.
- Code quality concerns - needs review.
- Configure support required.
- Needs thinking: How does this tie in with CPAN XS modules that use
PL_taint and friends? It's easy to backport the new macros via PPPort,
but that doesn't magically change all code out there. Might be
harmless, though, because whenever you're running under
NO_TAINT_SUPPORT, any check of PL_taint/etc is going to come up false.
Thus, the only CPAN code that SHOULD be adversely affected is code
that changes taint state.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
sv_len_utf8 is now careful not to record caches on magical or over-
loaded scalars (any non-PV, in fact). It also returns the number of logical characters correctly, regardless of whether its input is utf8.
So we can take advantage of that to simplify pp_sysread.
For pp_syswrite, we can use sv_or_pv_len_utf8 with the existing
string buffer.
|
|
|
|
|
|
| |
printf with an empty list was reading past the end of the stack and
using whatever it found as its format. If given an empty list, it
should treat the format as "".
|
| |
|
|
|
|
|
| |
MPE/iX was a business-oriented minicomputer operating system made by
Hewlett-Packard. Support from HP terminated at the end of 2010.
|
|
|
|
|
| |
This avoids a needless strlen(), and corrects a classic usage error for the
gv_fetch*() functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
$^L is neither a magical variable, nor a normal one (like $;) but
it's just a little bit special :)
This patch removes PL_formfeed - IMHO, an extra gv_fetchpv per page
when using formats isn't going to cause a sensible speed regression.
I suppose that removing the intrpvar.h hunk from the patch is enough
to keep binary compatibility - unless someone used PL_formfeed from
an XS module.
[with regen.pl run as noted by the author, and an additional change to
perl.c to remove the reference to PL_formfeed added soon after this patch
was sent]
|
|
|
|
|
| |
VM/ESA was a mainframe OS. IBM ended service on it in June 2003. It was
superseded by Z/VM.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This removes most register declarations in C code (and accompanying
documentation) in the Perl core. Retained are those in the ext
directory, Configure, and those that are associated with assembly
language.
See:
http://stackoverflow.com/questions/314994/whats-a-good-example-of-register-variable-usage-in-c
which says, in part:
There is no good example of register usage when using modern compilers
(read: last 10+ years) because it almost never does any good and can do
some bad. When you use register, you are telling the compiler "I know
how to optimize my code better than you do" which is almost never the
case. One of three things can happen when you use register:
The compiler ignores it, this is most likely. In this case the only
harm is that you cannot take the address of the variable in the
code.
The compiler honors your request and as a result the code runs slower.
The compiler honors your request and the code runs faster, this is the least likely scenario.
Even if one compiler produces better code when you use register, there
is no reason to believe another will do the same. If you have some
critical code that the compiler is not optimizing well enough your best
bet is probably to use assembler for that part anyway but of course do
the appropriate profiling to verify the generated code is really a
problem first.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
format FOO =
@
undef *STDOUT
.
$~ = FOO;
write
Commit 7ef822cddfe9 began the work by putting in a null check and a
goto (to bypass the top format), but the goto wentto some code that
lacked the null check. (It did actually fix the case of a IO with no
ofp, but not the case of a GV with no IO.) Interestingly, it added a
bad_ofp label, but did not add the code to goto it (an oversight?).
The unused bad_ofp label was commented out in commit 9cbac4c72b52.
There was already a check before 7ef822cddfe9 to see whether there was
an ofp, but only after the format scope has been popped.
This commit extends that check by making sure there is an io first.
It removes the commented-out bad_ofp label.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Formats called recursively were using the same set of lexicals, so the
inner call would stomp on the outer calls vars, usually clearing them
when exiting.
Previous commits prepared a CvDEPTH field for formats. This commit
sets it in P(USH|OP)FORMAT and pushes a new pad in enterwrite.
This also allows closures to work properly in formats. Formerly they
caused assertion failures in cv_clone. Now cv_clone’s assumptions
about CvDEPTH on CvOUTSIDE and find_runcv are met when subs are embed-
ded in formats.
|
|
|
|
|
| |
The subdirectory containing the port specific files was purged when 5.000
was released, but changes made to other files were not removed.
|
| |
|
|
|
|
|
|
| |
As they now simply return the results of S_ft_return_false() and
S_ft_return_true() respectively, use this explicitly in the 7 places where
the macros had been used.
|
|
|
|
|
| |
This makes the true and false code paths as similar as possible. It also
eliminates a macro that the HP compiler was choking on.
|
|
|
|
|
|
| |
Move the code that implements the non-stacking return processing from the
macro FT_RETURN_FALSE() into the static function S_ft_stacking_return_false().
Rename the function to S_ft_return_false() as it now handles all false cases.
|
|
|
|
|
|
| |
Move the code which deals with setting the return value on perl's stack
ahead of the code which calculates which op to run next (the return value of
the C function).
|
|
|
|
|
|
|
|
|
|
| |
Following commit d2c4d2d1e22d3125, all filetest ops avoid manipulating the
stack pointer until the point of pushing a return value. As all the filetest
returns now go through either FT_RETURN_FALSE() or FT_RETURN_TRUE(), it's
viable to put the dSP inside those two macros and use *PL_stack_sp in place
of TOPs. This eliminates all uses of sp in the bodies of the functions
(explicit, or implicit via macros), and that makes it clear that the main
bodies of the functions are not manipulating the stack.
|
|
|
|
|
|
|
|
| |
The macros FT_RETURN_FALSE and FT_RETURN_TRUE in pp_ctl.c are already very
complex, sufficient to trigger an internal failure in HP's compiler [and
possibly also some humans :-)]. Replacing RETURNX() with the 3 statements it
expands to makes the intent of macros clearer, and exposes more refactoring
possibilities.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes Scope::Escape compatibility by restoring the old
stack pointer stored on the context stack when exiting a write.
I don’t really understand why this fixes Scope::Escape, or rather, how
Scope::Escape ends up leaving some number of items on the stack other
than 1. But I *do* know this is the correct approach, as it mirrors
what pp_leavesub does in scalar context, but pops the stack back
to the old value (SP = newsp), rather than the old value+1 (see
pp_hot.c:pp_leavesub: MARK = newsp + 1; and later SP = MARK;). Then
the code that follows takes care of pushing write’s own return value.
|
|
|
|
|
|
|
|
|
| |
In commit 5e0adc2d66, which was a bug fix, I made the mistake of
checking the truth of the return value of gv_fetchsv, which is called
when truncate’s argument is a bareword.
This meant that truncate FOO, 0; would truncate the file named FOO if
the glob happened to have been deleted.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In restore_magic(), which is called after any magic processing, all of
the public OK flags have been shifted into the private OK flags. Thus
the lack of an appropriate public OK flags was used to trigger both get
magic and required conversions. This scheme did not cover ROK, however,
so all properly written code had to make sure mg_get was called the right
number of times anyway. Meanwhile the private OK flags gained a second
purpose of marking converted but non-authoritative values (e.g. the IV
conversion of an NV), and the inadequate flag shift mechanic broke this
in some cases.
This patch removes the shift mechanic for magic flags, thus exposing (and
fixing) some improper usage of magic SVs in which mg_get() was not called
correctly. It also has the side effect of making magic get functions
specifically set their SVs to undef if that is desired, as the new behavior
of empty get functions is to leave the value unchanged. This is a feature,
as now get magic that does not modify its value, e.g. tainting, does not
have to be special cased.
The changes to cpan/ here are only temporary, for development only, to
keep blead working until upstream applies them (or something like them).
Thanks to Rik and Father C for review input.
|
| |
|
|
|
|
|
|
|
|
|
| |
I noticed today that syscall(9, ...) (mmap) doesn't work for me.
The problem is obvious, pp_syscall() uses I32 for retval and the
"long" address doesn't fit into "int".
The one-liner below should fix the problem.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
amagic_call now does its best to propagate the operator's context into
the overload callback. It's not always possible - for instance,
dereferencing and stringify/boolify/numify always have to return a
value, even if it's not used, due to the way the overload callback works
in those cases - but the majority of cases should now work. In
particular, overloading <> to handle list context properly is now
possible.
For backcompat reasons (amagic_call and friends are technically public
api functions), list context will not be propagated unless specifically
requested via the AMGf_want_list flag. If this is passed, and the
operator is called in list context, amagic_call returns an AV* holding
all of the returned values instead of an SV*. Void context always
results in amagic_call returning &PL_sv_undef.
|
| |
|
|
|
|
|
|
|
| |
I'm not sure about that POPs at the beginning of pp_leavewrite, but it
seems to work. As far as I can tell, executing the format always leaves
an extra value on the stack, but I'm not sure where that happens
exactly, so I'm just fixing it up there.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we get this:
$ ./perl -Ilib -e '$@ = "3"; warn'
3 ...caught at -e line 1.
then we shouldn’t get this:
$ ./perl -Ilib -e '$@ = 3; warn'
Warning: something's wrong at -e line 1.
as the two scalars hold the same value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pp_warn was checking flags before calling get-magic, resulting in sev-
eral bugs that I fixed all at once::
• warn now calls get-magic exactly once on its argument, when there
is just one argument (it always worked correctly for multiple)
[perl #97480].
• warn calls get-magic exactly once on $@ when falling back to it,
instead of zero times.
• A tied variable returning an object that stringifies as an empty
string is no longer ignored if the tied variable was not ROK
before FETCH.
• A tied $@ containing a string, or $@ aliased to $1, is no
longer ignored.
• A tied $@ that last returned a reference but will return a string on
the next FETCH now gets "\t...caught" appended.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
See also the previous commit.
2dd78f96 added the ‘Undefined top format called’ message for those
cases where a GV doesn’t have a name. That was a bug that used to
happen with *{$io}, which can’t happen any more.
The code that 2dd78f96 added ended up changing a zero-length name to
be treated the same way as no name. It also checked the length by
cheating and checking the first character instead.
Now that we have support for embedded nulls, that logic ends up wrong
for names like "\0foo". And there is no need to treat "" differently
from "foo" anyway.
So this patch restores things the way they were before 2dd78f96.
It also improves the tests for ‘Undefined format’.
Writing tests for ‘Undefined top format’ was quite painful, as that
error seems to leave the internal state out of synch. I suspect
PL_formtarget needs to be localised, or the error just needs to come
earlier in pp_leavewrite. But I’ll save that for later, or for Dave
Mitchell. :-)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit:
commit 2dd78f96d61cc6382dc72214930c993567209597
Author: Jarkko Hietaniemi <jhi@iki.fi>
Date: Sun Aug 6 01:33:55 2000 +0000
Continue fixing the io warnings. This also
sort of fixes bug ID 20000802.003: the core dump
is no more. Whether the current behaviour is correct
(giving a warning: "Not a format reference"), is another matter.
p4raw-id: //depot/perl@6531
added a check to see whether the format GV’s name is null, and, if
so, it dies with ‘Not a format reference’. Before that, that message
occurred only for lack of a GV.
The bug mentioned is now #3617, involving write(*STDOUT{IO}). write
puts an implicit *{} around its argument.
*{$io} has historically been very buggy in its stringification, so
this patch seems to have been working around that bugginess, by fall-
ing back to the ‘Not a format reference’ error if the name couldn’t be
determined for ‘Undefined format "foo" called’.
*{$io} was fixed once and for all in 5.16. It now stringifies as
*foopackage::__ANONIO__.
I don’t think producing a completetly different error based on the
name of the GV (whether it’s "foo" or "") is correct at all. And the
patch that made it happen was just a fix for a crash that can’t hap-
pen any more.
So the only case that should produce ‘Not a format reference’ is that
in which there is no format GV (fgv).
I can prove that fgv is always set (see below), and has been at least
since 5.000, so that ‘Not a format reference’ actually could never
occur before 2dd78f96d61c. (Actually, XS code could set PL_defoutgv
to null until the previous commit, but everything would start crashing
as a result, so it has never been done in practice.)
gv_efullname4 always returns a name, so checking SvPOK(tmpsv) is
redundant; checking whether the string buffer begins with a non-null
char is not even correct, as "\0foo" fails that test.
Proof that fgv is always set:
The current (prior to this commit) code in pp_enterwrite is like this:
if (MAXARG == 0) {
gv = PL_defoutgv;
EXTEND(SP, 1);
}
else {
gv = MUTABLE_GV(POPs);
if (!gv)
gv = PL_defoutgv;
}
If the stack value is null (which actually can’t happen), PL_defoutgv
is used. PL_defoutgv can’t be null.
At this point, gv is set to something non-null.
io = GvIO(gv);
if (!io) {
RETPUSHNO;
}
Here we only set fgv to IoFMT_GV(io) if it is non-null. Otherwise we
use gv, which we know is non-null.
if (IoFMT_GV(io))
fgv = IoFMT_GV(io);
else
fgv = gv;
|
|
|
|
|
|
|
|
|
| |
Just search through the source for GvIOp(PL_defoutgv) and you will see
that perl assumes that PL_defoutgv is never null.
I tried setting it to null from XS and got crashes, unsurprisingly.
The only CPAN user of PL_defoutgv sets it to STDOUT.
|