summaryrefslogtreecommitdiff
path: root/embed.fnc
Commit message (Collapse)AuthorAgeFilesLines
* don't segfault given string repeat count larger than 2^31Jim Meyering2011-10-231-1/+1
| | | | | | | | | | | E.g., this overflows INT_MAX and overruns heap memory: $ perl -le 'print "v"x(2**31+1)' [Exit 139 (SEGV)] (Perl_repeatcpy): Use the same type for "count" as our sole callers in pp.c: IV (long), not I32 (int). Otherwise, passing the wider value to a narrower "I32 count"
* simplify op_dump() / -Dx sequencingDavid Mitchell2011-10-171-2/+0
| | | | | | | | | | | | | | | | Currently, whenever we dump an op tree, we first call sequence(), which walks the tree, creating address => sequence# mappings in PL_op_sequence. Then when individual ops or op-next fields are displayed, the sequence is looked up. Instead, do away with the initial walk, and just map addresses on request. This simplifies the code. As a deliberate side-effect, it no longer assigns a seq# of zero to null ops. This makes it easer to work out what's going on when you call op_dump() during a debugging session with partially constructed op-trees. It also removes the ambiguity in "====> 0" as to whether op_next is NULL or just points to an op_null.
* Cast to signed before negating, to avoid compiler warningsBrian Fraser2011-10-061-2/+2
|
* Restore whichsig to the list in perlapiFather Chrysostomos2011-10-061-0/+1
|
* whichsig nul-cleanup.Brian Fraser2011-10-061-1/+3
| | | | | This adds _pv, _pvn, and _pv versions of whichsig() in mg.c, which get both kill "NAME" and %SIG lookup nul-clean.
* Oust cv_ckproto_lenFather Chrysostomos2011-10-061-2/+0
| | | | | | | | | | It is no longer used in core (having been superseded by cv_ckproto_len_flags), is unused on CPAN, and is not part of the API. The cv_ckproto ‘public’ macro is modified to use the _flags version. I put ‘public’ in quotes because, even before this commit, cv_ckproto was using a non-exported function, and hence could never have worked on a strict linker (or whatever you call it).
* toke.c, op.c, sv.c: Prototype parsing and checking are nul-and-UTF8 clean.Brian Fraser2011-10-061-0/+3
| | | | | | | | | | | | This means that eval "sub foo ($;\0whoops) { say @_ }" will correctly include \0whoops in the CV's prototype (while complaining about illegal characters), and that use utf8; BEGIN { $::{"foo"} = "\$\0L\351on" } BEGIN { eval "sub foo (\$\0L\x{c3}\x{a9}on) {};"; } will not warn about a mismatched prototype.
* universal.c: sv_does() UTF8 cleanup.Brian Fraser2011-10-061-0/+4
| | | | | This adds _sv, _pv, and _pvn forms to sv_does, and changes it to use sv_ref() instead of sv_reftype().
* mro UTF8 cleanup.Brian Fraser2011-10-061-1/+1
| | | | | | | | | | | This patch also duplicates existing mro tests with copies that use Unicode in identifiers, to test the mro code. Since those tests trigger it, it also fixes a bug in the parsing of *{...}: If the first character inside the braces is a non-ASCII Unicode identifier character, the inside is now implicitly quoted if it is just an identifier (just as it is with ASCII identifiers), instead of being parsed as a bareword that would violate strict subs.
* universal.c: ->isa, sv_derived_from UTF8 cleanup.Brian Fraser2011-10-061-1/+6
| | | | | | | This makes them both nul-and-UTF8 clean, although the latter is somewhat superficial, as mro isn't clean yet. (Tests coming once ->can and ->DOES are clean)
* pp.c & sv.c: pp_ref UTF8 and null cleanup.Brian Fraser2011-10-061-0/+1
| | | | | | | | | This adds a new function to sv.c, sv_ref, which is a nul-and-UTF8 clean version of sv_reftype. pp_ref now uses that. sv_ref() not only returns the SV, but also takes in an SV to modify, so we can say both sv_ref(TARG, obj, TRUE); and sv = sv_ref(NULL, obj, TRUE);
* Add a sv_sethek() function to sv.cBrian Fraser2011-10-061-0/+1
| | | | This is exported so that attributes.xs can use it.
* op.c: newCONSTSUB and newXS UTF8 cleanup.Brian Fraser2011-10-061-0/+1
| | | | | | | | newXS was merged into newXS_flags; added a line in the docs recommeding using that instead. newCONSTSUB got a _flags version, which generates the CV in the right glob if passed the UTF-8 flag.
* Merge multi and flags params to gv_init_*Father Chrysostomos2011-10-061-3/+3
| | | | | Since multi is a boolean (even though it’s typed as an int), there is no need to have a separate parameter. We can just use a flag bit.
* Restore newGVgen to perlapi.podFather Chrysostomos2011-10-061-0/+1
|
* gv.c: newGVgen_flags and a flags parameter for gv_get_super_pkg.Brian Fraser2011-10-061-2/+2
|
* Remove method param from gv_autoload_*Father Chrysostomos2011-10-061-3/+3
| | | | | | | | method is a boolean flag (typed I32, but used as a boolean) added by commit 54310121b442. These new gv_autoload_* functions have a flags parameter, so there’s no reason for this extra effective bool. We can just use a flag bit.
* Remove 4 from new gv_autoload4_(sv|pvn?) functionsFather Chrysostomos2011-10-061-3/+3
| | | | | | | | | | | | The 4 was added in commit 54310121b442 (inseparable changes during 5.003/4 developement), presumably the ‘Don't look up &AUTOLOAD in @ISA when calling plain function’ part. Before that, gv_autoload had three arguments, so the 4 indicated the new version (with the method argument). Since these new functions don’t all have four arguments, and since they have a new naming convention, there is not reason for the 4.
* Restore gv_autoload4 to perlapi.podFather Chrysostomos2011-10-061-0/+2
| | | | | Even if it’s not documented (which I hope to rectify), it should still continue to be listed in perlapi.
* gv.c: Added gv_autoload4_(sv|pv|pvn)Brian Fraser2011-10-061-1/+5
|
* gv.c: Added gv_fetchmethod_(sv|pv|pvn)_flags.Brian Fraser2011-10-061-2/+5
| | | | | | In addition from taking a flags parameter, it also takes the length of the method; This will eventually make method lookup nul-clean.
* Restore gv_fetchmeth_autoload to perlapi.podFather Chrysostomos2011-10-061-0/+3
|
* gv.c: Added gv_fetchmeth_(sv|pv|pvn)_autoload.Brian Fraser2011-10-061-1/+5
|
* Restore gv_fetchmeth to perlapiFather Chrysostomos2011-10-061-0/+2
|
* gv.c: Added gv_fetchmeth_(sv|pv|pvn).Brian Fraser2011-10-061-1/+5
| | | | | I'm probably pushing this too early. Can't do the Perl-level tests because of that. TODO.
* Document gv_init*Father Chrysostomos2011-10-061-0/+2
|
* gv.c: Added gv_init_(sv|pv|pvn), renamed gv_init_sv as gv_init_svtype.Brian Fraser2011-10-061-2/+6
| | | | | | | | | gv_init_pvn() is the same as the old gv_init(), but takes a flags parameter, which will be used for the UTF-8 cleanup. The old gv_init() is now implemeneted as a macro in gv.h. Also included is some minimal testing in XS::APItest.
* utf8.c: Add function to retrieve new _Perl_IDStart propKarl Williamson2011-10-011-0/+1
|
* regcomp.c: Add invlist_invert_prop()Karl Williamson2011-10-011-0/+1
| | | | | | | | | This new function inverts a Unicode property. A regular inversion doesn't work because it operates on the whole of the code space, and Unicode property inversions don't invert above-Unicode code points. This does for inversion lists, what an earlier commit did for swashes. This function is currently not called by anyone.
* [perl #93590] $tainted ~~ [...] failingFather Chrysostomos2011-09-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When smartmatch is about to start, to avoid calling get-magic (e.g., FETCH methods) more than once, it copies any argument that has get-magic. Tainting uses get-magic to taint the expression. Calling mg_get(sv) on a tainted scalar causes PL_tainted to be set, causing any scalars modified by sv_setsv_flags to be tainted. That means that tainting magic gets copied from one scalar to another. So when smartmatch tries to copy the variable to avoid repeated calls to magic, it still copies taint magic to the new variable. For $scalar ~~ @array (or ~~ [...]), S_do_smartmatch calls itself recursively for each element of @array, with $scalar (on the suppos- edly non-magical copy of $scalar) on the left and the element on the right. In that recursive call, it again does the get-magic check and copies the argument. Since the copied of a tainted variable on the LHS is magical, it gets copied again. Since the first copy is a mortal (marked TEMP) with a refcount of one, the second copy steal its string buffer. The outer call to S_do_smartmatch then proceeds with the second ele- ment of @array, without realising that its copy of $scalar has lost its string buffer and is now undefined. So these produce incorrect results under -T (where $^X is ‘perl’): $^X =~ ["whatever", undef] # matches $^X =~ ["whatever", "perl"] # fails This problem did not start occurring until this commit: commit 8985fe98dcc5c0af2fadeac15dfbc13f553ee7fc Author: David Mitchell <davem@iabyn.com> Date: Thu Dec 30 10:32:44 2010 +0000 Better handling of magic methods freeing the SV mg_get used to increase the refcount unconditionally, pushing it on to the mortals stack. So the magical copy would have had a refcount of 2, preventing its string buffer from being stolen. Now it has a ref- erence count of 1. This commit solves it by adding a new parameter to S_do_smartmatch telling it that the variable has already been copied and does not even need to be checked. The $scalar~~@array case sets that parameter for the recursive calls. That avoids the whole string-stealing problem *and* avoids extra unnecessary SVs.
* remove index offsetting ($[)Zefram2011-09-091-1/+0
| | | | | | $[ remains as a variable. It no longer has compile-time magic. At runtime, it always reads as zero, accepts a write of zero, but dies on writing any other value.
* Move non-constant folding parts of fold_constants into a separate functions.Gerard Goossen2011-09-051-0/+2
| | | | | | | | | | The non-constant folding parts of fold_constants are moved into separate functions. op_integerize handles converting ops to integer (and special case of OP_NEGATE), op_std_init handling some standard functionality (forced scalar context and allocating the TARGET). Both functions are called where fold_constants is called (but we might want to make that a bit some selective and use op_std_init in other places).
* Eliminate is_gv_magical_svFather Chrysostomos2011-08-301-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This resolves perl bug #97978. Many built-in variables, like $], are actually created on the fly when first accessed. Perl likes to pretend that these variables have always existed, so it autovivifies the *] glob even in rvalue context (e.g., defined *{"]"}, close "]"). The list of variables that were autovivified was maintained separ- ately (in is_gv_magical_sv) from the code that actually creates them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it *wasn’t* being maintained, and there were new variables that never got added to is_gv_magical_sv and one deleted variable that was never removed. There are only two pieces of code that call is_gv_magical_sv, both in pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}). In both cases, the glob is immediately autovivified if is_gv_magical_sv returns true. So this commit eliminates the extra maintenance burden by extirpat- ing is_gv_magical_sv altogether, and replacing it with a new flag to gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a magical one. It does make defined(*{"frobbly"}) slightly slower, in that it creates a temporary glob and then frees it when it sees nothing magical has been done with it. But this case is rare enough it should not matter. At least I got rid of the bugginess.
* Eliminate global.sym, as makedef.pl can generate it internally.Nicholas Clark2011-08-251-5/+5
| | | | | | | | global.sym was a file listing the exported symbols, generated by regen/embed.pl from embed.fnc and regen/opcodes, which was only used by makedef.pl Move the code that generates global.sym from regen/embed.pl to makedef.pl, and thereby eliminate the need to ship a 907 line generated file.
* Move coresub op-creation from gv.c to op.cFather Chrysostomos2011-08-241-0/+3
| | | | | | | | | | | | For functions that take handles as arguments, this code will need to call static functions in op.c, like is_handle_constructor. While we could make is_handle_constructor into a non-static function and call it from gv.c, that seems backwards, as it would result in a lot of op-manipulation code in the middle of gv.c. So this commit creates a new function in op.c, called coresub_op, which is only called from gv.c, from the &CORE::sub code.
* Add find_rundefsv2 functionFather Chrysostomos2011-08-241-0/+2
| | | | | | | | | | Subs in the CORE package with a (_) prototype will use this. This accepts a CV and a sequence number, so that one can use it to find the $_ in the caller’s scope. It only uses the topmost call of a subroutine that is being called recur- sively, so it’s not really a general-purpose function. But it suffices for &CORE::abs and friends.
* Move making inplace sort and reverse away from the peephole optimiser to ↵Gerard Goossen2011-08-241-1/+1
| | | | | | | | scalarvoid. Why: The in place assignment is not just an optimisation but has significant different behaviour and thus doesn't belong in the peephole optimiser. Also the optree changes are unified and simpler.
* Revert "Test CORE::break’s prototype"Father Chrysostomos2011-08-241-1/+1
| | | | | | | | | This reverts commit e52d58aa5bea245b66786b4c9029e849a2be69d3. I don’t quite know how I managed it, but I really screw up this time! Two completely unrelated commits ended up getting merged into one, so, to avoid confusion down the road, I’m reverting it, only to reapply it shortly....
* Test CORE::break’s prototypeFather Chrysostomos2011-08-241-1/+1
|
* [perl #97088] Prevent double get-magic in various casesGerard Goossen2011-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch prevents get-magic from executing twice during autovivifi- cation when the op doing the autovivification is not directly nested inside the dereferencing op. This can happen in cases like this: ${ (), $a } = 1; Previously (as of 5.13.something), the outer op was marked with the OPpDEREFed flag, which indicated that get-magic had already been called by the vivifying op (calling get-magic during vivification is inevitable): $ perl5.14.0 -MO=Concise -e '${ $a } = 1' 8 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v:{ ->3 7 <2> sassign vKS/2 ->8 3 <$> const[IV 1] s ->4 6 <1> rv2sv sKRM*/DREFed,1 ->7 <-- right here - <@> scope sK ->6 - <0> ex-nextstate v ->4 5 <1> rv2sv sKM/DREFSV,1 ->6 4 <#> gv[*a] s ->5 -e syntax OK But in the ${()...} example above, there is a list op in the way that prevents the flag from being set inside the peephole optimizer. It’s not even possible to set it correctly in all cases, as in this exam- ple, which would need it both set and not set depending on which branch of the ternary operator is executed: ${ $x ? delete $a[0] : $a[0] } = 1 Instead of setting the OPpDEREFed flag, we now make a non-magic copy of the SV in vivify_ref (the first time get-magic is executed).
* Move pp_-specific code out of core_prototypeFather Chrysostomos2011-08-141-2/+1
| | | | | | | | | | | | | | Commit b8c38f0a2a65 refactored pp_prototype by moving much of its code to a new function in op.c, called core_prototype. This served two purposes: (1) to allow the code to be simplified, which required the use of static functions in op.c, and (2) to allow the &CORE::subs feature to share the same code. But some code was moved to core_prototype which, in hindsight, did not need to be moved, such as the ‘Can’t find an opnumber’ message. This commit moves that code back to pp_prototype, resulting in a sim- pler (and possibly faster, at least for &CORE::subs) core_prototype.
* Change core_prototype to take a keyword numFather Chrysostomos2011-08-141-1/+1
| | | | | | | | | | | | | This refactoring requires the caller to provide the keyword number to core_prototype. Consequently, it speeds up the code in gv.c:gv_fetchpvn_flags by allowing it to avoid an extra call to keyword(). This takes the place of the len parameter, which is no longer used. It used to be used only as an argument to keyword(). Since the code that uses strEQ is only reached if the keyword has already been veri- fied by keyword(), the name simply cannot have embedded nulls, so len is not necessary.
* Add inlinable &CORE::functionsFather Chrysostomos2011-08-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit allows this to work: BEGIN { *entangle = \&CORE::tie }; entangle $foo, $package; And the entangle call gets inlined as a tie op, the resulting op tree being indistinguishable. These subs are not yet callable via &foo syntax or through a refer- ence. That will come later, except for some functions, like sort(), which will probably never support it. Almost all overridable functions are supported. These few are not: - infix operators - not and getprotobynumber (can’t get the precedence right yet; prototype problem) - dump Subsequent commits (hopefully!) will deal with those. How this works: gv_fetchpvn_flags is extended with hooks to create subs inside the CORE package. Those subs are XSUBs (whose C function dies with an error, for now at least) with a call checker that blows away the entersub op and replaces it with whatever op the sub represents. This is slightly inefficient right now, as gv_fetchpvn_flags calls keyword(), only to have core_prototype call it again. That will be fixed in a future refactoring.
* Make core_prototype provide the op number as wellFather Chrysostomos2011-08-141-1/+2
| | | | | | | Since it has to calculate it, it might as well provide it, so callers do not have to go through that while(i < MAXO) loop yet again. (The &CORE::foo feature will use this.)
* Move bareword checking from the peephole optimizer to finalize_optree. Fixes ↵Gerard Goossen2011-08-111-1/+1
| | | | | | | | | | [perl #95998] The bareword checking is moved from the peephole optimizer to finalize_optree. newRANGE needs additional bareword checking because the constants may be optimized away by 'gen_constant_list'. The OPpCONST_STRICT flag is removed after giving an error about a bareword to prevent giving multiple errors about the same bareword.
* Move aassign common var detection to a separate function.Gerard Goossen2011-08-081-0/+3
|
* Remove Perl_modFather Chrysostomos2011-08-021-2/+0
| | | | | | | After mod was renamed to op_lvalue, this stub was added temporarily to provide a smoother transition for the compilers. The compiler maintainer is happy with its extirpation at this stage. See ticket #78908.
* Add finalize_optree function which can take over all the compile time ↵Gerard Goossen2011-07-281-0/+4
| | | | | | | | | | | | checking/finalization now being done by the peephole optimizer. This function takes the optree after it is finished building. It takes over some of the checking and final conversions which are currently being done by the peephole optimizer. Add the moment this is an unnecessary extra step after the peephole optimizer, but with a separate code generation step, the current peephole optimizer can't exists and this function will take over all its essential compile time functions.
* core_prototype: Remove special cases for lock and tieFather Chrysostomos2011-07-261-1/+1
| | | | | | | | core_prototype now calls scalar_mod_type in the OA_SCALARREF case. For core functions, the only thing distinguishing the \$ and \[$@%*] cases during parsing is the call to scalar_mod_type in op_lvalue_flags. So calling this same function here just works.
* Add core_prototype; make pp_prototype use itFather Chrysostomos2011-07-261-0/+3
| | | | | | | | | | | | | | | | This commit moves the code for generating core prototypes into a sepa- rate function, core_prototype, in op.c. This serves two porpoises: • It allows the lock and tie exceptional cases to be incorporated into the main prototype=generation code, which requires the use of a static function in op.c. • It allows other parts of the core (e.g., the upcoming \&CORE::foo feature) to use the same code. The docs for it are in a section boringly entitled ‘Functions in op.c’, for lack of a better name. This, I believe, is the only op.c function that is in perlintern currently, so it’s hard to see what to name a section that will, at least for now, contain nothing else.