summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
* [perl #117743] don't warn on $@ = undef; die;Tony Cook2013-04-261-1/+2
| | | | and fix the test that's meant to detect this bug.
* Remove the second param to tryAMAGICunTARGETlistFather Chrysostomos2012-12-091-1/+1
| | | | This parameter is no longer used. Its value is always 0.
* Stop using PL_glob_index for PL_globhookFather Chrysostomos2012-12-091-4/+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.
* Don’t pass PL_glob_index to glob overridesFather Chrysostomos2012-12-091-5/+10
| | | | | | | | 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).
* prevent multiple evaluations of ERRSVDaniel Dragan2012-11-231-31/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove the EPOC port.Nicholas Clark2012-11-191-12/+0
| | | | | | | 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.
* SVf_IsCOWFather Chrysostomos2012-11-141-4/+2
| | | | | | | | | | | | | | | 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.
* rmv context from Perl_croak_no_modify and Perl_croak_xs_usageDaniel Dragan2012-11-121-1/+1
| | | | | | | | | | | 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 .
* Add C define to remove taint support from perlSteffen Mueller2012-11-051-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Don’t leak when printf causes wide warningsFather Chrysostomos2012-11-021-4/+1
|
* Don’t leak when printfing to bad handle under fatal warningsFather Chrysostomos2012-11-021-2/+2
|
* fork() should return undef on failure, even in list contextJesse Luehrs2012-10-231-2/+2
|
* pp_sys.c: Simplify uses of sv_len_utf8Father Chrysostomos2012-10-011-15/+4
| | | | | | | | | 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.
* [perl #77094] Stop printf +() from reading past SPFather Chrysostomos2012-09-241-0/+3
| | | | | | 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 "".
* Don’t leak deleted iterator when tying hashFather Chrysostomos2012-09-221-0/+7
|
* Remove the MPE/iX port.Nicholas Clark2012-09-211-2/+2
| | | | | MPE/iX was a business-oriented minicomputer operating system made by Hewlett-Packard. Support from HP terminated at the end of 2010.
* Use gv_fetchpvs() instead of gv_fetchpv(), and GV_ADD, not TRUE.Nicholas Clark2012-09-201-1/+1
| | | | | This avoids a needless strlen(), and corrects a classic usage error for the gv_fetch*() functions.
* Get rid of PL_formfeed.Enache Adrian2012-09-201-1/+1
| | | | | | | | | | | | | | | | $^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]
* Remove the VM/ESA port.Nicholas Clark2012-08-311-12/+0
| | | | | VM/ESA was a mainframe OS. IBM ended service on it in June 2003. It was superseded by Z/VM.
* Omnibus removal of register declarationsKarl Williamson2012-08-181-39/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Don’t crash when undefining handle of active formatFather Chrysostomos2012-08-051-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Recursive formats and closures in formats.Father Chrysostomos2012-08-051-1/+5
| | | | | | | | | | | | | | 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.
* Remove dead code related to the Atari ST port of perl 4.0 patchlevel 19Nicholas Clark2012-07-281-32/+0
| | | | | The subdirectory containing the port specific files was purged when 5.000 was released, but changes made to other files were not removed.
* Comment the code with how filetest operators interact with the Perl stack.Nicholas Clark2012-07-281-0/+7
|
* Eliminate the macros FT_RETURN_FALSE() and FT_RETURN_TRUE().Nicholas Clark2012-07-281-12/+7
| | | | | | 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.
* Refactor the macro FT_RETURN_TRUE() into the function S_ft_return_true()Nicholas Clark2012-07-281-12/+12
| | | | | This makes the true and false code paths as similar as possible. It also eliminates a macro that the HP compiler was choking on.
* Consolidate the code for returning false values from filetest operators.Nicholas Clark2012-07-281-12/+7
| | | | | | 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.
* Reorder S_ft_stacking_return_false().Nicholas Clark2012-07-281-4/+6
| | | | | | 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).
* Remove dSP from all filetest ops.Nicholas Clark2012-07-281-13/+8
| | | | | | | | | | 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.
* Replace the macro RETURNX() with its expansion in FT_RETURN_{FALSE,TRUE}Nicholas Clark2012-07-281-8/+14
| | | | | | | | 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.
* [perl #113872] Fix leavewrite’s stack handlingFather Chrysostomos2012-07-261-8/+2
| | | | | | | | | | | | | 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.
* Stop truncate(word) from falling back to file nameFather Chrysostomos2012-07-251-3/+3
| | | | | | | | | 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.
* Magic flags harmonization.Chip Salzenberg2012-07-151-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* use right type for offset in sysread() or syswrite()Chip Salzenberg2012-07-111-1/+1
|
* [perl #113980] pp_syscall: "I32 retval" truncates the returned valueOleg Nesterov2012-07-041-1/+1
| | | | | | | | | 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.
* propagate context into overloads [perl #47119]Jesse Luehrs2012-06-281-1/+1
| | | | | | | | | | | | | | | | | 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.
* pp_sys.c: Squelch compiler warningFather Chrysostomos2012-06-251-1/+1
|
* fix stack handling in write() [perl #73690]Jesse Luehrs2012-06-251-4/+9
| | | | | | | 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.
* Make warn treat $@=3 and $@="3" the sameFather Chrysostomos2012-06-071-1/+1
| | | | | | | | | | | | | | 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.
* Make warn handle magic vars (fixes [perl #97480])Father Chrysostomos2012-06-071-7/+16
| | | | | | | | | | | | | | | | | 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.
* Use the same top format error for ""Father Chrysostomos2012-06-071-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. :-)
* Get rid of ‘Not a format reference’Father Chrysostomos2012-06-071-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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;
* Make setdefout accept only NNFather Chrysostomos2012-06-071-1/+2
| | | | | | | | | 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.
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Block signals during fork (fixes RT#82580)Leon Timmermans2012-05-251-0/+21
|
* Fix non-GCC compilationFather Chrysostomos2012-05-211-2/+2
| | | | I mistakenly thought XPUSHs(...) was an expression. Now it is.
* pp_sys.c:S_try_amagic_ftest: Remove SPAGAINFather Chrysostomos2012-05-211-2/+0
| | | | Overloading pushes a new stack to prevent the need for this.
* pp_sys.c: Remove SPAGAIN after my_(l)stat_flagsFather Chrysostomos2012-05-211-4/+0
| | | | | As of the previous commit, these two functions no longer affect the stack.
* Move stack extension into FT_* macrosFather Chrysostomos2012-05-211-7/+3
| | | | | | | | Every filetest operator with the OPf_REF flag set has to extend the stack for the argument. One operator was missing it until the previ- ous commit. Since we have special return macros for these operators, put the stack extension there, to avoid a repeat of this type of mis- take and reduce repetitiveness.
* Make -t BAREWORD extend the stackFather Chrysostomos2012-05-211-0/+1
| | | | | It appears always to have been this way. It was writing past the end of the stack.