Skip to content

Commit 88fdb3e

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
Add tests for the identity of constants repeated in different loading units but not present in the main unit.
Bug: #41974 Change-Id: I29a00aa6139dc2a1f865f8c5f659169c84c8e45d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169790 Reviewed-by: Régis Crelier <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent d0db3b1 commit 88fdb3e

14 files changed

+536
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_a_1.dart" deferred as a_1;
6+
import "split_constants_canonicalization_a_2.dart" deferred as a_2;
7+
8+
loadChildren() async {
9+
await a_1.loadLibrary();
10+
await a_2.loadLibrary();
11+
}
12+
13+
a_1_mint() => a_1.mint();
14+
a_1_string() => a_1.string();
15+
a_1_list() => a_1.list();
16+
a_1_map() => a_1.map();
17+
a_1_box() => a_1.box();
18+
a_1_enum() => a_1.enumm();
19+
a_1_type() => a_1.type();
20+
a_1_closure() => a_1.closure();
21+
22+
a_2_mint() => a_2.mint();
23+
a_2_string() => a_2.string();
24+
a_2_list() => a_2.list();
25+
a_2_map() => a_2.map();
26+
a_2_box() => a_2.box();
27+
a_2_enum() => a_2.enumm();
28+
a_2_type() => a_2.type();
29+
a_2_closure() => a_2.closure();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_b_1.dart" deferred as b_1;
6+
import "split_constants_canonicalization_b_2.dart" deferred as b_2;
7+
8+
loadChildren() async {
9+
await b_1.loadLibrary();
10+
await b_2.loadLibrary();
11+
}
12+
13+
b_1_mint() => b_1.mint();
14+
b_1_string() => b_1.string();
15+
b_1_list() => b_1.list();
16+
b_1_map() => b_1.map();
17+
b_1_box() => b_1.box();
18+
b_1_enum() => b_1.enumm();
19+
b_1_type() => b_1.type();
20+
b_1_closure() => b_1.closure();
21+
22+
b_2_mint() => b_2.mint();
23+
b_2_string() => b_2.string();
24+
b_2_list() => b_2.list();
25+
b_2_map() => b_2.map();
26+
b_2_box() => b_2.box();
27+
b_2_enum() => b_2.enumm();
28+
b_2_type() => b_2.type();
29+
b_2_closure() => b_2.closure();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2020, 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+
// VMOptions=--use_bare_instructions=false
6+
// VMOptions=--use_bare_instructions=true
7+
8+
import "package:expect/expect.dart";
9+
import "split_constants_canonicalization_a.dart" deferred as a;
10+
import "split_constants_canonicalization_b.dart" deferred as b;
11+
12+
class Box {
13+
final contents;
14+
const Box(this.contents);
15+
}
16+
17+
enum Enum {
18+
RED,
19+
GREEN,
20+
BLUE,
21+
}
22+
23+
commonClosure() {}
24+
25+
main() async {
26+
await a.loadLibrary();
27+
await a.loadChildren();
28+
await b.loadLibrary();
29+
await b.loadChildren();
30+
31+
var a_1_mint = await a.a_1_mint();
32+
var a_2_mint = await a.a_2_mint();
33+
var b_1_mint = await b.b_1_mint();
34+
var b_2_mint = await b.b_2_mint();
35+
Expect.isTrue(identical(a_1_mint, a_2_mint));
36+
Expect.isTrue(identical(a_1_mint, b_1_mint));
37+
Expect.isTrue(identical(a_1_mint, b_2_mint));
38+
39+
var a_1_string = await a.a_1_string();
40+
var a_2_string = await a.a_2_string();
41+
var b_1_string = await b.b_1_string();
42+
var b_2_string = await b.b_2_string();
43+
Expect.isTrue(identical(a_1_string, a_2_string));
44+
Expect.isTrue(identical(a_1_string, b_1_string));
45+
Expect.isTrue(identical(a_1_string, b_2_string));
46+
47+
var a_1_list = await a.a_1_list();
48+
var a_2_list = await a.a_2_list();
49+
var b_1_list = await b.b_1_list();
50+
var b_2_list = await b.b_2_list();
51+
Expect.isTrue(identical(a_1_list, a_2_list));
52+
Expect.isTrue(identical(a_1_list, b_1_list));
53+
Expect.isTrue(identical(a_1_list, b_2_list));
54+
55+
var a_1_map = await a.a_1_map();
56+
var a_2_map = await a.a_2_map();
57+
var b_1_map = await b.b_1_map();
58+
var b_2_map = await b.b_2_map();
59+
Expect.isTrue(identical(a_1_map, a_2_map));
60+
Expect.isTrue(identical(a_1_map, b_1_map));
61+
Expect.isTrue(identical(a_1_map, b_2_map));
62+
63+
var a_1_box = await a.a_1_box();
64+
var a_2_box = await a.a_2_box();
65+
var b_1_box = await b.b_1_box();
66+
var b_2_box = await b.b_2_box();
67+
Expect.isTrue(identical(a_1_box, a_2_box));
68+
Expect.isTrue(identical(a_1_box, b_1_box));
69+
Expect.isTrue(identical(a_1_box, b_2_box));
70+
71+
var a_1_enum = await a.a_1_enum();
72+
var a_2_enum = await a.a_2_enum();
73+
var b_1_enum = await b.b_1_enum();
74+
var b_2_enum = await b.b_2_enum();
75+
Expect.isTrue(identical(a_1_enum, a_2_enum));
76+
Expect.isTrue(identical(a_1_enum, b_1_enum));
77+
Expect.isTrue(identical(a_1_enum, b_2_enum));
78+
79+
var a_1_type = await a.a_1_type();
80+
var a_2_type = await a.a_2_type();
81+
var b_1_type = await b.b_1_type();
82+
var b_2_type = await b.b_2_type();
83+
Expect.isTrue(identical(a_1_type, a_2_type));
84+
Expect.isTrue(identical(a_1_type, b_1_type));
85+
Expect.isTrue(identical(a_1_type, b_2_type));
86+
87+
var a_1_closure = await a.a_1_closure();
88+
var a_2_closure = await a.a_2_closure();
89+
var b_1_closure = await b.b_1_closure();
90+
var b_2_closure = await b.b_2_closure();
91+
Expect.isTrue(identical(a_1_closure, a_2_closure));
92+
Expect.isTrue(identical(a_1_closure, b_1_closure));
93+
Expect.isTrue(identical(a_1_closure, b_2_closure));
94+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_a_1.dart" deferred as a_1;
6+
import "split_constants_canonicalization_a_2.dart" deferred as a_2;
7+
8+
loadChildren() async {
9+
await a_1.loadLibrary();
10+
await a_2.loadLibrary();
11+
}
12+
13+
a_1_mint() => a_1.mint();
14+
a_1_string() => a_1.string();
15+
a_1_list() => a_1.list();
16+
a_1_map() => a_1.map();
17+
a_1_box() => a_1.box();
18+
a_1_enum() => a_1.enumm();
19+
a_1_type() => a_1.type();
20+
a_1_closure() => a_1.closure();
21+
22+
a_2_mint() => a_2.mint();
23+
a_2_string() => a_2.string();
24+
a_2_list() => a_2.list();
25+
a_2_map() => a_2.map();
26+
a_2_box() => a_2.box();
27+
a_2_enum() => a_2.enumm();
28+
a_2_type() => a_2.type();
29+
a_2_closure() => a_2.closure();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_test.dart";
6+
7+
@pragma("vm:never-inline")
8+
mint() => 0x7FFFFFFFFFFFFFFF;
9+
10+
@pragma("vm:never-inline")
11+
string() => "We all have identical strings";
12+
13+
@pragma("vm:never-inline")
14+
list() => const <String>["We all have identical lists"];
15+
16+
@pragma("vm:never-inline")
17+
map() => const <String, String>{"We all have": "identical maps"};
18+
19+
@pragma("vm:never-inline")
20+
box() => const Box("We all have identical boxes");
21+
22+
@pragma("vm:never-inline")
23+
enumm() => Enum.GREEN;
24+
25+
@pragma("vm:never-inline")
26+
type() => Box;
27+
28+
@pragma("vm:never-inline")
29+
closure() => commonClosure;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020, 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+
import "split_constants_canonicalization_b_1.dart" deferred as b_1;
6+
import "split_constants_canonicalization_b_2.dart" deferred as b_2;
7+
8+
loadChildren() async {
9+
await b_1.loadLibrary();
10+
await b_2.loadLibrary();
11+
}
12+
13+
b_1_mint() => b_1.mint();
14+
b_1_string() => b_1.string();
15+
b_1_list() => b_1.list();
16+
b_1_map() => b_1.map();
17+
b_1_box() => b_1.box();
18+
b_1_enum() => b_1.enumm();
19+
b_1_type() => b_1.type();
20+
b_1_closure() => b_1.closure();
21+
22+
b_2_mint() => b_2.mint();
23+
b_2_string() => b_2.string();
24+
b_2_list() => b_2.list();
25+
b_2_map() => b_2.map();
26+
b_2_box() => b_2.box();
27+
b_2_enum() => b_2.enumm();
28+
b_2_type() => b_2.type();
29+
b_2_closure() => b_2.closure();

0 commit comments

Comments
 (0)