Abstract the Routine class.

Bug swiftshader:10

Change-Id: I29b1de8c1adb67449a380c307d12e2aea21f32cc
Reviewed-on: https://swiftshader-review.googlesource.com/7251
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Reactor/Routine.cpp b/src/Reactor/Routine.cpp
index 340b21d..df82ab8 100644
--- a/src/Reactor/Routine.cpp
+++ b/src/Reactor/Routine.cpp
@@ -14,74 +14,17 @@
 
 #include "Routine.hpp"
 
-#include "../Common/Memory.hpp"
 #include "../Common/Thread.hpp"
-#include "../Common/Types.hpp"
+
+#include <cassert>
 
 namespace sw
 {
-	Routine::Routine(int bufferSize) : bufferSize(bufferSize), dynamic(true)
+	Routine::Routine()
 	{
-		void *memory = allocateExecutable(bufferSize);
-
-		buffer = memory;
-		entry = memory;
-		functionSize = bufferSize;   // Updated by RoutineManager::endFunctionBody
-
 		bindCount = 0;
 	}
 
-	Routine::Routine(void *memory, int bufferSize, int offset) : bufferSize(bufferSize), functionSize(bufferSize), dynamic(false)
-	{
-		buffer = (unsigned char*)memory - offset;
-		entry = memory;
-
-		bindCount = 0;
-	}
-
-	Routine::~Routine()
-	{
-		if(dynamic)
-		{
-			deallocateExecutable(buffer, bufferSize);
-		}
-	}
-
-	void Routine::setFunctionSize(int functionSize)
-	{
-		this->functionSize = functionSize;
-	}
-
-	const void *Routine::getBuffer()
-	{
-		return buffer;
-	}
-
-	const void *Routine::getEntry()
-	{
-		return entry;
-	}
-
-	int Routine::getBufferSize()
-	{
-		return bufferSize;
-	}
-
-	int Routine::getFunctionSize()
-	{
-		return functionSize;
-	}
-
-	int Routine::getCodeSize()
-	{
-		return functionSize - static_cast<int>((uintptr_t)entry - (uintptr_t)buffer);
-	}
-
-	bool Routine::isDynamic()
-	{
-		return dynamic;
-	}
-
 	void Routine::bind()
 	{
 		atomicIncrement(&bindCount);
@@ -96,4 +39,9 @@
 			delete this;
 		}
 	}
+
+	Routine::~Routine()
+	{
+		assert(bindCount == 0);
+	}
 }