From eb8167a4f4d27fce0530f6724ab8032610cd146b Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 7 May 2014 15:43:14 -0700 Subject: 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 --- compiler/driver/compiler_driver-inl.h | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'compiler/driver/compiler_driver-inl.h') diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index d9f2a3adb8..08fd386226 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -28,7 +28,7 @@ #include "mirror/dex_cache-inl.h" #include "mirror/art_field-inl.h" #include "scoped_thread_state_change.h" -#include "sirt_ref-inl.h" +#include "handle_scope-inl.h" namespace art { @@ -42,10 +42,10 @@ inline mirror::ClassLoader* CompilerDriver::GetClassLoader(ScopedObjectAccess& s } inline mirror::Class* CompilerDriver::ResolveCompilingMethodsClass( - ScopedObjectAccess& soa, const SirtRef& dex_cache, - const SirtRef& class_loader, const DexCompilationUnit* mUnit) { - DCHECK(dex_cache->GetDexFile() == mUnit->GetDexFile()); - DCHECK(class_loader.get() == soa.Decode(mUnit->GetClassLoader())); + ScopedObjectAccess& soa, const Handle& dex_cache, + const Handle& class_loader, const DexCompilationUnit* mUnit) { + DCHECK_EQ(dex_cache->GetDexFile(), mUnit->GetDexFile()); + DCHECK_EQ(class_loader.Get(), soa.Decode(mUnit->GetClassLoader())); const DexFile::MethodId& referrer_method_id = mUnit->GetDexFile()->GetMethodId(mUnit->GetDexMethodIndex()); mirror::Class* referrer_class = mUnit->GetClassLinker()->ResolveType( @@ -59,11 +59,11 @@ inline mirror::Class* CompilerDriver::ResolveCompilingMethodsClass( } inline mirror::ArtField* CompilerDriver::ResolveField( - ScopedObjectAccess& soa, const SirtRef& dex_cache, - const SirtRef& class_loader, const DexCompilationUnit* mUnit, + ScopedObjectAccess& soa, const Handle& dex_cache, + const Handle& class_loader, const DexCompilationUnit* mUnit, uint32_t field_idx, bool is_static) { - DCHECK(dex_cache->GetDexFile() == mUnit->GetDexFile()); - DCHECK(class_loader.get() == soa.Decode(mUnit->GetClassLoader())); + DCHECK_EQ(dex_cache->GetDexFile(), mUnit->GetDexFile()); + DCHECK_EQ(class_loader.Get(), soa.Decode(mUnit->GetClassLoader())); mirror::ArtField* resolved_field = mUnit->GetClassLinker()->ResolveField( *mUnit->GetDexFile(), field_idx, dex_cache, class_loader, is_static); DCHECK_EQ(resolved_field == nullptr, soa.Self()->IsExceptionPending()); @@ -165,11 +165,11 @@ inline std::pair CompilerDriver::IsFastStaticField( } inline mirror::ArtMethod* CompilerDriver::ResolveMethod( - ScopedObjectAccess& soa, const SirtRef& dex_cache, - const SirtRef& class_loader, const DexCompilationUnit* mUnit, + ScopedObjectAccess& soa, const Handle& dex_cache, + const Handle& class_loader, const DexCompilationUnit* mUnit, uint32_t method_idx, InvokeType invoke_type) { DCHECK(dex_cache->GetDexFile() == mUnit->GetDexFile()); - DCHECK(class_loader.get() == soa.Decode(mUnit->GetClassLoader())); + DCHECK(class_loader.Get() == soa.Decode(mUnit->GetClassLoader())); mirror::ArtMethod* resolved_method = mUnit->GetClassLinker()->ResolveMethod( *mUnit->GetDexFile(), method_idx, dex_cache, class_loader, nullptr, invoke_type); DCHECK_EQ(resolved_method == nullptr, soa.Self()->IsExceptionPending()); @@ -206,8 +206,8 @@ inline uint16_t CompilerDriver::GetResolvedMethodVTableIndex( } inline int CompilerDriver::IsFastInvoke( - ScopedObjectAccess& soa, const SirtRef& dex_cache, - const SirtRef& class_loader, const DexCompilationUnit* mUnit, + ScopedObjectAccess& soa, const Handle& dex_cache, + const Handle& class_loader, const DexCompilationUnit* mUnit, mirror::Class* referrer_class, mirror::ArtMethod* resolved_method, InvokeType* invoke_type, MethodReference* target_method, const MethodReference* devirt_target, uintptr_t* direct_code, uintptr_t* direct_method) { @@ -217,7 +217,7 @@ inline int CompilerDriver::IsFastInvoke( } mirror::Class* methods_class = resolved_method->GetDeclaringClass(); if (UNLIKELY(!referrer_class->CanAccessResolvedMethod(methods_class, resolved_method, - dex_cache.get(), + dex_cache.Get(), target_method->dex_method_index))) { return 0; } @@ -237,7 +237,7 @@ inline int CompilerDriver::IsFastInvoke( // Sharpen a virtual call into a direct call. The method_idx is into referrer's // dex cache, check that this resolved method is where we expect it. CHECK(target_method->dex_file == mUnit->GetDexFile()); - DCHECK(dex_cache.get() == mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile())); + DCHECK(dex_cache.Get() == mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile())); CHECK(referrer_class->GetDexCache()->GetResolvedMethod(target_method->dex_method_index) == resolved_method) << PrettyMethod(resolved_method); int stats_flags = kFlagMethodResolved; @@ -259,8 +259,9 @@ inline int CompilerDriver::IsFastInvoke( devirt_target->dex_method_index, dex_cache, class_loader, NULL, kVirtual); } else { - SirtRef target_dex_cache(soa.Self(), - class_linker->FindDexCache(*devirt_target->dex_file)); + StackHandleScope<1> hs(soa.Self()); + Handle target_dex_cache( + hs.NewHandle(class_linker->FindDexCache(*devirt_target->dex_file))); called_method = class_linker->ResolveMethod(*devirt_target->dex_file, devirt_target->dex_method_index, target_dex_cache, class_loader, NULL, kVirtual); -- cgit v1.2.3-59-g8ed1b