Eliminate SVt_RV, and use SVt_IV to store plain references.
[p5sagit/p5-mst-13.2.git] / pp_hot.c
index 6fb53d4..276010c 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -150,7 +150,7 @@ PP(pp_sassign)
                   The gv becomes a(nother) reference to the constant.  */
                SV *const value = SvRV(cv);
 
-               SvUPGRADE((SV *)gv, SVt_RV);
+               SvUPGRADE((SV *)gv, SVt_IV);
                SvPCS_IMPORTED_on(gv);
                SvRV_set(gv, value);
                SvREFCNT_inc_simple_void(value);
@@ -496,8 +496,11 @@ PP(pp_defined)
 
 PP(pp_add)
 {
-    dVAR; dSP; dATARGET; bool useleft; tryAMAGICbin(add,opASSIGN);
-    useleft = USE_LEFT(TOPm1s);
+    dVAR; dSP; dATARGET; bool useleft; SV *svl, *svr;
+    tryAMAGICbin(add,opASSIGN);
+    svl = sv_2num(TOPm1s);
+    svr = sv_2num(TOPs);
+    useleft = USE_LEFT(svl);
 #ifdef PERL_PRESERVE_IVUV
     /* We must see if we can perform the addition with integers if possible,
        as the integer code detects overflow while the NV code doesn't.
@@ -545,8 +548,8 @@ PP(pp_add)
        unsigned code below is actually shorter than the old code. :-)
     */
 
-    SvIV_please(TOPs);
-    if (SvIOK(TOPs)) {
+    SvIV_please(svr);
+    if (SvIOK(svr)) {
        /* Unless the left argument is integer in range we are going to have to
           use NV maths. Hence only attempt to coerce the right argument if
           we know the left is integer.  */
@@ -562,12 +565,12 @@ PP(pp_add)
               lots of code to speed up what is probably a rarish case.  */
        } else {
            /* Left operand is defined, so is it IV? */
-           SvIV_please(TOPm1s);
-           if (SvIOK(TOPm1s)) {
-               if ((auvok = SvUOK(TOPm1s)))
-                   auv = SvUVX(TOPm1s);
+           SvIV_please(svl);
+           if (SvIOK(svl)) {
+               if ((auvok = SvUOK(svl)))
+                   auv = SvUVX(svl);
                else {
-                   register const IV aiv = SvIVX(TOPm1s);
+                   register const IV aiv = SvIVX(svl);
                    if (aiv >= 0) {
                        auv = aiv;
                        auvok = 1;      /* Now acting as a sign flag.  */
@@ -582,12 +585,12 @@ PP(pp_add)
            bool result_good = 0;
            UV result;
            register UV buv;
-           bool buvok = SvUOK(TOPs);
+           bool buvok = SvUOK(svr);
        
            if (buvok)
-               buv = SvUVX(TOPs);
+               buv = SvUVX(svr);
            else {
-               register const IV biv = SvIVX(TOPs);
+               register const IV biv = SvIVX(svr);
                if (biv >= 0) {
                    buv = biv;
                    buvok = 1;
@@ -645,13 +648,14 @@ PP(pp_add)
     }
 #endif
     {
-       dPOPnv;
+       NV value = SvNV(svr);
+       (void)POPs;
        if (!useleft) {
            /* left operand is undef, treat as zero. + 0.0 is identity. */
            SETn(value);
            RETURN;
        }
-       SETn( value + TOPn );
+       SETn( value + SvNV(svl) );
        RETURN;
     }
 }
@@ -1323,7 +1327,8 @@ play_it_again:
             && !SvROK(TARG))   /* Cannot trust since INTUIT cannot guess ^ */
            goto yup;
     }
-    if (CALLREGEXEC(rx, (char*)s, (char *)strend, (char*)truebase, minmatch, TARG, INT2PTR(void*, gpos), r_flags))
+    if (CALLREGEXEC(rx, (char*)s, (char *)strend, (char*)truebase,
+                    minmatch, TARG, NUM2PTR(void*, gpos), r_flags))
     {
        PL_curpm = pm;
        if (dynpm->op_pmflags & PMf_ONCE) {
@@ -2935,8 +2940,8 @@ Perl_vivify_ref(pTHX_ SV *sv, U32 to_what)
     if (!SvOK(sv)) {
        if (SvREADONLY(sv))
            Perl_croak(aTHX_ PL_no_modify);
-       if (SvTYPE(sv) < SVt_RV)
-           sv_upgrade(sv, SVt_RV);
+       if (SvTYPE(sv) < SVt_PV && SvTYPE(sv) != SVt_IV)
+           sv_upgrade(sv, SVt_IV);
        else if (SvTYPE(sv) >= SVt_PV) {
            SvPV_free(sv);
             SvLEN_set(sv, 0);
@@ -3097,16 +3102,24 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
        }
        if (!sep || ((sep - name) == 5 && strnEQ(name, "SUPER", 5))) {
            /* the method name is unqualified or starts with SUPER:: */
+#ifndef USE_ITHREADS
+           if (sep)
+               stash = CopSTASH(PL_curcop);
+#else
            bool need_strlen = 1;
            if (sep) {
                packname = CopSTASHPV(PL_curcop);
            }
-           else if (stash) {
+           else
+#endif
+           if (stash) {
                HEK * const packhek = HvNAME_HEK(stash);
                if (packhek) {
                    packname = HEK_KEY(packhek);
                    packlen = HEK_LEN(packhek);
+#ifdef USE_ITHREADS
                    need_strlen = 0;
+#endif
                } else {
                    goto croak;
                }
@@ -3117,8 +3130,10 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
                Perl_croak(aTHX_
                           "Can't use anonymous symbol table for method lookup");
            }
-           else if (need_strlen)
+#ifdef USE_ITHREADS
+           if (need_strlen)
                packlen = strlen(packname);
+#endif
 
        }
        else {