[vm/concurrency] Lazily populate various members of ObjectStore under lock

Fixes https://github.com/dart-lang/sdk/issues/46638

TEST=Fixes flaky TSAN data race on iso-stress builder

Change-Id: I992e73d155c42b2fc2d1fc17d6e02d589c8334c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207127
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index b289ca1..d983c2c 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -5581,6 +5581,7 @@
     OBJECT_STORE_FIELD_LIST(DECLARE_OBJECT_STORE_FIELD,
                             DECLARE_OBJECT_STORE_FIELD,
                             DECLARE_OBJECT_STORE_FIELD,
+                            DECLARE_OBJECT_STORE_FIELD,
                             DECLARE_OBJECT_STORE_FIELD)
 #undef DECLARE_OBJECT_STORE_FIELD
 };
diff --git a/runtime/vm/compiler/runtime_offsets_extracted.h b/runtime/vm/compiler/runtime_offsets_extracted.h
index b038391..075622e 100644
--- a/runtime/vm/compiler/runtime_offsets_extracted.h
+++ b/runtime/vm/compiler/runtime_offsets_extracted.h
@@ -220,11 +220,11 @@
     12;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    128;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 68;
+    176;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 116;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    156;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 48;
+    204;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 4;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
@@ -762,11 +762,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -1309,11 +1310,11 @@
     12;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    128;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 68;
+    176;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 116;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    156;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 48;
+    204;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 4;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
@@ -1848,11 +1849,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -2396,11 +2398,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -2943,11 +2946,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -3487,11 +3491,11 @@
     12;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    128;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 68;
+    176;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 116;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    156;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 48;
+    204;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 4;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
@@ -4023,11 +4027,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -4564,11 +4569,11 @@
     12;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    128;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 68;
+    176;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 116;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    156;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 48;
+    204;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 12;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 4;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset = 8;
@@ -5097,11 +5102,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -5639,11 +5645,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -6180,11 +6187,12 @@
     24;
 static constexpr dart::compiler::target::word NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word ObjectStore_double_type_offset =
-    256;
-static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 136;
+    352;
+static constexpr dart::compiler::target::word ObjectStore_int_type_offset = 232;
 static constexpr dart::compiler::target::word ObjectStore_string_type_offset =
-    312;
-static constexpr dart::compiler::target::word ObjectStore_type_type_offset = 96;
+    408;
+static constexpr dart::compiler::target::word ObjectStore_type_type_offset =
+    192;
 static constexpr dart::compiler::target::word OneByteString_data_offset = 16;
 static constexpr dart::compiler::target::word PointerBase_data_field_offset = 8;
 static constexpr dart::compiler::target::word Pointer_type_arguments_offset =
@@ -6753,13 +6761,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 128;
+    AOT_ObjectStore_double_type_offset = 176;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    68;
+    116;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 156;
+    AOT_ObjectStore_string_type_offset = 204;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    48;
+    96;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     12;
 static constexpr dart::compiler::target::word
@@ -7360,13 +7368,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -7973,13 +7981,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -8583,13 +8591,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -9192,13 +9200,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -9797,13 +9805,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 128;
+    AOT_ObjectStore_double_type_offset = 176;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    68;
+    116;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 156;
+    AOT_ObjectStore_string_type_offset = 204;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    48;
+    96;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     12;
 static constexpr dart::compiler::target::word
@@ -10397,13 +10405,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -11003,13 +11011,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -11606,13 +11614,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
@@ -12208,13 +12216,13 @@
 static constexpr dart::compiler::target::word
     AOT_NativeArguments_thread_offset = 0;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_double_type_offset = 256;
+    AOT_ObjectStore_double_type_offset = 352;
 static constexpr dart::compiler::target::word AOT_ObjectStore_int_type_offset =
-    136;
+    232;
 static constexpr dart::compiler::target::word
-    AOT_ObjectStore_string_type_offset = 312;
+    AOT_ObjectStore_string_type_offset = 408;
 static constexpr dart::compiler::target::word AOT_ObjectStore_type_type_offset =
