Separate OLD_JIT code.

Either move Old JIT code into OldJIT directory or wrap them
with #if USE_OLD_JIT, so that we can remove Old JIT easily
in the future.

Change-Id: Id820cc2143ac4b7685460ba38258c664f4da495e
diff --git a/lib/CodeGen/CodeMemoryManager.cpp b/lib/CodeGen/CodeMemoryManager.cpp
index c5271e6..9ecc1c3 100644
--- a/lib/CodeGen/CodeMemoryManager.cpp
+++ b/lib/CodeGen/CodeMemoryManager.cpp
@@ -17,7 +17,7 @@
 #include <cutils/log.h>
 
 #include "CodeMemoryManager.h"
-#include "ExecutionEngine/ContextManager.h"
+#include "ExecutionEngine/OldJIT/ContextManager.h"
 
 #include "llvm/Support/ErrorHandling.h"
 
diff --git a/lib/ExecutionEngine/Android.mk b/lib/ExecutionEngine/Android.mk
index b72e22b..e849827 100644
--- a/lib/ExecutionEngine/Android.mk
+++ b/lib/ExecutionEngine/Android.mk
@@ -24,7 +24,6 @@
 
 libbcc_executionengine_SRC_FILES := \
   Compiler.cpp \
-  ContextManager.cpp \
   FileHandle.cpp \
   Runtime.c \
   RuntimeStub.c \
@@ -32,16 +31,29 @@
   ScriptCompiled.cpp \
   SourceInfo.cpp
 
-ifeq ($(libbcc_USE_CACHE),1)
+ifeq ($(libbcc_USE_OLD_JIT),1)
 libbcc_executionengine_SRC_FILES += \
-  CacheReader.cpp \
-  CacheWriter.cpp \
-  ScriptCached.cpp \
-  Sha1Helper.cpp \
+  OldJIT/ContextManager.cpp
+endif
+
+ifeq ($(libbcc_USE_CACHE),1)
+ifeq ($(libbcc_USE_OLD_JIT),1)
+libbcc_executionengine_SRC_FILES += \
+  OldJIT/CacheReader.cpp \
+  OldJIT/CacheWriter.cpp
+endif
+
+ifeq ($(libbcc_USE_MCJIT),1)
+libbcc_executionengine_SRC_FILES += \
   MCCacheWriter.cpp \
   MCCacheReader.cpp
 endif
 
+libbcc_executionengine_SRC_FILES += \
+  ScriptCached.cpp \
+  Sha1Helper.cpp
+endif
+
 
 #=====================================================================
 # Device Static Library: libbccExecutionEngine
diff --git a/lib/ExecutionEngine/Compiler.cpp b/lib/ExecutionEngine/Compiler.cpp
index 98a35b3..5b03144 100644
--- a/lib/ExecutionEngine/Compiler.cpp
+++ b/lib/ExecutionEngine/Compiler.cpp
@@ -18,7 +18,10 @@
 
 #include "Config.h"
 
-#include "ContextManager.h"
+#if USE_OLD_JIT
+#include "OldJIT/ContextManager.h"
+#endif
+
 #include "DebugHelper.h"
 #include "FileHandle.h"
 #include "Runtime.h"
diff --git a/lib/ExecutionEngine/MCCacheReader.cpp b/lib/ExecutionEngine/MCCacheReader.cpp
index 0a97abb..82b7cdc 100644
--- a/lib/ExecutionEngine/MCCacheReader.cpp
+++ b/lib/ExecutionEngine/MCCacheReader.cpp
@@ -16,7 +16,6 @@
 
 #include "MCCacheReader.h"
 
-#include "ContextManager.h"
 #include "DebugHelper.h"
 #include "FileHandle.h"
 #include "ScriptCached.h"
diff --git a/lib/ExecutionEngine/MCCacheWriter.cpp b/lib/ExecutionEngine/MCCacheWriter.cpp
index ef98e79..ea45551 100644
--- a/lib/ExecutionEngine/MCCacheWriter.cpp
+++ b/lib/ExecutionEngine/MCCacheWriter.cpp
@@ -16,7 +16,6 @@
 
 #include "MCCacheWriter.h"
 
-#include "ContextManager.h"
 #include "DebugHelper.h"
 #include "FileHandle.h"
 #include "Script.h"
