runtime: Bitstring implementation for subtype checking (3/4).

Implement the subtype check manipulation of the class hierarchy.
This walks the class hierarchy tree and allocates bitstring values
to each class by encoding the path from the class to the root as a
bitstring.

Used to implement O(1) subtype checking in the subsequent CL.

Test: art/test.py -b -j32 --host --target
Bug: 64692057
Change-Id: I484940bbb3901b56236245cdd4f8f4a8d859f919
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 189c0d0..caca68d 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -101,6 +101,7 @@
   kClassLinkerClassesLock,  // TODO rename.
   kJitCodeCacheLock,
   kCHALock,
+  kSubtypeCheckLock,
   kBreakpointLock,
   kMonitorLock,
   kMonitorListLock,
@@ -646,9 +647,15 @@
   // Guards Class Hierarchy Analysis (CHA).
   static Mutex* cha_lock_ ACQUIRED_AFTER(deoptimization_lock_);
 
+  // Guard the update of the SubtypeCheck data stores in each Class::status_ field.
+  // This lock is used in SubtypeCheck methods which are the interface for
+  // any SubtypeCheck-mutating methods.
+  // In Class::IsSubClass, the lock is not required since it does not update the SubtypeCheck data.
+  static Mutex* subtype_check_lock_ ACQUIRED_AFTER(cha_lock_);
+
   // The thread_list_lock_ guards ThreadList::list_. It is also commonly held to stop threads
   // attaching and detaching.
-  static Mutex* thread_list_lock_ ACQUIRED_AFTER(cha_lock_);
+  static Mutex* thread_list_lock_ ACQUIRED_AFTER(subtype_check_lock_);
 
   // Signaled when threads terminate. Used to determine when all non-daemons have terminated.
   static ConditionVariable* thread_exit_cond_ GUARDED_BY(Locks::thread_list_lock_);