[vm] Add missing logical edges from instances to their class and from types to their type class.

If all other edges to these objects are removed, v8_snapshot_profile_writer_test will complain they appear to be unreachable.

TEST=ci
Change-Id: I291fa285f5c0f9578fad574263d9311adf4c8818
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245203
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc
index c718234..2b20b44 100644
--- a/runtime/vm/app_snapshot.cc
+++ b/runtime/vm/app_snapshot.cc
@@ -3828,6 +3828,12 @@
     for (intptr_t i = 0; i < count; i++) {
       InstancePtr instance = objects_[i];
       AutoTraceObject(instance);
+#if defined(DART_PRECOMPILER)
+      if (FLAG_write_v8_snapshot_profile_to != nullptr) {
+        ClassPtr cls = s->isolate_group()->class_table()->At(cid_);
+        s->AttributePropertyRef(cls, "<class>");
+      }
+#endif
       intptr_t offset = Instance::NextFieldOffset();
       while (offset < next_field_offset) {
         if (unboxed_fields_bitmap.Get(offset / kCompressedWordSize)) {
@@ -4084,6 +4090,13 @@
 
   void WriteType(Serializer* s, TypePtr type) {
     AutoTraceObject(type);
+#if defined(DART_PRECOMPILER)
+    if (FLAG_write_v8_snapshot_profile_to != nullptr) {
+      ClassPtr type_class =
+          s->isolate_group()->class_table()->At(type->untag()->type_class_id_);
+      s->AttributePropertyRef(type_class, "<type_class>");
+    }
+#endif
     WriteFromTo(type);
     COMPILE_ASSERT(
         std::is_unsigned<decltype(UntaggedType::type_class_id_)>::value);