speeding up object creation/destruction 4x times
[p5sagit/p5-mst-13.2.git] / perl.h
diff --git a/perl.h b/perl.h
index 562da8a..8313c07 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -183,7 +183,7 @@ class CPerlObj;
 struct perl_thread;
 #    define pTHX       register struct perl_thread *thr
 #    define aTHX       thr
-#    define dTHR       dNOOP
+#    define dTHR       dNOOP /* only backward compatibility */
 #    define dTHXa(a)   pTHX = (struct perl_thread*)a
 #  else
 #    ifndef MULTIPLICITY
@@ -303,7 +303,7 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
 #endif
 
 #define WITH_THX(s) STMT_START { dTHX; s; } STMT_END
-#define WITH_THR(s) STMT_START { dTHR; s; } STMT_END
+#define WITH_THR(s) WITH_THX(s)
 
 /*
  * SOFT_CAST can be used for args to prototyped functions to retain some
@@ -3055,46 +3055,53 @@ enum {
   to_sv_amg,   to_av_amg,
   to_hv_amg,   to_gv_amg,
   to_cv_amg,   iter_amg,    
-  max_amg_code
+  DESTROY_amg, max_amg_code
   /* Do not leave a trailing comma here.  C9X allows it, C89 doesn't. */
 };
 
 #define NofAMmeth max_amg_code
+#define AMG_id2name(id) ((char*)PL_AMG_names[id]+1)
 
 #ifdef DOINIT
 EXTCONST char * PL_AMG_names[NofAMmeth] = {
-  "fallback",  "abs",                  /* "fallback" should be the first. */
-  "bool",      "nomethod",
-  "\"\"",      "0+",
-  "+",         "+=",
-  "-",         "-=",
-  "*",         "*=",
-  "/",         "/=",
-  "%",         "%=",
-  "**",                "**=",
-  "<<",                "<<=",
-  ">>",                ">>=",
-  "&",         "&=",
-  "|",         "|=",
-  "^",         "^=",
-  "<",         "<=",
-  ">",         ">=",
-  "==",                "!=",
-  "<=>",       "cmp",
-  "lt",                "le",
-  "gt",                "ge",
-  "eq",                "ne",
-  "!",         "~",
-  "++",                "--",
-  "atan2",     "cos",
-  "sin",       "exp",
-  "log",       "sqrt",
-  "x",         "x=",
-  ".",         ".=",
-  "=",         "neg",
-  "${}",       "@{}",
-  "%{}",       "*{}",
-  "&{}",       "<>",
+  /* Names kept in the symbol table.  fallback => "()", the rest has
+     "(" prepended.  The only other place in perl which knows about
+     this convention is AMG_id2name (used for debugging output and
+     'nomethod' only), the only other place which has it hardwired is
+     overload.pm.  */
+  "()",                "(abs",                 /* "fallback" should be the first. */
+  "(bool",     "(nomethod",
+  "(\"\"",     "(0+",
+  "(+",                "(+=",
+  "(-",                "(-=",
+  "(*",                "(*=",
+  "(/",                "(/=",
+  "(%",                "(%=",
+  "(**",       "(**=",
+  "(<<",       "(<<=",
+  "(>>",       "(>>=",
+  "(&",                "(&=",
+  "(|",                "(|=",
+  "(^",                "(^=",
+  "(<",                "(<=",
+  "(>",                "(>=",
+  "(==",       "(!=",
+  "(<=>",      "(cmp",
+  "(lt",       "(le",
+  "(gt",       "(ge",
+  "(eq",       "(ne",
+  "(!",                "(~",
+  "(++",       "(--",
+  "(atan2",    "(cos",
+  "(sin",      "(exp",
+  "(log",      "(sqrt",
+  "(x",                "(x=",
+  "(.",                "(.=",
+  "(=",                "(neg",
+  "(${}",      "(@{}",
+  "(%{}",      "(*{}",
+  "(&{}",      "(<>",
+  "DESTROY",
 };
 #else
 EXTCONST char * PL_AMG_names[NofAMmeth];
@@ -3122,10 +3129,15 @@ typedef struct am_table_short AMTS;
 #define AMGfallYES     3
 
 #define AMTf_AMAGIC            1
+#define AMTf_OVERLOADED                2
 #define AMT_AMAGIC(amt)                ((amt)->flags & AMTf_AMAGIC)
 #define AMT_AMAGIC_on(amt)     ((amt)->flags |= AMTf_AMAGIC)
 #define AMT_AMAGIC_off(amt)    ((amt)->flags &= ~AMTf_AMAGIC)
+#define AMT_OVERLOADED(amt)    ((amt)->flags & AMTf_OVERLOADED)
+#define AMT_OVERLOADED_on(amt) ((amt)->flags |= AMTf_OVERLOADED)
+#define AMT_OVERLOADED_off(amt)        ((amt)->flags &= ~AMTf_OVERLOADED)
 
+#define StashHANDLER(stash,meth)       gv_handler((stash),CAT2(meth,_amg))
 
 /*
  * some compilers like to redefine cos et alia as faster