Bug 891215 (part 7) - Remove FindSCCs-inl.h. r=terrence.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 08 Jul 2013 21:08:28 -0700
changeset 138205 defc6801c431ca073e5fecf33dc00203b146a2d7
parent 138204 517f46403ff699097788c8ee3effa901652515e3
child 138206 2fea433d4a88829b2aea8260e86b103336ad7414
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersterrence
bugs891215
milestone25.0a1
Bug 891215 (part 7) - Remove FindSCCs-inl.h. r=terrence.
js/src/gc/FindSCCs-inl.h
js/src/gc/FindSCCs.h
js/src/jsapi-tests/testFindSCCs.cpp
js/src/jsgc.cpp
js/src/vm/Debugger.cpp
deleted file mode 100644
--- a/js/src/gc/FindSCCs-inl.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef gc_FindSCCs_inl_h
-#define gc_FindSCCs_inl_h
-
-#include "jsfriendapi.h"
-
-#include "gc/FindSCCs.h"
-
-namespace js {
-namespace gc {
-
-template<class Node>
-ComponentFinder<Node>::ComponentFinder(uintptr_t sl)
-  : clock(1),
-    stack(NULL),
-    firstComponent(NULL),
-    cur(NULL),
-    stackLimit(sl),
-    stackFull(false)
-{
-}
-
-template<class Node>
-ComponentFinder<Node>::~ComponentFinder()
-{
-    JS_ASSERT(!stack);
-    JS_ASSERT(!firstComponent);
-}
-
-template<class Node>
-void
-ComponentFinder<Node>::addNode(Node *v)
-{
-    if (v->gcDiscoveryTime == Undefined) {
-        JS_ASSERT(v->gcLowLink == Undefined);
-        processNode(v);
-    }
-}
-
-template<class Node>
-void
-ComponentFinder<Node>::processNode(Node *v)
-{
-    v->gcDiscoveryTime = clock;
-    v->gcLowLink = clock;
-    ++clock;
-
-    v->gcNextGraphNode = stack;
-    stack = v;
-
-    int stackDummy;
-    if (stackFull || !JS_CHECK_STACK_SIZE(stackLimit, &stackDummy)) {
-        stackFull = true;
-        return;
-    }
-
-    Node *old = cur;
-    cur = v;
-    cur->findOutgoingEdges(*this);
-    cur = old;
-
-    if (stackFull)
-        return;
-
-    if (v->gcLowLink == v->gcDiscoveryTime) {
-        Node *nextComponent = firstComponent;
-        Node *w;
-        do {
-            JS_ASSERT(stack);
-            w = stack;
-            stack = w->gcNextGraphNode;
-
-            /*
-             * Record that the element is no longer on the stack by setting the
-             * discovery time to a special value that's not Undefined.
-             */
-            w->gcDiscoveryTime = Finished;
-
-            /* Figure out which group we're in. */
-            w->gcNextGraphComponent = nextComponent;
-
-            /*
-             * Prepend the component to the beginning of the output list to
-             * reverse the list and achieve the desired order.
-             */
-            w->gcNextGraphNode = firstComponent;
-            firstComponent = w;
-        } while (w != v);
-    }
-}
-
-template<class Node>
-void
-ComponentFinder<Node>::addEdgeTo(Node *w)
-{
-    if (w->gcDiscoveryTime == Undefined) {
-        processNode(w);
-        cur->gcLowLink = Min(cur->gcLowLink, w->gcLowLink);
-    } else if (w->gcDiscoveryTime != Finished) {
-        cur->gcLowLink = Min(cur->gcLowLink, w->gcDiscoveryTime);
-    }
-}
-
-template<class Node>
-Node *
-ComponentFinder<Node>::getResultsList()
-{
-    if (stackFull) {
-        /*
-         * All nodes after the stack overflow are in |stack|. Put them all in
-         * one big component of their own.
-         */
-        Node *firstGoodComponent = firstComponent;
-        for (Node *v = stack; v; v = stack) {
-            stack = v->gcNextGraphNode;
-            v->gcNextGraphComponent = firstGoodComponent;
-            v->gcNextGraphNode = firstComponent;
-            firstComponent = v;
-        }
-        stackFull = false;
-    }
-
-    JS_ASSERT(!stack);
-
-    Node *result = firstComponent;
-    firstComponent = NULL;
-
-    for (Node *v = result; v; v = v->gcNextGraphNode) {
-        v->gcDiscoveryTime = Undefined;
-        v->gcLowLink = Undefined;
-    }
-
-    return result;
-}
-
-template<class Node>
-/* static */ void
-ComponentFinder<Node>::mergeGroups(Node *first)
-{
-    for (Node *v = first; v; v = v->gcNextGraphNode)
-        v->gcNextGraphComponent = NULL;
-}
-
-} /* namespace gc */
-} /* namespace js */
-
-#endif /* gc_FindSCCs_inl_h */
--- a/js/src/gc/FindSCCs.h
+++ b/js/src/gc/FindSCCs.h
@@ -58,39 +58,140 @@ struct GraphNodeBase
  *
  * ComponentFinder<MyGraphNode> finder;
  * finder.addNode(v);
  */
 template<class Node>
 class ComponentFinder
 {
   public:
-    ComponentFinder(uintptr_t stackLimit);
-    ~ComponentFinder();
+    ComponentFinder(uintptr_t sl)
+      : clock(1),
+        stack(NULL),
+        firstComponent(NULL),
+        cur(NULL),
+        stackLimit(sl),
+        stackFull(false)
+    {}
+
+    ~ComponentFinder() {
+        JS_ASSERT(!stack);
+        JS_ASSERT(!firstComponent);
+    }
 
     /* Forces all nodes to be added to a single component. */
     void useOneComponent() { stackFull = true; }
 
-    void addNode(Node *v);
-    Node *getResultsList();
+    void addNode(Node *v) {
+        if (v->gcDiscoveryTime == Undefined) {
+            JS_ASSERT(v->gcLowLink == Undefined);
+            processNode(v);
+        }
+    }
 
-    static void mergeGroups(Node *first);
+    Node *getResultsList() {
+        if (stackFull) {
+            /*
+             * All nodes after the stack overflow are in |stack|. Put them all in
+             * one big component of their own.
+             */
+            Node *firstGoodComponent = firstComponent;
+            for (Node *v = stack; v; v = stack) {
+                stack = v->gcNextGraphNode;
+                v->gcNextGraphComponent = firstGoodComponent;
+                v->gcNextGraphNode = firstComponent;
+                firstComponent = v;
+            }
+            stackFull = false;
+        }
+
+        JS_ASSERT(!stack);
+
+        Node *result = firstComponent;
+        firstComponent = NULL;
+
+        for (Node *v = result; v; v = v->gcNextGraphNode) {
+            v->gcDiscoveryTime = Undefined;
+            v->gcLowLink = Undefined;
+        }
+
+        return result;
+    }
+
+    static void mergeGroups(Node *first) {
+        for (Node *v = first; v; v = v->gcNextGraphNode)
+            v->gcNextGraphComponent = NULL;
+    }
 
   public:
     /* Call from implementation of GraphNodeBase::findOutgoingEdges(). */
-    void addEdgeTo(Node *w);
+    void addEdgeTo(Node *w) {
+        if (w->gcDiscoveryTime == Undefined) {
+            processNode(w);
+            cur->gcLowLink = Min(cur->gcLowLink, w->gcLowLink);
+        } else if (w->gcDiscoveryTime != Finished) {
+            cur->gcLowLink = Min(cur->gcLowLink, w->gcDiscoveryTime);
+        }
+    }
 
   private:
     /* Constant used to indicate an unprocessed vertex. */
     static const unsigned Undefined = 0;
 
     /* Constant used to indicate an processed vertex that is no longer on the stack. */
     static const unsigned Finished = (unsigned)-1;
 
-    void processNode(Node *v);
+    void processNode(Node *v) {
+        v->gcDiscoveryTime = clock;
+        v->gcLowLink = clock;
+        ++clock;
+
+        v->gcNextGraphNode = stack;
+        stack = v;
+
+        int stackDummy;
+        if (stackFull || !JS_CHECK_STACK_SIZE(stackLimit, &stackDummy)) {
+            stackFull = true;
+            return;
+        }
+
+        Node *old = cur;
+        cur = v;
+        cur->findOutgoingEdges(*this);
+        cur = old;
+
+        if (stackFull)
+            return;
+
+        if (v->gcLowLink == v->gcDiscoveryTime) {
+            Node *nextComponent = firstComponent;
+            Node *w;
+            do {
+                JS_ASSERT(stack);
+                w = stack;
+                stack = w->gcNextGraphNode;
+
+                /*
+                 * Record that the element is no longer on the stack by setting the
+                 * discovery time to a special value that's not Undefined.
+                 */
+                w->gcDiscoveryTime = Finished;
+
+                /* Figure out which group we're in. */
+                w->gcNextGraphComponent = nextComponent;
+
+                /*
+                 * Prepend the component to the beginning of the output list to
+                 * reverse the list and achieve the desired order.
+                 */
+                w->gcNextGraphNode = firstComponent;
+                firstComponent = w;
+            } while (w != v);
+        }
+    }
 
   private:
     unsigned       clock;
     Node           *stack;
     Node           *firstComponent;
     Node           *cur;
     uintptr_t      stackLimit;
     bool           stackFull;
--- a/js/src/jsapi-tests/testFindSCCs.cpp
+++ b/js/src/jsapi-tests/testFindSCCs.cpp
@@ -11,18 +11,16 @@
 #include <string.h>
 #include <stdarg.h>
 
 #include "jscntxt.h"
 #include "jsgc.h"
 
 #include "gc/FindSCCs.h"
 
-#include "gc/FindSCCs-inl.h"
-
 static const unsigned MaxVertices = 10;
 
 using js::gc::GraphNodeBase;
 using js::gc::ComponentFinder;
 
 struct TestNode : public GraphNodeBase<TestNode>
 {
     unsigned   index;
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -68,17 +68,16 @@
 #include "ion/IonCode.h"
 #ifdef JS_ION
 # include "ion/BaselineJIT.h"
 #endif
 
 #include "jsgcinlines.h"
 #include "jsobjinlines.h"
 
-#include "gc/FindSCCs-inl.h"
 #include "vm/String-inl.h"
 #include "vm/Stack-inl.h"
 
 #ifdef XP_WIN
 # include "jswin.h"
 #else
 # include <unistd.h>
 #endif
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -17,17 +17,16 @@
 #include "gc/Marking.h"
 #include "ion/BaselineJIT.h"
 #include "js/Vector.h"
 
 #include "jsfuninlines.h"
 #include "jsgcinlines.h"
 #include "jsopcodeinlines.h"
 
-#include "gc/FindSCCs-inl.h"
 #include "vm/Stack-inl.h"
 
 using namespace js;
 
 using js::frontend::IsIdentifier;
 using mozilla::ArrayLength;
 using mozilla::Maybe;