summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Cromie <jcromie@cpan.org>2005-06-13 05:57:01 -0600
committerNicholas Clark <nick@ccl4.org>2005-06-16 16:25:54 +0000
commit950dc694f02cbe5346df696fa50703abdb7b5684 (patch)
treecca0393a29521e8345186c5ced6073197d3528ab
parent3a242bf865f141cec0182498303b227285835533 (diff)
downloadperl-950dc694f02cbe5346df696fa50703abdb7b5684.tar.gz
Re: [perl #36048] Refactor S_more_*v into one function
Message-ID: <42ADC8ED.4090009@divsol.com> Date: Mon, 13 Jun 2005 11:57:01 -0600 p4raw-id: //depot/perl@24875
-rw-r--r--sv.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index f690ee6fce..da216d54bc 100644
--- a/sv.c
+++ b/sv.c
@@ -1125,6 +1125,86 @@ Perl_report_uninit(pTHX_ SV* uninit_sv)
"", "", "");
}
+#define USE_S_MORE_THINGY
+
+#ifdef USE_S_MORE_THINGY
+
+#define S_more_thingy(TYPE,lctype) \
+STATIC void \
+S_more_## lctype (pTHX) \
+{ \
+ TYPE* lctype; \
+ TYPE* lctype ## end; \
+ void *ptr; \
+ New(711, ptr, PERL_ARENA_SIZE/sizeof(TYPE), TYPE); \
+ *((void **) ptr) = (void *)PL_## lctype ## _arenaroot; \
+ PL_## lctype ## _arenaroot = ptr; \
+ \
+ lctype = (TYPE*) ptr; \
+ lctype ## end = &lctype[PERL_ARENA_SIZE / sizeof(TYPE) - 1]; \
+ \
+ /* fudge by sizeof XPVIV */ \
+ lctype += (sizeof(XPVIV) - 1) / sizeof(TYPE) + 1; \
+ \
+ PL_ ## lctype ## _root = lctype; \
+ while ( lctype < lctype ## end) { \
+ *(TYPE**) lctype = (TYPE*)(lctype + 1); \
+ lctype++; \
+ } \
+ *(TYPE**) lctype = 0; \
+}
+
+#define S_more_thingy_allocated(lctype) \
+STATIC void \
+S_more_## lctype (pTHX) \
+{ \
+ lctype ## _allocated * lctype ; \
+ lctype ## _allocated * lctype ## end; \
+ void *ptr; \
+ New(711, ptr, PERL_ARENA_SIZE/sizeof(lctype ## _allocated ), lctype ## _allocated ); \
+ *((void **) ptr) = (void *)PL_ ## lctype ## _arenaroot; \
+ PL_## lctype ## _arenaroot = ptr; \
+ \
+ lctype = (lctype ## _allocated *) ptr; \
+ lctype ## end = &lctype[PERL_ARENA_SIZE / sizeof(lctype ## _allocated ) - 1]; \
+ \
+ /* fudge by sizeof XPVIV */ \
+ lctype += (sizeof(XPVIV) - 1) / sizeof(lctype ## _allocated ) + 1; \
+ \
+ PL_ ## lctype ## _root = lctype; \
+ while ( lctype < lctype ## end) { \
+ *(lctype ## _allocated **) lctype = (lctype ## _allocated *)(lctype + 1); \
+ lctype++; \
+ } \
+ *(lctype ## _allocated **) lctype = 0; \
+}
+
+S_more_thingy(NV, xnv)
+
+S_more_thingy_allocated(xpv)
+
+S_more_thingy_allocated(xpviv)
+
+S_more_thingy(XPVNV, xpvnv)
+
+S_more_thingy(XPVCV, xpvcv)
+
+S_more_thingy_allocated(xpvav)
+
+S_more_thingy_allocated(xpvhv)
+
+S_more_thingy(XPVGV, xpvgv)
+
+S_more_thingy(XPVMG, xpvmg)
+
+S_more_thingy(XPVBM, xpvbm)
+
+S_more_thingy(XPVLV, xpvlv)
+
+
+#else
+
+
/* allocate another arena's worth of NV bodies */
STATIC void
@@ -1350,6 +1430,8 @@ S_more_xpvbm(pTHX)
*((XPVBM**)xpvbm) = 0;
}
+#endif
+
/* grab a new NV body from the free list, allocating more if necessary */
STATIC XPVNV*