Factor out AttemptToGrowTree.
authorAndreas Gal <gal@mozilla.com>
Fri, 25 Jul 2008 02:00:02 -0700
changeset 17825 f5149a2b93091409dc28978c5c29cd00460188d3
parent 17824 2666adaeb7527e7eeda8ce1c2db9cd1ed7ccc85d
child 17826 75805867814e6e819ba7508a20ffd01dc126b55e
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
Factor out AttemptToGrowTree.
js/src/jstracer.cpp
js/src/jstracer.h
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -1211,17 +1211,17 @@ js_StartRecorder(JSContext* cx, GuardRec
     JS_TRACE_MONITOR(cx).recorder = new (&gc) TraceRecorder(cx, anchor, f, typeMap);
     if (cx->throwing) {
         js_AbortRecording(cx, NULL, "setting up recorder failed");
         return false;
     }
     return true;
 }
 
-GuardRecord*
+static GuardRecord*
 js_ExecuteTree(JSContext* cx, Fragment* f)
 {
     AUDIT(traceTriggered);
 
     /* execute previously recorded trace */
     TreeInfo* ti = (TreeInfo*)f->vmprivate;
     if (OBJ_SCOPE(JS_GetGlobalForObject(cx, cx->fp->scopeChain))->shape != ti->globalShape) {
         AUDIT(globalShapeMismatchAtEntry);
@@ -1276,16 +1276,40 @@ js_ExecuteTree(JSContext* cx, Fragment* 
     JS_ASSERT(*(uint64*)&stack[ti->maxNativeStackSlots] == 0xdeadbeefdeadbeefLL);
     JS_ASSERT(*(uint64*)&global[ti->ngslots] == 0xdeadbeefdeadbeefLL);
 
     AUDIT(sideExitIntoInterpreter);
     
     return lr;
 }
 
+static bool
+js_AttemptToExtendTree(JSContext* cx, GuardRecord* lr)
+{
+    debug_only(printf("trying to attach another branch to the tree\n");)
+
+    Fragment* c;
+    if (!(c = lr->target)) {
+        c = JS_TRACE_MONITOR(cx).fragmento->createBranch(lr, lr->exit);
+        c->spawnedFrom = lr->guard;
+        c->parent = lr->from;
+        lr->exit->target = c;
+        lr->target = c;
+        c->root = c->parent;
+        c->calldepth = lr->calldepth;
+    }
+
+    if (++c->hits() >= HOTEXIT) {
+        /* start tracing secondary trace from this point */
+        c->lirbuf = c->parent->lirbuf;
+        return js_StartRecorder(cx, lr, c, lr->guard->exit()->typeMap);
+    }
+    return false;
+}
+
 bool
 js_LoopEdge(JSContext* cx, jsbytecode* oldpc)
 {
     JSTraceMonitor* tm = &JS_TRACE_MONITOR(cx);
 
     /* is the recorder currently active? */
     if (tm->recorder) {
         TraceRecorder* r = tm->recorder;
@@ -1373,35 +1397,17 @@ js_LoopEdge(JSContext* cx, jsbytecode* o
     
     if (!lr) /* did the tree actually execute? */
         return false;
     
     /* if the side exit terminates the loop, don't try to attach a trace here */
     if (lr->exit->loopExit)
         return false;
 
-    debug_only(printf("trying to attach another branch to the tree\n");)
-
-    Fragment* c;
-    if (!(c = lr->target)) {
-        c = tm->fragmento->createBranch(lr, lr->exit);
-        c->spawnedFrom = lr->guard;
-        c->parent = f;
-        lr->exit->target = c;
-        lr->target = c;
-        c->root = f;
-        c->calldepth = lr->calldepth;
-    }
-
-    if (++c->hits() >= HOTEXIT) {
-        /* start tracing secondary trace from this point */
-        c->lirbuf = f->lirbuf;
-        return js_StartRecorder(cx, lr, c, lr->guard->exit()->typeMap);
-    }
-    return false;
+    return js_AttemptToExtendTree(cx, lr);
 }
 
 void
 js_AbortRecording(JSContext* cx, jsbytecode* abortpc, const char* reason)
 {
     AUDIT(recorderAborted);
     debug_only(if (!abortpc) abortpc = cx->fp->regs->pc;
                printf("Abort recording (line %d, pc %d): %s.\n",
--- a/js/src/jstracer.h
+++ b/js/src/jstracer.h
@@ -247,19 +247,16 @@ public:
     JS_BEGIN_MACRO                                                            \
         TraceRecorder* r = JS_TRACE_MONITOR(cx).recorder;                     \
         if (!r->record_##x()) {                                               \
             js_AbortRecording(cx, NULL, #x);                                  \
             ENABLE_TRACER(0);                                                 \
         }                                                                     \
     JS_END_MACRO
 
-extern nanojit::GuardRecord*
-js_ExecuteTree(JSContext* cx, nanojit::Fragment* f);
-
 extern bool
 js_LoopEdge(JSContext* cx, jsbytecode* oldpc);
 
 extern void
 js_AbortRecording(JSContext* cx, jsbytecode* abortpc, const char* reason);
 
 extern void
 js_InitJIT(JSContext* cx);