Skip to content

Commit e535e81

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[model] Update instructions for generating benchmark data in CFE
Change-Id: I505390321f8ca26391503dd4645b56a208108fc7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429661 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent 84a1b11 commit e535e81

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

pkg/front_end/test/types/README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,36 @@ To collect new data for a benchmark, follow these steps:
1616
1. Identify the program that the benchmark is based on, for example,
1717
`pkg/compiler/lib/src/dart2js.dart`.
1818

19-
2. Modify `pkg/kernel/lib/type_environment.dart` as described in the method
20-
`SubtypeTester._collect_isSubtypeOf`.
19+
2. Modify `pkg/kernel/lib/src/types.dart` as described in the method
20+
`SubtypeTester._collect_performNullabilityAwareSubtypeCheck`.
2121

22-
3. Compile the program using Fasta, for example:
22+
3. Compile the program using CFE, for example:
2323

24-
./sdk/bin/dart pkg/front_end/tool/compile.dart pkg/compiler/lib/src/dart2js.dart
24+
```shell
25+
$ ./sdk/bin/dart pkg/front_end/tool/compile.dart pkg/compiler/lib/src/dart2js.dart
26+
```
2527

26-
4. This produces a file named `type_checks.json` in the current directory.
28+
This produces a file named `type_checks.json` in the current directory.
2729

28-
5. Compress the file using `gzip`.
30+
4. Rename the file and compress it using `gzip`:
31+
32+
```shell
33+
$ mv type_checks.json dart2js.json
34+
$ gzip dart2js.json
35+
```
36+
37+
This produces a file named `dart2js.json.gz`.
38+
39+
5. Move the file to the directory `pkg/front_end/test/fasta/types/benchmark_data/` in the Dart SDK checkout:
40+
41+
```shell
42+
$ mv dart2js.json.gz pkg/front_end/test/fasta/types/benchmark_data/
43+
```
44+
45+
6. Run the corresponding test:
46+
47+
```shell
48+
$ python3 tools/test.py -n cfe-unittest-asserts-release-mac --detect-host pkg/front_end/test/types/dart2js_benchmark_test
49+
```
50+
51+
Note: this will run the test with the locally updated benchmark data. Fresh checkouts of the Dart SDK will not have the updated data.

pkg/front_end/tool/bench_maker.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ class BenchMaker implements DartTypeVisitor1<void, StringBuffer> {
404404
@override
405405
void visitStructuralParameterType(
406406
StructuralParameterType node, StringBuffer sb) {
407-
throw "not implemented";
407+
String name = computeStructuralParameterName(node.parameter);
408+
sb.write(name);
408409
}
409410

410411
@override
@@ -416,12 +417,12 @@ class BenchMaker implements DartTypeVisitor1<void, StringBuffer> {
416417

417418
@override
418419
void visitTypedefType(TypedefType node, StringBuffer sb) {
419-
throw "not implemented";
420+
sb.write(node.unalias);
420421
}
421422

422423
@override
423424
void visitExtensionType(ExtensionType node, StringBuffer sb) {
424-
throw "not implemented";
425+
sb.write(node.extensionTypeErasure);
425426
}
426427

427428
Map<String, dynamic> toJson() {

pkg/kernel/lib/src/types.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ class Types with StandardBounds {
5858
/// `performNullabilityAwareSubtypeCheck`.
5959
/// 3. Comment out the call to `_performNullabilityAwareSubtypeCheck` below.
6060
// ignore:unused_element
61-
bool _collect_performNullabilityAwareSubtypeCheck(
62-
DartType subtype, DartType supertype, SubtypeCheckMode mode) {
61+
IsSubtypeOf _collect_performNullabilityAwareSubtypeCheck(
62+
DartType subtype, DartType supertype) {
6363
IsSubtypeOf result = const IsSubtypeOf.always();
64-
//result = _performNullabilityAwareSubtypeCheck(subtype, supertype, mode);
65-
bool booleanResult = _isSubtypeFromMode(result, mode);
64+
// result = _performNullabilityAwareSubtypeCheck(subtype, supertype);
65+
bool booleanResult = result.isSubtypeWhenUsingNullabilities();
6666
(typeChecksForTesting ??= <Object>[])
6767
.add([subtype, supertype, booleanResult]);
68-
return booleanResult;
68+
return result;
6969
}
7070

7171
IsSubtypeOf performNullabilityAwareSubtypeCheck(DartType s, DartType t) {

0 commit comments

Comments
 (0)