-    96;
+    192;
 static constexpr dart::compiler::target::word AOT_OneByteString_data_offset =
     16;
 static constexpr dart::compiler::target::word
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index 560a73f..f062909 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -633,17 +633,10 @@
 ObjectPtr DartLibraryCalls::ToString(const Instance& receiver) {
   Thread* thread = Thread::Current();
   Zone* zone = thread->zone();
-  Function& function = Function::Handle(
+  const auto& function = Function::Handle(
       zone,
       thread->isolate_group()->object_store()->_object_to_string_function());
-  if (function.IsNull()) {
-    const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
-    ASSERT(!core_lib.IsNull());
-    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectToString());
-    ASSERT(!function.IsNull());
-    thread->isolate_group()->object_store()->set__object_to_string_function(
-        function);
-  }
+  ASSERT(!function.IsNull());
   const int kNumArguments = 1;
   const Array& args = Array::Handle(zone, Array::New(kNumArguments));
   args.SetAt(0, receiver);
@@ -656,17 +649,10 @@
 ObjectPtr DartLibraryCalls::HashCode(const Instance& receiver) {
   Thread* thread = Thread::Current();
   Zone* zone = thread->zone();
-  Function& function = Function::Handle(
+  const auto& function = Function::Handle(
       zone,
       thread->isolate_group()->object_store()->_object_hash_code_function());
-  if (function.IsNull()) {
-    const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
-    ASSERT(!core_lib.IsNull());
-    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectHashCode());
-    ASSERT(!function.IsNull());
-    thread->isolate_group()->object_store()->set__object_hash_code_function(
-        function);
-  }
+  ASSERT(!function.IsNull());
   const int kNumArguments = 1;
   const Array& args = Array::Handle(zone, Array::New(kNumArguments));
   args.SetAt(0, receiver);
@@ -680,16 +666,9 @@
                                    const Instance& right) {
   Thread* thread = Thread::Current();
   Zone* zone = thread->zone();
-  Function& function = Function::Handle(
+  const auto& function = Function::Handle(
       zone, thread->isolate_group()->object_store()->_object_equals_function());
-  if (function.IsNull()) {
-    const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
-    ASSERT(!core_lib.IsNull());
-    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectEquals());
-    ASSERT(!function.IsNull());
-    thread->isolate_group()->object_store()->set__object_equals_function(
-        function);
-  }
+  ASSERT(!function.IsNull());
   const int kNumArguments = 2;
   const Array& args = Array::Handle(zone, Array::New(kNumArguments));
   args.SetAt(0, left);
@@ -721,23 +700,10 @@
 ObjectPtr DartLibraryCalls::LookupHandler(Dart_Port port_id) {
   Thread* thread = Thread::Current();
   Zone* zone = thread->zone();
-  Function& function = Function::Handle(
+  const auto& function = Function::Handle(
       zone, thread->isolate_group()->object_store()->lookup_port_handler());
-  const int kTypeArgsLen = 0;
   const int kNumArguments = 1;
-  if (function.IsNull()) {
-    Library& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
-    ASSERT(!isolate_lib.IsNull());
-    const String& class_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
-    const String& function_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_lookupHandler()));
-    function = Resolver::ResolveStatic(isolate_lib, class_name, function_name,
-                                       kTypeArgsLen, kNumArguments,
-                                       Object::empty_array());
-    ASSERT(!function.IsNull());
-    thread->isolate_group()->object_store()->set_lookup_port_handler(function);
-  }
+  ASSERT(!function.IsNull());
   Array& args = Array::Handle(
       zone, thread->isolate()->isolate_object_store()->dart_args_1());
   if (args.IsNull()) {
@@ -755,21 +721,7 @@
   Zone* zone = thread->zone();
   Function& function = Function::Handle(
       zone, thread->isolate_group()->object_store()->lookup_open_ports());
-  const int kTypeArgsLen = 0;
-  const int kNumArguments = 0;
-  if (function.IsNull()) {
-    Library& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
-    ASSERT(!isolate_lib.IsNull());
-    const String& class_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
-    const String& function_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_lookupOpenPorts()));
-    function = Resolver::ResolveStatic(isolate_lib, class_name, function_name,
-                                       kTypeArgsLen, kNumArguments,
-                                       Object::empty_array());
-    ASSERT(!function.IsNull());
-    thread->isolate_group()->object_store()->set_lookup_open_ports(function);
-  }
+  ASSERT(!function.IsNull());
   const Object& result = Object::Handle(
       zone, DartEntry::InvokeFunction(function, Object::empty_array()));
   return result.ptr();
@@ -781,23 +733,10 @@
   auto zone = thread->zone();
   auto isolate = thread->isolate();
   auto object_store = thread->isolate_group()->object_store();
-  Function& function =
+  const auto& function =
       Function::Handle(zone, object_store->handle_message_function());
-  const int kTypeArgsLen = 0;
   const int kNumArguments = 2;
-  if (function.IsNull()) {
-    Library& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
-    ASSERT(!isolate_lib.IsNull());
-    const String& class_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_RawReceivePortImpl()));
-    const String& function_name = String::Handle(
-        zone, isolate_lib.PrivateName(Symbols::_handleMessage()));
-    function = Resolver::ResolveStatic(isolate_lib, class_name, function_name,
-                                       kTypeArgsLen, kNumArguments,
-                                       Object::empty_array());
-    ASSERT(!function.IsNull());
-    object_store->set_handle_message_function(function);
-  }
+  ASSERT(!function.IsNull());
   Array& args =
       Array::Handle(zone, isolate->isolate_object_store()->dart_args_2());
   if (args.IsNull()) {
diff --git a/runtime/vm/object_store.cc b/runtime/vm/object_store.cc
index b3decbb..5f947b7 100644
--- a/runtime/vm/object_store.cc
+++ b/runtime/vm/object_store.cc
@@ -122,7 +122,8 @@
     static const char* const names[] = {
 #define EMIT_FIELD_NAME(type, name) #name "_",
         OBJECT_STORE_FIELD_LIST(EMIT_FIELD_NAME, EMIT_FIELD_NAME,
-                                EMIT_FIELD_NAME, EMIT_FIELD_NAME)
+                                EMIT_FIELD_NAME, EMIT_FIELD_NAME,
+                                EMIT_FIELD_NAME)
 #undef EMIT_FIELD_NAME
     };
     ObjectPtr* current = from();
