summaryrefslogtreecommitdiff
path: root/runtime/lambda/box_table.h
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2015-09-27 19:19:06 -0700
committer Igor Murashkin <iam@google.com> 2015-09-27 19:19:23 -0700
commit6918bf13eb855b3aa8ccdddda2d27ae8c60cec56 (patch)
tree907f504a4d004ac1e44b73c3984e365e889407e8 /runtime/lambda/box_table.h
parent446ca43e8f876dcc1ee90fcf432d6392c44a3f60 (diff)
Revert "Revert "lambda: Experimental support for capture-variable and liberate-variable""
This reverts commit 7bbb80ab52c203e44d2ded2c947b3b03b4b31ec4. Change-Id: If806ce5c6c5e96fdb2c3761dee096f74e7e5b001
Diffstat (limited to 'runtime/lambda/box_table.h')
-rw-r--r--runtime/lambda/box_table.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/runtime/lambda/box_table.h b/runtime/lambda/box_table.h
index 9ffda6658f..adb733271e 100644
--- a/runtime/lambda/box_table.h
+++ b/runtime/lambda/box_table.h
@@ -34,6 +34,7 @@ class Object; // forward declaration
} // namespace mirror
namespace lambda {
+struct Closure; // forward declaration
/*
* Store a table of boxed lambdas. This is required to maintain object referential equality
@@ -44,7 +45,7 @@ namespace lambda {
*/
class BoxTable FINAL {
public:
- using ClosureType = art::ArtMethod*;
+ using ClosureType = art::lambda::Closure*;
// Boxes a closure into an object. Returns null and throws an exception on failure.
mirror::Object* BoxLambda(const ClosureType& closure)
@@ -72,10 +73,9 @@ class BoxTable FINAL {
REQUIRES(!Locks::lambda_table_lock_);
BoxTable();
- ~BoxTable() = default;
+ ~BoxTable();
private:
- // FIXME: This needs to be a GcRoot.
// Explanation:
// - After all threads are suspended (exclusive mutator lock),
// the concurrent-copying GC can move objects from the "from" space to the "to" space.
@@ -97,30 +97,30 @@ class BoxTable FINAL {
void BlockUntilWeaksAllowed()
SHARED_REQUIRES(Locks::lambda_table_lock_);
+ // Wrap the Closure into a unique_ptr so that the HashMap can delete its memory automatically.
+ using UnorderedMapKeyType = ClosureType;
+
// EmptyFn implementation for art::HashMap
struct EmptyFn {
- void MakeEmpty(std::pair<ClosureType, ValueType>& item) const {
- item.first = nullptr;
- }
- bool IsEmpty(const std::pair<ClosureType, ValueType>& item) const {
- return item.first == nullptr;
- }
+ void MakeEmpty(std::pair<UnorderedMapKeyType, ValueType>& item) const
+ NO_THREAD_SAFETY_ANALYSIS; // SHARED_REQUIRES(Locks::mutator_lock_)
+
+ bool IsEmpty(const std::pair<UnorderedMapKeyType, ValueType>& item) const;
};
// HashFn implementation for art::HashMap
struct HashFn {
- size_t operator()(const ClosureType& key) const {
- // TODO(iam): Rewrite hash function when ClosureType is no longer an ArtMethod*
- return static_cast<size_t>(reinterpret_cast<uintptr_t>(key));
- }
+ size_t operator()(const UnorderedMapKeyType& key) const
+ NO_THREAD_SAFETY_ANALYSIS; // SHARED_REQUIRES(Locks::mutator_lock_)
};
// EqualsFn implementation for art::HashMap
struct EqualsFn {
- bool operator()(const ClosureType& lhs, const ClosureType& rhs) const;
+ bool operator()(const UnorderedMapKeyType& lhs, const UnorderedMapKeyType& rhs) const
+ NO_THREAD_SAFETY_ANALYSIS; // SHARED_REQUIRES(Locks::mutator_lock_)
};
- using UnorderedMap = art::HashMap<ClosureType,
+ using UnorderedMap = art::HashMap<UnorderedMapKeyType,
ValueType,
EmptyFn,
HashFn,