diff options
author | Ian Rogers <irogers@google.com> | 2014-07-15 22:23:51 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-07-16 06:13:46 -0700 |
commit | 22d5e735f403c57525fe868304c7123f0ce66399 (patch) | |
tree | 2458684efa56f0b800dd75a9dedd0449f76f581f /runtime/handle_scope.h | |
parent | fbde4dd1cb6db729e3f3ee5bdae0cdd824d73054 (diff) | |
download | android_art-22d5e735f403c57525fe868304c7123f0ce66399.tar.gz android_art-22d5e735f403c57525fe868304c7123f0ce66399.tar.bz2 android_art-22d5e735f403c57525fe868304c7123f0ce66399.zip |
Remove object_utils.h.
Break into object_lock, field_helper and method_helper.
Clean up header files following this.
Also tidy some of the Handle code in response to compiler errors when resolving
the changes in this CL.
Change-Id: I73e63015a0f02a754d0866bfaf58208aebcaa295
Diffstat (limited to 'runtime/handle_scope.h')
-rw-r--r-- | runtime/handle_scope.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h index 2fd42d2350..42ef77927c 100644 --- a/runtime/handle_scope.h +++ b/runtime/handle_scope.h @@ -30,8 +30,9 @@ class Object; class Thread; -// HandleScopes can be allocated within the bridge frame between managed and native code backed by -// stack storage or manually allocated in native. +// HandleScopes are scoped objects containing a number of Handles. They are used to allocate +// handles, for these handles (and the objects contained within them) to be visible/roots for the +// GC. It is most common to stack allocate HandleScopes using StackHandleScope. class PACKED(4) HandleScope { public: ~HandleScope() {} @@ -131,6 +132,7 @@ class PACKED(4) HandleScope { private: template<size_t kNumReferences> friend class StackHandleScope; + DISALLOW_COPY_AND_ASSIGN(HandleScope); }; @@ -153,7 +155,7 @@ class HandleWrapper : public Handle<T> { // Scoped handle storage of a fixed size that is usually stack allocated. template<size_t kNumReferences> -class PACKED(4) StackHandleScope : public HandleScope { +class PACKED(4) StackHandleScope FINAL : public HandleScope { public: explicit StackHandleScope(Thread* self); ~StackHandleScope(); @@ -182,20 +184,29 @@ class PACKED(4) StackHandleScope : public HandleScope { template<class T> Handle<T> NewHandle(T* object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { SetReference(pos_, object); - return Handle<T>(GetHandle(pos_++)); + Handle<T> h(GetHandle(pos_)); + pos_++; + return h; } template<class T> HandleWrapper<T> NewHandleWrapper(T** object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { SetReference(pos_, *object); - Handle<T> h(GetHandle(pos_++)); + Handle<T> h(GetHandle(pos_)); + pos_++; return HandleWrapper<T>(object, h); } private: - // references_storage_ needs to be first so that it matches the address of references_. + // References_storage_ needs to be first so that it appears in the same location as + // HandleScope::references_. StackReference<mirror::Object> references_storage_[kNumReferences]; + + // The thread that the stack handle scope is a linked list upon. The stack handle scope will + // push and pop itself from this thread. Thread* const self_; + + // Position new handles will be created. size_t pos_; template<size_t kNumRefs> friend class StackHandleScope; |