@@ -336,13 +337,16 @@
 #endif
 }
 
-void ObjectStore::LazyInitCoreTypes() {
+void ObjectStore::LazyInitCoreMembers() {
   auto* const thread = Thread::Current();
   SafepointWriteRwLocker locker(thread,
                                 thread->isolate_group()->program_lock());
   if (list_class_.load() == Type::null()) {
     ASSERT(non_nullable_list_rare_type_.load() == Type::null());
     ASSERT(non_nullable_map_rare_type_.load() == Type::null());
+    ASSERT(_object_equals_function_.load() == Function::null());
+    ASSERT(_object_hash_code_function_.load() == Function::null());
+    ASSERT(_object_to_string_function_.load() == Function::null());
 
     auto* const zone = thread->zone();
     const auto& core_lib = Library::Handle(zone, Library::CoreLibrary());
@@ -360,10 +364,24 @@
     ASSERT(!cls.IsNull());
     type ^= cls.RareType();
     non_nullable_map_rare_type_.store(type.ptr());
+
+    auto& function = Function::Handle(zone);
+
+    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectHashCode());
+    ASSERT(!function.IsNull());
+    _object_hash_code_function_.store(function.ptr());
+
+    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectEquals());
+    ASSERT(!function.IsNull());
+    _object_equals_function_.store(function.ptr());
+
+    function = core_lib.LookupFunctionAllowPrivate(Symbols::_objectToString());
+    ASSERT(!function.IsNull());
+    _object_to_string_function_.store(function.ptr());
   }
 }
 
-void ObjectStore::LazyInitFutureTypes() {
+void ObjectStore::LazyInitAsyncMembers() {
   auto* const thread = Thread::Current();
   SafepointWriteRwLocker locker(thread,
                                 thread->isolate_group()->program_lock());
@@ -400,4 +418,36 @@
   }
 }
 
