summaryrefslogtreecommitdiffstats
path: root/runtime/utils.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-09-10 14:44:24 -0700
committerIan Rogers <irogers@google.com>2014-09-12 14:57:53 -0700
commit7b078e8c04f3e1451dbdd18543c8b9692b5b067e (patch)
tree414229c6b87eb20ea24c40780752da5a3999a49a /runtime/utils.cc
parentf79ba17defbd9342e44ab9f3de0807054673d3c9 (diff)
downloadart-7b078e8c04f3e1451dbdd18543c8b9692b5b067e.tar.gz
art-7b078e8c04f3e1451dbdd18543c8b9692b5b067e.tar.bz2
art-7b078e8c04f3e1451dbdd18543c8b9692b5b067e.zip
Compile time performance improvements focusing on interpret-only.
Reduce virtual method dispatch in the method verifier and make more code inline-able. Add a StringPiece with const char* equality operator to avoid redundant StringPieces and strlens. Remove back link from register line to verifier and pass as argument to reduce size of RegisterLine. Remove instruction length from instruction flags and compute from the instruction, again to reduce size. Add suspend checks to resolve and verify to allow for more easy monitor inflation and reduce contention on Locks::thread_list_suspend_thread_lock_. Change ThrowEarlierClassFailure to throw pre-allocated exception. Avoid calls to Thread::Current() by passing self. Template specialize IsValidClassName. Make ANR reporting with SIGQUIT run using checkpoints rather than suspending all threads. This makes the stack/lock analysis less lock error prone. Extra Barrier assertions and condition variable time out is now returned as a boolean both from Barrier and ConditionVariable::Wait. 2 threaded host x86-64 interpret-only numbers from 341 samples: Before change: Avg 176.137ms 99% CI 3.468ms to 1060.770ms After change: Avg 139.163% 99% CI 3.027ms to 838.257ms Reduction in average compile time after change is 20.9%. Slow-down without change is 26.5%. Bug: 17471626 - Fix bug where RegTypeCache::JavaLangObject/String/Class/Throwable could return unresolved type when class loading is disabled. Bug: 17398101 Change-Id: Id59ce3cc520701c6ecf612f7152498107bc40684
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r--runtime/utils.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc
index d15a09ab2..6135e5d84 100644
--- a/runtime/utils.cc
+++ b/runtime/utils.cc
@@ -823,7 +823,8 @@ bool IsValidMemberName(const char* s) {
}
enum ClassNameType { kName, kDescriptor };
-static bool IsValidClassName(const char* s, ClassNameType type, char separator) {
+template<ClassNameType kType, char kSeparator>
+static bool IsValidClassName(const char* s) {
int arrayCount = 0;
while (*s == '[') {
arrayCount++;
@@ -835,7 +836,8 @@ static bool IsValidClassName(const char* s, ClassNameType type, char separator)
return false;
}
- if (arrayCount != 0) {
+ ClassNameType type = kType;
+ if (type != kDescriptor && arrayCount != 0) {
/*
* If we're looking at an array of some sort, then it doesn't
* matter if what is being asked for is a class name; the
@@ -903,7 +905,7 @@ static bool IsValidClassName(const char* s, ClassNameType type, char separator)
return (type == kDescriptor) && !sepOrFirst && (s[1] == '\0');
case '/':
case '.':
- if (c != separator) {
+ if (c != kSeparator) {
// The wrong separator character.
return false;
}
@@ -925,15 +927,15 @@ static bool IsValidClassName(const char* s, ClassNameType type, char separator)
}
bool IsValidBinaryClassName(const char* s) {
- return IsValidClassName(s, kName, '.');
+ return IsValidClassName<kName, '.'>(s);
}
bool IsValidJniClassName(const char* s) {
- return IsValidClassName(s, kName, '/');
+ return IsValidClassName<kName, '/'>(s);
}
bool IsValidDescriptor(const char* s) {
- return IsValidClassName(s, kDescriptor, '/');
+ return IsValidClassName<kDescriptor, '/'>(s);
}
void Split(const std::string& s, char separator, std::vector<std::string>& result) {