From: Brian Norris <banorris@uci.edu>
Date: Mon, 14 May 2012 19:14:53 +0000 (-0700)
Subject: tree: kill class TreeNode
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=76f4470373fac52522d64e75cd394baeb617e76b;p=cdsspec-compiler.git

tree: kill class TreeNode

Superceded by NodeStack
---

diff --git a/Makefile b/Makefile
index e61de2a..22a1c64 100644
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,9 @@ LIB_SO=lib$(LIB_NAME).so
 USER_O=userprog.o
 USER_H=libthreads.h libatomic.h
 
-MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc malloc.c threads.cc tree.cc librace.cc action.cc nodestack.cc clockvector.cc main.cc
-MODEL_O=libthreads.o schedule.o libatomic.o model.o malloc.o threads.o tree.o librace.o action.o nodestack.o clockvector.o main.o
-MODEL_H=libthreads.h schedule.h common.h libatomic.h model.h threads.h tree.h librace.h action.h nodestack.h clockvector.h
+MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc malloc.c threads.cc librace.cc action.cc nodestack.cc clockvector.cc main.cc
+MODEL_O=libthreads.o schedule.o libatomic.o model.o malloc.o threads.o librace.o action.o nodestack.o clockvector.o main.o
+MODEL_H=libthreads.h schedule.h common.h libatomic.h model.h threads.h librace.h action.h nodestack.h clockvector.h
 
 CPPFLAGS=-Wall -g
 LDFLAGS=-ldl
diff --git a/tree.cc b/tree.cc
deleted file mode 100644
index c161ca8..0000000
--- a/tree.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "tree.h"
-#include "action.h"
-
-int TreeNode::totalNodes = 0;
-
-TreeNode::TreeNode(TreeNode *par, ModelAction *act)
-{
-	TreeNode::totalNodes++;
-	this->parent = par;
-	if (!parent) {
-		num_threads = 1;
-	} else {
-		num_threads = parent->num_threads;
-		if (act && act->get_type() == THREAD_CREATE)
-			num_threads++;
-	}
-}
-
-TreeNode::~TreeNode() {
-	std::map<int, class TreeNode *>::iterator it;
-
-	for (it = children.begin(); it != children.end(); it++)
-		delete it->second;
-}
-
-TreeNode * TreeNode::explore_child(ModelAction *act)
-{
-	TreeNode *n;
-	std::set<int>::iterator it;
-	thread_id_t id = act->get_tid();
-	int i = id_to_int(id);
-
-	if (!hasBeenExplored(id)) {
-		n = new TreeNode(this, act);
-		children[i] = n;
-	} else {
-		n = children[i];
-	}
-	if ((it = backtrack.find(i)) != backtrack.end())
-		backtrack.erase(it);
-
-	return n;
-}
-
-int TreeNode::setBacktrack(thread_id_t id)
-{
-	int i = id_to_int(id);
-	if (backtrack.find(i) != backtrack.end())
-		return 1;
-	backtrack.insert(i);
-	return 0;
-}
-
-thread_id_t TreeNode::getNextBacktrack()
-{
-	if (backtrack.empty())
-		return THREAD_ID_T_NONE;
-	return int_to_id(*backtrack.begin());
-}
-
-TreeNode * TreeNode::getRoot()
-{
-	if (parent)
-		return parent->getRoot();
-	return this;
-}
-
-bool TreeNode::is_enabled(Thread *t)
-{
-	return id_to_int(t->get_id()) < num_threads;
-}
diff --git a/tree.h b/tree.h
deleted file mode 100644
index 864ce8f..0000000
--- a/tree.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __TREE_H__
-#define __TREE_H__
-
-#include <set>
-#include <map>
-#include <cstddef>
-#include "threads.h"
-
-class ModelAction;
-
-/*
- * An n-ary tree
- *
- * A tree with n possible branches from each node - used for recording the
- * execution paths we've executed / backtracked
- */
-class TreeNode {
-public:
-	TreeNode(TreeNode *par = NULL, ModelAction *act = NULL);
-	~TreeNode();
-	bool hasBeenExplored(thread_id_t id) { return children.find(id_to_int(id)) != children.end(); }
-	TreeNode * explore_child(ModelAction *act);
-	thread_id_t getNextBacktrack();
-
-	/* Return 1 if already in backtrack, 0 otherwise */
-	int setBacktrack(thread_id_t id);
-	TreeNode * getRoot();
-	static int getTotalNodes() { return TreeNode::totalNodes; }
-
-	bool is_enabled(Thread *t);
-private:
-	TreeNode *parent;
-	std::map<int, class TreeNode *> children;
-	std::set<int> backtrack;
-	static int totalNodes;
-	int num_threads;
-};
-
-#endif /* __TREE_H__ */