+void ObjectStore::LazyInitIsolateMembers() {
+  auto* const thread = Thread::Current();
+  SafepointWriteRwLocker locker(thread,
+                                thread->isolate_group()->program_lock());
+  if (lookup_port_handler_.load() == Type::null()) {
+    ASSERT(lookup_open_ports_.load() == Type::null());
+    ASSERT(handle_message_function_.load() == Type::null());
+
+    auto* const zone = thread->zone();
+    const auto& isolate_lib = Library::Handle(zone, Library::IsolateLibrary());
+    auto& cls = Class::Handle(zone);
+    auto& function = Function::Handle(zone);
+
+    cls = isolate_lib.LookupClassAllowPrivate(Symbols::_RawReceivePortImpl());
+    ASSERT(!cls.IsNull());
+    const auto& error = cls.EnsureIsFinalized(thread);
+    ASSERT(error == Error::null());
+
+    function = cls.LookupFunctionAllowPrivate(Symbols::_lookupHandler());
+    ASSERT(!function.IsNull());
+    lookup_port_handler_.store(function.ptr());
+
+    function = cls.LookupFunctionAllowPrivate(Symbols::_lookupOpenPorts());
+    ASSERT(!function.IsNull());
+    lookup_open_ports_.store(function.ptr());
+
+    function = cls.LookupFunctionAllowPrivate(Symbols::_handleMessage());
+    ASSERT(!function.IsNull());
+    handle_message_function_.store(function.ptr());
+  }
+}
+
 }  // namespace dart
diff --git a/runtime/vm/object_store.h b/runtime/vm/object_store.h
index f28fa99..404f142 100644
--- a/runtime/vm/object_store.h
+++ b/runtime/vm/object_store.h
@@ -37,8 +37,21 @@
 // R_ - needs getter only
 // RW - needs getter and setter
 // CR - needs lazy Core init getter
-// FR - needs lazy Future init getter
-#define OBJECT_STORE_FIELD_LIST(R_, RW, CR, FR)                                \
+// FR - needs lazy Async init getter
+// IR - needs lazy Isolate init getter
+#define OBJECT_STORE_FIELD_LIST(R_, RW, CR, FR, IR)                            \
+  CR(Class, list_class)                    /* maybe be null, lazily built */   \
+  CR(Type, non_nullable_list_rare_type)    /* maybe be null, lazily built */   \
+  CR(Type, non_nullable_map_rare_type)     /* maybe be null, lazily built */   \
+  CR(Function, _object_equals_function)    /* maybe be null, lazily built */   \
+  CR(Function, _object_hash_code_function) /* maybe be null, lazily built */   \
+  CR(Function, _object_to_string_function) /* maybe be null, lazily built */   \
+  FR(Type, non_nullable_future_rare_type)  /* maybe be null, lazily built */   \
+  FR(Type, non_nullable_future_never_type) /* maybe be null, lazily built */   \
+  FR(Type, nullable_future_null_type)      /* maybe be null, lazily built */   \
+  IR(Function, lookup_port_handler)        /* maybe be null, lazily built */   \
+  IR(Function, lookup_open_ports)          /* maybe be null, lazily built */   \
+  IR(Function, handle_message_function)    /* maybe be null, lazily built */   \
   RW(Class, object_class)                                                      \
   RW(Type, object_type)                                                        \
   RW(Type, legacy_object_type)                                                 \
@@ -81,12 +94,6 @@
   RW(Type, string_type)                                                        \
   RW(Type, legacy_string_type)                                                 \
   RW(Type, non_nullable_string_type)                                           \
-  CR(Class, list_class)                    /* maybe be null, lazily built */   \
-  CR(Type, non_nullable_list_rare_type)    /* maybe be null, lazily built */   \
-  CR(Type, non_nullable_map_rare_type)     /* maybe be null, lazily built */   \
-  FR(Type, non_nullable_future_rare_type)  /* maybe be null, lazily built */   \
-  FR(Type, non_nullable_future_never_type) /* maybe be null, lazily built */   \
-  FR(Type, nullable_future_null_type)      /* maybe be null, lazily built */   \
   RW(TypeArguments, type_argument_int)                                         \
   RW(TypeArguments, type_argument_legacy_int)                                  \
   RW(TypeArguments, type_argument_non_nullable_int)                            \
