Handle the new METHOP.
[p5sagit/Devel-Size.git] / Size.xs
diff --git a/Size.xs b/Size.xs
index f06f85e..c66f1c6 100644 (file)
--- a/Size.xs
+++ b/Size.xs
@@ -215,6 +215,9 @@ typedef enum {
 #ifdef OA_GVOP
     , OPc_GVOP /* 13 */
 #endif
+#ifdef OA_METHOP
+    , OPc_METHOP
+#endif
 
 } opclass;
 
@@ -337,6 +340,11 @@ cc_opclass(const OP * const o)
         case OA_CONDOP: TAG;
            return OPc_CONDOP;
 #endif
+
+#ifdef OA_METHOP
+       case OA_METHOP: TAG;
+           return OPc_METHOP;
+#endif
         }
         warn("Devel::Size: Can't determine class of operator %s, assuming BASEOP\n",
          PL_op_name[o->op_type]);
@@ -518,14 +526,35 @@ op_size(pTHX_ const OP * const baseop, struct state *st)
 #endif
 #ifdef USE_ITHREADS
           check_new_and_strlen(st, basecop->cop_file);
+#if PERL_VERSION < 17 || (PERL_VERSION == 17 && PERL_SUBVERSION == 0)
+         /* This pointer is owned by the COP, and freed with it.  */
           check_new_and_strlen(st, basecop->cop_stashpv);
 #else
-         sv_size(aTHX_ st, (SV *)basecop->cop_stash, SOME_RECURSION);
+         /* A per-interpreter pointer for this stash is allocated in
+            PL_stashpad. */
+         if (check_new(st, PL_stashpad + basecop->cop_stashoff))
+             st->total_size += sizeof(PL_stashpad[basecop->cop_stashoff]);
+#endif
+#else
          sv_size(aTHX_ st, (SV *)basecop->cop_filegv, SOME_RECURSION);
 #endif
 
         }
         TAG;break;
+#ifdef OA_METHOP
+       case OPc_METHOP: TAG;
+           st->total_size += sizeof(struct methop);
+           if (baseop->op_type != OP_METHOD)
+               sv_size(aTHX_ st, cMETHOPx_meth(baseop), SOME_RECURSION);
+#if PERL_VERSION*1000+PERL_SUBVERSION >= 21007
+           if (baseop->op_type == OP_METHOD_REDIR || baseop->op_type == OP_METHOD_REDIR_SUPER) {
+               SV *rclass = cMETHOPx_rclass(baseop);
+               if(SvTYPE(rclass) != SVt_PVHV)
+                   sv_size(aTHX_ st, rclass, SOME_RECURSION);
+           }
+#endif
+           TAG;break;
+#endif
       default:
         TAG;break;
       }
@@ -700,7 +729,7 @@ sv_size(pTHX_ struct state *const st, const SV * const orig_thing,
   }
   st->total_size += sizeof(SV) + body_sizes[type];
 
-  if (type >= SVt_PVMG) {
+  if (SvMAGICAL(thing)) {
       magic_size(aTHX_ thing, st);
   }