Split JIT image from oBCC.
This change is the first step to merge CacheReader and
MCCacheReader (CacheWriter and MCCacheWriter.) In this
commit, we split the executable generated by OLD JIT
into a separated file with ".jit-image" as the file extension.
Change-Id: Icd40623e1247ffdfa93558b8e9fc4378a78b4ea1
diff --git a/lib/ExecutionEngine/Script.cpp b/lib/ExecutionEngine/Script.cpp
index ec52b60..ee18f47 100644
--- a/lib/ExecutionEngine/Script.cpp
+++ b/lib/ExecutionEngine/Script.cpp
@@ -222,7 +222,8 @@
}
#if USE_OLD_JIT
- std::string objPath(mCacheDir + mCacheName + ".oBCC");
+ std::string objPath(mCacheDir + mCacheName + ".jit-image");
+ std::string infoPath(mCacheDir + mCacheName + ".oBCC"); // TODO: .info instead
#elif USE_MCJIT
std::string objPath(mCacheDir + mCacheName + ".o");
std::string infoPath(mCacheDir + mCacheName + ".info");
@@ -230,17 +231,15 @@
FileHandle objFile;
if (objFile.open(objPath.c_str(), OpenMode::Read) < 0) {
- // Unable to open the cache file in read mode.
+ // Unable to open the executable file in read mode.
return 1;
}
-#if !USE_OLD_JIT && USE_MCJIT
FileHandle infoFile;
if (infoFile.open(infoPath.c_str(), OpenMode::Read) < 0) {
- // Unable to open the cache file in read mode.
+ // Unable to open the metadata information file in read mode.
return 1;
}
-#endif
#if USE_OLD_JIT
CacheReader reader;
@@ -265,12 +264,7 @@
}
// Read cache file
-#if USE_OLD_JIT
- ScriptCached *cached = reader.readCacheFile(&objFile, this);
-#elif USE_MCJIT
ScriptCached *cached = reader.readCacheFile(&objFile, &infoFile, this);
-#endif
-
if (!cached) {
mIsContextSlotNotAvail = reader.isContextSlotNotAvail();
@@ -356,12 +350,10 @@
#endif
!getBooleanProp("debug.bcc.nocache")) {
- FileHandle objFile;
-
#if USE_OLD_JIT
- std::string objPath(mCacheDir + mCacheName + ".oBCC");
+ std::string objPath(mCacheDir + mCacheName + ".jit-image");
+ std::string infoPath(mCacheDir + mCacheName + ".oBCC");
#elif USE_MCJIT
- FileHandle infoFile;
std::string objPath(mCacheDir + mCacheName + ".o");
std::string infoPath(mCacheDir + mCacheName + ".info");
#endif
@@ -376,11 +368,11 @@
::unlink(infoPath.c_str());
#endif
- if (objFile.open(objPath.c_str(), OpenMode::Write) >= 0
-#if !USE_OLD_JIT && USE_MCJIT
- && infoFile.open(infoPath.c_str(), OpenMode::Write) >= 0
-#endif
- ) {
+ FileHandle objFile;
+ FileHandle infoFile;
+
+ if (objFile.open(objPath.c_str(), OpenMode::Write) >= 0 &&
+ infoFile.open(infoPath.c_str(), OpenMode::Write) >= 0) {
#if USE_OLD_JIT
CacheWriter writer;
@@ -409,11 +401,7 @@
"__isThreadable");
}
-#if USE_OLD_JIT
- if (!writer.writeCacheFile(&objFile, this, libRS_threadable)) {
-#elif USE_MCJIT
if (!writer.writeCacheFile(&objFile, &infoFile, this, libRS_threadable)) {
-#endif
objFile.truncate();
objFile.close();
@@ -422,7 +410,6 @@
objPath.c_str(), strerror(errno));
}
-#if !USE_OLD_JIT && USE_MCJIT
infoFile.truncate();
infoFile.close();
@@ -430,7 +417,6 @@
LOGE("Unable to remove the invalid cache file: %s. (reason: %s)\n",
infoPath.c_str(), strerror(errno));
}
-#endif
}
}
}