Skip to content

Commit 5b69fdd

Browse files
sstricklCommit Queue
authored andcommitted
[vm] Fix v8 snapshot profile issue with deferred libaries.
TEST=vm/dart/regress_flutter169921 Issue: flutter/flutter#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 <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 505f08b commit 5b69fdd

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Deferred library used by regress_flutter169921_program.dart.
6+
7+
@pragma('vm:never-inline')
8+
Object? foo(int v) {
9+
// Avoid unboxing on return by mixing int and String
10+
return v == 0 ? 0x8FFFFFFFFFFFFFFF : "";
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Program used by regress_flutter169921_test.dart.
6+
7+
import 'regress_flutter169921_deferred.dart' deferred as d;
8+
9+
void main() async {
10+
d.loadLibrary();
11+
print(d.foo(0));
12+
print(d.foo(1));
13+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for https://github.com/flutter/flutter/issues/169921.
6+
7+
// OtherResources=regress_flutter169921_program.dart
8+
// OtherResources=regress_flutter169921_deferred.dart
9+
10+
import "dart:io";
11+
12+
import 'package:expect/expect.dart';
13+
import 'package:path/path.dart' as path;
14+
15+
import 'use_flag_test_helper.dart';
16+
17+
main(List<String> args) async {
18+
if (!isAOTRuntime) {
19+
return; // Running in JIT: AOT binaries not available.
20+
}
21+
22+
if (Platform.isAndroid) {
23+
return; // SDK tree not available on the test device.
24+
}
25+
26+
// These are the tools we need to be available to run on a given platform:
27+
if (!File(platformDill).existsSync()) {
28+
throw "Cannot run test as $platformDill does not exist";
29+
}
30+
if (!await testExecutable(genSnapshot)) {
31+
throw "Cannot run test as $genSnapshot not available";
32+
}
33+
34+
await withTempDir('regress_flutter169921_test', (String tempDir) async {
35+
final cwDir = path.dirname(Platform.script.toFilePath());
36+
final script = path.join(cwDir, 'regress_flutter169921_program.dart');
37+
final scriptDill = path.join(tempDir, 'regress_flutter169921_program.dill');
38+
39+
await run(genKernel, <String>[
40+
'--aot',
41+
'--platform=$platformDill',
42+
'-o',
43+
scriptDill,
44+
script,
45+
]);
46+
47+
final manifest = path.join(tempDir, 'manifest.json');
48+
final profile = path.join(tempDir, 'profile.json');
49+
final snapshot = path.join(tempDir, 'snapshot.so');
50+
await run(genSnapshot, <String>[
51+
'--snapshot-kind=app-aot-elf',
52+
'--elf=$snapshot',
53+
'--loading-unit-manifest=$manifest',
54+
'--write-v8-snapshot-profile-to=$profile',
55+
scriptDill,
56+
]);
57+
58+
await runError(dartPrecompiledRuntime, [snapshot], printStderr: true);
59+
});
60+
}

runtime/vm/app_snapshot.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7765,6 +7765,11 @@ bool Serializer::CreateArtificialNodeIfNeeded(ObjectPtr obj) {
77657765
type = "RecordType";
77667766
break;
77677767
};
7768+
// Can appear in weakened constant hash tables.
7769+
case kMintCid: {
7770+
type = "Mint";
7771+
break;
7772+
}
77687773
default:
77697774
FATAL("Request to create artificial node for object with cid %d", cid);
77707775
}

0 commit comments

Comments
 (0)