[vm] Fix v8 snapshot profile issue with deferred libaries.

TEST=vm/dart/regress_flutter169921

Issue: https://github.com/flutter/flutter/issues/169921
Change-Id: I9a996dcc1213712e6545cf134b436d60ea76b71d
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453881
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
diff --git a/runtime/tests/vm/dart/regress_flutter169921_deferred.dart b/runtime/tests/vm/dart/regress_flutter169921_deferred.dart
new file mode 100644
index 0000000..68fc8f4
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_flutter169921_deferred.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2025, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Deferred library used by regress_flutter169921_program.dart.
+
+@pragma('vm:never-inline')
+Object? foo(int v) {
+  // Avoid unboxing on return by mixing int and String
+  return v == 0 ? 0x8FFFFFFFFFFFFFFF : "";
+}
diff --git a/runtime/tests/vm/dart/regress_flutter169921_program.dart b/runtime/tests/vm/dart/regress_flutter169921_program.dart
new file mode 100644
index 0000000..95ec623
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_flutter169921_program.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2025, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Program used by regress_flutter169921_test.dart.
+
+import 'regress_flutter169921_deferred.dart' deferred as d;
+
+void main() async {
+  d.loadLibrary();
+  print(d.foo(0));
+  print(d.foo(1));
+}
diff --git a/runtime/tests/vm/dart/regress_flutter169921_test.dart b/runtime/tests/vm/dart/regress_flutter169921_test.dart
new file mode 100644
index 0000000..5257140
--- /dev/null
+++ b/runtime/tests/vm/dart/regress_flutter169921_test.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2025, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://github.com/flutter/flutter/issues/169921.
+
+// OtherResources=regress_flutter169921_program.dart
+// OtherResources=regress_flutter169921_deferred.dart
+
+import "dart:io";
+
+import 'package:expect/expect.dart';
+import 'package:path/path.dart' as path;
+
+import 'use_flag_test_helper.dart';
+
+main(List<String> args) async {
+  if (!isAOTRuntime) {
+    return; // Running in JIT: AOT binaries not available.
+  }
+
+  if (Platform.isAndroid) {
+    return; // SDK tree not available on the test device.
+  }
+
+  // These are the tools we need to be available to run on a given platform:
+  if (!File(platformDill).existsSync()) {
+    throw "Cannot run test as $platformDill does not exist";
+  }
+  if (!await testExecutable(genSnapshot)) {
+    throw "Cannot run test as $genSnapshot not available";
+  }
+
+  await withTempDir('regress_flutter169921_test', (String tempDir) async {
+    final cwDir = path.dirname(Platform.script.toFilePath());
+    final script = path.join(cwDir, 'regress_flutter169921_program.dart');
+    final scriptDill = path.join(tempDir, 'regress_flutter169921_program.dill');
+
+    await run(genKernel, <String>[
+      '--aot',
+      '--platform=$platformDill',
+      '-o',
+      scriptDill,
+      script,
+    ]);
+
+    final manifest = path.join(tempDir, 'manifest.json');
+    final profile = path.join(tempDir, 'profile.json');
+    final snapshot = path.join(tempDir, 'snapshot.so');
+    await run(genSnapshot, <String>[
+      '--snapshot-kind=app-aot-elf',
+      '--elf=$snapshot',
+      '--loading-unit-manifest=$manifest',
+      '--write-v8-snapshot-profile-to=$profile',
+      scriptDill,
+    ]);
+
+    await runError(dartPrecompiledRuntime, [snapshot], printStderr: true);
+  });
+}
diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc
index b0bd293..5de7084 100644
--- a/runtime/vm/app_snapshot.cc
+++ b/runtime/vm/app_snapshot.cc
@@ -7765,6 +7765,11 @@
       type = "RecordType";
       break;
     };
+    // Can appear in weakened constant hash tables.
+    case kMintCid: {
+      type = "Mint";
+      break;
+    }
     default:
       FATAL("Request to create artificial node for object with cid %d", cid);
   }