Skip to content

Commit 2a3d3eb

Browse files
jensjohaCommit Bot
authored andcommitted
[CFE] Fuzz pass that splits files
Change-Id: I03a16cca748a9a81a6f34f847e08c4ad38e86e6b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239668 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 8033f60 commit 2a3d3eb

File tree

6 files changed

+470
-104
lines changed

6 files changed

+470
-104
lines changed

pkg/front_end/lib/src/fasta/incremental_compiler.dart

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
251251

252252
IncrementalKernelTarget? get kernelTargetForTesting => _lastGoodKernelTarget;
253253

254+
bool get skipExperimentalInvalidationChecksForTesting => false;
255+
254256
/// Returns the [Package] used for the package [packageName] in the most
255257
/// recent compilation.
256258
Package? getPackageForPackageName(String packageName) =>
@@ -1245,52 +1247,54 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
12451247
// procedures, if the changed file is used as a mixin anywhere else
12461248
// we can't only recompile the changed file.
12471249
// TODO(jensj): Check for mixins in a smarter and faster way.
1248-
for (LibraryBuilder builder in reusedResult.notReusedLibraries) {
1249-
if (missingSources!.contains(builder.fileUri)) {
1250-
continue;
1251-
}
1252-
Library lib = builder.library;
1253-
for (Class c in lib.classes) {
1254-
if (!c.isAnonymousMixin && !c.isEliminatedMixin) {
1250+
if (!skipExperimentalInvalidationChecksForTesting) {
1251+
for (LibraryBuilder builder in reusedResult.notReusedLibraries) {
1252+
if (missingSources!.contains(builder.fileUri)) {
12551253
continue;
12561254
}
1257-
for (Supertype supertype in c.implementedTypes) {
1258-
if (missingSources.contains(supertype.classNode.fileUri)) {
1259-
// This is probably a mixin from one of the libraries we want
1260-
// to rebuild only the body of.
1261-
// TODO(jensj): We can probably add this to the rebuildBodies
1262-
// list and just rebuild that library too.
1263-
// print("Usage of mixin in ${lib.importUri}");
1264-
return null;
1255+
Library lib = builder.library;
1256+
for (Class c in lib.classes) {
1257+
if (!c.isAnonymousMixin && !c.isEliminatedMixin) {
1258+
continue;
1259+
}
1260+
for (Supertype supertype in c.implementedTypes) {
1261+
if (missingSources.contains(supertype.classNode.fileUri)) {
1262+
// This is probably a mixin from one of the libraries we want
1263+
// to rebuild only the body of.
1264+
// TODO(jensj): We can probably add this to the rebuildBodies
1265+
// list and just rebuild that library too.
1266+
// print("Usage of mixin in ${lib.importUri}");
1267+
return null;
1268+
}
12651269
}
12661270
}
12671271
}
1268-
}
12691272

1270-
// Special case FFI: Because the VM ffi transformation inlines
1271-
// size and position, if the changed file contains ffi structs
1272-
// we can't only recompile the changed file.
1273-
// TODO(jensj): Come up with something smarter for this. E.g. we might
1274-
// check if the FFI-classes are used in other libraries, or as actual nested
1275-
// structures in other FFI-classes etc.
1276-
// Alternatively (https://github.com/dart-lang/sdk/issues/45899) we might
1277-
// do something else entirely that doesn't require special handling.
1278-
if (_importsFfi()) {
1279-
for (LibraryBuilder builder in rebuildBodies!) {
1280-
Library lib = builder.library;
1281-
for (LibraryDependency dependency in lib.dependencies) {
1282-
Library importLibrary = dependency.targetLibrary;
1283-
if (importLibrary.importUri == dartFfiUri) {
1284-
// Explicitly imports dart:ffi.
1285-
return null;
1286-
}
1287-
for (Reference exportReference in importLibrary.additionalExports) {
1288-
NamedNode? export = exportReference.node;
1289-
if (export is Class) {
1290-
Class c = export;
1291-
if (c.enclosingLibrary.importUri == dartFfiUri) {
1292-
// Implicitly imports a dart:ffi class.
1293-
return null;
1273+
// Special case FFI: Because the VM ffi transformation inlines
1274+
// size and position, if the changed file contains ffi structs
1275+
// we can't only recompile the changed file.
1276+
// TODO(jensj): Come up with something smarter for this. E.g. we might
1277+
// check if the FFI-classes are used in other libraries, or as actual
1278+
// nested structures in other FFI-classes etc.
1279+
// Alternatively (https://github.com/dart-lang/sdk/issues/45899) we might
1280+
// do something else entirely that doesn't require special handling.
1281+
if (_importsFfi()) {
1282+
for (LibraryBuilder builder in rebuildBodies!) {
1283+
Library lib = builder.library;
1284+
for (LibraryDependency dependency in lib.dependencies) {
1285+
Library importLibrary = dependency.targetLibrary;
1286+
if (importLibrary.importUri == dartFfiUri) {
1287+
// Explicitly imports dart:ffi.
1288+
return null;
1289+
}
1290+
for (Reference exportReference in importLibrary.additionalExports) {
1291+
NamedNode? export = exportReference.node;
1292+
if (export is Class) {
1293+
Class c = export;
1294+
if (c.enclosingLibrary.importUri == dartFfiUri) {
1295+
// Implicitly imports a dart:ffi class.
1296+
return null;
1297+
}
12941298
}
12951299
}
12961300
}

pkg/front_end/lib/src/fasta/util/textual_outline.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import 'package:_fe_analyzer_shared/src/parser/listener.dart';
2424

2525
import 'package:_fe_analyzer_shared/src/scanner/token.dart' show Token;
2626

27+
import '../fasta_codes.dart' show codeNativeClauseShouldBeAnnotation;
28+
2729
import '../messages.dart' show Message;
2830

2931
abstract class _Chunk implements Comparable<_Chunk> {
@@ -884,6 +886,10 @@ class TextualOutlineListener extends Listener {
884886
@override
885887
void handleRecoverableError(
886888
Message message, Token startToken, Token endToken) {
889+
// We ignore this message, as done by stack_listener.dart.
890+
if (message.code == codeNativeClauseShouldBeAnnotation) {
891+
return;
892+
}
887893
gotError = true;
888894
}
889895
}

0 commit comments

Comments
 (0)