Change 32675 by [EMAIL PROTECTED] on 2007/12/20 19:49:50
Perl_newAV() can become a mathom by making newAV() a wrapper around
newSV_type() and tweaking Perl_sv_upgrade().
Affected files ...
... //depot/perl/av.c#122 edit
... //depot/perl/av.h#42 edit
... //depot/perl/embed.fnc#539 edit
... //depot/perl/embed.h#726 edit
... //depot/perl/mathoms.c#81 edit
... //depot/perl/proto.h#875 edit
... //depot/perl/sv.c#1444 edit
Differences ...
==== //depot/perl/av.c#122 (text) ====
Index: perl/av.c
--- perl/av.c#121~32237~ 2007-11-07 15:23:27.000000000 -0800
+++ perl/av.c 2007-12-20 11:49:50.000000000 -0800
@@ -355,25 +355,6 @@
}
/*
-=for apidoc newAV
-
-Creates a new AV. The reference count is set to 1.
-
-=cut
-*/
-
-AV *
-Perl_newAV(pTHX)
-{
- register AV * const av = (AV*)newSV_type(SVt_PVAV);
- /* sv_upgrade does AvREAL_only() */
- AvALLOC(av) = 0;
- AvARRAY(av) = NULL;
- AvMAX(av) = AvFILLp(av) = -1;
- return av;
-}
-
-/*
=for apidoc av_make
Creates a new AV and populates it with a list of SVs. The SVs are copied
==== //depot/perl/av.h#42 (text) ====
Index: perl/av.h
--- perl/av.h#41~29670~ 2007-01-02 13:45:08.000000000 -0800
+++ perl/av.h 2007-12-20 11:49:50.000000000 -0800
@@ -116,6 +116,16 @@
#define NEGATIVE_INDICES_VAR "NEGATIVE_INDICES"
/*
+=for apidoc newAV
+
+Creates a new AV. The reference count is set to 1.
+
+=cut
+*/
+
+#define newAV() ((AV *)newSV_type(SVt_PVAV))
+
+/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
==== //depot/perl/embed.fnc#539 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#538~32672~ 2007-12-20 09:47:48.000000000 -0800
+++ perl/embed.fnc 2007-12-20 11:49:50.000000000 -0800
@@ -565,7 +565,7 @@
|NN const char *const filename \
|NULLOK const char *const proto|U32 flags
Apd |CV* |newXS |NULLOK const char* name|NN XSUBADDR_t f|NN
const char* filename
-Apda |AV* |newAV
+Amdba |AV* |newAV
Apa |OP* |newAVREF |NN OP* o
Apa |OP* |newBINOP |I32 type|I32 flags|NULLOK OP* first|NULLOK OP*
last
Apa |OP* |newCVREF |I32 flags|NULLOK OP* o
==== //depot/perl/embed.h#726 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#725~32672~ 2007-12-20 09:47:48.000000000 -0800
+++ perl/embed.h 2007-12-20 11:49:50.000000000 -0800
@@ -552,7 +552,6 @@
#define newSUB Perl_newSUB
#define newXS_flags Perl_newXS_flags
#define newXS Perl_newXS
-#define newAV Perl_newAV
#define newAVREF Perl_newAVREF
#define newBINOP Perl_newBINOP
#define newCVREF Perl_newCVREF
@@ -2846,7 +2845,6 @@
#define newSUB(a,b,c,d) Perl_newSUB(aTHX_ a,b,c,d)
#define newXS_flags(a,b,c,d,e) Perl_newXS_flags(aTHX_ a,b,c,d,e)
#define newXS(a,b,c) Perl_newXS(aTHX_ a,b,c)
-#define newAV() Perl_newAV(aTHX)
#define newAVREF(a) Perl_newAVREF(aTHX_ a)
#define newBINOP(a,b,c,d) Perl_newBINOP(aTHX_ a,b,c,d)
#define newCVREF(a,b) Perl_newCVREF(aTHX_ a,b)
==== //depot/perl/mathoms.c#81 (text) ====
Index: perl/mathoms.c
--- perl/mathoms.c#80~32672~ 2007-12-20 09:47:48.000000000 -0800
+++ perl/mathoms.c 2007-12-20 11:49:50.000000000 -0800
@@ -66,7 +66,7 @@
PERL_CALLCONV int Perl_fprintf_nocontext(PerlIO *stream, const char *format,
...);
PERL_CALLCONV int Perl_printf_nocontext(const char *format, ...);
PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
-
+PERL_CALLCONV AV * Perl_newAV(pTHX);
/* ref() is now a macro using Perl_doref;
* this version provided for binary compatibility only.
@@ -1328,6 +1328,16 @@
return 0;
}
+AV *
+Perl_newAV(pTHX)
+{
+ return (AV*)newSV_type(SVt_PVAV);
+ /* sv_upgrade does AvREAL_only():
+ AvALLOC(av) = 0;
+ AvARRAY(av) = NULL;
+ AvMAX(av) = AvFILLp(av) = -1; */
+}
+
#endif /* NO_MATHOMS */
/*
==== //depot/perl/proto.h#875 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#874~32672~ 2007-12-20 09:47:48.000000000 -0800
+++ perl/proto.h 2007-12-20 11:49:50.000000000 -0800
@@ -1508,9 +1508,9 @@
__attribute__nonnull__(pTHX_2)
__attribute__nonnull__(pTHX_3);
-PERL_CALLCONV AV* Perl_newAV(pTHX)
+/* PERL_CALLCONV AV* Perl_newAV(pTHX)
__attribute__malloc__
- __attribute__warn_unused_result__;
+ __attribute__warn_unused_result__; */
PERL_CALLCONV OP* Perl_newAVREF(pTHX_ OP* o)
__attribute__malloc__
==== //depot/perl/sv.c#1444 (text) ====
Index: perl/sv.c
--- perl/sv.c#1443~32533~ 2007-11-28 09:47:20.000000000 -0800
+++ perl/sv.c 2007-12-20 11:49:50.000000000 -0800
@@ -1253,6 +1253,13 @@
AvMAX(sv) = -1;
AvFILLp(sv) = -1;
AvREAL_only(sv);
+ if (old_type >= SVt_RV) {
+ AvALLOC(sv) = 0;
+ } else {
+ /* It will have been zeroed when the new body was allocated.
+ Lets not write to it, in case it confuses a write-back
+ cache. */
+ }
}
/* SVt_NULL isn't the only thing upgraded to AV or HV.
End of Patch.