OSDN Git Service

Use image pointer size for profile info
authorMathieu Chartier <mathieuc@google.com>
Tue, 15 Sep 2015 01:50:08 +0000 (18:50 -0700)
committerMathieu Chartier <mathieuc@google.com>
Tue, 15 Sep 2015 17:02:40 +0000 (10:02 -0700)
May fix some random crashes in dex2oat due to cross compilation.

Change-Id: I633652500e8c7dfec38044dffd07eb467973d82a

runtime/art_method-inl.h
runtime/art_method.cc
runtime/art_method.h
runtime/gc/collector/concurrent_copying.cc
runtime/jit/jit_instrumentation.cc
runtime/mirror/class-inl.h
runtime/runtime.cc

index a84c20a..d6b2b7e 100644 (file)
@@ -528,13 +528,12 @@ inline mirror::Class* ArtMethod::GetReturnType(bool resolve, size_t ptr_size) {
 }
 
 template<typename RootVisitorType>
-void ArtMethod::VisitRoots(RootVisitorType& visitor) {
+void ArtMethod::VisitRoots(RootVisitorType& visitor, size_t pointer_size) {
   ArtMethod* interface_method = nullptr;
   mirror::Class* klass = declaring_class_.Read();
   if (UNLIKELY(klass != nullptr && klass->IsProxyClass())) {
     // For normal methods, dex cache shortcuts will be visited through the declaring class.
     // However, for proxies we need to keep the interface method alive, so we visit its roots.
-    size_t pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
     interface_method = mirror::DexCache::GetElementPtrSize(
         GetDexCacheResolvedMethods(pointer_size),
         GetDexMethodIndex(),
@@ -542,11 +541,11 @@ void ArtMethod::VisitRoots(RootVisitorType& visitor) {
     DCHECK(interface_method != nullptr);
     DCHECK_EQ(interface_method,
               Runtime::Current()->GetClassLinker()->FindMethodForProxy(klass, this));
-    interface_method->VisitRoots(visitor);
+    interface_method->VisitRoots(visitor, pointer_size);
   }
 
   visitor.VisitRootIfNonNull(declaring_class_.AddressWithoutBarrier());
-  ProfilingInfo* profiling_info = GetProfilingInfo();
+  ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size);
   if (hotness_count_ != 0 && !IsNative() && profiling_info != nullptr) {
     profiling_info->VisitRoots(visitor);
   }
index 65f41cc..3e3232b 100644 (file)
@@ -596,12 +596,13 @@ const uint8_t* ArtMethod::GetQuickenedInfo() {
 }
 
 ProfilingInfo* ArtMethod::CreateProfilingInfo() {
+  DCHECK(!Runtime::Current()->IsAotCompiler());
   ProfilingInfo* info = ProfilingInfo::Create(this);
   MemberOffset offset = ArtMethod::EntryPointFromJniOffset(sizeof(void*));
   uintptr_t pointer = reinterpret_cast<uintptr_t>(this) + offset.Uint32Value();
   if (!reinterpret_cast<Atomic<ProfilingInfo*>*>(pointer)->
           CompareExchangeStrongSequentiallyConsistent(nullptr, info)) {
-    return GetProfilingInfo();
+    return GetProfilingInfo(sizeof(void*));
   } else {
     return info;
   }
index 3f2161f..9415372 100644 (file)
@@ -392,8 +392,8 @@ class ArtMethod FINAL {
 
   ProfilingInfo* CreateProfilingInfo() SHARED_REQUIRES(Locks::mutator_lock_);
 
-  ProfilingInfo* GetProfilingInfo() {
-    return reinterpret_cast<ProfilingInfo*>(GetEntryPointFromJni());
+  ProfilingInfo* GetProfilingInfo(size_t pointer_size) {
+    return reinterpret_cast<ProfilingInfo*>(GetEntryPointFromJniPtrSize(pointer_size));
   }
 
   void* GetEntryPointFromJni() {
@@ -458,7 +458,7 @@ class ArtMethod FINAL {
 
   // NO_THREAD_SAFETY_ANALYSIS since we don't know what the callback requires.
   template<typename RootVisitorType>
-  void VisitRoots(RootVisitorType& visitor) NO_THREAD_SAFETY_ANALYSIS;
+  void VisitRoots(RootVisitorType& visitor, size_t pointer_size) NO_THREAD_SAFETY_ANALYSIS;
 
   const DexFile* GetDexFile() SHARED_REQUIRES(Locks::mutator_lock_);
 
index 4cbcdc5..399591b 100644 (file)
@@ -1472,7 +1472,7 @@ void ConcurrentCopying::AssertToSpaceInvariant(GcRootSource* gc_root_source,
         ArtMethod* method = gc_root_source->GetArtMethod();
         LOG(INTERNAL_FATAL) << "gc root in method " << method << " " << PrettyMethod(method);
         RootPrinter root_printer;
-        method->VisitRoots(root_printer);
+        method->VisitRoots(root_printer, sizeof(void*));
       }
       ref->GetLockWord(false).Dump(LOG(INTERNAL_FATAL));
       region_space_->DumpNonFreeRegions(LOG(INTERNAL_FATAL));
index f485682..d437dd5 100644 (file)
@@ -98,7 +98,7 @@ void JitInstrumentationListener::InvokeVirtualOrInterface(Thread* thread,
                                                           uint32_t dex_pc,
                                                           ArtMethod* callee ATTRIBUTE_UNUSED) {
   DCHECK(this_object != nullptr);
-  ProfilingInfo* info = caller->GetProfilingInfo();
+  ProfilingInfo* info = caller->GetProfilingInfo(sizeof(void*));
   if (info != nullptr) {
     info->AddInvokeInfo(thread, dex_pc, this_object->GetClass());
   }
index 10b381d..93f2aea 100644 (file)
@@ -842,10 +842,10 @@ void mirror::Class::VisitNativeRoots(Visitor& visitor, size_t pointer_size) {
     }
   }
   for (ArtMethod& method : GetDirectMethods(pointer_size)) {
-    method.VisitRoots(visitor);
+    method.VisitRoots(visitor, pointer_size);
   }
   for (ArtMethod& method : GetVirtualMethods(pointer_size)) {
-    method.VisitRoots(visitor);
+    method.VisitRoots(visitor, pointer_size);
   }
 }
 
index bbadb1e..6b144cf 100644 (file)
@@ -1399,19 +1399,20 @@ void Runtime::VisitConstantRoots(RootVisitor* visitor) {
   // Visiting the roots of these ArtMethods is not currently required since all the GcRoots are
   // null.
   BufferedRootVisitor<16> buffered_visitor(visitor, RootInfo(kRootVMInternal));
+  const size_t pointer_size = GetClassLinker()->GetImagePointerSize();
   if (HasResolutionMethod()) {
-    resolution_method_->VisitRoots(buffered_visitor);
+    resolution_method_->VisitRoots(buffered_visitor, pointer_size);
   }
   if (HasImtConflictMethod()) {
-    imt_conflict_method_->VisitRoots(buffered_visitor);
+    imt_conflict_method_->VisitRoots(buffered_visitor, pointer_size);
   }
   if (imt_unimplemented_method_ != nullptr) {
-    imt_unimplemented_method_->VisitRoots(buffered_visitor);
+    imt_unimplemented_method_->VisitRoots(buffered_visitor, pointer_size);
   }
   for (size_t i = 0; i < kLastCalleeSaveType; ++i) {
     auto* m = reinterpret_cast<ArtMethod*>(callee_save_methods_[i]);
     if (m != nullptr) {
-      m->VisitRoots(buffered_visitor);
+      m->VisitRoots(buffered_visitor, pointer_size);
     }
   }
 }