[vm/concurrency] Move class registration from Isolate to IsolateGroup

We share the program across all isolates within a group. So hot-reload
should not depend on a particular isolate. This CL moves class
registration (which hot reload triggers) from Isolate to IsolateGroup.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Refactoring of existing implementation.

Change-Id: Ibdb4e67a095c7f2f3e3c1a8f8194bd0ca936b140
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184266
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
index 248cf45..3f1274c 100644
--- a/runtime/vm/class_table.cc
+++ b/runtime/vm/class_table.cc
@@ -72,10 +72,11 @@
 }
 
 void ClassTable::set_table(ClassPtr* table) {
-  Isolate* isolate = Isolate::Current();
-  ASSERT(isolate != nullptr);
+  // We don't have to stop mutators, since the old table is the prefix of the
+  // new table. But we should ensure that all writes to the current table are
+  // visible once the new table is visible.
   table_.store(table);
-  isolate->set_cached_class_table_table(table);
+  IsolateGroup::Current()->set_cached_class_table_table(table);
 }
 
 ClassTable::ClassTable(SharedClassTable* shared_class_table)
diff --git a/runtime/vm/class_table.h b/runtime/vm/class_table.h
index 3660e29..9f23820 100644
--- a/runtime/vm/class_table.h
+++ b/runtime/vm/class_table.h
@@ -420,7 +420,7 @@
   friend Isolate* CreateWithinExistingIsolateGroup(IsolateGroup* group,
                                                    const char* name,
                                                    char** error);
-  friend class Isolate;  // for table()
+  friend class IsolateGroup;  // for table()
   static const int kInitialCapacity = SharedClassTable::kInitialCapacity;
   static const int kCapacityIncrement = SharedClassTable::kCapacityIncrement;
 
diff --git a/runtime/vm/compiler/assembler/assembler_arm.cc b/runtime/vm/compiler/assembler/assembler_arm.cc
index 8bad1fc..42d0440 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm.cc
@@ -2024,9 +2024,9 @@
   ASSERT(result != class_id);
 
   const intptr_t table_offset =
-      target::Isolate::cached_class_table_table_offset();
+      target::IsolateGroup::cached_class_table_table_offset();
 
-  LoadIsolate(result);
+  LoadIsolateGroup(result);
   LoadFromOffset(result, result, table_offset);
   ldr(result, Address(result, class_id, LSL, target::kWordSizeLog2));
 }
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.cc b/runtime/vm/compiler/assembler/assembler_arm64.cc
index f1d8195..af87467 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.cc
+++ b/runtime/vm/compiler/assembler/assembler_arm64.cc
@@ -1188,9 +1188,9 @@
   ASSERT(result != class_id);
 
   const intptr_t table_offset =
-      target::Isolate::cached_class_table_table_offset();
+      target::IsolateGroup::cached_class_table_table_offset();
 
-  LoadIsolate(result);
+  LoadIsolateGroup(result);
   LoadFromOffset(result, result, table_offset);
   ldr(result, Address(result, class_id, UXTX, Address::Scaled));
 }
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.cc b/runtime/vm/compiler/assembler/assembler_ia32.cc
index 7c5abdd..c845d8a 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.cc
+++ b/runtime/vm/compiler/assembler/assembler_ia32.cc
@@ -2709,8 +2709,8 @@
   ASSERT(result != class_id);
 
   const intptr_t table_offset =
-      target::Isolate::cached_class_table_table_offset();
-  LoadIsolate(result);
+      target::IsolateGroup::cached_class_table_table_offset();
+  LoadIsolateGroup(result);
   movl(result, Address(result, table_offset));
   movl(result, Address(result, class_id, TIMES_4, 0));
 }
diff --git a/runtime/vm/compiler/assembler/assembler_x64.cc b/runtime/vm/compiler/assembler/assembler_x64.cc
index c089993..03122d3 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.cc
+++ b/runtime/vm/compiler/assembler/assembler_x64.cc
@@ -2193,9 +2193,9 @@
 void Assembler::LoadClassById(Register result, Register class_id) {
   ASSERT(result != class_id);
   const intptr_t table_offset =
-      target::Isolate::cached_class_table_table_offset();
+      target::IsolateGroup::cached_class_table_table_offset();
 
-  LoadIsolate(result);
+  LoadIsolateGroup(result);
   movq(result, Address(result, table_offset));
   movq(result, Address(result, class_id, TIMES_8, 0));
 }
diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h
index f135cff..2160708 100644
--- a/runtime/vm/compiler/runtime_api.h
+++ b/runtime/vm/compiler/runtime_api.h
@@ -1151,7 +1151,6 @@
   static word default_tag_offset();
   static word current_tag_offset();
   static word user_tag_offset();
-  static word cached_class_table_table_offset();
   static word ic_miss_code_offset();
 #if !defined(PRODUCT)
   static word single_step_offset();
@@ -1161,6 +1160,7 @@
 class IsolateGroup : public AllStatic {
  public:
   static word shared_class_table_offset();
+  static word cached_class_table_table_offset();
 };
 
 class SharedClassTable : public AllStatic {
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index b7cf933..94dc8ed 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -165,8 +165,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 20;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
@@ -174,7 +172,9 @@
     Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 8;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 44;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 40;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -698,8 +698,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -707,7 +705,9 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 80;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -1236,8 +1236,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 20;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
@@ -1245,7 +1243,9 @@
     Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 8;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 44;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 16;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 40;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -1766,8 +1766,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -1775,7 +1773,9 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 80;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -2307,8 +2307,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -2316,7 +2314,9 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 80;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -2847,8 +2847,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -2856,7 +2854,9 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
-static constexpr dart::compiler::target::word Isolate_single_step_offset = 88;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
+static constexpr dart::compiler::target::word Isolate_single_step_offset = 80;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -3386,8 +3386,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 20;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
@@ -3395,6 +3393,8 @@
     Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -3913,8 +3913,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -3922,6 +3920,8 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -4445,8 +4445,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 20;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 28;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 20;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 24;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 28;
@@ -4454,6 +4452,8 @@
     Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 16;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 16;
 static constexpr dart::compiler::target::word
@@ -4969,8 +4969,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -4978,6 +4976,8 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -5504,8 +5504,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -5513,6 +5511,8 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -6038,8 +6038,6 @@
 static constexpr dart::compiler::target::word ICData_owner_offset = 40;
 static constexpr dart::compiler::target::word ICData_state_bits_offset = 52;
 static constexpr dart::compiler::target::word Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word Isolate_current_tag_offset = 40;
 static constexpr dart::compiler::target::word Isolate_default_tag_offset = 48;
 static constexpr dart::compiler::target::word Isolate_ic_miss_code_offset = 56;
@@ -6047,6 +6045,8 @@
     Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word LinkedHashMap_data_offset = 32;
 static constexpr dart::compiler::target::word
@@ -6581,8 +6581,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 16;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 20;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     20;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -6593,8 +6591,10 @@
     AOT_Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    44;
+    40;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     16;
@@ -7175,8 +7175,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -7187,8 +7185,10 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    88;
+    80;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -7775,8 +7775,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -7787,8 +7785,10 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    88;
+    80;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -8373,8 +8373,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -8385,8 +8383,10 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    88;
+    80;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -8970,8 +8970,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -8982,8 +8980,10 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_single_step_offset =
-    88;
+    80;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -9567,8 +9567,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 16;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 20;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 36;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     20;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -9579,6 +9577,8 @@
     AOT_Isolate_cached_object_store_offset = 32;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 8;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 16;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 16;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     16;
@@ -10154,8 +10154,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -10166,6 +10164,8 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -10747,8 +10747,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -10759,6 +10757,8 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -11338,8 +11338,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -11350,6 +11348,8 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
@@ -11928,8 +11928,6 @@
 static constexpr dart::compiler::target::word AOT_ICData_owner_offset = 32;
 static constexpr dart::compiler::target::word AOT_ICData_state_bits_offset = 40;
 static constexpr dart::compiler::target::word AOT_Int32x4_value_offset = 8;
-static constexpr dart::compiler::target::word
-    AOT_Isolate_cached_class_table_table_offset = 72;
 static constexpr dart::compiler::target::word AOT_Isolate_current_tag_offset =
     40;
 static constexpr dart::compiler::target::word AOT_Isolate_default_tag_offset =
@@ -11940,6 +11938,8 @@
     AOT_Isolate_cached_object_store_offset = 64;
 static constexpr dart::compiler::target::word
     AOT_IsolateGroup_shared_class_table_offset = 16;
+static constexpr dart::compiler::target::word
+    AOT_IsolateGroup_cached_class_table_table_offset = 32;
 static constexpr dart::compiler::target::word AOT_Isolate_user_tag_offset = 32;
 static constexpr dart::compiler::target::word AOT_LinkedHashMap_data_offset =
     32;
diff --git a/runtime/vm/compiler/runtime_offsets_list.h b/runtime/vm/compiler/runtime_offsets_list.h
index 73a9fa5..3a0da0f 100644
--- a/runtime/vm/compiler/runtime_offsets_list.h
+++ b/runtime/vm/compiler/runtime_offsets_list.h
@@ -127,12 +127,12 @@
   FIELD(ICData, owner_offset)                                                  \
   FIELD(ICData, state_bits_offset)                                             \
   FIELD(Int32x4, value_offset)                                                 \
-  FIELD(Isolate, cached_class_table_table_offset)                              \
   FIELD(Isolate, current_tag_offset)                                           \
   FIELD(Isolate, default_tag_offset)                                           \
   FIELD(Isolate, ic_miss_code_offset)                                          \
   FIELD(Isolate, cached_object_store_offset)                                   \
   FIELD(IsolateGroup, shared_class_table_offset)                               \
+  FIELD(IsolateGroup, cached_class_table_table_offset)                         \
   NOT_IN_PRODUCT(FIELD(Isolate, single_step_offset))                           \
   FIELD(Isolate, user_tag_offset)                                              \
   FIELD(LinkedHashMap, data_offset)                                            \
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 0e06e44..f781823 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -333,6 +333,8 @@
                            ObjectStore* object_store,
                            Dart_IsolateFlags api_flags)
     : shared_class_table_(new SharedClassTable()),
