summaryrefslogtreecommitdiff
path: root/sv.h
Commit message (Collapse)AuthorAgeFilesLines
* Store FBMs in PVMGs, instead of GVs.Nicholas Clark2011-06-111-9/+9
| | | | | | | | This should reduce the complexity of code dealing with GVs, as they no longer try to play several different incompatible roles. (As suggested by Ben Morrow. However, it didn't turn out to be as straightforward as one might have hoped).
* Store the BM table in mg_ptr instead of after SvCUR().Nicholas Clark2011-06-111-2/+0
| | | | | | | | | | | | Previously the 256 byte Boyer-Moore table was stored in the buffer of SvPVX() after the raw string by extending the buffer. Given that the scalar is alway upgraded to add PERL_MAGIC_bm magic, to clear the table and other flags, there's no extra memory cost in using mg_ptr in the MAGIC struct to point directly to the table. I believe that this removes the last place in the core that stores data beyond SvCUR().
* Abolish xbm_rare. Move BmUSEFUL() to union _xnvu and BmPREVIOUS() to the UV.Nicholas Clark2011-06-111-7/+5
| | | | | | | This reduces the complexity of the union declarations in sv.h. As B.xs is accessing the structures/unions directly, instead of using the macros, it needs a patch too.
* Use SvTAIL() instead of BmFLAGS(). The core no longer uses BmFLAGS().Nicholas Clark2011-06-111-1/+3
|
* Emulate the value of BmFLAGS() using SvTAIL().Nicholas Clark2011-06-111-7/+3
| | | | | | | | | | | | | | | | | | | | Don't set BmFLAGS() in Perl_fbm_compile() Originally fbm_compile() had an I32 flags argument, which seems to have been part of case folding/locale improvements. bbce6d69784bf43b removed this. SvTAIL() was only used in once place until c277df42229d99fe. 2779dcf1a3ceec16 added the U32 flags argument to fbm_compile(), not used until cf93c79d660ae36c. That commit also added FBMcf_TAIL and FBMcf_TAIL{z,Z,DOLLAR} but didn't use the last three. Additionally, it stored the BmFLAGS as part of the compiled table: + table[-1] = flags; /* Not used yet */ f722798beaa43749 added FBMcf_TAIL_DOLLARM, renumbered FBMcf_TAIL{z,Z,DOLLAR}, but still didn't use anything other than FBMcf_TAIL. The core, nothing on CPAN, and nothing visible to Google codesearch, has ever used the 4 specialist flags. The only use is 0 or FBMcf_TAIL, which is in lockstep with SvTAIL() of 0 or non-0.
* Use 0x40008000 in SvFLAGS() for SVpad_NAME, not 0x40000000Nicholas Clark2011-06-111-2/+15
| | | | This eliminates potential confusion between SVpad_NAME and SVpbm_VALID.
* Improve comments in sv.h describing SVrepl_EVAL and SVf_IVisUV.Nicholas Clark2011-05-241-2/+1
|
* Remove empty #ifdef/#else/#endif block.Nicholas Clark2011-05-191-3/+0
| | | | | | This was added (with contents) in b162af07ec759e1b. The contents were moved elsewhere in the refactoring of ac09da3b9065d6e7, but that change failed to remove the block it had now emptied.
* Store the compiled format in mg_ptr instead of after SvCUR() - fixes RT #89218Nicholas Clark2011-05-181-5/+5
| | | | | | | | | | | | | | | | | | | | | 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.
* Inline sv_cmp() and sv_cmp_locale() as macros wrapping their flags variants.Nicholas Clark2010-11-111-0/+2
| | | | | | We can't move Perl_sv_cmp() and Perl_sv_cmp_locale() to mathoms.c, as they are referenced by function pointer in pp_sort.c - pointers which require the specific current calling signature.
* rt #72398 - get magic before downgrading in SvPVbyte()Tony Cook2010-10-251-0/+7
|
* Revert "[perl #77928] Glob slot assignment and set-magic"Father Chrysostomos2010-09-291-16/+2
| | | | This reverts commit cffb36981555111f364a511fb5763f65ea748c0e.
* systematically provide pv/pvn/pvs/sv quartetsZefram2010-09-281-0/+4
| | | | | Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
* [perl #77928] Glob slot assignment and set-magicFather Chrysostomos2010-09-281-2/+16
| | | | Stop set-magic from being called after ref-to-glob assignment.
* define SvTRUE_nomg for compilers other than gccFather Chrysostomos2010-09-241-0/+15
| | | | This time I *really* broke the Windows build!
* [perl #76814] FETCH called twice - !Father Chrysostomos2010-09-241-0/+23
| | | | | | This fixes ! by changing sv_2bool to sv_2bool_flags (with a macro wrapper) and adding SvTRUE_nomg. It also corrects the docs that state incorrectly that SvTRUE does not handle magic.
* [perl #76814] FETCH called twice - string comparison opsFather Chrysostomos2010-09-241-0/+2
| | | | | | This patch changes sv_eq, sv_cmp, sv_cmp_locale and sv_collxfrm to _flags forms, with macros under the old names for sv_eq and sv_collxfrm, but functions for sv_cmp* since pp_sort.c needs them.
* fix some 64-bit casts under DEBUG_LEAKING_SCALARSDavid Mitchell2010-09-011-1/+1
|
* Remove CALL_FPTR and CPERLscope.Ben Morrow2010-08-201-4/+4
| | | | | | | | | | | | | | | | These are left from PERL_OBJECT, which was an implementation of multiplicity using C++ objects. PERL_OBJECT was removed in 5.8, but the macros seem to have been cargo-culted all over the core (including in places where they would have been inappropriate originally). Since they now do exactly nothing, it's cleaner to remove them. I have left the definitions in perl.h, under #ifndef PERL_CORE, since some CPAN XS code uses them (also often incorrectly). I have also left STATIC alone, since it seems potentially more useful and is much more ingrained. The only appearance of these macros this patch doesn't touch is in Devel-PPPort, because that's a CPAN module.
* DEBUG_LEAKING_SCALARS: add sv_debug_parentDavid Mitchell2010-08-011-2/+2
| | | | | Rather than just recording whether an SV was cloned (sv->sv_debug_cloned), record the address of the SV we were cloned from.
* Store xio_ifp in sv_u in the SV head, reducing XPVIO by 1 pointer.Nicholas Clark2010-06-301-3/+18
| | | | | | | | | When accessing a file handle for reading, this reduces pointer dereferences by 1, which will reduce CPU cache pressure. As SVt_PVIO is also the default type provided to source filters, the code needs to allow them to continue to use the sv_u for SvPVX(). Re-use the existing IOf_FAKE_DIRP to signal this, as it's only set when a source filter is added.
* Only allow SvPVX() on SVt_PVIO when IOf_FAKE_DIRP is set.Nicholas Clark2010-06-301-1/+4
|
* Eliminate macro _XPVIO_TAIL by inlining it within struct xpvio.Nicholas Clark2010-06-281-30/+27
| | | | | | | _XPVIO_TAIL was added in 167f2c4d08e1e800, but has only been used in 1 location since xpvio_allocated was removed in b6f609162799aa49. This restores the header layout to the situation as it was before 167f2c4d08e1e800, although there are changes to the structure itself.
* Better ithreads cloning - add all SVs with a 0 refcnt to the temps stack.Nicholas Clark2010-05-241-0/+1
| | | | | | | | | | Track all SVs created by sv_dup() that have a 0 reference count. If they still have a 0 reference count at the end of cloning, assign a reference to each to the temps stack. As the temps stack is cleared at thread exit, SVs book keeping will be correct and consistent before perl_destruct() makes its check for leaked scalars. Remove special case code for checking each @_ and the parent's temp stack.
* Cleaner implementations for Perl_clone_params_{new,del}Nicholas Clark2010-05-241-0/+1
| | | | Not source or binary compatible with maint-5.12.
* make overload respect get magicDavid Mitchell2010-05-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In most places, ops checked their args for overload *before* doing mg_get(). This meant that, among other issues, tied vars that returned overloaded objects wouldn't trigger calling the overloaded method. (Actually, for tied and arrays and hashes, it still often would since mg_get gets called beforehand in rvalue context). This patch does the following: Makes sure get magic is called first. Moves most of the overload code formerly included by macros at the start of each pp function into the separate helper functions Perl_try_amagic_bin, Perl_try_amagic_un, S_try_amagic_ftest, with 3 new wrapper macros: tryAMAGICbin_MG, tryAMAGICun_MG, tryAMAGICftest_MG. This made the code 3800 bytes smaller. Makes sure that FETCH is not called multiple times. Much of this bit was helped by some earlier work from Father Chrysostomos. Added new functions and macros sv_inc_nomg(), sv_dec_nomg(), dPOPnv_nomg, dPOPXiirl_ul_nomg, dPOPTOPnnrl_nomg, dPOPTOPiirl_ul_nomg dPOPTOPiirl_nomg, SvIV_please_nomg, SvNV_nomg (again, some of these were based on Father Chrysostomos's work). Fixed the list version of the repeat operator (x): it now only calls overloaded methods for the scalar version: (1,2,$overloaded) x 10 no longer erroneously calls x_method($overloaded,10)) The only thing I haven't checked/fixed yet is overloading the iterator operator, <>.
* Remove union _xivu from _XPVCV_COMMON, and hence structs xpvcv and xpvfmNicholas Clark2010-05-211-4/+3
| | | | | | | Replaced with xcv_depth and xfm_lines respectively. Both structures might benefit from some field re-ordering. Update the descriptive comments in the definition of union _xivu.
* Remove union _xivu from struct regexp - replace it with a non-union paren_names.Nicholas Clark2010-05-211-1/+0
| | | | This was the only user of xivu_hv in union _xivu, so remove that too.
* Remove union _xivu from struct xpvav - replace it with a non-union xav_alloc.Nicholas Clark2010-05-211-1/+0
| | | | This was the only user of xivu_p1 in union _xivu, so remove that too.
* In the SV body, exchange the positions of the NV and stash/magic.Nicholas Clark2010-05-211-13/+12
|
* SvIVX() isn't valid on SVt_REGEXPNicholas Clark2010-05-201-0/+3
|
* add SV_SKIP_OVERLOAD flag to sv_2*v_flags fnsDavid Mitchell2010-05-081-0/+3
| | | | | | While trying to coerce an SV into a string or whatever, stop if you suddenly discover it's overloaded (this may not happen until after you've called it's get magic)
* add flags arg to sv_2nv (as sv_2nv_flags)David Mitchell2010-05-081-0/+1
|
* Don't allocate pointer table entries from arenas.Nicholas Clark2010-04-251-7/+3
| | | | | Instead, allocate a private arena chain per pointer table, and free that chain when its pointer table is freed. Patch from RT #72598.
* Innocently looking union member swapReini Urban2009-12-061-1/+1
| | | | | | This helps statically initializing union members on gcc, otherwise we get "initializer element is not computable at load time". This speeds up initializing larger B::C/B::CC compiled programs with -O1/-O2 by 10%.
* Abolish xio_lines from struct PVIO - store IoLINES() in the IVX slot.Nicholas Clark2009-11-191-2/+2
|
* PVIOs don't use the SvIVX slot.Nicholas Clark2009-11-191-0/+2
|
* Doc typo fixRafael Garcia-Suarez2009-09-301-1/+1
|
* Eliminate *_ALLOCATED_HEAD and *_HEAD macros which are now used only once.Nicholas Clark2009-08-221-5/+2
|
* Eliminate the remaining definitions for *_allocated structs.Nicholas Clark2009-08-221-15/+0
|
* Perl_newIO() can become a mathom by making newIO() a wrapper around newSV_type()Nicholas Clark2009-08-081-0/+3
| | | | and tweaking Perl_sv_upgrade().
* Eliminate struct regexp_allocated and xpvio_allocated.Nicholas Clark2009-07-171-6/+0
| | | | | | Calculate memory allocation using regexp and XPVIO, and the offset of the first real structure member. This avoids tripping over alignment differences between X* and x*_allocated, because x*_allocated doesn't have a double in it.
* Add a parameter "destructing" to Gv_AMupdate()Rafael Garcia-Suarez2009-07-081-1/+1
| | | | | | | | This boolean parameter indicates if the function has been called to update the overload magic table while looking up the DESTROY method. In this case, it's probably best to avoid croaking if those tables could not be updated (for example due to a method that could not be loaded.)
* Fix API docs:SvGAMAGIC returns a U32, not a char*Steffen Mueller2009-06-191-1/+1
|
* Make SvOK and SvTRUE API docs slightly less utterly confusingSteffen Mueller2009-06-131-3/+3
|
* Bump coopyright year in embed.pl and various files that were just touchedRafael Garcia-Suarez2009-01-021-1/+1
| | | | (and run "make regen")
* Faster sv_utf8_upgrade()karl williamson2009-01-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider what currently happens when the tokenizer is scanning a string. It looks through it byte-by-byte until it finds a character that forces it to decide to go to utf8. It then calls sv_utf8_upgrade() with the portion of the string scanned so far. sv_utf8_upgrade() starts over from the beginning, and scans the string byte-by-byte until it finds a character that varies between non-utf8 and utf8. It then calls bytes_to_utf8(). bytes_to_utf8() allocates a new string that can handle the worst case expansion, 2n+1, of the entire string, and starts over from the beginning, and scans the input string byte-by-byte copying and converting each character to the output string as it goes. It doesn't return the size of the new string, so sv_utf8_upgrade() assumes it is only as big as what actually got converted, throwing away knowledge of any spare. It then returns to the tokenizer, which immediately does a grow to get space for the unparsed input. This is likely to cause a new string to be allocated and copied from the one we had just created, even if that string in actuality had enough space in it. Thus, the invariant head portion of the string is scanned 3 times, and probably 2 strings will be allocated and copied. My solution to cutting this down is to do several things. First, I added an extra flag for sv_utf8_upgrade that says don't bother to check if the string needs to be converted to utf8, just assume it does. This eliminates one of the passes. I also added a new parameter to sv_utf8_upgrade that says when you return, I want this much unused space in the string. That eliminates the extra grow. This was all done by renaming the current work-horse function from sv_utf8_upgrade_flags to be sv_utf8_upgrade_flags_grow() and making the current function name be a macro which calls the revised one with a 0 grow parameter. I also improved the internal efficiency of sv_utf8_upgrade so that when it does scan the string, it doesn't call bytes_to_utf8, but does the conversion itself, using a fast memory copy instead of the byte-oriented one for the invariant header, and it uses that header to get a better estimate of the needed size of the new string, and it doesn't throw away the knowledge of the allocated size. And, if it is clear without scanning the whole string that the conversion will fit in the already allocated string, it just uses that instead of allocating and copying a new one, using the algorithm I copied from the tokenizer. (In this case it does have to finish scanning the whole string to get the correct size.) The comments have details. It still is byte-oriented. Vectorization et. al. could yield performance improvements. One idea for that is in the comments. The patch also includes a new synonym I created which is a more accurate name than NATIVE_TO_ASCII.
* Update comments and documentation dealing with utfKarl2008-12-261-4/+4
|
* It looks like the previous patch is working fine on UNIXish boxes,Steve Peters2008-12-191-0/+4
| | | | | but is failing on Windows. Anyways sv_utf8_upgrade_nomg() is a macro anyways, so moving the documentation to sv.h.
* Allow lvalue usage of SvRV() and add MUTABLE_SV() check.Marcus Holland-Moritz2008-11-101-1/+13
| | | | | Also add new SvRV_const() macro for read-only access. p4raw-id: //depot/perl@34804