Move inline caches GC handling in JitCodeCache.

Make the classes they hold weak references and visit
them during SweepJitRoots.

This fixes the newly introduced deadlock:

Thread1:
1) Lock JitCodeCache lock to create Profiling info for
  ArtMethod m.
2) m is a copied method, we need to track the actual holder,
   needing to decode a weak reference.
3) Weak references are not accessible due to GC.

GC Thread:
- Disallow weak reference access.
- Wait for checkpoint.

Thread2:
- Try to lock JitCodeCache lock
- Deadlock, as Thread1 owns the JitCodeCache lock.

Test: test-art-host
bug: 31289185
bug: 33198826

Change-Id: I7ee17631015450ace8d2a0264415a81c5a902bb8
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 8a3bac7..7479755 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1782,6 +1782,9 @@
   intern_table_->ChangeWeakRootState(gc::kWeakRootStateNoReadsOrWrites);
   java_vm_->DisallowNewWeakGlobals();
   heap_->DisallowNewAllocationRecords();
+  if (GetJit() != nullptr) {
+    GetJit()->GetCodeCache()->DisallowInlineCacheAccess();
+  }
 
   // All other generic system-weak holders.
   for (gc::AbstractSystemWeakHolder* holder : system_weak_holders_) {
@@ -1795,6 +1798,9 @@
   intern_table_->ChangeWeakRootState(gc::kWeakRootStateNormal);  // TODO: Do this in the sweeping.
   java_vm_->AllowNewWeakGlobals();
   heap_->AllowNewAllocationRecords();
+  if (GetJit() != nullptr) {
+    GetJit()->GetCodeCache()->AllowInlineCacheAccess();
+  }
 
   // All other generic system-weak holders.
   for (gc::AbstractSystemWeakHolder* holder : system_weak_holders_) {
@@ -1810,6 +1816,9 @@
   intern_table_->BroadcastForNewInterns();
   java_vm_->BroadcastForNewWeakGlobals();
   heap_->BroadcastForNewAllocationRecords();
+  if (GetJit() != nullptr) {
+    GetJit()->GetCodeCache()->BroadcastForInlineCacheAccess();
+  }
 
   // All other generic system-weak holders.
   for (gc::AbstractSystemWeakHolder* holder : system_weak_holders_) {