summaryrefslogtreecommitdiff
path: root/doop.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow assignment to &CORE::keys()Father Chrysostomos2016-05-201-2/+2
|
* Allow &CORE::foo() with hash functionsFather Chrysostomos2016-05-201-2/+6
| | | | | &CORE::keys does not yet work as an lvalue. (I’m not sure how to make that work.)
* [perl #128187] Forbid sub :lvalue{keys} in aassignFather Chrysostomos2016-05-201-0/+7
| | | | | | | | | | | | This commit makes perl die when keys(%hash) is returned from an lvalue sub and the lvalue sub call is assigned to in list assignment: sub foo : lvalue { keys(%INC) } (foo) = 3; # death This prevents an assignment that is completely useless and probably a mistake, and it makes the lvalue-sub use of keys behave the same way as (keys(%INC)) = 3.
* doop.c: fix typo in header commentDavid Mitchell2016-02-151-1/+1
|
* make gimme consistently U8David Mitchell2016-02-031-1/+1
| | | | | | | | | | | | | The value of gimme stored in the context stack is U8. Make all other uses in the main core consistent with this. My primary motivation on this was that the new function cx_pushblock(), which I gave a 'U8 gimme' parameter, was generating warnings where callers were passing I32 gimme vars to it. Rather than play whack-a-mole, it seemed simpler to just uniformly use U8 everywhere. Porting/bench.pl shows a consistent reduction of about 2 instructions on the loop and sub benchmarks, so this change isn't harming performance.
* Deprecate wide chars in logical string opsKarl Williamson2015-12-161-0/+17
| | | | | | | See thread starting at http://nntp.perl.org/group/perl.perl5.porters/227698 Ricardo Signes provided the perldelta and perldiag text.
* doop.c: Fix typo in commentKarl Williamson2015-12-161-1/+1
|
* fix up EXTEND() callersDavid Mitchell2015-10-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | The previous commit made it clear that the N argument to EXTEND() is supposed to be signed, in particular SSize_t, and now typically triggers compiler warnings where this isn't the case. This commit fixes the various places in core that passed the wrong sort of N to EXTEND(). The fixes are in three broad categories. First, where sensible, I've changed the relevant var to be SSize_t. Second, where its expected that N could never be large enough to wrap, I've just added an assert and a cast. Finally, I've added extra code to detect whether the cast could wrap/truncate, and if so set N to -1, which will trigger a panic in stack_grow(). This also fixes [perl #125937] 'x' operator on list causes segfault with possible stack corruption
* Merge declaration and initialisation of local variableDagfinn Ilmari Mannsåker2015-07-221-2/+1
| | | | | | | Commit 2b32fed8 removed the PUTBACK/SPAGAIN around hv_iterval and Perl_sv_setpvf, but didn't take the opportunity to merge the initialisation with the declaration now that there's no code between them.
* Delete experimental autoderef featureAaron Crane2015-07-131-2/+2
|
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* [perl #123759] always count on OPpTRANS_IDENTICALHugo van der Sanden2015-02-091-26/+14
| | | | | | | | | | | If we detect that an in-place transliteration will not result in any changes to the string, we set OPpTRANS_IDENTICAL and skip the normal checks for readonlyness; but if we do that, we must make sure to use the same logic to decide which transliteration strategy to use, or we may end up trying to write to the readonly string anyway. This resulted in several ways to hit assert failures, found by AFL (<http://lcamtuf.coredump.cx/afl>).
* avoid C labels in column 0David Mitchell2015-01-211-1/+1
| | | | | | | | | Generally the guideline is to outdent C labels (e.g. 'foo:') 2 columns from the surrounding code. If the label starts at column zero, then it means that diffs, such as those generated by git, display the label rather than the function name at the head of a diff block: which makes diffs harder to peruse.
* Remove PUTBACK/SPAGAIN from hash iter opsFather Chrysostomos2014-12-281-7/+2
| | | | | | | | | | These were added by perl-5a2-2-g463ee0b and perl-5.003-2-gc750a3e. At the time, hv_iternext and hv_iterval could reallocate the stack, but hv_iterkey was safe. perl-5.6.0-8537-g574c802 divorced the comments about hv_iterkey from the lines containing hv_iterkey, making things a bit confusing. Somewhere along the road, all tied hash functionality started being guarded with PUSHSTACK, so these hash functions won’t reallocate the stack any more.
* Call string overloading once in join($ov,...)Father Chrysostomos2014-10-201-4/+3
|
* Use sv_catpvn instead of sv_catsv in doop.c:do_joinFather Chrysostomos2014-10-171-2/+11
| | | | | | Bunchmarking shows that SvPV+sv_catpvn is faster that sv_catsv. Why exactly I don’t know, but perhaps fewer functions and flag checks are the cause.
* comment pp_foo aliases in pp*.cDavid Mitchell2014-09-191-0/+3
| | | | | | | | Where pp_foo() also handles OP_BAR, add a comment above the function mentioning that it also does pp_bar. This means that "grep pp_bar pp*.c" quickly locates the file/function that handles OP_BAR.
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-13/+0
| | | | | | | | 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.
* UV casting to avoid intermediate sign extension.Jarkko Hietaniemi2014-05-291-2/+2
| | | | | | | | | [perl #121746] Fix for Coverity perl5 CIDs 29069, 29070, 29071: Unintended sign extension: ... ... if ... U8 (8 bits unsigned) ... 32 bits, signed ... 64 bits, unsigned ... is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.
* vec(): downgrade before accessing string bufferDavid Mitchell2014-05-021-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This code: #!perl -l $x = substr "\x{100}\xff\xfe", 1; print vec($x, 0, 8); print vec($x, 0, 8); In 5.18 and earlier prints 255 255 With blead it prints: 195 255 This is due to the fact that it does SvPV() first to get the string buffer, then calls sv_utf8_downgrade(). With COW, the PVX of the SV may no longer equal the value earlier returned by SvPV(), but vec() continues to use the old pointer. This bug has always been present, but COW made it more noticeable. The fix is to just redo the SvPV() after a downgrade.
* Use separate macros for byte vs uv UnicodeKarl Williamson2013-09-101-3/+3
| | | | | | | This removes a macro not yet even in a development release, and splits its calls into two classes: those where the input is a byte; and those where it can be any unsigned integer. The byte implementation avoids a function call on EBCDIC platforms.
* Convert some uvuni() to uvchr()Karl Williamson2013-08-291-7/+7
| | | | | All the tables are now based on the native character set, so using uvuni() in almost all cases is wrong.
* Make tr/a/b/ croak on read-only null COWsFather Chrysostomos2013-08-111-1/+0
| | | | | | | | | | | $ ./perl -Ilib -e 'use constant nullrocow => (keys%{{""=>undef}})[0]; for(nullrocow) { y/a/b/ }' $ ./perl -Ilib -e 'use constant nullro => ""; for(nullro) { y/a/b/ }' Modification of a read-only value attempted at -e line 1. It should croak on COW scalars that are read-only, even if they are zero-length, just as it does on non-COW scalars. This logic is left over from when READONLY+FAKE meant COW.
* doop.c: Correct introductory textFather Chrysostomos2013-06-141-2/+2
| | | | do_chomp has not been in that file since 81745e4ea46c8.
* Remove "register" declarationsKarl Williamson2012-11-241-1/+1
| | | | | | | This finishes the removal of register declarations started by eb578fdb5569b91c28466a4d1939e381ff6ceaf4. It neglected the ones in function parameter declarations, and didn't include things in dist, ext, and lib, which this does include
* 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Omnibus removal of register declarationsKarl Williamson2012-08-181-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* doop.c: Simplify do_trans’ un-cow logicFather Chrysostomos2012-07-271-3/+1
| | | | | Since it calls SvPV_force_nomg a little further on, there is no need for a separate sv_force_normal call to handle COWs.
* Flatten vstrings modified in placeFather Chrysostomos2012-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A substitution forces its target to a string upon successful substitu- tion, even if the substitution did nothing: $ ./perl -Ilib -le '$a = *f; $a =~ s/f/f/; print ref \$a' SCALAR Notice that $a is no longer a glob after s///. But vstrings are different: $ ./perl -Ilib -le '$a = v102; $a =~ s/f/f/; print ref \$a' VSTRING I fixed this in 5.16 (1e6bda93) for those cases where the vstring ends up with a value that doesn’t correspond to the actual string: $ ./perl -Ilib -le '$a = v102; $a =~ s/f/o/; print ref \$a' SCALAR It works through vstring set-magic, that does the check and removes the magic if it doesn’t match. I did it that way because I couldn’t think of any other way to fix bug #29070, and I didn’t realise at the time that I hadn’t fixed all the bugs. By making SvTHINKFIRST true on a vstring, we force it through sv_force_normal before any in-place string operations. We can also make sv_force_normal handle vstrings as well. This fixes all the lin- gering-vstring-magic bugs in just two lines, making the vstring set- magic (which is also slow) redundant. It also allows the special case in sv_setsv_flags to be removed. Or at least that was what I had hoped. It turns out that pp_subst, twists and turns in tortuous ways, and needs special treatment for things like this. And do_trans functions wasn’t checking SvTHINKFIRST when arguably it should have. I tweaked sv_2pv{utf8,byte} to avoid copying magic variables that do not need copying.
* Magic flags harmonization.Chip Salzenberg2012-07-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* 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.
* Fix for [perl #9423] vec assignments generate 2 warningsBrian Fraser2012-05-261-2/+9
| | | | | | | | | | | | Before this commit, this: vec(my $v,0,1) = 1; would've produced four warnings about uninitialized values; however, the ticket argued that these were spurious. This commit removes the warning in the case of lvalue vec, since it is similar to |=, but leaves it in place for rvalue vec.
* Fix for [perl #8931], call magic only once for join's first arg.Brian Fraser2012-05-251-1/+1
|
* [rt #111730] don't use I32 for offsets in vec()Tony Cook2012-05-211-3/+3
| | | | | | do_vecset() do_vecget() used I32 for the offset, which meant that offsets outside the -2Gb - +2Gb offset were truncated, resulting in various misbehaviours.
* [perl #44895] += warning on uninit magic varFather Chrysostomos2012-01-091-1/+1
| | | | | | | | | | | | | | The only uses of USE_LEFT in core now occur when SvGETMAGIC has already been called. So returning true for magical SVs is not neces- sary. In fact, it was never correct. Also, the code in do_vop (which handles bitwise operations on strings) to avoid an uninitialized warning had the same buggy SvGMAGICAL check. Now, the warning from $uninit += 1 is suppressed for all undefined vars, not just amagical ones. This causes 6 to-do tests in assignwarn.t to pass.
* Call FETCH once for $tied_ref =~ y/a/b/Father Chrysostomos2011-11-241-1/+1
|
* Trim dead code in do_kv.Eric Brine2011-08-241-14/+2
| | | | | | | | | | | | | | | | | | | | A small piece of code in do_kv has three bugs: - TARG could have been returned as an lvalue, so its refcount could be greater than 1, resulting in data getting clobbered. (See RT#20933 for previously fixed occurrence of this bug). - LvTARG is refcounted, so it's buggy to just NULL it. - TARG is returned without being initialised. The first two bugs disappeared recently when we stopped putting the lvalues in TARG for that op. The third remains. However, it seems that code is never called. It can only be called by putting NULL (not undef) on the Perl stack. I don't see how that's possible here. The test suite never reaches that code, so it seems it's just dead code.
* Clean: Actually use HvUSEDKEYS() instead of HvKEYS()Michael Witten2011-05-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This: commit 8aacddc1ea3837f8f1a911d90c644451fc7cfc86 Author: Nick Ing-Simmons <nik@tiuk.ti.com> Date: Tue Dec 18 15:55:22 2001 +0000 Tidied version of Jeffrey Friedl's <jfriedl@yahoo.com> restricted hashes - added delete of READONLY value inhibit & test for same - re-tabbed p4raw-id: //depot/perlio@13760 essentially deprecated HvKEYS() in favor of HvUSEDKEYS(); this is explained in line 144 (now 313) of file `hv.h': /* * HvKEYS gets the number of keys that actually exist(), and is provided * for backwards compatibility with old XS code. The core uses HvUSEDKEYS * (keys, excluding placeholdes) and HvTOTALKEYS (including placeholders) */ This commit simply puts that into practice, and is equivalent to running the following (at least with a35ef416833511da752c4b5b836b7a8915712aab checked out): git grep -l HvKEYS | sed /hv.h/d | xargs sed -i s/HvKEYS/HvUSEDKEYS/ Notice that HvKEYS is currently just an alias for HvUSEDKEYS: $ git show a35ef416833511da752c4b5b836b7a8915712aab:hv.h | sed -n 318p #define HvKEYS(hv) HvUSEDKEYS(hv) According to `make tests': All tests successful.
* [perl #82250] fix tainted (s)print formatDavid Mitchell2011-03-141-0/+8
| | | | | | | | | | | | commit 20ee07fbbcfa6be9f90bb8e5474a4d69d7396617 introduced dieing in (s)printf when the format is tainted; however it only worked when the format is part of an expression (because TAINT_PROPER checks for PL_tainted being set). Fix by doing TAINT_PROPER only after get magic has been done on the format SV (which will set PL_tainted). This is done by moving the checks in pp_sprintf and pp_prtf into do_sprintf() (which is called by the two pp functions).
* Move do_chomp() from pp.c to doop.c, and make it static.Nicholas Clark2010-12-271-167/+0
| | | | It was never part of the public API, and only ever used by pp_{s,}cho{,m}p.
* Merge Perl_do_chop() and Perl_do_chomp().Nicholas Clark2010-12-271-90/+45
| | | | | | They share code for dealing with PVAVs, PVHVs, read only values and handling PL_encoding. They are not part of the public API, and Google codesearch shows no users outside the core.
* Convert Perl_do_chomp() to the same prototype as Perl_do_chop().Nicholas Clark2010-12-271-15/+12
| | | | Pass in an SV to hold the count, rather than returning the count.
* Allow push/pop/keys/etc to act on referencesDavid Golden2010-10-311-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All built-in functions that operate directly on array or hash containers now also accept hard references to arrays or hashes: |----------------------------+---------------------------| | Traditional syntax | Terse syntax | |----------------------------+---------------------------| | push @$arrayref, @stuff | push $arrayref, @stuff | | unshift @$arrayref, @stuff | unshift $arrayref, @stuff | | pop @$arrayref | pop $arrayref | | shift @$arrayref | shift $arrayref | | splice @$arrayref, 0, 2 | splice $arrayref, 0, 2 | | keys %$hashref | keys $hashref | | keys @$arrayref | keys $arrayref | | values %$hashref | values $hashref | | values @$arrayref | values $arrayref | | ($k,$v) = each %$hashref | ($k,$v) = each $hashref | | ($k,$v) = each @$arrayref | ($k,$v) = each $arrayref | |----------------------------+---------------------------| This allows these built-in functions to act on long dereferencing chains or on the return value of subroutines without needing to wrap them in C<@{}> or C<%{}>: push @{$obj->tags}, $new_tag; # old way push $obj->tags, $new_tag; # new way for ( keys %{$hoh->{genres}{artists}} ) {...} # old way for ( keys $hoh->{genres}{artists} ) {...} # new way For C<push>, C<unshift> and C<splice>, the reference will auto-vivify if it is not defined, just as if it were wrapped with C<@{}>. Calling C<keys> or C<values> directly on a reference gives a substantial performance improvement over explicit dereferencing. For C<keys>, C<values>, C<each>, when overloaded dereferencing is present, the overloaded dereference is used instead of dereferencing the underlying reftype. Warnings are issued about assumptions made in the following three ambiguous cases: (a) If both %{} and @{} overloading exists, %{} is used (b) If %{} overloading exists on a blessed arrayref, %{} is used (c) If @{} overloading exists on a blessed hashref, @{} is used
* [perl #76814] FETCH called twice - yFather Chrysostomos2010-09-241-6/+6
| | | | | This patch stops y from calling get-magic twice. (This has caused double magick since as far back as 5.6.2.)
* Fix untimely destruction introduced by lvalue ops [RT#67838] by returning a ↵Eric Brine2010-08-131-22/+16
| | | | TEMP instead of using TARG. Made appropriate TODO tests live.
* Add Perl_croak_no_modify() to implement Perl_croak("%s", PL_no_modify).Nicholas Clark2010-06-271-3/+3
| | | | | This reduces object code size, reducing CPU cache pressure on the non-exception paths.
* SvREFCNT_dec already checks if the SV is non-NULL (continued)Vincent Pit2009-11-081-2/+1
|
* SvREFCNT_dec already checks if the SV is non-NULLVincent Pit2009-11-051-2/+1
|
* Add Perl_ck_warner(), which combines Perl_ckwarn() and Perl_warner().Nicholas Clark2009-10-121-9/+6
| | | | | | | Replace ckWARN{,2,3,4}() && Perl_warner() with it, which trades reduced code size (about 0.2%), for 1 more function call if warnings are not enabled. However, if we're now in the L1 or L2 cache when we weren't previously, that's still going to be a speed win.