So now there's a buy 5 get one free offer on PVAV bodies.
p4raw-id: //depot/perl@24619
return FALSE;
}
+SV **
+Perl_av_arylen_p(pTHX_ AV *av) {
+ dVAR;
+ MAGIC *mg = mg_find((SV*)av, PERL_MAGIC_arylen_p);
+
+ if (!mg) {
+ mg = sv_magicext((SV*)av, 0, PERL_MAGIC_arylen_p, 0, 0, 0);
+
+ if (!mg) {
+ Perl_die(aTHX_ "panic: av_arylen_p");
+ }
+ /* sv_magicext won't set this for us because we pass in a NULL obj */
+ mg->mg_flags |= MGf_REFCOUNTED;
+ }
+ return &(mg->mg_obj);
+}
+
/*
* Local variables:
* c-indentation-style: bsd
} xiv_u;
MAGIC* xmg_magic; /* magic for scalar array */
HV* xmg_stash; /* class package */
- SV* xav_arylen;
};
#if !defined(PERL_EXPERIMENTAL_LAYOUT)
} xiv_u;
MAGIC* xmg_magic; /* magic for scalar array */
HV* xmg_stash; /* class package */
- SV* xav_arylen;
} xpvav_allocated;
#endif
#define AvALLOC(av) (*((SV***)&((XPVAV*) SvANY(av))->xav_alloc))
#define AvMAX(av) ((XPVAV*) SvANY(av))->xav_max
#define AvFILLp(av) ((XPVAV*) SvANY(av))->xav_fill
-#define AvARYLEN(av) (*((SV**)&((XPVAV*) SvANY(av))->xav_arylen))
+#define AvARYLEN(av) (*Perl_av_arylen_p(aTHX_ (AV*)av))
#define AvREAL(av) (SvFLAGS(av) & SVpav_REAL)
#define AvREAL_on(av) (SvFLAGS(av) |= SVpav_REAL)
{ PERL_MAGIC_pos, "pos(.)" },
{ PERL_MAGIC_symtab, "symtab(:)" },
{ PERL_MAGIC_backref, "backref(<)" },
+ { PERL_MAGIC_arylen_p, "arylen_p(@)" },
{ PERL_MAGIC_overload, "overload(A)" },
{ PERL_MAGIC_bm, "bm(B)" },
{ PERL_MAGIC_regdata, "regdata(D)" },
PerlIO_putc(file, '\n');
Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)AvFILLp(sv));
Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)AvMAX(sv));
- Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", PTR2UV(AvARYLEN(sv)));
+ Perl_dump_indent(aTHX_ level, file, " ARYLEN = 0x%"UVxf"\n", SvMAGIC(sv) ? PTR2UV(AvARYLEN(sv)) : 0);
sv_setpvn(d, "", 0);
if (AvREAL(sv)) sv_catpv(d, ",REAL");
if (AvREIFY(sv)) sv_catpv(d, ",REIFY");
Apd |SV** |av_store |AV* ar|I32 key|SV* val
Apd |void |av_undef |AV* ar
Apd |void |av_unshift |AV* ar|I32 num
+Apo |SV** |av_arylen_p |AV* av
pR |OP* |bind_match |I32 type|NN OP* left|NN OP* pat
pR |OP* |block_end |I32 floor|OP* seq
ApR |I32 |block_gimme
Perl_av_store
Perl_av_undef
Perl_av_unshift
+Perl_av_arylen_p
Perl_block_gimme
Perl_call_list
Perl_cast_ulong
#define PERL_MAGIC_backref '<' /* for weak ref data */
#define PERL_MAGIC_symtab ':' /* extra data for symbol tables */
#define PERL_MAGIC_rhash '%' /* extra data for restricted hashes */
+#define PERL_MAGIC_arylen_p '@' /* to move arylen out of XPVAV */
#define PERL_MAGIC_ext '~' /* Available for use by extensions */
{
dSP;
AV *av = (AV*)TOPs;
- SV *sv = AvARYLEN(av);
- if (!sv) {
- AvARYLEN(av) = sv = NEWSV(0,0);
- sv_upgrade(sv, SVt_IV);
- sv_magic(sv, (SV*)av, PERL_MAGIC_arylen, Nullch, 0);
+ SV **sv = Perl_av_arylen_p(aTHX_ (AV*)av);
+ if (!*sv) {
+ *sv = NEWSV(0,0);
+ sv_upgrade(*sv, SVt_PVMG);
+ sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, Nullch, 0);
}
- SETs(sv);
+ SETs(*sv);
RETURN;
}
PERL_CALLCONV SV** Perl_av_store(pTHX_ AV* ar, I32 key, SV* val);
PERL_CALLCONV void Perl_av_undef(pTHX_ AV* ar);
PERL_CALLCONV void Perl_av_unshift(pTHX_ AV* ar, I32 num);
+PERL_CALLCONV SV** Perl_av_arylen_p(pTHX_ AV* av);
PERL_CALLCONV OP* Perl_bind_match(pTHX_ I32 type, OP* left, OP* pat)
__attribute__warn_unused_result__
__attribute__nonnull__(pTHX_2)
AvMAX(sv) = -1;
AvFILLp(sv) = -1;
AvALLOC(sv) = 0;
- AvARYLEN(sv)= 0;
AvREAL_only(sv);
}
/* to here. */
case PERL_MAGIC_vec:
vtable = &PL_vtbl_vec;
break;
+ case PERL_MAGIC_arylen_p:
case PERL_MAGIC_rhash:
case PERL_MAGIC_symtab:
case PERL_MAGIC_vstring:
SvLEN_set(dstr, SvLEN(sstr));
SvMAGIC_set(dstr, mg_dup(SvMAGIC(sstr), param));
SvSTASH_set(dstr, hv_dup_inc(SvSTASH(sstr), param));
- AvARYLEN((AV*)dstr) = sv_dup_inc(AvARYLEN((AV*)sstr), param);
if (AvARRAY((AV*)sstr)) {
SV **dst_ary, **src_ary;
SSize_t items = AvFILLp((AV*)sstr) + 1;