Use different .so names in a debug context
Bug: 37670543
Bug: 36006390
Bug: 37679566
Bug: 37636434
In debug context, a script is forced to be recompiled every time it
is initialized.
To avoid the same .so file being written to by another thread,
while it is being loaded and used by one thread, do not save the .so
file. Delete it right after loading it.
Test: RefocusTest and RSTest (including ScriptGroup2 tests) with
debug.rs.debug set to 1 and CTS on Angler
Change-Id: If63e3d21e3d9abd007a66e0ec79c9e6f1c9f13a0
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 545e92f..dec9ab2 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -57,24 +57,6 @@
#ifndef RS_COMPATIBILITY_LIB
-static bool is_force_recompile() {
- char buf[PROP_VALUE_MAX];
-
- // Re-compile if floating point precision has been overridden.
- android::renderscript::property_get("debug.rs.precision", buf, "");
- if (buf[0] != '\0') {
- return true;
- }
-
- // Re-compile if debug.rs.forcerecompile is set.
- android::renderscript::property_get("debug.rs.forcerecompile", buf, "0");
- if ((::strcmp(buf, "1") == 0) || (::strcmp(buf, "true") == 0)) {
- return true;
- } else {
- return false;
- }
-}
-
static void setCompileArguments(std::vector<const char*>* args,
const std::string& bcFileName,
const char* cacheDir, const char* resName,
@@ -381,7 +363,8 @@
compileArguments.push_back(checksumStr.c_str());
compileArguments.push_back(nullptr);
- if (!is_force_recompile() && !useRSDebugContext) {
+ const bool reuse = !is_force_recompile() && !useRSDebugContext;
+ if (reuse) {
mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
// Read RS info from the shared object to detect checksum mismatch
@@ -391,8 +374,8 @@
}
}
- // If we can't, it's either not there or out of date. We compile the bit code and try loading
- // again.
+ // If reuse is desired and we can't, it's either not there or out of date.
+ // We compile the bit code and try loading again.
if (mScriptSO == nullptr) {
if (!compileBitcode(bcFileName, (const char*)bitcode, bitcodeSize,
compileArguments))
@@ -402,14 +385,21 @@
return false;
}
- if (!SharedLibraryUtils::createSharedLibrary(mCtx->getContext()->getDriverName(),
- cacheDir, resName)) {
+ std::string SOPath;
+
+ if (!SharedLibraryUtils::createSharedLibrary(
+ mCtx->getContext()->getDriverName(), cacheDir, resName, reuse,
+ &SOPath)) {
ALOGE("Linker: Failed to link object file '%s'", resName);
mCtx->unlockMutex();
return false;
}
- mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
+ if (reuse) {
+ mScriptSO = SharedLibraryUtils::loadSharedLibrary(cacheDir, resName);
+ } else {
+ mScriptSO = SharedLibraryUtils::loadAndDeleteSharedLibrary(SOPath.c_str());
+ }
if (mScriptSO == nullptr) {
ALOGE("Unable to load '%s'", resName);
mCtx->unlockMutex();