diff options
author | Mathieu Chartier <mathieuc@google.com> | 2014-05-07 15:43:14 -0700 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2014-05-13 14:45:54 -0700 |
commit | eb8167a4f4d27fce0530f6724ab8032610cd146b (patch) | |
tree | bcfeaf13ad78f2dd68466bbd0e20c71944f7e854 /runtime/thread.h | |
parent | 6fb66a2bc4e1c0b7931101153e58714991237af7 (diff) | |
download | art-eb8167a4f4d27fce0530f6724ab8032610cd146b.tar.gz art-eb8167a4f4d27fce0530f6724ab8032610cd146b.tar.bz2 art-eb8167a4f4d27fce0530f6724ab8032610cd146b.zip |
Add Handle/HandleScope and delete SirtRef.
Delete SirtRef and replaced it with Handle. Handles are value types
which wrap around StackReference*.
Renamed StackIndirectReferenceTable to HandleScope.
Added a scoped handle wrapper which wraps around an Object** and
restores it in its destructor.
Renamed Handle::get -> Get.
Bug: 8473721
Change-Id: Idbfebd4f35af629f0f43931b7c5184b334822c7a
Diffstat (limited to 'runtime/thread.h')
-rw-r--r-- | runtime/thread.h | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/runtime/thread.h b/runtime/thread.h index 32311e1b00..1bbe617441 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -31,12 +31,12 @@ #include "entrypoints/quick/quick_entrypoints.h" #include "gc/allocator/rosalloc.h" #include "globals.h" +#include "handle_scope.h" #include "jvalue.h" #include "object_callbacks.h" #include "offsets.h" #include "runtime_stats.h" #include "stack.h" -#include "stack_indirect_reference_table.h" #include "thread_state.h" #include "throw_location.h" #include "UniquePtr.h" @@ -648,35 +648,40 @@ class Thread { return tlsPtr_.managed_stack.NumJniShadowFrameReferences(); } - // Number of references in SIRTs on this thread. - size_t NumSirtReferences(); + // Number of references in handle scope on this thread. + size_t NumHandleReferences(); - // Number of references allocated in SIRTs & JNI shadow frames on this thread. + // Number of references allocated in handle scopes & JNI shadow frames on this thread. size_t NumStackReferences() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return NumSirtReferences() + NumJniShadowFrameReferences(); + return NumHandleReferences() + NumJniShadowFrameReferences(); }; // Is the given obj in this thread's stack indirect reference table? - bool SirtContains(jobject obj) const; + bool HandleScopeContains(jobject obj) const; - void SirtVisitRoots(RootCallback* visitor, void* arg, uint32_t thread_id) + void HandleScopeVisitRoots(RootCallback* visitor, void* arg, uint32_t thread_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void PushSirt(StackIndirectReferenceTable* sirt) { - sirt->SetLink(tlsPtr_.top_sirt); - tlsPtr_.top_sirt = sirt; + HandleScope* GetTopHandleScope() { + return tlsPtr_.top_handle_scope; } - StackIndirectReferenceTable* PopSirt() { - StackIndirectReferenceTable* sirt = tlsPtr_.top_sirt; - DCHECK(sirt != NULL); - tlsPtr_.top_sirt = tlsPtr_.top_sirt->GetLink(); - return sirt; + void PushHandleScope(HandleScope* handle_scope) { + handle_scope->SetLink(tlsPtr_.top_handle_scope); + tlsPtr_.top_handle_scope = handle_scope; + } + + HandleScope* PopHandleScope() { + HandleScope* handle_scope = tlsPtr_.top_handle_scope; + DCHECK(handle_scope != nullptr); + tlsPtr_.top_handle_scope = tlsPtr_.top_handle_scope->GetLink(); + return handle_scope; } template<size_t pointer_size> - static ThreadOffset<pointer_size> TopSirtOffset() { - return ThreadOffsetFromTlsPtr<pointer_size>(OFFSETOF_MEMBER(tls_ptr_sized_values, top_sirt)); + static ThreadOffset<pointer_size> TopHandleScopeOffset() { + return ThreadOffsetFromTlsPtr<pointer_size>(OFFSETOF_MEMBER(tls_ptr_sized_values, + top_handle_scope)); } DebugInvokeReq* GetInvokeReq() const { @@ -950,7 +955,7 @@ class Thread { managed_stack(), suspend_trigger(nullptr), jni_env(nullptr), self(nullptr), opeer(nullptr), jpeer(nullptr), stack_begin(nullptr), stack_size(0), throw_location(), stack_trace_sample(nullptr), wait_next(nullptr), monitor_enter_object(nullptr), - top_sirt(nullptr), class_loader_override(nullptr), long_jump_context(nullptr), + top_handle_scope(nullptr), class_loader_override(nullptr), long_jump_context(nullptr), instrumentation_stack(nullptr), debug_invoke_req(nullptr), single_step_control(nullptr), deoptimization_shadow_frame(nullptr), name(nullptr), pthread_self(0), last_no_thread_suspension_cause(nullptr), thread_local_start(nullptr), @@ -1006,8 +1011,8 @@ class Thread { // If we're blocked in MonitorEnter, this is the object we're trying to lock. mirror::Object* monitor_enter_object; - // Top of linked list of stack indirect reference tables or NULL for none. - StackIndirectReferenceTable* top_sirt; + // Top of linked list of handle scopes or nullptr for none. + HandleScope* top_handle_scope; // Needed to get the right ClassLoader in JNI_OnLoad, but also // useful for testing. |