From: Florian Ragwitz <rafl@debian.org>
Date: Mon, 1 Oct 2012 01:07:29 +0000 (+0900)
Subject: Add refcounted_he structs counting
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4f77653ed2a2445477e8436276d2d92cf388fec;p=p5sagit%2FDevel-Size.git

Add refcounted_he structs counting
---

diff --git a/Memory.xs b/Memory.xs
index 899de95..a782f06 100644
--- a/Memory.xs
+++ b/Memory.xs
@@ -24,6 +24,8 @@
 #include "XSUB.h"
 #include "ppport.h"
 
+#include "refcounted_he.h"
+
 /* Not yet in ppport.h */
 #ifndef CvISXSUB
 #  define CvISXSUB(cv)  (CvXSUB(cv) ? TRUE : FALSE)
@@ -718,6 +720,50 @@ regex_size(pTHX_ const REGEXP * const baseregex, struct state *st, pPATH) {
 }
 
 static void
+hek_size(pTHX_ struct state *st, HEK *hek, U32 shared, pPATH)
+{
+    dNPathNodes(1, NPathArg);
+
+    /* Hash keys can be shared. Have we seen this before? */
+    if (!check_new(st, hek))
+	return;
+    NPathPushNode("hek", NPtype_NAME);
+    ADD_SIZE(st, "hek_len", HEK_BASESIZE + hek->hek_len
+#if PERL_VERSION < 8
+	+ 1 /* No hash key flags prior to 5.8.0  */
+#else
+	+ 2
+#endif
+	);
+    if (shared) {
+#if PERL_VERSION < 10
+	ADD_SIZE(st, "he", sizeof(struct he));
+#else
+	ADD_SIZE(st, "shared_he", STRUCT_OFFSET(struct shared_he, shared_he_hek));
+#endif
+    }
+}
+
+static void
+refcounted_he_size(pTHX_ struct state *st, struct refcounted_he *he, pPATH)
+{
+  dNPathNodes(1, NPathArg);
+  if (!check_new(st, he))
+    return;
+  NPathPushNode("refcounted_he_size", NPtype_NAME);
+  ADD_SIZE(st, "refcounted_he", sizeof(struct refcounted_he));
+
+#ifdef USE_ITHREADS
+  ADD_SIZE(st, "refcounted_he_data", NPtype_NAME);
+#else
+  hek_size(aTHX_ st, he->refcounted_he_hek, 0, NPathLink("refcounted_he_hek"));
+#endif
+
+  if (he->refcounted_he_next)
+    refcounted_he_size(aTHX_ st, he->refcounted_he_next, NPathLink("refcounted_he_next"));
+}
+
+static void
 op_size(pTHX_ const OP * const baseop, struct state *st, pPATH)
 {
     /* op_size recurses to follow the chain of opcodes.  For the node path we
@@ -848,32 +894,6 @@ op_size(pTHX_ const OP * const baseop, struct state *st, pPATH)
   }
 }
 
-static void
-hek_size(pTHX_ struct state *st, HEK *hek, U32 shared, pPATH)
-{
-    dNPathNodes(1, NPathArg);
-
-    /* Hash keys can be shared. Have we seen this before? */
-    if (!check_new(st, hek))
-	return;
-    NPathPushNode("hek", NPtype_NAME);
-    ADD_SIZE(st, "hek_len", HEK_BASESIZE + hek->hek_len
-#if PERL_VERSION < 8
-	+ 1 /* No hash key flags prior to 5.8.0  */
-#else
-	+ 2
-#endif
-	);
-    if (shared) {
-#if PERL_VERSION < 10
-	ADD_SIZE(st, "he", sizeof(struct he));
-#else
-	ADD_SIZE(st, "shared_he", STRUCT_OFFSET(struct shared_he, shared_he_hek));
-#endif
-    }
-}
-
-
 #if PERL_VERSION < 8 || PERL_SUBVERSION < 9
 #  define SVt_LAST 16
 #endif