summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-03-07 17:09:58 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-07 17:09:58 +0000
commitdf29be4d63c4187a7eb35b8f473ad9fad1fc439a (patch)
treed36413d70d7e68197bcc1d496b13818637fca33b /runtime/class_linker.cc
parent52fcfea4b717367f92dc9ac2a25a44991dfd79fd (diff)
parentc4af33fa1ff7e0c42f02613fa1a879e4613aaad7 (diff)
Merge "ART: Use try-lock for interface marking" into pi-dev
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c667fe2f30..2a80e3c609 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4977,8 +4977,14 @@ bool ClassLinker::InitializeDefaultInterfaceRecursive(Thread* self,
// interface since we can still avoid the traversal. This is purely a performance optimization.
if (result) {
// TODO This should be done in a better way
- ObjectLock<mirror::Class> lock(self, iface);
- iface->SetRecursivelyInitialized();
+ // Note: Use a try-lock to avoid blocking when someone else is holding the lock on this
+ // interface. It is bad (Java) style, but not impossible. Marking the recursive
+ // initialization is a performance optimization (to avoid another idempotent visit
+ // for other implementing classes/interfaces), and can be revisited later.
+ ObjectTryLock<mirror::Class> lock(self, iface);
+ if (lock.Acquired()) {
+ iface->SetRecursivelyInitialized();
+ }
}
return result;
}