Change cache dependency tracking.
Remove the fix dependencies and make it depend only on the source
hash. More changes coming soon to add dependencies on the Android
build fingerprint and the command line used to compile.
Change-Id: I8964044affccf52326ce286f879307eca79d0b24
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 0f845bd..5adc362 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -70,8 +70,7 @@
return NULL;
}
- RSInfo::DependencyTableTy dep_info;
- uint8_t bitcode_sha1[20];
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
Sha1Util::GetSHA1DigestFromBuffer(bitcode_sha1, pBitcode, pBitcodeSize);
// {pCacheDir}/{pResName}.o
@@ -79,8 +78,6 @@
llvm::sys::path::append(output_path, pResName);
llvm::sys::path::replace_extension(output_path, ".o");
- dep_info.push(std::make_pair(output_path.c_str(), bitcode_sha1));
-
//===--------------------------------------------------------------------===//
// Acquire the read lock for reading the Script object file.
//===--------------------------------------------------------------------===//
@@ -121,7 +118,7 @@
// Open and load the RS info file.
//===--------------------------------------------------------------------===//
InputFile info_file(info_path.string());
- RSInfo *info = RSInfo::ReadFromFile(info_file, dep_info);
+ RSInfo *info = RSInfo::ReadFromFile(info_file);
// Release the lock on object_file.
object_file->unlock();
@@ -131,6 +128,15 @@
return NULL;
}
+ // If the info file contains a different hash for the source than what we are
+ // looking for, bail. The bit code found on disk is out of date and needs to
+ // be recompiled first.
+ if (!info->CheckDependency(output_path.c_str(), bitcode_sha1)) {
+ delete object_file;
+ delete info;
+ return NULL;
+ }
+
//===--------------------------------------------------------------------===//
// Create the RSExecutable.
//===--------------------------------------------------------------------===//
@@ -194,7 +200,7 @@
const char* pScriptName,
const char *pOutputPath,
const char *pRuntimePath,
- const RSInfo::DependencyTableTy &pDeps,
+ const RSInfo::DependencyHashTy &pSourceHash,
bool pSkipLoad, bool pDumpIR) {
//android::StopWatch compile_time("bcc: RSCompilerDriver::compileScript time");
RSInfo *info = NULL;
@@ -204,7 +210,7 @@
//===--------------------------------------------------------------------===//
// RS info may contains configuration (such as #optimization_level) to the
// compiler therefore it should be extracted before compilation.
- info = RSInfo::ExtractFromSource(pScript.getSource(), pDeps);
+ info = RSInfo::ExtractFromSource(pScript.getSource(), pSourceHash);
if (info == NULL) {
return Compiler::kErrInvalidSource;
}
@@ -354,8 +360,7 @@
//===--------------------------------------------------------------------===//
// Prepare dependency information.
//===--------------------------------------------------------------------===//
- RSInfo::DependencyTableTy dep_info;
- uint8_t bitcode_sha1[20];
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
Sha1Util::GetSHA1DigestFromBuffer(bitcode_sha1, pBitcode, pBitcodeSize);
//===--------------------------------------------------------------------===//
@@ -366,8 +371,6 @@
llvm::sys::path::append(output_path, pResName);
llvm::sys::path::replace_extension(output_path, ".o");
- dep_info.push(std::make_pair(output_path.c_str(), bitcode_sha1));
-
//===--------------------------------------------------------------------===//
// Load the bitcode and create script.
//===--------------------------------------------------------------------===//
@@ -401,7 +404,7 @@
//===--------------------------------------------------------------------===//
Compiler::ErrorCode status = compileScript(*script, pResName,
output_path.c_str(),
- pRuntimePath, dep_info, false,
+ pRuntimePath, bitcode_sha1, false,
pDumpIR);
// Script is no longer used. Free it to get more memory.
@@ -415,10 +418,10 @@
}
-bool RSCompilerDriver::build(RSScript &pScript, const char *pOut,
- const char *pRuntimePath) {
- RSInfo::DependencyTableTy dep_info;
- RSInfo *info = RSInfo::ExtractFromSource(pScript.getSource(), dep_info);
+bool RSCompilerDriver::buildForCompatLib(RSScript &pScript, const char *pOut,
+ const char *pRuntimePath) {
+ uint8_t bitcode_sha1[SHA1_DIGEST_LENGTH];
+ RSInfo *info = RSInfo::ExtractFromSource(pScript.getSource(), bitcode_sha1);
if (info == NULL) {
return false;
}
@@ -429,7 +432,7 @@
pScript.setEmbedInfo(true);
Compiler::ErrorCode status = compileScript(pScript, pOut, pOut, pRuntimePath,
- dep_info, true);
+ bitcode_sha1, true);
if (status != Compiler::kSuccess) {
return false;
}
diff --git a/lib/Renderscript/RSInfo.cpp b/lib/Renderscript/RSInfo.cpp
index 5937fe4..e8793e7 100644
--- a/lib/Renderscript/RSInfo.cpp
+++ b/lib/Renderscript/RSInfo.cpp
@@ -34,199 +34,35 @@
using namespace bcc;
-#ifdef __LP64__
-#define SYSLIBPATH "/system/lib64"
-#else
-#define SYSLIBPATH "/system/lib"
-#endif
-
-const char RSInfo::LibBCCPath[] = SYSLIBPATH"/libbcc.so";
-const char RSInfo::LibCompilerRTPath[] = SYSLIBPATH"/libcompiler_rt.so";
-const char RSInfo::LibRSPath[] = SYSLIBPATH"/libRS.so";
-const char RSInfo::LibCLCorePath[] = SYSLIBPATH"/libclcore.bc";
-const char RSInfo::LibCLCoreDebugPath[] = SYSLIBPATH"/libclcore_debug.bc";
-#if defined(__i386__) || defined(__x86_64__)
-const char RSInfo::LibCLCoreX86Path[] = SYSLIBPATH"/libclcore_x86.bc";
-#endif
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
-const char RSInfo::LibCLCoreNEONPath[] = SYSLIBPATH"/libclcore_neon.bc";
-#endif
-
-const uint8_t *RSInfo::LibBCCSHA1 = NULL;
-const uint8_t *RSInfo::LibCompilerRTSHA1 = NULL;
-const uint8_t *RSInfo::LibRSSHA1 = NULL;
-const uint8_t *RSInfo::LibCLCoreSHA1 = NULL;
-const uint8_t *RSInfo::LibCLCoreDebugSHA1 = NULL;
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
-const uint8_t *RSInfo::LibCLCoreNEONSHA1 = NULL;
-#endif
-
-bool RSInfo::LoadBuiltInSHA1Information() {
-#ifdef TARGET_BUILD
- if (LibBCCSHA1 != NULL) {
- // Loaded before.
- return true;
- }
-
- void *h = ::dlopen(SYSLIBPATH"/libbcc.sha1.so", RTLD_LAZY | RTLD_NOW);
- if (h == NULL) {
- ALOGE("Failed to load SHA-1 information from shared library '"
- "/system/lib64/libbcc.sha1.so'! (%s)", ::dlerror());
- return false;
- }
-
- LibBCCSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libbcc_so_SHA1"));
- LibCompilerRTSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libcompiler_rt_so_SHA1"));
- LibRSSHA1 = reinterpret_cast<const uint8_t *>(::dlsym(h, "libRS_so_SHA1"));
- LibCLCoreSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_bc_SHA1"));
- LibCLCoreDebugSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_debug_bc_SHA1"));
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- LibCLCoreNEONSHA1 =
- reinterpret_cast<const uint8_t *>(::dlsym(h, "libclcore_neon_bc_SHA1"));
-#endif
-
- return true;
-#else // TARGET_BUILD
- return false;
-#endif // TARGET_BUILD
-}
-
android::String8 RSInfo::GetPath(const char *pFilename) {
android::String8 result(pFilename);
result.append(".info");
return result;
}
-#define PRINT_DEPENDENCY(PREFIX, N, X) \
- ALOGV("\t" PREFIX "Source name: %s, " \
- "SHA-1: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" \
+#define PRINT_DEPENDENCY(PREFIX, X) \
+ ALOGV("\t" PREFIX "SHA-1: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" \
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", \
- (N), (X)[ 0], (X)[ 1], (X)[ 2], (X)[ 3], (X)[ 4], (X)[ 5], \
+ (X)[ 0], (X)[ 1], (X)[ 2], (X)[ 3], (X)[ 4], (X)[ 5], \
(X)[ 6], (X)[ 7], (X)[ 8], (X)[ 9], (X)[10], (X)[11], \
(X)[12], (X)[13], (X)[14], (X)[15], (X)[16], (X)[17], \
(X)[18], (X)[19]);
-bool RSInfo::CheckDependency(const RSInfo &pInfo,
- const char *pInputFilename,
- const DependencyTableTy &pDeps) {
- // Built-in dependencies are libbcc.so, libRS.so and libclcore.bc plus
- // libclcore_neon.bc if NEON is available on the target device.
-#if !defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- static const unsigned NumBuiltInDependencies = 5;
-#else
- static const unsigned NumBuiltInDependencies = 6;
-#endif
-
- LoadBuiltInSHA1Information();
-
- if (pInfo.mDependencyTable.size() != (pDeps.size() + NumBuiltInDependencies)) {
- ALOGD("Number of dependencies recorded mismatch (%lu v.s. %lu) in %s!",
- static_cast<unsigned long>(pInfo.mDependencyTable.size()),
- static_cast<unsigned long>(pDeps.size() + NumBuiltInDependencies), pInputFilename);
- return false;
- } else {
- // Built-in dependencies always go first.
- const std::pair<const char *, const uint8_t *> &cache_libbcc_dep =
- pInfo.mDependencyTable[0];
- const std::pair<const char *, const uint8_t *> &cache_libcompiler_rt_dep =
- pInfo.mDependencyTable[1];
- const std::pair<const char *, const uint8_t *> &cache_libRS_dep =
- pInfo.mDependencyTable[2];
- const std::pair<const char *, const uint8_t *> &cache_libclcore_dep =
- pInfo.mDependencyTable[3];
- const std::pair<const char *, const uint8_t *> &cache_libclcore_debug_dep =
- pInfo.mDependencyTable[4];
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- const std::pair<const char *, const uint8_t *> &cache_libclcore_neon_dep =
- pInfo.mDependencyTable[5];
-#endif
-
- // Check libbcc.so.
- if (::memcmp(cache_libbcc_dep.second, LibBCCSHA1, SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibBCCPath);
- PRINT_DEPENDENCY("current - ", LibBCCPath, LibBCCSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libbcc_dep.first,
- cache_libbcc_dep.second);
+bool RSInfo::CheckDependency(const char* pInputFilename,
+ const DependencyHashTy& pExpectedSourceHash) {
+ if (::memcmp(mSourceHash, pExpectedSourceHash, SHA1_DIGEST_LENGTH) != 0) {
+ ALOGD("Cache %s is dirty due to the source it depends on has been changed:",
+ pInputFilename);
+ PRINT_DEPENDENCY("given - ", pExpectedSourceHash);
+ PRINT_DEPENDENCY("cache - ", mSourceHash);
return false;
}
+ // TODO Remove once done with cache fixes.
+ // ALOGD("Cache %s is not dirty, the source it depends on has not changed:", pInputFilename);
+ // PRINT_DEPENDENCY("given - ", pExpectedSourceHash);
+ // PRINT_DEPENDENCY("cache - ", mSourceHash);
- // Check libcompiler_rt.so.
- if (::memcmp(cache_libcompiler_rt_dep.second, LibCompilerRTSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCompilerRTPath);
- PRINT_DEPENDENCY("current - ", LibCompilerRTPath, LibCompilerRTSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libcompiler_rt_dep.first,
- cache_libcompiler_rt_dep.second);
- return false;
- }
-
- // Check libRS.so.
- if (::memcmp(cache_libRS_dep.second, LibRSSHA1, SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibRSPath);
- PRINT_DEPENDENCY("current - ", LibRSPath, LibRSSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libRS_dep.first,
- cache_libRS_dep.second);
- return false;
- }
-
- // Check libclcore.bc.
- if (::memcmp(cache_libclcore_dep.second, LibCLCoreSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCLCorePath);
- PRINT_DEPENDENCY("current - ", LibCLCorePath, LibCLCoreSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_dep.first,
- cache_libclcore_dep.second);
- return false;
- }
-
- // Check libclcore_debug.bc.
- if (::memcmp(cache_libclcore_debug_dep.second, LibCLCoreDebugSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCLCoreDebugPath);
- PRINT_DEPENDENCY("current - ", LibCLCoreDebugPath, LibCLCoreDebugSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_debug_dep.first,
- cache_libclcore_debug_dep.second);
- return false;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- // Check libclcore_neon.bc if NEON is available.
- if (::memcmp(cache_libclcore_neon_dep.second, LibCLCoreNEONSHA1,
- SHA1_DIGEST_LENGTH) != 0) {
- ALOGD("Cache %s is dirty due to %s has been updated.", pInputFilename,
- LibCLCoreNEONPath);
- PRINT_DEPENDENCY("current - ", LibCLCoreNEONPath, LibCLCoreNEONSHA1);
- PRINT_DEPENDENCY("cache - ", cache_libclcore_neon_dep.first,
- cache_libclcore_neon_dep.second);
- return false;
- }
-#endif
-
- for (unsigned i = 0; i < pDeps.size(); i++) {
- const std::pair<const char *, const uint8_t *> &cache_dep =
- pInfo.mDependencyTable[i + NumBuiltInDependencies];
-
- if ((::strcmp(pDeps[i].first, cache_dep.first) != 0) ||
- (::memcmp(pDeps[i].second, cache_dep.second,
- SHA1_DIGEST_LENGTH) != 0)) {
- ALOGD("Cache %s is dirty due to the source it dependends on has been "
- "changed:", pInputFilename);
- PRINT_DEPENDENCY("given - ", pDeps[i].first, pDeps[i].second);
- PRINT_DEPENDENCY("cache - ", cache_dep.first, cache_dep.second);
- return false;
- }
- }
- }
-
- return true;
+ return true;
}
RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(NULL) {
@@ -237,7 +73,6 @@
mHeader.headerSize = sizeof(mHeader);
- mHeader.dependencyTable.itemSize = sizeof(rsinfo::DependencyTableItem);
mHeader.pragmaList.itemSize = sizeof(rsinfo::PragmaItem);
mHeader.objectSlotList.itemSize = sizeof(rsinfo::ObjectSlotItem);
mHeader.exportVarNameList.itemSize = sizeof(rsinfo::ExportVarNameItem);
@@ -253,6 +88,7 @@
}
::memset(mStringPool, 0, mHeader.strPoolSize);
}
+ mSourceHash = NULL;
}
RSInfo::~RSInfo() {
@@ -260,15 +96,12 @@
}
bool RSInfo::layout(off_t initial_offset) {
- mHeader.dependencyTable.offset = initial_offset +
- mHeader.headerSize +
- mHeader.strPoolSize;
- mHeader.dependencyTable.count = mDependencyTable.size();
-
-#define AFTER(_list) ((_list).offset + (_list).itemSize * (_list).count)
- mHeader.pragmaList.offset = AFTER(mHeader.dependencyTable);
+ mHeader.pragmaList.offset = initial_offset +
+ mHeader.headerSize +
+ mHeader.strPoolSize;
mHeader.pragmaList.count = mPragmas.size();
+#define AFTER(_list) ((_list).offset + (_list).itemSize * (_list).count)
mHeader.objectSlotList.offset = AFTER(mHeader.pragmaList);
mHeader.objectSlotList.count = mObjectSlots.size();
@@ -295,17 +128,18 @@
ALOGV("\tHeader size: %u", mHeader.headerSize);
ALOGV("\tString pool size: %u", mHeader.strPoolSize);
+ if (mSourceHash == NULL) {
+ ALOGE("Source hash: NULL!");
+ } else {
+ PRINT_DEPENDENCY("Source hash: ", mSourceHash);
+ }
+
#define DUMP_LIST_HEADER(_name, _header) do { \
ALOGV(_name ":"); \
ALOGV("\toffset: %u", (_header).offset); \
ALOGV("\t# of item: %u", (_header).count); \
ALOGV("\tsize of each item: %u", (_header).itemSize); \
} while (false)
- DUMP_LIST_HEADER("Dependency table", mHeader.dependencyTable);
- for (DependencyTableTy::const_iterator dep_iter = mDependencyTable.begin(),
- dep_end = mDependencyTable.end(); dep_iter != dep_end; dep_iter++) {
- PRINT_DEPENDENCY("", dep_iter->first, dep_iter->second);
- }
DUMP_LIST_HEADER("Pragma list", mHeader.pragmaList);
for (PragmaListTy::const_iterator pragma_iter = mPragmas.begin(),
diff --git a/lib/Renderscript/RSInfoExtractor.cpp b/lib/Renderscript/RSInfoExtractor.cpp
index 338243b..1684ed4 100644
--- a/lib/Renderscript/RSInfoExtractor.cpp
+++ b/lib/Renderscript/RSInfoExtractor.cpp
@@ -105,28 +105,10 @@
return pStringWriteStart;
}
-bool writeDependency(const std::string &pSourceName, const uint8_t *pSHA1,
- char *pStringPool, off_t *pWriteStart,
- RSInfo::DependencyTableTy &pDepTable) {
- const char *source_name = writeString(pSourceName, pStringPool, pWriteStart);
-
- uint8_t *sha1 = reinterpret_cast<uint8_t *>(pStringPool + *pWriteStart);
-
- // SHA-1 is special. It's size of SHA1_DIGEST_LENGTH (=20) bytes long without
- // null-terminator.
- ::memcpy(sha1, pSHA1, SHA1_DIGEST_LENGTH);
- // Record in the result RSInfo object.
- pDepTable.push(std::make_pair(source_name, sha1));
- // Update the string pool pointer.
- *pWriteStart += SHA1_DIGEST_LENGTH;
-
- return true;
-}
-
} // end anonymous namespace
RSInfo *RSInfo::ExtractFromSource(const Source &pSource,
- const DependencyTableTy &pDeps)
+ const DependencyHashTy &pSourceHashToEmbed)
{
const llvm::Module &module = pSource.getModule();
const char *module_name = module.getModuleIdentifier().c_str();
@@ -163,22 +145,8 @@
string_pool_size += getMetadataStringLength<1>(export_func);
string_pool_size += getMetadataStringLength<1>(export_foreach_name);
- // Don't forget to reserve the space for the dependency informationin string
- // pool.
- string_pool_size += ::strlen(LibBCCPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCompilerRTPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibRSPath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCLCorePath) + 1 + SHA1_DIGEST_LENGTH;
- string_pool_size += ::strlen(LibCLCoreDebugPath) + 1 + SHA1_DIGEST_LENGTH;
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- string_pool_size += ::strlen(LibCLCoreNEONPath) + 1 + SHA1_DIGEST_LENGTH;
-#endif
- for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
- // +1 for null-terminator
- string_pool_size += ::strlen(/* name */pDeps[i].first) + 1;
- // +SHA1_DIGEST_LENGTH for SHA-1 checksum
- string_pool_size += SHA1_DIGEST_LENGTH;
- }
+ // Reserve the space for the source hash.
+ string_pool_size += SHA1_DIGEST_LENGTH;
// Allocate result object
result = new (std::nothrow) RSInfo(string_pool_size);
@@ -362,58 +330,17 @@
}
#undef FOR_EACH_NODE_IN
- if (LoadBuiltInSHA1Information()) {
- //===------------------------------------------------------------------===//
- // Record built-in dependency information.
- //===------------------------------------------------------------------===//
- if (!writeDependency(LibBCCPath, LibBCCSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibCompilerRTPath, LibCompilerRTSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibRSPath, LibRSSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibCLCorePath, LibCLCoreSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
- if (!writeDependency(LibCLCoreDebugPath, LibCLCoreDebugSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- if (!writeDependency(LibCLCoreNEONPath, LibCLCoreNEONSHA1,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
-#endif
-
- //===------------------------------------------------------------------===//
- // Record dependency information.
- //===------------------------------------------------------------------===//
- for (unsigned i = 0, e = pDeps.size(); i != e; i++) {
- if (!writeDependency(/* name */pDeps[i].first, /* SHA-1 */pDeps[i].second,
- result->mStringPool, &cur_string_pool_offset,
- result->mDependencyTable)) {
- goto bail;
- }
- }
+ //===------------------------------------------------------------------===//
+ // Record dependency information.
+ //===------------------------------------------------------------------===//
+ {
+ // Store the SHA-1 in the string pool but without a null-terminator.
+ result->mHeader.sourceSha1Idx = cur_string_pool_offset;
+ uint8_t* sha1 = reinterpret_cast<uint8_t*>(result->mStringPool + cur_string_pool_offset);
+ ::memcpy(sha1, pSourceHashToEmbed, SHA1_DIGEST_LENGTH);
+ // Update the string pool pointer.
+ cur_string_pool_offset += SHA1_DIGEST_LENGTH;
+ result->mSourceHash = sha1;
}
//===--------------------------------------------------------------------===//
diff --git a/lib/Renderscript/RSInfoReader.cpp b/lib/Renderscript/RSInfoReader.cpp
index ccf9b73..bf66b66 100644
--- a/lib/Renderscript/RSInfoReader.cpp
+++ b/lib/Renderscript/RSInfoReader.cpp
@@ -36,33 +36,6 @@
const RSInfo &pInfo,
ItemContainer &pResult);
-// Process DependencyTableItem in the file
-template<> inline bool
-helper_read_list_item<rsinfo::DependencyTableItem, RSInfo::DependencyTableTy>(
- const rsinfo::DependencyTableItem &pItem,
- const RSInfo &pInfo,
- RSInfo::DependencyTableTy &pResult)
-{
- const char *id = pInfo.getStringFromPool(pItem.id);
- const uint8_t *sha1 =
- reinterpret_cast<const uint8_t *>(pInfo.getStringFromPool(pItem.sha1));
-
- if (id == NULL) {
- ALOGE("Invalid string index %d for source id in RS dependenct table.",
- pItem.id);
- return false;
- }
-
- if (sha1 == NULL) {
- ALOGE("Invalid string index %d for SHA-1 checksum in RS dependenct table.",
- pItem.id);
- return false;
- }
-
- pResult.push(std::make_pair(id, sha1));
- return true;
-}
-
// Process PragmaItem in the file
template<> inline bool
helper_read_list_item<rsinfo::PragmaItem, RSInfo::PragmaListTy>(
@@ -173,7 +146,7 @@
} // end anonymous namespace
-RSInfo *RSInfo::ReadFromFile(InputFile &pInput, const DependencyTableTy &pDeps) {
+RSInfo *RSInfo::ReadFromFile(InputFile &pInput) {
android::FileMap *map = NULL;
RSInfo *result = NULL;
const uint8_t *data;
@@ -228,7 +201,6 @@
// Check the size.
if ((header->headerSize != sizeof(rsinfo::Header)) ||
- (header->dependencyTable.itemSize != sizeof(rsinfo::DependencyTableItem)) ||
(header->pragmaList.itemSize != sizeof(rsinfo::PragmaItem)) ||
(header->objectSlotList.itemSize != sizeof(rsinfo::ObjectSlotItem)) ||
(header->exportVarNameList.itemSize != sizeof(rsinfo::ExportVarNameItem)) ||
@@ -242,7 +214,6 @@
#define LIST_DATA_RANGE(_list_header) \
((_list_header).offset + (_list_header).count * (_list_header).itemSize)
if (((header->headerSize + header->strPoolSize) > filesize) ||
- (LIST_DATA_RANGE(header->dependencyTable) > filesize) ||
(LIST_DATA_RANGE(header->pragmaList) > filesize) ||
(LIST_DATA_RANGE(header->objectSlotList) > filesize) ||
(LIST_DATA_RANGE(header->exportVarNameList) > filesize) ||
@@ -279,9 +250,11 @@
}
// Populate all the data to the result object.
- if (!helper_read_list<rsinfo::DependencyTableItem, DependencyTableTy>
- (data, *result, header->dependencyTable, result->mDependencyTable)) {
- goto bail;
+ result->mSourceHash =
+ reinterpret_cast<const uint8_t*>(result->getStringFromPool(header->sourceSha1Idx));
+ if (result->mSourceHash == NULL) {
+ ALOGE("Invalid string index %d for SHA-1 checksum of source.", header->sourceSha1Idx);
+ goto bail;
}
if (!helper_read_list<rsinfo::PragmaItem, PragmaListTy>
diff --git a/lib/Renderscript/RSInfoWriter.cpp b/lib/Renderscript/RSInfoWriter.cpp
index 0eee62c..f9e2e2f 100644
--- a/lib/Renderscript/RSInfoWriter.cpp
+++ b/lib/Renderscript/RSInfoWriter.cpp
@@ -31,29 +31,6 @@
helper_adapt_list_item(ItemType &pResult, const RSInfo &pInfo,
const typename ItemContainer::const_iterator &pItem);
-template<> inline bool
-helper_adapt_list_item<rsinfo::DependencyTableItem, RSInfo::DependencyTableTy>(
- rsinfo::DependencyTableItem &pResult,
- const RSInfo &pInfo,
- const RSInfo::DependencyTableTy::const_iterator &pItem) {
- pResult.id = pInfo.getStringIdxInPool(pItem->first);
- pResult.sha1 =
- pInfo.getStringIdxInPool(reinterpret_cast<const char *>(pItem->second));
-
- if (pResult.id == rsinfo::gInvalidStringIndex) {
- ALOGE("RS dependency table contains invalid source id string '%s'.",
- pItem->first);
- return false;
- }
-
- if (pResult.sha1 == rsinfo::gInvalidStringIndex) {
- ALOGE("RS dependency table contains invalid SHA-1 checksum string in '%s'.",
- pItem->first);
- return false;
- }
-
- return true;
-}
template<> inline bool
helper_adapt_list_item<rsinfo::PragmaItem, RSInfo::PragmaListTy>(
@@ -194,12 +171,6 @@
return false;
}
- // Write dependencyTable.
- if (!helper_write_list<rsinfo::DependencyTableItem, DependencyTableTy>
- (pOutput, *this, mHeader.dependencyTable, mDependencyTable)) {
- return false;
- }
-
// Write pragmaList.
if (!helper_write_list<rsinfo::PragmaItem, PragmaListTy>
(pOutput, *this, mHeader.pragmaList, mPragmas)) {
diff --git a/lib/Renderscript/RSScript.cpp b/lib/Renderscript/RSScript.cpp
index b7335ab..884de22 100644
--- a/lib/Renderscript/RSScript.cpp
+++ b/lib/Renderscript/RSScript.cpp
@@ -16,35 +16,18 @@
#include "bcc/Renderscript/RSScript.h"
+#include "bcc/Assert.h"
#include "bcc/Renderscript/RSInfo.h"
#include "bcc/Source.h"
#include "bcc/Support/Log.h"
using namespace bcc;
-bool RSScript::LinkRuntime(RSScript &pScript, const char *rt_path) {
+bool RSScript::LinkRuntime(RSScript &pScript, const char *core_lib) {
+ bccAssert(core_lib != NULL);
+
// Using the same context with the source in pScript.
BCCContext &context = pScript.getSource().getContext();
- const char* core_lib = RSInfo::LibCLCorePath;
-
- // x86 devices will use an optimized library.
-#if defined(__i386__) || defined(__x86_64__)
- core_lib = RSInfo::LibCLCoreX86Path;
-#endif
-
- // NEON-capable devices can use an accelerated math library for all
- // reduced precision scripts.
-#if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_CLCORE_NEON)
- const RSInfo* info = pScript.getInfo();
- if ((info != NULL) &&
- (info->getFloatPrecisionRequirement() != RSInfo::FP_Full)) {
- core_lib = RSInfo::LibCLCoreNEONPath;
- }
-#endif
-
- if (rt_path != NULL) {
- core_lib = rt_path;
- }
Source *libclcore_source = Source::CreateFromFile(context, core_lib);
if (libclcore_source == NULL) {