diff options
author | Igor Murashkin <iam@google.com> | 2015-07-10 13:49:08 -0700 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2015-07-20 15:11:59 -0700 |
commit | e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7 (patch) | |
tree | 595a3c807e1cbaa4b8c22b93685d70faa4ff0f5a /runtime/base/mutex.h | |
parent | e07300b712f44397ecbfed1ef7f880686e46274a (diff) | |
download | art-e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7.tar.gz art-e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7.tar.bz2 art-e2facc5b18cd756a8b5500fb3d90da69c9ee0fb7.zip |
runtime: Add lambda box/unbox object equality
A lambda that is boxed with box-lambda is now stored as a weak reference
in a global runtime table (lambda::BoxTable). Repeatedly boxing the same
lambda closure value will always return the same java.lang.Object back.
Since there is no way to observe the address of an object, a GC can
happen and clean up the table of any dead boxed lambdas, which can also
shrink the table to prevent the memory use from growing too much.
(Note that a lambda closure is immutable, so hashing over it is
guaranteed safe.)
Change-Id: I786c1323ff14eed937936b303d511875f9642524
Diffstat (limited to 'runtime/base/mutex.h')
-rw-r--r-- | runtime/base/mutex.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index f87467a0e1..5b258e5ddb 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -60,6 +60,7 @@ enum LockLevel { kUnexpectedSignalLock, kThreadSuspendCountLock, kAbortLock, + kLambdaTableLock, kJdwpSocketLock, kRegionSpaceRegionLock, kTransactionLogLock, @@ -648,6 +649,10 @@ class Locks { // Have an exclusive logging thread. static Mutex* logging_lock_ ACQUIRED_AFTER(unexpected_signal_lock_); + + // Allow reader-writer mutual exclusion on the boxed table of lambda objects. + // TODO: this should be a RW mutex lock, except that ConditionVariables don't work with it. + static Mutex* lambda_table_lock_ ACQUIRED_AFTER(mutator_lock_); }; } // namespace art |