summaryrefslogtreecommitdiff
path: root/universal.c
Commit message (Collapse)AuthorAgeFilesLines
* utf8::upgrade: Don't coerce undef argKarl Williamson2022-11-141-3/+13
| | | | This fixes GH #20419
* Add sv_derived_from_hv() helper functionPaul "LeoNerd" Evans2022-10-251-0/+21
|
* Make PerlIO::get_layers accept IO referencesLeon Timmermans2022-08-121-5/+9
|
* Perl_newSV_type_mortal - new inline function introduced and usedRichard Leach2022-03-071-3/+2
| | | | | | | | | | | | | | | There's no efficient way to create a mortal SV of any type other than SVt_NULL (via sv_newmortal). The options are either to do: * SV* sv = sv_newmortal; sv_upgrade(sv, SVt_SOMETYPE); but sv_upgrade is needlessly inefficient on new SVs. * SV* sv = sv_2mortal(newSV_type(SVt_SOMETYPE) but this will perform runtime checks to see if (sv) and if (SvIMMORTAL(sv), and for a new SV we know that those answers will always be yes and no. This commit adds a new inline function which is basically a mortalizing wrapper around the now-inlined newSV_type.
* Only expose Internals::getcwd() in miniperlNicholas Clark2021-10-041-2/+3
| | | | | | | | | | | | | It's only used during bootstrapping for miniperl when the XS version of Cwd is not yet available, and only needed on platforms that don't already provide their own builtin for getcwd(). It was added in v5.30.0 with the clear warning that [it] may be removed or changed without notice and is not used by any code on CPAN. (Cwd references it, but won't use it once installed as it will have already found an XS implementation (platform specific or generic).
* Convert some existing uses of SvRV_set() to use the new sv_setrv* family of ↵Paul "LeoNerd" Evans2021-08-251-2/+1
| | | | functions
* Rename G_ARRAY to G_LIST; provide back-compat when not(PERL_CORE)Paul "LeoNerd" Evans2021-06-021-2/+2
|
* Add GV_NOUNIVERSAL flag to skip UNIVERSAL lookupMarc Reisner2021-04-151-4/+1
| | | | | | | | For the `isa` infix operator, we can fall back to `sv_derived_from_sv` instead of looking up UNIVERSAL::isa. Passing GV_NOUNIVERSAL will tell gv_fetchmeth_internal not to look at UNIVERSAL for the method, and instead return NULL. Then `Perl_sv_isa_sv` will skip the if block and check `sv_derived_from_sv` which does the same thing UNIVERSAL::isa would have done.
* Ensure isa object method still works after using isa infix operatorMarc Reisner2021-04-151-5/+3
|
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-306/+306
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-1/+1
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Use av_top_index() instead of av_tindex()Karl Williamson2020-08-191-1/+1
| | | | | | | I was never happy with this short form, and other people weren't either. Now that most things are better expressed in terms of av_count, convert the few remaining items that are clearer when referring to an index into using the fully spelled out form
* universal.c: Convert to use av_count()Karl Williamson2020-08-191-3/+3
|
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-4/+4
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Clarify in documentation that sv_isa_sv does not invoke magicPaul "LeoNerd" Evans2019-12-111-0/+2
|
* Add the `isa` operatorPaul "LeoNerd" Evans2019-12-091-0/+68
| | | | | | | | | | | | | | | | | | Adds a new infix operator named `isa`, with the semantics that $x isa SomeClass is true if and only if `$x` is a blessed object reference that is either `SomeClass` directly, or includes the class somewhere in its @ISA hierarchy. It is false without warning or error for non-references or non-blessed references. This operator respects `->isa` method overloading, and is intended to replace boilerplate code such as use Scalar::Util 'blessed'; blessed($x) and $x->isa("SomeClass")
* move the implementation of %-, %+ into coreTony Cook2019-12-041-23/+191
| | | | | | Previousl this could cause problems during minitest. Fixes #17293
* Factor out common code from sv_derived_from_* subs familySergey Aleynikov2019-11-041-36/+50
| | | | | into one that takes both SV*/char*+len arguments, like hv_common, to be able to use speedups from SV* stash lookup API.
* (perl #133951) add Internals::getcwdTony Cook2019-04-151-0/+22
|
* Rename global variable to prevent confusion with localJames E Keenan2018-11-261-3/+3
| | | | Per: https://lgtm.com/projects/g/Perl/perl5/alerts/?mode=tree&ruleFocus=2157860312
* revert smartmatch to 5.27.6 behaviourZefram2017-12-291-34/+0
| | | | | | | | | | | | | The pumpking has determined that the CPAN breakage caused by changing smartmatch [perl #132594] is too great for the smartmatch changes to stay in for 5.28. This reverts most of the merge in commit da4e040f42421764ef069371d77c008e6b801f45. All core behaviour and documentation is reverted. The removal of use of smartmatch from a couple of tests (that aren't testing smartmatch) remains. Customisation of a couple of CPAN modules to make them portable across smartmatch types remains. A small bugfix in scope.c also remains.
* eviscerate smartmatchZefram2017-11-221-0/+34
| | | | | | | | | | | | | | | Regularise smartmatch's operand handling, by removing the implicit enreferencement and just supplying scalar context. Eviscerate its runtime behaviour, by removing all the matching rules other than rhs overloading. Overload smartmatching in the Regexp package to perform regexp matching. There are consequential customisations to autodie, in two areas. Firstly, autodie::exception objects are matchers, but autodie has been advising smartmatching with the exception on the lhs. This has to change to the rhs, in both documentation and tests. Secondly, it uses smartmatching as part of its hint mechanism. Most of the hint examples, in documentation and tests, have to change to subroutines, to be portable across Perl versions.
* Use SvLEN_set/SvCUR_set in a few extra locationsNicolas R2017-10-191-2/+2
| | | | | | SvLEN was set without using the generic macro SvLEN_set. Use it in three extra locations, and also use SvCUR_set instead of SvCUR.
* use cv_set_call_checker_flags() where possibleZefram2017-08-081-4/+4
| | | | | | | | | | | | | | | Call checkers established by core code were being set through cv_set_call_checker(), so requiring GVs to be created in some cases where they could be avoided. Make all the checkers non-GV-namegv capable, and set them with cv_set_call_checker_flags(). The checkers for Devel::Peek::Dump() and utf8::{unicode_to_native,native_to_unicode}() were already fit to handle non-GV names, so required no changes. The checker for CORE:: subs, ck_entersub_args_core(), was naughtily using the name to decide which sub it was dealing with in some cases, so move that information into the ckobj that was already being used to identify the sub in most cases. It also required reformulation of some error reporting code to use cv_name().
* make callers of SvTRUE() more efficientDavid Mitchell2017-07-271-7/+9
| | | | | | Where its obvious that the args can't be null, use SvTRUE_NN() instead. Avoid possible multiple evaluations of the arg by assigning to a local var first if necessary.
* PERL_GLOBAL_STRUCT_PRIVATE: fix PL_isa_DOESDavid Mitchell2017-03-171-6/+1
| | | | | | | | | I added the global string constant PL_isa_DOES recently. This caused t/porting/libperl.t to fail under -DPERL_GLOBAL_STRUCT_PRIVATE builds. This commit makes PL_isa_DOES be declared and defined in a similar way to other such global constants. This is pure cargo-culting - I have no real idea of the point of all the EXTCONST, INIT and globvar.sym stuff.
* fix some comment typos about PL_isa_DOESDavid Mitchell2017-01-071-3/+4
| | | | ... and expand one of the comments a bit.
* Clean up warnings uncovered by 'clang -Weverything'.Andy Lester2016-12-051-4/+0
| | | | For: RT #130195
* Change white space to avoid C++ deprecation warningKarl Williamson2016-11-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | C++11 requires space between the end of a string literal and a macro, so that a feature can unambiguously be added to the language. Starting in g++ 6.2, the compiler emits a warning when there isn't a space (presumably so that future versions can support C++11). Unfortunately there are many such instances in the perl core. This commit fixes those, including those in ext/, but individual commits will be used for the other modules, those in dist/ and cpan/. This commit also inserts space at the end of a macro before a string literal, even though that is not deprecated, and removes useless "" literals following a macro (instead of inserting a blank). The result is easier to read, making the macro stand out, and be clearer as to the intention. Code and modules included with the Perl core need to be compilable using C++. This is so that perl can be embedded in C++ programs. (Actually, only the hdr files need to be so compilable, but it would be hard to test that just the hdrs are compilable.) So we need to accommodate changes to the C++ language.
* Cleanup PERL_VERSION checks in .c filesNicolas R2016-11-151-5/+0
| | | | | | This commit is removing code not exercised by blead or any later versions using PERL_VERSION. This is a noop, mainly cleaning code.
* remove DOES's usage of SvSCREAMDavid Mitchell2016-11-121-5/+12
| | | | | | | | | | | | | | | | Currently the SvSCREAM flag is set on a temporary SV whose string value is "isa", but where for the purposes of printing Can't call method "XXX" its name is treated as "DOES" rather than "isa". Instead, set the temp SV's PVX buffer to point to a special static string (PL_isa_DOES) whose value is "isa", but the where the error reporting code can compare the address with PL_isa_DOES and if so, print "DOES" instead. This is to reduce the number of odd special cases for the SvSCREAM flag.
* universal.c: use new SvPVCLEAR and constant string friendly macrosYves Orton2016-10-191-3/+3
|
* restore Internals::hv_clear_placeholders for nowYves Orton2016-08-251-0/+15
|
* Move hash introspection routines into Hash::Util/Util.xs and out of universal.cYves Orton2016-08-141-65/+0
|
* s/XS_hash_util_/XS_Hash_Util_/gYves Orton2016-08-141-9/+9
|
* move a declaration so that the Internals:: functions are grouped togetherYves Orton2016-08-141-1/+1
|
* move Internals::hv_clear_placeholders() to Hash::Util::_clear_placeholders()Yves Orton2016-08-141-15/+0
| | | | | | | | There is no reason for this code to be in Internals:: or in universal.c at all, it should only be used from Hash::Util during things like lock_keys(). Moves the function to the XS code in Hash::Util, and renames it as well, along with commented out documentation for what it does.
* universal.c:XS_re_regnames_count: redundant codeFather Chrysostomos2016-08-121-3/+0
| | | | If we croak when items != 0, then SP -= items is a no-op, as is PUTBACK.
* Change scalar(%hash) to be the same as 0+keys(%hash)Yves Orton2016-06-221-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This subject has a long history see [perl #114576] for more discussion. https://rt.perl.org/Public/Bug/Display.html?id=114576 There are a variety of reasons we want to change the return signature of scalar(%hash). One is that it leaks implementation details about our associative array structure. Another is that it requires us to keep track of the used buckets in the hash, which we use for no other purpose but for scalar(%hash). Another is that it is just odd. Almost nothing needs to know these values. Perhaps debugging, but we have several much better functions for introspecting the internals of a hash. By changing the return signature we can remove all the logic related to maintaining and updating xhv_fill_lazy. This should make hot code paths a little faster, and maybe save some memory for traversed hashes. In order to provide some form of backwards compatibility we adds three new functions to the Hash::Util namespace: bucket_ratio(), num_buckets() and used_buckets(). These functions are actually implemented in universal.c, and thus always available even if Hash::Util is not loaded. This simplifies testing. At the same time Hash::Util contains backwards compatible code so that the new functions are available from it should they be needed in older perls. There are many tests in t/op/hash.t that are more or less obsolete after this patch as they test that xhv_fill_lazy is correctly set in various situations. However since we have a backwards compat layer we can just switch them to use bucket_ratio(%hash) instead of scalar(%hash) and keep the tests, just in case they are actually testing something not tested elsewhere.
* 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.
* utf8::unicode_to_native() should return UV, not an IVKarl Williamson2015-09-021-2/+2
| | | | | | | | Same for the native_to_unicode() While it is true that UTF-EBCDIC is limited to a a code point of a maximum of 2**31 - 1, in order for the correct code to execute to catch an attempt at a larger one, it needs to be a UV.
* Remove PERL_OLD_COPY_ON_WRITEFather Chrysostomos2015-06-291-6/+0
|
* clean up sv_isobject usageDaniel Dragan2015-06-111-1/+1
| | | | | | | | | -previous usage proves getmagic is unnecessary or ignored or already called S_do_smartmatch Perl_sv_does_sv -in pp_dbmopen dont call sv_isobject twice in a row on the same SV in 1 permutation
* perlapi: Wrap long verbatim lines to 79 columnsKarl Williamson2015-04-231-1/+2
|
* fix some minor compiler warningsDavid Mitchell2015-04-181-1/+1
| | | | | | | S_deb_curcv's first param differed in constness between declaration and definition. GIMME_V can return an I32, so don't assign it to a U8.
* 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.
* universal.c: remove all trace of op_siblingDavid Mitchell2015-03-191-5/+7
| | | | | | | | | | | The OpSIBLING() macro and op_sibling_splice() are a higher-level way of manipulating optrees that ensure portability in the face of PERL_OP_PARENT etc. This commit also helps with the lofty goal of nothing outside of op.c directly accessing the op_sibling field. This is a follow-on/improvement to bac7a184cda7b.
* universal.c: PERL_OP_PARENT supportFather Chrysostomos2015-03-181-3/+3
|
* Optimize out unicode_to_native(), native_to_unicode()Karl Williamson2015-03-121-0/+63
| | | | | | | These just return their argument on ASCII platforms, so can get rid of the function call overhead there. Thanks to Zefram and Matthew Horsfall for their help in this.