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 00000000000..68fc8f42ded --- /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 00000000000..95ec623d873 --- /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 00000000000..5257140e8c5 --- /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 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, [ + '--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, [ + '--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 b0bd293e908..5de7084acfe 100644 --- a/runtime/vm/app_snapshot.cc +++ b/runtime/vm/app_snapshot.cc @@ -7765,6 +7765,11 @@ bool Serializer::CreateArtificialNodeIfNeeded(ObjectPtr obj) { 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); }