@@ -158,12 +165,6 @@
   RW(GrowableObjectArray, pending_classes)                                     \
   RW(Instance, stack_overflow)                                                 \
   RW(Instance, out_of_memory)                                                  \
-  RW(Function, _object_equals_function)                                        \
-  RW(Function, _object_hash_code_function)                                     \
-  RW(Function, _object_to_string_function)                                     \
-  RW(Function, lookup_port_handler)                                            \
-  RW(Function, lookup_open_ports)                                              \
-  RW(Function, handle_message_function)                                        \
   RW(Function, growable_list_factory)                                          \
   RW(Function, simple_instance_of_function)                                    \
   RW(Function, simple_instance_of_true_function)                               \
@@ -403,18 +404,22 @@
   }                                                                            \
   static intptr_t name##_offset() { return OFFSET_OF(ObjectStore, name##_); }
 #define DECLARE_LAZY_INIT_CORE_GETTER(Type, name)                              \
-  DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitCoreTypes)
-#define DECLARE_LAZY_INIT_FUTURE_GETTER(Type, name)                            \
-  DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitFutureTypes)
+  DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitCoreMembers)
+#define DECLARE_LAZY_INIT_ASYNC_GETTER(Type, name)                             \
+  DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitAsyncMembers)
+#define DECLARE_LAZY_INIT_ISOLATE_GETTER(Type, name)                           \
+  DECLARE_LAZY_INIT_GETTER(Type, name, LazyInitIsolateMembers)
   OBJECT_STORE_FIELD_LIST(DECLARE_GETTER,
                           DECLARE_GETTER_AND_SETTER,
                           DECLARE_LAZY_INIT_CORE_GETTER,
-                          DECLARE_LAZY_INIT_FUTURE_GETTER)
+                          DECLARE_LAZY_INIT_ASYNC_GETTER,
+                          DECLARE_LAZY_INIT_ISOLATE_GETTER)
 #undef DECLARE_GETTER
 #undef DECLARE_GETTER_AND_SETTER
 #undef DECLARE_LAZY_INIT_GETTER
 #undef DECLARE_LAZY_INIT_CORE_GETTER
-#undef DECLARE_LAZY_INIT_FUTURE_GETTER
+#undef DECLARE_LAZY_INIT_ASYNC_GETTER
+#undef DECLARE_LAZY_INIT_ISOLATE_GETTER
 
   LibraryPtr bootstrap_library(BootstrapLibraryId index) {
     switch (index) {
@@ -462,19 +467,21 @@
 #endif
 
  private:
-  void LazyInitCoreTypes();
-  void LazyInitFutureTypes();
+  void LazyInitCoreMembers();
+  void LazyInitAsyncMembers();
+  void LazyInitIsolateMembers();
 
   // Finds a core library private method in Object.
   FunctionPtr PrivateObjectLookup(const String& name);
 
-  ObjectPtr* from() { return reinterpret_cast<ObjectPtr*>(&object_class_); }
+  ObjectPtr* from() { return reinterpret_cast<ObjectPtr*>(&list_class_); }
 #define DECLARE_OBJECT_STORE_FIELD(type, name) type##Ptr name##_;
 #define DECLARE_LAZY_OBJECT_STORE_FIELD(type, name)                            \
   AcqRelAtomic<type##Ptr> name##_;
   OBJECT_STORE_FIELD_LIST(DECLARE_OBJECT_STORE_FIELD,
                           DECLARE_OBJECT_STORE_FIELD,
                           DECLARE_LAZY_OBJECT_STORE_FIELD,
+                          DECLARE_LAZY_OBJECT_STORE_FIELD,
                           DECLARE_LAZY_OBJECT_STORE_FIELD)
 #undef DECLARE_LAZY_OBJECT_STORE_FIELD
 #undef DECLARE_OBJECT_STORE_FIELD