Don't have the string “debug.bcc.nocache” scattered in Script.cpp.

bccPrepareSharedObject() will also use isCacheable() function to set up the
cache.

Change-Id: I3d6a09348398beb0987bd747ad5ed13b6fb1ddb0
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index 128aa48..04bed87 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -251,18 +251,8 @@
 
 #if USE_CACHE
 int Script::internalLoadCache(bool checkOnly) {
-  if (getBooleanProp("debug.bcc.nocache")) {
-    // Android system environment property disable the cache mechanism by
-    // setting "debug.bcc.nocache".  So we will not load the cache file any
-    // way.
+  if (!isCacheable())
     return 1;
-  }
-
-  if (mCacheDir.empty() || mCacheName.empty()) {
-    // The application developer has not specify the cachePath, so
-    // we don't know where to open the cache file.
-    return 1;
-  }
 
   std::string objPath = getCachedObjectPath();
   std::string infoPath = getCacheInfoPath();
@@ -389,13 +379,12 @@
   // Note: If the address of the context is not in the context slot, then
   // we don't have to cache it.
 
-  if (!mCacheDir.empty() &&
-      !mCacheName.empty() &&
+  if (
 #if USE_OLD_JIT
       !mIsContextSlotNotAvail &&
       ContextManager::get().isManagingContext(getContext()) &&
 #endif
-      !getBooleanProp("debug.bcc.nocache")) {
+      isCacheable()) {
 
     std::string objPath = getCachedObjectPath();
     std::string infoPath = getCacheInfoPath();
@@ -760,6 +749,27 @@
   return 0;
 }
 
+bool Script::isCacheable() const {
+#if USE_CACHE
+  if (getBooleanProp("debug.bcc.nocache")) {
+    // Android system environment property: Disables the cache mechanism by
+    // setting "debug.bcc.nocache".  So we will not load the cache file any
+    // way.
+    return false;
+  }
+
+  if (mCacheDir.empty() || mCacheName.empty()) {
+    // The application developer has not specified the cachePath, so
+    // we don't know where to open the cache file.
+    return false;
+  }
+
+  return true;
+#else
+  return false;
+#endif
+}
+
 #if USE_MCJIT
 size_t Script::getELFSize() const {
   switch (mStatus) {
diff --git a/lib/ExecutionEngine/Script.h b/lib/ExecutionEngine/Script.h
index 5a42db6..8f78683 100644
--- a/lib/ExecutionEngine/Script.h
+++ b/lib/ExecutionEngine/Script.h
@@ -204,6 +204,7 @@
     char *getContext();
 #endif
 
+    bool isCacheable() const;
 
     void setError(int error) {
       if (mErrorCode == BCC_NO_ERROR && error != BCC_NO_ERROR) {