+      class_table_(new ClassTable(shared_class_table_.get())),
+      cached_class_table_table_(class_table_->table()),
       embedder_data_(embedder_data),
       thread_pool_(),
       isolates_lock_(new SafepointRwLock()),
@@ -349,7 +351,6 @@
       thread_registry_(new ThreadRegistry()),
       safepoint_handler_(new SafepointHandler(this)),
       object_store_(object_store),
-      class_table_(new ClassTable(shared_class_table_.get())),
       store_buffer_(new StoreBuffer()),
       heap_(nullptr),
       saved_unlinked_calls_(Array::null()),
@@ -890,17 +891,17 @@
   state->FreePersistentHandle(handle_);
 }
 
-void Isolate::RegisterClass(const Class& cls) {
+void IsolateGroup::RegisterClass(const Class& cls) {
 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
-  if (group()->IsReloading()) {
-    group()->program_reload_context()->RegisterClass(cls);
+  if (IsReloading()) {
+    program_reload_context()->RegisterClass(cls);
     return;
   }
 #endif  // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
   if (cls.IsTopLevel()) {
-    group()->class_table()->RegisterTopLevel(cls);
+    class_table()->RegisterTopLevel(cls);
   } else {
-    group()->class_table()->Register(cls);
+    class_table()->Register(cls);
   }
 }
 
@@ -1712,7 +1713,6 @@
       isolate_object_store_(
           new IsolateObjectStore(isolate_group->object_store())),
       object_store_shared_ptr_(isolate_group->object_store_shared_ptr()),
-      class_table_(isolate_group->class_table_shared_ptr()),
 #if !defined(DART_PRECOMPILED_RUNTIME)
       native_callback_trampolines_(),
 #endif
@@ -1739,7 +1739,6 @@
       catch_entry_moves_cache_(),
       loaded_prefixes_set_storage_(nullptr) {
   cached_object_store_ = object_store_shared_ptr_.get();
-  cached_class_table_table_ = group()->class_table_->table();
   FlagsCopyFrom(api_flags);
   SetErrorsFatal(true);
   // TODO(asiva): A Thread is not available here, need to figure out
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 2c7e484..809af6a 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -438,6 +438,18 @@
     return OFFSET_OF(IsolateGroup, shared_class_table_);
   }
 
+  ClassPtr* cached_class_table_table() {
+    return cached_class_table_table_.load();
+  }
+  void set_cached_class_table_table(ClassPtr* cached_class_table_table) {
+    cached_class_table_table_.store(cached_class_table_table);
+  }
+  static intptr_t cached_class_table_table_offset() {
+    COMPILE_ASSERT(sizeof(IsolateGroup::cached_class_table_table_) ==
+                   kWordSize);
+    return OFFSET_OF(IsolateGroup, cached_class_table_table_);
+  }
+
   void set_obfuscation_map(const char** map) { obfuscation_map_ = map; }
   const char** obfuscation_map() const { return obfuscation_map_; }
 
@@ -769,6 +781,7 @@
 
   MutatorThreadPool* thread_pool() { return thread_pool_.get(); }
 
+  void RegisterClass(const Class& cls);
   void RegisterStaticField(const Field& field, const Instance& initial_value);
   void FreeStaticField(const Field& field);
 
@@ -820,15 +833,14 @@
 
   void set_heap(std::unique_ptr<Heap> value);
 
-  const std::shared_ptr<ClassTable>& class_table_shared_ptr() const {
-    return class_table_;
-  }
   const std::shared_ptr<ObjectStore>& object_store_shared_ptr() const {
     return object_store_;
   }
 
   // Accessed from generated code.
   std::unique_ptr<SharedClassTable> shared_class_table_;
+  std::unique_ptr<ClassTable> class_table_;
+  AcqRelAtomic<ClassPtr*> cached_class_table_table_;
   // End accessed from generated code.
 
   const char** obfuscation_map_ = nullptr;
@@ -884,7 +896,6 @@
   uint64_t id_ = 0;
 
   std::shared_ptr<ObjectStore> object_store_;
-  std::shared_ptr<ClassTable> class_table_;
   std::unique_ptr<StoreBuffer> store_buffer_;
   std::unique_ptr<Heap> heap_;
   std::unique_ptr<DispatchTable> dispatch_table_;
@@ -987,23 +998,12 @@
   bool IsScheduled() { return scheduled_mutator_thread() != nullptr; }
   Thread* scheduled_mutator_thread() const { return scheduled_mutator_thread_; }
 
-  // Register a newly introduced class.
-  void RegisterClass(const Class& cls);
-
   ThreadRegistry* thread_registry() const { return group()->thread_registry(); }
 
   SafepointHandler* safepoint_handler() const {
     return group()->safepoint_handler();
   }
 
-  ClassPtr* cached_class_table_table() { return cached_class_table_table_; }
-  void set_cached_class_table_table(ClassPtr* cached_class_table_table) {
-    cached_class_table_table_ = cached_class_table_table;
-  }
-  static intptr_t cached_class_table_table_offset() {
-    return OFFSET_OF(Isolate, cached_class_table_table_);
-  }
-
   void set_object_store(ObjectStore* object_store);
   static intptr_t cached_object_store_offset() {
     return OFFSET_OF(Isolate, cached_object_store_);
@@ -1539,8 +1539,6 @@
   CodePtr ic_miss_code_;
   // Cached value of object_store_shared_ptr_, here for generated code access
   ObjectStore* cached_object_store_ = nullptr;
-  // Cached value of class_table_->table_, here for generated code access
-  ClassPtr* cached_class_table_table_ = nullptr;
   FieldTable* field_table_ = nullptr;
   bool single_step_ = false;
   bool is_system_isolate_ = false;
@@ -1551,8 +1549,6 @@
   std::unique_ptr<IsolateObjectStore> isolate_object_store_;
   // shared in AOT(same pointer as on IsolateGroup), not shared in JIT
   std::shared_ptr<ObjectStore> object_store_shared_ptr_;
-  // shared in AOT(same pointer as on IsolateGroup), not shared in JIT
-  std::shared_ptr<ClassTable> class_table_;
 
 #if !defined(DART_PRECOMPILED_RUNTIME)
   NativeCallbackTrampolines native_callback_trampolines_;
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index df33cd1..33ac31c 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -4509,7 +4509,7 @@
   result.set_instance_size_in_words(0, 0);
 
   if (register_class) {
-    Isolate::Current()->RegisterClass(result);
+    IsolateGroup::Current()->RegisterClass(result);
   }
   return result.ptr();
 }