summaryrefslogtreecommitdiffstats
path: root/runtime/utils.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2014-09-05 14:01:17 +0100
committerVladimir Marko <vmarko@google.com>2014-09-10 16:02:14 +0100
commitaa4497db59f1eeec954f2ba5da6d458fcdf9b3a4 (patch)
tree1efe5c6c5fe93ae73b6ad02db1a4ac368c71c00e /runtime/utils.h
parent6724a9531c92368491dd17937d0087f73a7c0642 (diff)
downloadandroid_art-aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4.tar.gz
android_art-aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4.tar.bz2
android_art-aa4497db59f1eeec954f2ba5da6d458fcdf9b3a4.zip
Improve dex location canonicalization-related performance.
Eagerly add canonical dex file locations to the OatFile's primary lookup map in Setup(). This moves the boot.oat work from every app startup to the zygote initialization. Since we always ended up initializing the canonical location map anyway due to the way that we're loading dex files, the lazy initialization didn't save anything. Clean up dex file name canonicalization to make sure we free() the memory returned by realpath() rather than using std::unique_ptr<> with the default deleter. Avoid some unnecessary duplicate OatDexFile lookups. Bug: 16828525 Bug: 17346103 Change-Id: Id8fbc8992f62996138eb2006a0046c6529747c09
Diffstat (limited to 'runtime/utils.h')
-rw-r--r--runtime/utils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/utils.h b/runtime/utils.h
index 7fb5bbd3da..50462b11b3 100644
--- a/runtime/utils.h
+++ b/runtime/utils.h
@@ -20,6 +20,7 @@
#include <pthread.h>
#include <limits>
+#include <memory>
#include <string>
#include <vector>
@@ -502,6 +503,18 @@ void PushWord(std::vector<uint8_t>* buf, int32_t data);
void EncodeUnsignedLeb128(uint32_t data, std::vector<uint8_t>* buf);
void EncodeSignedLeb128(int32_t data, std::vector<uint8_t>* buf);
+// Deleter using free() for use with std::unique_ptr<>. See also UniqueCPtr<> below.
+struct FreeDelete {
+ // NOTE: Deleting a const object is valid but free() takes a non-const pointer.
+ void operator()(const void* ptr) const {
+ free(const_cast<void*>(ptr));
+ }
+};
+
+// Alias for std::unique_ptr<> that uses the C function free() to delete objects.
+template <typename T>
+using UniqueCPtr = std::unique_ptr<T, FreeDelete>;
+
} // namespace art
#endif // ART_RUNTIME_UTILS_H_