Cleanup iteration over all slots to use a single macro to avoid code duplication.
authorAndreas Gal <gal@mozilla.com>
Thu, 24 Jul 2008 14:51:14 -0700
changeset 17820 6747a00cdc2c2d82c1fe8c459222afdad7625920
parent 17819 d4612c4b9cc2a504016021b7635d36acbb7640ba
child 17821 81375d2214942696bc81f38b1de872085fad105b
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherderautoland@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Cleanup iteration over all slots to use a single macro to avoid code duplication.
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -433,16 +433,22 @@ public:
                 while (vp < vpstop) { code; ++vp; INC_VPNUM(); }              \
             }                                                                 \
             SET_VPNAME("stack");                                              \
             vp = StackBase(f); vpstop = f->regs->sp;                          \
             while (vp < vpstop) { code; ++vp; INC_VPNUM(); }                  \
         }                                                                     \
     JS_END_MACRO
 
+#define FORALL_SLOTS(cx, ngslots, gslots, callDepth, code)                    \
+    JS_BEGIN_MACRO                                                            \
+        FORALL_GLOBAL_SLOTS(cx, ngslots, gslots, code);                       \
+        FORALL_SLOTS_IN_PENDING_FRAMES(cx, callDepth, code);                  \
+    JS_END_MACRO
+
 TraceRecorder::TraceRecorder(JSContext* cx, GuardRecord* _anchor,
         Fragment* _fragment, uint8* typeMap)
 {
     this->cx = cx;
     this->globalObj = JS_GetGlobalForObject(cx, cx->fp->scopeChain);
     this->anchor = _anchor;
     this->fragment = _fragment;
     this->lirbuf = _fragment->lirbuf;
@@ -961,23 +967,17 @@ TraceRecorder::snapshot()
     exit.calldepth = getCallDepth();
     exit.ip_adj = cx->fp->regs->pc - entryRegs->pc;
     exit.sp_adj = (cx->fp->regs->sp - entryRegs->sp) * sizeof(double);
     exit.rp_adj = exit.calldepth;
     uint8* m = exit.typeMap = (uint8 *)data->payload();
     /* Determine the type of a store by looking at the current type of the actual value the
        interpreter is using. For numbers we have to check what kind of store we used last
        (integer or double) to figure out what the side exit show reflect in its typemap. */
-    FORALL_GLOBAL_SLOTS(cx, treeInfo->ngslots, treeInfo->gslots,
-        LIns* i = get(vp);
-        *m++ = isNumber(*vp)
-            ? (isPromoteInt(i) ? JSVAL_INT : JSVAL_DOUBLE)
-            : JSVAL_TAG(*vp);
-    );
-    FORALL_SLOTS_IN_PENDING_FRAMES(cx, callDepth,
+    FORALL_SLOTS(cx, treeInfo->ngslots, treeInfo->gslots, callDepth,
         LIns* i = get(vp);
         *m++ = isNumber(*vp)
             ? (isPromoteInt(i) ? JSVAL_INT : JSVAL_DOUBLE)
             : JSVAL_TAG(*vp);
     );
     return &exit;
 }
 
@@ -1069,22 +1069,17 @@ TraceRecorder::checkType(jsval& v, uint8
 }
 
 /* Make sure that the current values in the given stack frame and all stack frames
    up and including entryFrame are type-compatible with the entry map. */
 bool
 TraceRecorder::verifyTypeStability(uint8* map)
 {
     uint8* m = map;
-    FORALL_GLOBAL_SLOTS(cx, treeInfo->ngslots, treeInfo->gslots,
-        if (!checkType(*vp, *m))
-            return false;
-        ++m
-    );
-    FORALL_SLOTS_IN_PENDING_FRAMES(cx, callDepth,
+    FORALL_SLOTS(cx, treeInfo->ngslots, treeInfo->gslots, callDepth,
         if (!checkType(*vp, *m))
             return false;
         ++m
     );
     return !recompileFlag;
 }
 
 void
@@ -1282,20 +1277,17 @@ js_LoopEdge(JSContext* cx, jsbytecode* o
                 ti->maxCallDepth = 0;
             }
 
             /* capture the entry type map if we don't have one yet (or we threw it away) */
             if (!ti->typeMap) {
                 ti->typeMap = (uint8*)malloc(ti->entryNativeStackSlots * sizeof(uint8));
                 uint8* m = ti->typeMap;
                 /* remember the coerced type of each active slot in the type map */
-                FORALL_GLOBAL_SLOTS(cx, ti->ngslots, ti->gslots,
-                    *m++ = getCoercedType(*vp)
-                );
-                FORALL_SLOTS_IN_PENDING_FRAMES(cx, 0/*callDepth*/,
+                FORALL_SLOTS(cx, ti->ngslots, ti->gslots, 0/*callDepth*/,
                     *m++ = getCoercedType(*vp)
                 );
             }
             /* recording primary trace */
             return js_StartRecorder(cx, NULL, f, ti->typeMap);
         }
         return false;
     }