diff --git a/lib/ExecutionEngine/CacheReader.cpp b/lib/ExecutionEngine/OldJIT/CacheReader.cpp
similarity index 100%
rename from lib/ExecutionEngine/CacheReader.cpp
rename to lib/ExecutionEngine/OldJIT/CacheReader.cpp
diff --git a/lib/ExecutionEngine/CacheReader.h b/lib/ExecutionEngine/OldJIT/CacheReader.h
similarity index 100%
rename from lib/ExecutionEngine/CacheReader.h
rename to lib/ExecutionEngine/OldJIT/CacheReader.h
diff --git a/lib/ExecutionEngine/CacheWriter.cpp b/lib/ExecutionEngine/OldJIT/CacheWriter.cpp
similarity index 100%
rename from lib/ExecutionEngine/CacheWriter.cpp
rename to lib/ExecutionEngine/OldJIT/CacheWriter.cpp
diff --git a/lib/ExecutionEngine/CacheWriter.h b/lib/ExecutionEngine/OldJIT/CacheWriter.h
similarity index 100%
rename from lib/ExecutionEngine/CacheWriter.h
rename to lib/ExecutionEngine/OldJIT/CacheWriter.h
diff --git a/lib/ExecutionEngine/ContextManager.cpp b/lib/ExecutionEngine/OldJIT/ContextManager.cpp
similarity index 100%
rename from lib/ExecutionEngine/ContextManager.cpp
rename to lib/ExecutionEngine/OldJIT/ContextManager.cpp
diff --git a/lib/ExecutionEngine/ContextManager.h b/lib/ExecutionEngine/OldJIT/ContextManager.h
similarity index 100%
rename from lib/ExecutionEngine/ContextManager.h
rename to lib/ExecutionEngine/OldJIT/ContextManager.h
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index ee18f47..26929fd 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -18,11 +18,18 @@
 
 #include "Config.h"
 
-#include "CacheReader.h"
-#include "CacheWriter.h"
+#if USE_OLD_JIT
+#include "OldJIT/CacheReader.h"
+#include "OldJIT/CacheWriter.h"
+#endif
+
 #include "MCCacheReader.h"
 #include "MCCacheWriter.h"
-#include "ContextManager.h"
+
+#if USE_OLD_JIT
+#include "OldJIT/ContextManager.h"
+#endif
+
 #include "DebugHelper.h"
 #include "FileHandle.h"
 #include "ScriptCompiled.h"
@@ -684,6 +691,7 @@
 }
 
 
+#if USE_OLD_JIT
 char *Script::getContext() {
   switch (mStatus) {
 
@@ -703,6 +711,7 @@
     }
   }
 }
