OSDN Git Service

Check if a class is verified before visiting profiling info.
authorNicolas Geoffray <ngeoffray@google.com>
Wed, 4 May 2016 08:51:24 +0000 (09:51 +0100)
committerNicolas Geoffray <ngeoffray@google.com>
Wed, 4 May 2016 08:53:42 +0000 (09:53 +0100)
The call to IsNative expects non-retired classes, and we know
we don't have any profiling info for non-verified classes anyway.

bug:28542527
Change-Id: I5bb9528a8d357bc8940c2190e2cde33a13df3e8d

runtime/art_method-inl.h

index 6449efa..7647ad6 100644 (file)
@@ -456,13 +456,18 @@ void ArtMethod::VisitRoots(RootVisitorType& visitor, size_t pointer_size) {
       interface_method->VisitRoots(visitor, pointer_size);
     }
     visitor.VisitRoot(declaring_class_.AddressWithoutBarrier());
-    // Runtime methods and native methods use the same field as the profiling info for
-    // storing their own data (jni entrypoint for native methods, and ImtConflictTable for
-    // some runtime methods).
-    if (!IsNative() && !IsRuntimeMethod()) {
-      ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size);
-      if (profiling_info != nullptr) {
-        profiling_info->VisitRoots(visitor);
+    // We know we don't have profiling information if the class hasn't been verified. Note
+    // that this check also ensures the IsNative call can be made, as IsNative expects a fully
+    // created class (and not a retired one).
+    if (klass->IsVerified()) {
+      // Runtime methods and native methods use the same field as the profiling info for
+      // storing their own data (jni entrypoint for native methods, and ImtConflictTable for
+      // some runtime methods).
+      if (!IsNative() && !IsRuntimeMethod()) {
+        ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size);
+        if (profiling_info != nullptr) {
+          profiling_info->VisitRoots(visitor);
+        }
       }
     }
   }