lambda: Add support for invoke-interface for boxed innate lambdas
Lambda closures created with the 'create-lambda' instruction
(termed "innate lambdas") can be turned into an object with 'box-lambda'.
This CL enables support for those kinds of lambdas to work with
'invoke-interface' by generating a proxy class for the lambda.
Note: MIPS32/64 support not included.
Bug: 24618608
Bug: 25107649
Change-Id: Ic8f1bb66ebeaed4097e758a50becf1cff6ccaefb
diff --git a/runtime/base/allocator.h b/runtime/base/allocator.h
index 969f5b9..e2ade07 100644
--- a/runtime/base/allocator.h
+++ b/runtime/base/allocator.h
@@ -53,6 +53,7 @@
kAllocatorTagClassTable,
kAllocatorTagInternTable,
kAllocatorTagLambdaBoxTable,
+ kAllocatorTagLambdaProxyClassBoxTable,
kAllocatorTagMaps,
kAllocatorTagLOS,
kAllocatorTagSafeMap,
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 70bd398..6ca56f5 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -65,6 +65,7 @@
Mutex* Locks::trace_lock_ = nullptr;
Mutex* Locks::unexpected_signal_lock_ = nullptr;
Mutex* Locks::lambda_table_lock_ = nullptr;
+Mutex* Locks::lambda_class_table_lock_ = nullptr;
Uninterruptible Roles::uninterruptible_;
struct AllMutexData {
@@ -954,6 +955,7 @@
DCHECK(trace_lock_ != nullptr);
DCHECK(unexpected_signal_lock_ != nullptr);
DCHECK(lambda_table_lock_ != nullptr);
+ DCHECK(lambda_class_table_lock_ != nullptr);
} else {
// Create global locks in level order from highest lock level to lowest.
LockLevel current_lock_level = kInstrumentEntrypointsLock;
@@ -1072,6 +1074,10 @@
DCHECK(lambda_table_lock_ == nullptr);
lambda_table_lock_ = new Mutex("lambda table lock", current_lock_level);
+ UPDATE_CURRENT_LOCK_LEVEL(kLambdaClassTableLock);
+ DCHECK(lambda_class_table_lock_ == nullptr);
+ lambda_class_table_lock_ = new Mutex("lambda class table lock", current_lock_level);
+
UPDATE_CURRENT_LOCK_LEVEL(kAbortLock);
DCHECK(abort_lock_ == nullptr);
abort_lock_ = new Mutex("abort lock", current_lock_level, true);
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index d4c9057..e2d7062 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -60,6 +60,7 @@
kUnexpectedSignalLock,
kThreadSuspendCountLock,
kAbortLock,
+ kLambdaClassTableLock,
kLambdaTableLock,
kJdwpSocketLock,
kRegionSpaceRegionLock,
@@ -692,6 +693,10 @@
// 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_);
+
+ // Allow reader-writer mutual exclusion on the boxed table of lambda proxy classes.
+ // TODO: this should be a RW mutex lock, except that ConditionVariables don't work with it.
+ static Mutex* lambda_class_table_lock_ ACQUIRED_AFTER(lambda_table_lock_);
};
class Roles {