summaryrefslogtreecommitdiff
path: root/proto.h
Commit message (Collapse)AuthorAgeFilesLines
* Move non-constant folding parts of fold_constants into a separate functions.Gerard Goossen2011-09-051-0/+10
| | | | | | | | | | 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-6/+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.
* Move coresub op-creation from gv.c to op.cFather Chrysostomos2011-08-241-0/+5
| | | | | | | | | | | | 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/+5
| | | | | | | | | | 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-5/+5
| | | | | | | | 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-5/+5
| | | | | | | | | 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-5/+5
|
* [perl #97088] Prevent double get-magic in various casesGerard Goossen2011-08-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Refactor unpack’s newDEFSVOP logic; correct prototypeFather Chrysostomos2011-08-211-6/+0
| | | | | | | | | | | | | | | | | unpack is the only op that takes an implicit $_ for its second argu- ment. (For others it’s the first.) Instead of special-casing unpack with its own ck_ routine, we can sim- ply modify the logic in ck_fun to apply OA_DEFGV to the first optional argument, not just the first argument. Currently OA_DEFGV is not set in PL_opargs[OP_UNPACK], which means the automatically-generated prototype is ($;$), instead of ($_). This commit sets the flag on the op, changes it to use ck_fun directly, and updates ck_fun and the prototype-generation code accord- ingly. I couldn’t put this in multiple commits, as the changes are interdependent.
* Move pp_-specific code out of core_prototypeFather Chrysostomos2011-08-141-1/+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/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | 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/+1
|
* Remove Perl_modFather Chrysostomos2011-08-021-1/+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/+10
| | | | | | | | | | | | 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-4/+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/+5
| | | | | | | | | | | | | | | | 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.
* Perl_my_p{open,close} do not exist under PERL_IMPLICIT_SYS.Nicholas Clark2011-07-241-7/+9
| | | | | PERL_IMPLICIT_SYS only builds on Win32. Correct embed.fnc to reflect the reality.
* do_exec needs no compatibility version in mathoms.c as it's not in the API.Nicholas Clark2011-07-241-2/+0
| | | | | | | | | 9555a685dbd794b0 replaced it with a macro and added the full-name version in mathoms.c to retain compatibility with any program whose source code uses the full name. However, as do_exec was never in the API, no program would be using it. (It's also unconditionally explicitly not exported on various platforms including Win32. Google Codesearch and grep.cpan.me find no users of it outside the core.)
* Rename store/fetch_cop_label as cop_*Father Chrysostomos2011-07-161-11/+11
| | | | | | | | This makes them consistent with other functions that put the basic datum type first (like hv_*, sv_*, cophh_*). Since fetch_cop_label is marked as experimental (M), this change should be OK.
* Make prototypes and declarations for Perl_pad_add_name_{pv,pvn,sv} agree.Nicholas Clark2011-07-141-2/+2
| | | | | | cc76b5cc1552a605 added all 3 functions to the API, but declared prototypes with const U32 flags, whilst the definitions had that parameter non-const. Some compilers issue warnings about this inconsistency.
* Added a flags parameter to pad_findlex.Brian Fraser2011-07-121-4/+4
|
* APIify pad functionsZefram2011-07-121-15/+37
| | | | | | | Move several pad functions into the core API. Document the pad functions more consistently for perlapi. Fix the interface issues around delimitation of lexical variable names, providing _pvn, _pvs, _pv, and _sv forms of pad_add_name and pad_findmy.
* Propagate (non-)lvalue context through nested callsFather Chrysostomos2011-07-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, this code would fail: $foo = "foo"; sub foo :lvalue{ return index "foo","o" } sub bar :lvalue { foo } $x = bar; (It would fail for ‘return $]’ as well. Whether it’s a PADTMP or a read-only scalar makes no difference.) foo would think it was being called in true lvalue context, because the entersub op that called it (in bar) was marked that way, bar being an lvalue sub as well. The PUSHSUB macro in cop.h needed to be modified to account for dynamic, or indetermine, context (i.e., indeterminable at compile time). This happens when an entersub op is an argument to return or the last statement in a subroutine. In those cases it has to propa- gate the context from the caller. So what we now do is this: Both lvalue and in-args flags are turned on for an entersub op when op_lvalue is called with OP_LEAVESUBLV as the type. Then PUSHSUB copies into the context stack only those flags that are set both on the current entersub op and in the context stack for the previous sub call.
* Restrict some inversion list functionsKarl Williamson2011-07-031-20/+20
| | | | | These functions are internal only with names beginning with underscore. I hadn't realized that their definitions could be restricted.
* Allow utf8.c to access 4 inversion list functionsKarl Williamson2011-07-031-26/+28
|
* Change 4 inversion list functions from S_ to Perl_Karl Williamson2011-07-031-4/+4
| | | | | This is in preparation for them to be called from another file. Note that they are still protected by an #ifdef in embed.fnc.
* Change _invlist_invert() from being in-lineKarl Williamson2011-07-031-1/+1
| | | | | | This is in preparation for it to be called from another file. If for performance reasons it needs to be made inline again, it could then be moved into a header.
* Change names of some inversion list functionsKarl Williamson2011-07-031-26/+26
| | | | | | The names now begin with an underscore to emphasize that they are for internal use only. This is in preparation for making them accessible beyond regcomp.c.
* Add 3 methods for inversion listsKarl Williamson2011-07-031-0/+18
| | | | This adds inversion, cloning, and set subtraction
* Add an element to inversion list data structureKarl Williamson2011-07-031-0/+12
| | | | | This element is restricted to either 0 or 1. The comments detail how its use enables an inversion list to be efficiently inverted.
* Add length element to inversion listsKarl Williamson2011-07-031-0/+6
| | | | | Future changes will make the length no longer the same as SvCUR, so create an element to hold the correct length
* Add iterator for inversion listsKarl Williamson2011-07-031-0/+19
|
* regcomp.c: Rmv no longer called functionKarl Williamson2011-07-031-5/+0
| | | | | | | | | | | | | | This hasn't been used since 626725768b7b17463e9ec7b92e2da37105036252 Author: Nicholas Clark <nick@ccl4.org> Date: Thu May 26 22:29:40 2011 -0600 regcomp.c: Fix memory leak regression here was a remaining memory leak in the new inversion lists data structure under threading. This solves it by changing the implementation to use a SVpPV instead of doing our own memory management. Then the already existing code for handling SVs returns the memory when done.
* regcomp.c: Remove no longer called functionKarl Williamson2011-07-031-5/+0
| | | | | | The invlist_destroy function was misleading, as it has changed to just decrement the reference count, which may or may not lead to immediate destruction
* regcomp.c: Revise inversion list APIKarl Williamson2011-07-031-8/+8
| | | | | | | These are static functions so no external effect. Revise the calling sequence of two functions so that they can know enough to free memory if appropriate of the other parameters. This hides from the callers the need for tracking when to free memory.
* Change inversion lists to SVsKarl Williamson2011-07-031-17/+17
| | | | | | The inversion list is an opaque object, currently implemented as an SV. Even if it ends up being an HV in the future, Nicholas is of the opinion that it should be presented to the world as an SV*.
* Factor stack adjustments on leave in a new static functionVincent Pit2011-06-261-0/+7
| | | | This is just a refactoring. There should be no functional changes.
* add do_ncmp fn and make pp_ncmp, pp_eq etc use itDavid Mitchell2011-06-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | Extract most of the body of pp_ncmp() (numeric compare) into a separate function, do_ncmp(), then make the following ops use it: pp_ncmp pp_lt pp_le pp_eq pp_ne pp_ge pp_gt This removes a lot of similar or duplicated code, most of which is dedicated to handling the various combinations of IV verses UV verses NV verses NaN. The various ops first check for, and directly process, the simple and common case of both args being SvIOK_notUV(), and pass the processing on to do_ncmp() otherwise. Benchmarking seems to indicate (but with a lot of noise) that the SvIOK_notUV case is slightly faster than before, and the do_ncmp() branch slightly slower.
* op_lvalue .= _flagsFather Chrysostomos2011-06-241-1/+2
| | | | | | | | | | Add flags param to op_lvalue, so that the caller can ask it not to croak when encountering an unmodifiable op (upcoming). This is in preparation for making the \$ prototype accept any lvalue. There is no mathom, as the changes that this will support are by no means suitable for maint.
* regcomp.c: Fix memory leak regressionNicholas Clark2011-05-261-6/+0
| | | | | | | | There was a remaining memory leak in the new inversion lists data structure under threading. This solves it by changing the implementation to use a SVpPV instead of doing our own memory management. Then the already existing code for handling SVs returns the memory when done.
* add hfree_next_entry(), hv_free_ent_ret()David Mitchell2011-05-191-0/+13
| | | | | | | | | | | | | Move body of hfreeentries()' central loop into a new function, hfree_next_entry(); leaving hfreeentries() as a simple loop that calls hfree_next_entry() until there are no entries left. This will in future allow sv_clear() to free a hash iteratively rather than recursively. Similarly, turn hv_free_ent() into a thin wrapper around a new function, hv_free_ent_ret(), which doesn't free HeVAL(), but rather just returns the SV instead.
* Store the compiled format in mg_ptr instead of after SvCUR() - fixes RT #89218Nicholas Clark2011-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Formats are compiled down to a sequence of U32 opcodes in doparseform(). Previously the block of opcodes was stored in the buffer of SvPVX() after the raw string by extending the buffer, and calculating the first U32 aligned address after SvCUR(). A flag bit on the scalar was set to signal this hackery, tested with SvCOMPILED() The flag bit used happened to be the same as one of the two used by to signal Boyer-Moore compiled scalars. The assumption was that no scalar can be used for both. Unfortunately, this isn't quite true. Given that the scalar is alway upgraded to PVMG to add PERL_MAGIC_fm magic, to clear the cached compiled version, there's no extra memory cost in using mg_ptr in the MAGIC struct to point directly to the block of U32 opcodes. The test for "is there a compiled version" can switch to mg_find(..., PERL_MAGIC_fm) returning a pointer, and the use of a flag bit abolished. Retain SvCOMPILED() and SvCOMPILED_{on,off}() as compatibility for XS code on CPAN - the first is always 0, the other two now no-ops.
* S_doparseform() should return void, not OP*, as it should use Perl_die not DIENicholas Clark2011-05-181-2/+1
| | | | | | | | | | | a1b950687051c32e added an error condition in S_doparseform() but used DIE(...) to report it. DIE is defined as C<return Perl_die>, which acts as a hint to the compiler about the control flow [as Perl_die() never returns], but also forces the return type to be OP *. Whilst this is appropriate for pp functions, it's not for S_doparseform() - a1b950687051c32e had to change the return type to OP* and return NULL, just to appease DIE(). Hence use Perl_die() instead, remove return statements, and remove the didn't-return-NULL (dead) code from pp_formline.
* utf8.c: Add _flags version of to_utf8_fold()Karl Williamson2011-05-031-8/+16
| | | | | | | | | | And also to_uni_fold(). The flag allows retrieving either simple or full folds. The interface is subject to change, so these are marked experimental and their names begin with underscore. The old versions are turned into macros calling the new versions with the correct extra parameter.
* embed.fnc: Allow NULL arg to to_utf8_case()Karl Williamson2011-05-031-3/+2
| | | | | | | Code within the function doesn't assume that the parameter is non-null, and in fact the specials are retrieved by swash_init(). Having the parameter null just means that no specials will be retrieved in the current call.
* Make push/shift $scalar accept only unblessed aryrefsFather Chrysostomos2011-04-181-6/+0
| | | | See ticket #80626.
* Add depth parameter to reg_namedseqKarl Williamson2011-03-201-1/+1
|