+#endif
 
 
 int Script::registerSymbolCallback(BCCSymbolLookupFn pFn, void *pContext) {
diff --git a/lib/ExecutionEngine/Script.h b/lib/ExecutionEngine/Script.h
index 4f99581..921af8c 100644
--- a/lib/ExecutionEngine/Script.h
+++ b/lib/ExecutionEngine/Script.h
@@ -140,7 +140,9 @@
 
     int registerSymbolCallback(BCCSymbolLookupFn pFn, void *pContext);
 
+#if USE_OLD_JIT
     char *getContext();
+#endif
 
 
     void setError(int error) {
diff --git a/lib/ExecutionEngine/ScriptCached.cpp b/lib/ExecutionEngine/ScriptCached.cpp
index 7c3ad1f..a7d21f7 100644
--- a/lib/ExecutionEngine/ScriptCached.cpp
+++ b/lib/ExecutionEngine/ScriptCached.cpp
@@ -20,7 +20,10 @@
 
 #include <bcc/bcc_cache.h>
 
-#include "ContextManager.h"
+#if USE_OLD_JIT
+#include "OldJIT/ContextManager.h"
+#endif
+
 #include "DebugHelper.h"
 
 #include <stdlib.h>
@@ -29,9 +32,11 @@
 
 ScriptCached::~ScriptCached() {
   // Deallocate the bcc script context
+#if USE_OLD_JIT
   if (mContext) {
     ContextManager::get().deallocateContext(mContext);
   }
+#endif
 
   // Deallocate string pool, exported var list, exported func list
   if (mpStringPoolRaw) { free(mpStringPoolRaw); }
diff --git a/lib/ExecutionEngine/ScriptCached.h b/lib/ExecutionEngine/ScriptCached.h
index 39cf663..a627e5c 100644
--- a/lib/ExecutionEngine/ScriptCached.h
+++ b/lib/ExecutionEngine/ScriptCached.h
@@ -66,7 +66,9 @@
 
     FuncTable mFunctions;
 
+#if USE_OLD_JIT
     char *mContext;
+#endif
 
 #if USE_MCJIT
     RSExecRef mRSExecutable;
@@ -79,8 +81,14 @@
 
   public:
     ScriptCached(Script *owner)
-      : mpOwner(owner), mpExportVars(NULL), mpExportFuncs(NULL),
-        mpObjectSlotList(NULL), mContext(NULL), mpStringPoolRaw(NULL),
+      : mpOwner(owner),
+        mpExportVars(NULL),
+        mpExportFuncs(NULL),
+        mpObjectSlotList(NULL),
+#if USE_OLD_JIT
+        mContext(NULL),
+#endif
+        mpStringPoolRaw(NULL),
         mLibRSThreadable(false) {
     }
 
@@ -122,9 +130,11 @@
     void getObjectSlotList(size_t objectSlotListSize,
                            uint32_t *objectSlotList);
 
+#if USE_OLD_JIT
     char *getContext() {
       return mContext;
     }
+#endif
 
     // Dirty hack for libRS.
     // TODO(all): This should be removed in the future.
diff --git a/lib/ExecutionEngine/ScriptCompiled.cpp b/lib/ExecutionEngine/ScriptCompiled.cpp
index f5ea2e0..bb3c79a 100644
--- a/lib/ExecutionEngine/ScriptCompiled.cpp
+++ b/lib/ExecutionEngine/ScriptCompiled.cpp
@@ -17,12 +17,15 @@
 #include "ScriptCompiled.h"
 
 #include "bcc_internal.h"
-#include "ContextManager.h"
+#if USE_OLD_JIT
+#include "OldJIT/ContextManager.h"
+#endif
 #include "DebugHelper.h"
 
 namespace bcc {
 
 ScriptCompiled::~ScriptCompiled() {
+#if USE_OLD_JIT
   // Deallocate the BCC context
   if (mContext) {
     ContextManager::get().deallocateContext(mContext);
@@ -35,6 +38,7 @@
       delete I->second;
     }
   }
+#endif
 }
 
 void ScriptCompiled::getExportVarList(size_t varListSize, void **varList) {
diff --git a/lib/ExecutionEngine/ScriptCompiled.h b/lib/ExecutionEngine/ScriptCompiled.h
index 3800645..9593be8 100644
--- a/lib/ExecutionEngine/ScriptCompiled.h
+++ b/lib/ExecutionEngine/ScriptCompiled.h
@@ -61,11 +61,17 @@
 
     FuncInfoMap mEmittedFunctions;
 
+#if USE_OLD_JIT
     char *mContext; // Context of BCC script (code and data)
+#endif
 
   public:
     ScriptCompiled(Script *owner)
-      : mpOwner(owner), mCompiler(this), mContext(NULL) {
+      : mpOwner(owner), mCompiler(this)
+#if USE_OLD_JIT
+        , mContext(NULL)
+#endif
+    {
     }
 
     ~ScriptCompiled();
@@ -131,9 +137,12 @@
     void getObjectSlotList(size_t objectSlotListSize,
                            uint32_t *objectSlotList);
 
+#if USE_OLD_JIT
     char *getContext() {
       return mContext;
     }
+#endif
+
 #if USE_MCJIT
     const char *getELF() const {
       return &*mCompiler.getELF().begin();
diff --git a/lib/ExecutionEngine/SourceInfo.cpp b/lib/ExecutionEngine/SourceInfo.cpp
index 40b2fd9..32992d8 100644
--- a/lib/ExecutionEngine/SourceInfo.cpp
+++ b/lib/ExecutionEngine/SourceInfo.cpp
@@ -17,11 +17,15 @@
 #include "SourceInfo.h"
 
 #if USE_CACHE
-#include "CacheReader.h"
-#include "CacheWriter.h"
+#if USE_OLD_JIT
+#include "OldJIT/CacheReader.h"
+#include "OldJIT/CacheWriter.h"
+#endif
+#if USE_MCJIT
 #include "MCCacheWriter.h"
 #include "MCCacheReader.h"
 #endif
+#endif
 
 #include "DebugHelper.h"
 #include "ScriptCompiled.h"
@@ -188,10 +192,15 @@
   }
 }
 
+#if USE_OLD_JIT
 template void SourceInfo::introDependency<CacheReader>(CacheReader &);
 template void SourceInfo::introDependency<CacheWriter>(CacheWriter &);
+#endif
+
+#if USE_MCJIT
 template void SourceInfo::introDependency<MCCacheWriter>(MCCacheWriter &);
 template void SourceInfo::introDependency<MCCacheReader>(MCCacheReader &);
+#endif
 #endif // USE_CACHE