Migrate pkg/vm to null safety, part 4

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/46620
Change-Id: I74c45ed1525248447e769cc832366728e7a017fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208020
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Alexander Markov
2021-07-27 17:52:18 +00:00
committed by commit-bot@chromium.org
parent ccd063bda5
commit 45ae00676a
10 changed files with 141 additions and 150 deletions
@@ -42,7 +42,7 @@ abstract class IncrementalKernelGenerator {
/// Notice that the component has to include the platform, and that no other
/// platform will be loaded.
factory IncrementalKernelGenerator.fromComponent(
CompilerOptions options, Uri entryPoint, Component component,
CompilerOptions options, Uri entryPoint, Component? component,
[bool? outlineOnly, IncrementalSerializer? incrementalSerializer]) {
return new IncrementalCompiler.fromComponent(
new CompilerContext(
@@ -72,7 +72,7 @@ abstract class IncrementalKernelGenerator {
/// Returns a component whose libraries are the recompiled libraries,
/// or - in the case of [fullComponent] - a full Component.
Future<Component> computeDelta({List<Uri> entryPoints, bool fullComponent});
Future<Component> computeDelta({List<Uri>? entryPoints, bool fullComponent});
/// Returns [CoreTypes] used during compilation.
/// Valid after [computeDelta] is called.
@@ -136,7 +136,7 @@ abstract class IncrementalKernelGenerator {
List<TypeParameter> typeDefinitions,
String syntheticProcedureName,
Uri libraryUri,
[String className,
[String? className,
bool isStatic = false]);
/// Sets experimental features.
@@ -58,7 +58,7 @@ export 'compiler_state.dart' show InitializedCompilerState;
/// Re-uses cached components from [oldState.workerInputCache], and reloads them
/// as necessary based on [workerInputDigests].
Future<InitializedCompilerState> initializeIncrementalCompiler(
InitializedCompilerState oldState,
InitializedCompilerState? oldState,
Set<String> tags,
Uri sdkSummary,
Uri packagesFile,
@@ -99,7 +99,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
}
Future<InitializedCompilerState> initializeCompiler(
InitializedCompilerState oldState,
InitializedCompilerState? oldState,
Uri sdkSummary,
Uri librariesSpecificationUri,
Uri packagesFile,
+21 -22
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
/// Defines wrapper class around incremental compiler to support
/// the flow, where incremental deltas can be rejected by VM.
import 'dart:async';
@@ -20,23 +18,23 @@ const String kDebugProcedureName = ":Eval";
/// deltas and combines them together into resultant program until it is
/// accepted.
class IncrementalCompiler {
IncrementalKernelGenerator _generator;
IncrementalSerializer incrementalSerializer;
late IncrementalKernelGenerator _generator;
IncrementalSerializer? incrementalSerializer;
// Component that reflect the state that was most recently accepted by the
// client. Is [null], if no compilation results were accepted by the client.
Component _lastKnownGood;
List<Component> _pendingDeltas;
Component? _lastKnownGood;
late List<Component> _pendingDeltas;
CompilerOptions _compilerOptions;
bool initialized = false;
bool fullComponent = false;
Uri initializeFromDillUri;
Uri? initializeFromDillUri;
Uri _entryPoint;
final bool forExpressionCompilationOnly;
Uri get entryPoint => _entryPoint;
IncrementalKernelGenerator get generator => _generator;
Component get lastKnownGoodComponent => _lastKnownGood;
Component? get lastKnownGoodComponent => _lastKnownGood;
IncrementalCompiler(this._compilerOptions, this._entryPoint,
{this.initializeFromDillUri, bool incrementalSerialization: true})
@@ -61,12 +59,12 @@ class IncrementalCompiler {
///
/// If [entryPoint] is specified, that points to new entry point for the
/// compilation. Otherwise, previously set entryPoint is used.
Future<Component> compile({Uri entryPoint}) async {
Future<Component> compile({Uri? entryPoint}) async {
final task = new TimelineTask();
try {
task.start("IncrementalCompiler.compile");
_entryPoint = entryPoint ?? _entryPoint;
List<Uri> entryPoints;
List<Uri>? entryPoints;
if (entryPoint != null) entryPoints = [entryPoint];
Component component = await _generator.computeDelta(
entryPoints: entryPoints, fullComponent: fullComponent);
@@ -80,8 +78,9 @@ class IncrementalCompiler {
}
_combinePendingDeltas(bool includePlatform) {
Procedure mainMethod;
NonNullableByDefaultCompiledMode compilationMode;
Procedure? mainMethod;
NonNullableByDefaultCompiledMode compilationMode =
NonNullableByDefaultCompiledMode.Invalid;
Map<Uri, Library> combined = <Uri, Library>{};
Map<Uri, Source> uriToSource = new Map<Uri, Source>();
for (Component delta in _pendingDeltas) {
@@ -104,8 +103,8 @@ class IncrementalCompiler {
..setMainMethodAndMode(mainMethod?.reference, true, compilationMode);
}
CoreTypes getCoreTypes() => _generator.getCoreTypes();
ClassHierarchy getClassHierarchy() => _generator.getClassHierarchy();
CoreTypes? getCoreTypes() => _generator.getCoreTypes();
ClassHierarchy? getClassHierarchy() => _generator.getClassHierarchy();
/// This lets incremental compiler know that results of last [compile] call
/// were accepted, don't need to be included into subsequent [compile] calls
@@ -118,13 +117,14 @@ class IncrementalCompiler {
Map<Uri, Library> combined = <Uri, Library>{};
Map<Uri, Source> uriToSource = <Uri, Source>{};
if (_lastKnownGood != null) {
Component? lastKnownGood = _lastKnownGood;
if (lastKnownGood != null) {
// TODO(aam): Figure out how to skip no-longer-used libraries from
// [_lastKnownGood] libraries.
for (Library library in _lastKnownGood.libraries) {
for (Library library in lastKnownGood.libraries) {
combined[library.importUri] = library;
}
uriToSource.addAll(_lastKnownGood.uriToSource);
uriToSource.addAll(lastKnownGood.uriToSource);
}
Component candidate = _combinePendingDeltas(true);
@@ -133,13 +133,13 @@ class IncrementalCompiler {
}
uriToSource.addAll(candidate.uriToSource);
_lastKnownGood = new Component(
_lastKnownGood = lastKnownGood = new Component(
libraries: combined.values.toList(),
uriToSource: uriToSource,
)..setMainMethodAndMode(
candidate.mainMethod?.reference, true, candidate.mode);
for (final repo in candidate.metadata.values) {
_lastKnownGood.addMetadataRepository(repo);
lastKnownGood.addMetadataRepository(repo);
}
_pendingDeltas.clear();
}
@@ -182,12 +182,12 @@ class IncrementalCompiler {
fullComponent = true;
}
Future<Procedure> compileExpression(
Future<Procedure?> compileExpression(
String expression,
List<String> definitions,
List<String> typeDefinitions,
String libraryUri,
String klass,
String? klass,
bool isStatic) {
Map<String, DartType> completeDefinitions = {};
for (String name in definitions) {
@@ -202,7 +202,6 @@ class IncrementalCompiler {
}
Uri library = Uri.parse(libraryUri);
if (library == null) return null;
return _generator.compileExpression(expression, completeDefinitions,
typeParameters, kDebugProcedureName, library, klass, isStatic);
+82 -74
View File
@@ -2,10 +2,7 @@
// 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.
// @dart=2.9
/// Defines the VM-specific translation of Dart source code to kernel binaries.
library vm.kernel_front_end;
import 'dart:async';
import 'dart:io' show File, IOSink;
@@ -162,7 +159,7 @@ const int compileTimeErrorExitCode = 254;
/// Run kernel compiler tool with given [options] and [usage]
/// and return exit code.
Future<int> runCompiler(ArgResults options, String usage) async {
final String platformKernel = options['platform'];
final String? platformKernel = options['platform'];
if (options['help']) {
print(usage);
@@ -176,26 +173,26 @@ Future<int> runCompiler(ArgResults options, String usage) async {
final String input = options.rest.single;
final String outputFileName = options['output'] ?? "$input.dill";
final String packages = options['packages'];
final String? packages = options['packages'];
final String targetName = options['target'];
final String fileSystemScheme = options['filesystem-scheme'];
final String depfile = options['depfile'];
final String fromDillFile = options['from-dill'];
final List<String> fileSystemRoots = options['filesystem-root'];
final String? fileSystemScheme = options['filesystem-scheme'];
final String? depfile = options['depfile'];
final String? fromDillFile = options['from-dill'];
final List<String>? fileSystemRoots = options['filesystem-root'];
final bool aot = options['aot'];
final bool tfa = options['tfa'];
final bool linkPlatform = options['link-platform'];
final bool embedSources = options['embed-sources'];
final bool enableAsserts = options['enable-asserts'];
final bool nullSafety = options['sound-null-safety'];
final bool? nullSafety = options['sound-null-safety'];
final bool useProtobufTreeShakerV2 = options['protobuf-tree-shaker-v2'];
final bool splitOutputByPackages = options['split-output-by-packages'];
final String manifestFilename = options['manifest'];
final String dataDir = options['component-name'] ?? options['data-dir'];
final String? manifestFilename = options['manifest'];
final String? dataDir = options['component-name'] ?? options['data-dir'];
final bool minimalKernel = options['minimal-kernel'];
final bool treeShakeWriteOnlyFields = options['tree-shake-write-only-fields'];
final List<String> experimentalFlags = options['enable-experiment'];
final List<String>? experimentalFlags = options['enable-experiment'];
final Map<String, String> environmentDefines = {};
if (!parseCommandLineDefines(options['define'], environmentDefines, usage)) {
@@ -217,7 +214,7 @@ Future<int> runCompiler(ArgResults options, String usage) async {
final fileSystem =
createFrontEndFileSystem(fileSystemScheme, fileSystemRoots);
final Uri packagesUri = packages != null ? resolveInputUri(packages) : null;
final Uri? packagesUri = packages != null ? resolveInputUri(packages) : null;
final platformKernelUri = Uri.base.resolveUri(new Uri.file(platformKernel));
final List<Uri> additionalDills = <Uri>[];
@@ -232,7 +229,8 @@ Future<int> runCompiler(ArgResults options, String usage) async {
final verbosity = Verbosity.parseArgument(options['verbosity']);
final errorPrinter = new ErrorPrinter(verbosity);
final errorDetector = new ErrorDetector(previousErrorHandler: errorPrinter);
final errorDetector =
new ErrorDetector(previousErrorHandler: errorPrinter.call);
final CompilerOptions compilerOptions = new CompilerOptions()
..sdkSummary = platformKernelUri
@@ -280,19 +278,20 @@ Future<int> runCompiler(ArgResults options, String usage) async {
errorPrinter.printCompilationMessages();
if (errorDetector.hasCompilationErrors || (results.component == null)) {
final Component? component = results.component;
if (errorDetector.hasCompilationErrors || (component == null)) {
return compileTimeErrorExitCode;
}
final IOSink sink = new File(outputFileName).openWrite();
final BinaryPrinter printer = new BinaryPrinter(sink,
libraryFilter: (lib) => !results.loadedLibraries.contains(lib));
printer.writeComponentFile(results.component);
printer.writeComponentFile(component);
await sink.close();
if (depfile != null) {
await writeDepfile(
fileSystem, results.compiledSources, outputFileName, depfile);
fileSystem, results.compiledSources!, outputFileName, depfile);
}
if (splitOutputByPackages) {
@@ -314,14 +313,14 @@ Future<int> runCompiler(ArgResults options, String usage) async {
/// Results of [compileToKernel]: generated kernel [Component] and
/// collection of compiled sources.
class KernelCompilationResults {
final Component component;
final Component? component;
/// Set of libraries loaded from .dill, with or without the SDK depending on
/// the compilation settings.
final Set<Library> loadedLibraries;
final ClassHierarchy classHierarchy;
final CoreTypes coreTypes;
final Iterable<Uri> compiledSources;
final ClassHierarchy? classHierarchy;
final CoreTypes? coreTypes;
final Iterable<Uri>? compiledSources;
KernelCompilationResults(this.component, this.loadedLibraries,
this.classHierarchy, this.coreTypes, this.compiledSources);
@@ -338,29 +337,30 @@ Future<KernelCompilationResults> compileToKernel(
List<String> deleteToStringPackageUris: const <String>[],
bool aot: false,
bool useGlobalTypeFlowAnalysis: false,
Map<String, String> environmentDefines,
required Map<String, String> environmentDefines,
bool enableAsserts: true,
bool useProtobufTreeShakerV2: false,
bool minimalKernel: false,
bool treeShakeWriteOnlyFields: false,
String fromDillFile: null}) async {
String? fromDillFile: null}) async {
// Replace error handler to detect if there are compilation errors.
final errorDetector =
new ErrorDetector(previousErrorHandler: options.onDiagnostic);
options.onDiagnostic = errorDetector;
options.onDiagnostic = errorDetector.call;
final target = options.target!;
options.environmentDefines =
options.target.updateEnvironmentDefines(environmentDefines);
target.updateEnvironmentDefines(environmentDefines);
CompilerResult compilerResult;
CompilerResult? compilerResult;
if (fromDillFile != null) {
compilerResult =
await loadKernel(options.fileSystem, resolveInputUri(fromDillFile));
} else {
compilerResult = await kernelForProgram(source, options);
}
Component component = compilerResult?.component;
Iterable<Uri> compiledSources = component?.uriToSource?.keys;
final Component? component = compilerResult?.component;
Iterable<Uri>? compiledSources = component?.uriToSource.keys;
Set<Library> loadedLibraries = createLoadedLibrariesSet(
compilerResult?.loadedComponents, compilerResult?.sdkComponent,
@@ -373,13 +373,8 @@ Future<KernelCompilationResults> compileToKernel(
// Run global transformations only if component is correct.
if ((aot || minimalKernel) && component != null) {
await runGlobalTransformations(
options.target,
component,
useGlobalTypeFlowAnalysis,
enableAsserts,
useProtobufTreeShakerV2,
errorDetector,
await runGlobalTransformations(target, component, useGlobalTypeFlowAnalysis,
enableAsserts, useProtobufTreeShakerV2, errorDetector,
minimalKernel: minimalKernel,
treeShakeWriteOnlyFields: treeShakeWriteOnlyFields);
@@ -387,7 +382,7 @@ Future<KernelCompilationResults> compileToKernel(
// compiledSources is component.uriToSource.keys.
// Make a copy of compiledSources to detach it from
// component.uriToSource which is cleared below.
compiledSources = compiledSources.toList();
compiledSources = compiledSources!.toList();
component.metadata.clear();
component.uriToSource.clear();
@@ -406,7 +401,7 @@ Future<KernelCompilationResults> compileToKernel(
}
Set<Library> createLoadedLibrariesSet(
List<Component> loadedComponents, Component sdkComponent,
List<Component>? loadedComponents, Component? sdkComponent,
{bool includePlatform: false}) {
final Set<Library> loadedLibraries = {};
if (loadedComponents != null) {
@@ -481,8 +476,11 @@ Future runGlobalTransformations(
/// Runs given [action] with [CompilerContext]. This is needed to
/// be able to report compile-time errors.
Future<T> runWithFrontEndCompilerContext<T>(Uri source,
CompilerOptions compilerOptions, Component component, T action()) async {
Future<T> runWithFrontEndCompilerContext<T>(
Uri source,
CompilerOptions compilerOptions,
Component component,
Future<T> action()) async {
final processedOptions =
new ProcessedOptions(options: compilerOptions, inputs: [source]);
@@ -498,7 +496,7 @@ Future<T> runWithFrontEndCompilerContext<T>(Uri source,
}
class ErrorDetector {
final DiagnosticMessageHandler previousErrorHandler;
final DiagnosticMessageHandler? previousErrorHandler;
bool hasCompilationErrors = false;
ErrorDetector({this.previousErrorHandler});
@@ -514,8 +512,9 @@ class ErrorDetector {
class ErrorPrinter {
final Verbosity verbosity;
final DiagnosticMessageHandler previousErrorHandler;
final compilationMessages = <Uri, List<DiagnosticMessage>>{};
final DiagnosticMessageHandler? previousErrorHandler;
final Map<Uri?, List<DiagnosticMessage>> compilationMessages =
<Uri?, List<DiagnosticMessage>>{};
ErrorPrinter(this.verbosity, {this.previousErrorHandler});
@@ -539,8 +538,8 @@ class ErrorPrinter {
}
return 0;
});
for (final Uri sourceUri in sortedUris) {
for (final DiagnosticMessage message in compilationMessages[sourceUri]) {
for (final Uri? sourceUri in sortedUris) {
for (final DiagnosticMessage message in compilationMessages[sourceUri]!) {
if (Verbosity.shouldPrint(verbosity, message)) {
printDiagnosticMessage(message, print);
}
@@ -576,7 +575,7 @@ Future<void> autoDetectNullSafetyMode(
}
/// Create front-end target with given name.
Target createFrontEndTarget(String targetName,
Target? createFrontEndTarget(String targetName,
{bool trackWidgetCreation = false, bool nullSafety = false}) {
// Make sure VM-specific targets are available.
installAdditionalTargets();
@@ -591,9 +590,8 @@ Target createFrontEndTarget(String targetName,
/// If requested, create a virtual mutli-root file system and/or an http aware
/// file system.
FileSystem createFrontEndFileSystem(
String multiRootFileSystemScheme, List<String> multiRootFileSystemRoots,
{bool allowHttp}) {
allowHttp ??= false;
String? multiRootFileSystemScheme, List<String>? multiRootFileSystemRoots,
{bool allowHttp = false}) {
FileSystem fileSystem = StandardFileSystem.instance;
if (allowHttp) {
fileSystem = HttpAwareFileSystem(fileSystem);
@@ -615,7 +613,7 @@ FileSystem createFrontEndFileSystem(
Future<Uri> asFileUri(FileSystem fileSystem, Uri uri) async {
FileSystemEntity fse = fileSystem.entityForUri(uri);
if (fse is MultiRootFileSystemEntity) {
fse = await (fse as MultiRootFileSystemEntity).delegate;
fse = await fse.delegate;
}
return fse.uri;
}
@@ -645,8 +643,9 @@ Future<Uri> convertToPackageUri(
Future writeOutputSplitByPackages(Uri source, CompilerOptions compilerOptions,
KernelCompilationResults compilationResults, String outputFileName) async {
final packages = <String>[];
await runWithFrontEndCompilerContext(
source, compilerOptions, compilationResults.component, () async {
final Component component = compilationResults.component!;
await runWithFrontEndCompilerContext(source, compilerOptions, component,
() async {
// When loading a kernel file list, flutter_runner and dart_runner expect
// 'main' to be last.
await forEachPackage(compilationResults,
@@ -655,12 +654,10 @@ Future writeOutputSplitByPackages(Uri source, CompilerOptions compilerOptions,
final String filename = '$outputFileName-$package.dilp';
final IOSink sink = new File(filename).openWrite();
Component partComponent = compilationResults.component;
final BinaryPrinter printer = new BinaryPrinter(sink,
libraryFilter: (lib) =>
packageFor(lib, compilationResults.loadedLibraries) == package);
printer.writeComponentFile(partComponent);
printer.writeComponentFile(component);
await sink.close();
}, mainFirst: false);
@@ -673,7 +670,7 @@ Future writeOutputSplitByPackages(Uri source, CompilerOptions compilerOptions,
await packagesList.close();
}
String packageFor(Library lib, Set<Library> loadedLibraries) {
String? packageFor(Library lib, Set<Library> loadedLibraries) {
// Core libraries are not written into any package kernel binaries.
if (loadedLibraries.contains(lib)) return null;
@@ -701,23 +698,25 @@ void sortComponent(Component component) {
}
}
Future<Null> forEachPackage<T>(KernelCompilationResults results,
T action(String package, List<Library> libraries),
{bool mainFirst}) async {
final Component component = results.component;
Future<void> forEachPackage(KernelCompilationResults results,
Future<void> action(String package, List<Library> libraries),
{required bool mainFirst}) async {
final Component component = results.component!;
final Set<Library> loadedLibraries = results.loadedLibraries;
sortComponent(component);
final packages = new Map<String, List<Library>>();
final Map<String, List<Library>> packages = <String, List<Library>>{};
packages['main'] = <Library>[]; // Always create 'main'.
for (Library lib in component.libraries) {
packages
.putIfAbsent(packageFor(lib, loadedLibraries), () => <Library>[])
.add(lib);
final String? package = packageFor(lib, loadedLibraries);
// Ignore external libraries.
if (package == null) {
continue;
}
packages.putIfAbsent(package, () => <Library>[]).add(lib);
}
packages.remove(null); // Ignore external libraries.
final mainLibraries = packages.remove('main');
final mainLibraries = packages.remove('main')!;
if (mainFirst) {
await action('main', mainLibraries);
}
@@ -728,7 +727,7 @@ Future<Null> forEachPackage<T>(KernelCompilationResults results,
component.setMainMethodAndMode(null, true, compilationMode);
component.problemsAsJson = null;
for (String package in packages.keys) {
await action(package, packages[package]);
await action(package, packages[package]!);
}
component.setMainMethodAndMode(mainMethod?.reference, true, compilationMode);
component.problemsAsJson = problemsAsJson;
@@ -750,8 +749,8 @@ Future<void> writeDepfile(FileSystem fileSystem, Iterable<Uri> compiledSources,
file.write(_escapePath(output));
file.write(':');
for (Uri dep in compiledSources) {
// Skip empty or corelib dependencies.
if (dep == null || dep.scheme == 'org-dartlang-sdk') continue;
// Skip corelib dependencies.
if (dep.scheme == 'org-dartlang-sdk') continue;
Uri uri = await asFileUri(fileSystem, dep);
file.write(' ');
file.write(_escapePath(uri.toFilePath()));
@@ -761,7 +760,7 @@ Future<void> writeDepfile(FileSystem fileSystem, Iterable<Uri> compiledSources,
}
Future<void> createFarManifest(
String output, String dataDir, String packageManifestFilename) async {
String output, String? dataDir, String packageManifestFilename) async {
List<String> packages = await File('$output-packages').readAsLines();
// Make sure the 'main' package is the last (convention with package loader).
@@ -791,7 +790,7 @@ Future<void> createFarManifest(
'typed_data',
'vector_math'
]) {
Digest digest;
Digest? digest;
if (packages.contains(package)) {
final filenameInBuild = '$output-$package.dilp';
final bytes = await File(filenameInBuild).readAsBytes();
@@ -813,11 +812,20 @@ class CompilerResultLoadedFromKernel implements CompilerResult {
CompilerResultLoadedFromKernel(this.component);
List<int> get summary => null;
@override
List<int>? get summary => null;
@override
List<Component> get loadedComponents => const <Component>[];
@override
List<Uri> get deps => const <Uri>[];
CoreTypes get coreTypes => null;
ClassHierarchy get classHierarchy => null;
@override
CoreTypes? get coreTypes => null;
@override
ClassHierarchy? get classHierarchy => null;
}
Future<CompilerResult> loadKernel(
-2
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'package:kernel/target/targets.dart';
import 'package:vm/target/vm.dart' show VmTarget;
+3 -8
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'package:kernel/ast.dart' show Component, Library;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/target/changed_structure_notifier.dart';
@@ -14,7 +12,7 @@ import 'package:vm/target/vm.dart' show VmTarget;
class FlutterTarget extends VmTarget {
FlutterTarget(TargetFlags flags) : super(flags);
WidgetCreatorTracker _widgetTracker;
late final WidgetCreatorTracker _widgetTracker = WidgetCreatorTracker();
@override
String get name => 'flutter';
@@ -57,15 +55,12 @@ class FlutterTarget extends VmTarget {
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
{void Function(String msg) logger,
ChangedStructureNotifier changedStructureNotifier}) {
{void Function(String msg)? logger,
ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
if (flags.trackWidgetCreation) {
if (_widgetTracker == null) {
_widgetTracker = WidgetCreatorTracker();
}
_widgetTracker.transform(component, libraries, changedStructureNotifier);
}
}
-2
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'package:kernel/target/targets.dart';
import 'package:vm/target/vm.dart' show VmTarget;
-2
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'package:kernel/target/targets.dart' show targets, TargetFlags;
import 'package:vm/target/dart_runner.dart' show DartRunnerTarget;
import 'package:vm/target/flutter.dart' show FlutterTarget;
+20 -23
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'package:kernel/ast.dart';
import 'package:kernel/clone.dart';
import 'package:kernel/class_hierarchy.dart';
@@ -34,14 +32,14 @@ import '../transformations/ffi_use_sites.dart' as transformFfiUseSites
class VmTarget extends Target {
final TargetFlags flags;
Class _growableList;
Class _immutableList;
Class _internalLinkedHashMap;
Class _immutableMap;
Class _oneByteString;
Class _twoByteString;
Class _smi;
Class _double; // _Double, not double.
Class? _growableList;
Class? _immutableList;
Class? _internalLinkedHashMap;
Class? _immutableMap;
Class? _oneByteString;
Class? _twoByteString;
Class? _smi;
Class? _double; // _Double, not double.
VmTarget(this.flags);
@@ -116,7 +114,7 @@ class VmTarget extends Target {
final Field little =
coreTypes.index.getField('dart:typed_data', 'Endian', 'little');
host.isConst = true;
host.initializer = new CloneVisitorNotMembers().clone(little.initializer)
host.initializer = new CloneVisitorNotMembers().clone(little.initializer!)
..parent = host;
}
@@ -126,8 +124,8 @@ class VmTarget extends Target {
CoreTypes coreTypes,
List<Library> libraries,
DiagnosticReporter diagnosticReporter,
{void Function(String msg) logger,
ChangedStructureNotifier changedStructureNotifier}) {
{void Function(String msg)? logger,
ChangedStructureNotifier? changedStructureNotifier}) {
super.performPreConstantEvaluationTransformations(
component, coreTypes, libraries, diagnosticReporter,
logger: logger, changedStructureNotifier: changedStructureNotifier);
@@ -152,11 +150,11 @@ class VmTarget extends Target {
CoreTypes coreTypes,
ClassHierarchy hierarchy,
List<Library> libraries,
Map<String, String> environmentDefines,
Map<String, String>? environmentDefines,
DiagnosticReporter diagnosticReporter,
ReferenceFromIndex referenceFromIndex,
{void Function(String msg) logger,
ChangedStructureNotifier changedStructureNotifier}) {
ReferenceFromIndex? referenceFromIndex,
{void Function(String msg)? logger,
ChangedStructureNotifier? changedStructureNotifier}) {
transformMixins.transformLibraries(
this, coreTypes, hierarchy, libraries, referenceFromIndex);
logger?.call("Transformed mixin applications");
@@ -184,7 +182,7 @@ class VmTarget extends Target {
}
// TODO(kmillikin): Make this run on a per-method basis.
bool productMode = environmentDefines["dart.vm.product"] == "true";
bool productMode = environmentDefines!["dart.vm.product"] == "true";
transformAsync.transformLibraries(
new TypeEnvironment(coreTypes, hierarchy), libraries,
productMode: productMode);
@@ -204,9 +202,9 @@ class VmTarget extends Target {
CoreTypes coreTypes,
ClassHierarchy hierarchy,
Procedure procedure,
Map<String, String> environmentDefines,
{void Function(String msg) logger}) {
bool productMode = environmentDefines["dart.vm.product"] == "true";
Map<String, String>? environmentDefines,
{void Function(String msg)? logger}) {
bool productMode = environmentDefines!["dart.vm.product"] == "true";
transformAsync.transformProcedure(
new TypeEnvironment(coreTypes, hierarchy), procedure,
productMode: productMode);
@@ -451,7 +449,7 @@ class VmTarget extends Target {
}
@override
Class concreteIntLiteralClass(CoreTypes coreTypes, int value) {
Class? concreteIntLiteralClass(CoreTypes coreTypes, int value) {
const int bitsPerInt32 = 32;
const int smiBits32 = bitsPerInt32 - 2;
const int smiMin32 = -(1 << smiBits32);
@@ -490,7 +488,6 @@ class VmTarget extends Target {
Map<String, String> updateEnvironmentDefines(Map<String, String> map) {
// TODO(alexmarkov): Call this from the front-end in order to have
// the same defines when compiling platform.
assert(map != null);
map['dart.isVM'] = 'true';
// TODO(dartbug.com/36460): Derive dart.library.* definitions from platform.
for (String library in extraRequiredLibraries) {
+10 -12
View File
@@ -2,8 +2,6 @@
// 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.
// @dart=2.9
import 'dart:async';
import 'dart:io';
@@ -37,11 +35,11 @@ class TestingVmTarget extends VmTarget {
}
Future<Component> compileTestCaseToKernelProgram(Uri sourceUri,
{Target target,
{Target? target,
bool enableSuperMixins = false,
List<String> experimentalFlags,
Map<String, String> environmentDefines,
Uri packagesFileUri}) async {
List<String>? experimentalFlags,
Map<String, String>? environmentDefines,
Uri? packagesFileUri}) async {
final platformKernel =
computePlatformBinariesLocation().resolve('vm_platform_strong.dill');
target ??= new TestingVmTarget(new TargetFlags())
@@ -62,11 +60,11 @@ Future<Component> compileTestCaseToKernelProgram(Uri sourceUri,
};
final Component component =
(await kernelForProgram(sourceUri, options)).component;
(await kernelForProgram(sourceUri, options))!.component!;
// Make sure the library name is the same and does not depend on the order
// of test cases.
component.mainMethod.enclosingLibrary.name = '#lib';
component.mainMethod!.enclosingLibrary.name = '#lib';
return component;
}
@@ -75,19 +73,19 @@ String kernelLibraryToString(Library library) {
final StringBuffer buffer = new StringBuffer();
final printer = new Printer(buffer, showMetadata: true);
printer.writeLibraryFile(library);
printer.writeConstantTable(library.enclosingComponent);
printer.writeConstantTable(library.enclosingComponent!);
return buffer
.toString()
.replaceAll(library.importUri.toString(), library.name);
.replaceAll(library.importUri.toString(), library.name!);
}
String kernelComponentToString(Component component) {
final StringBuffer buffer = new StringBuffer();
new Printer(buffer, showMetadata: true).writeComponentFile(component);
final mainLibrary = component.mainMethod.enclosingLibrary;
final mainLibrary = component.mainMethod!.enclosingLibrary;
return buffer
.toString()
.replaceAll(mainLibrary.importUri.toString(), mainLibrary.name);
.replaceAll(mainLibrary.importUri.toString(), mainLibrary.name!);
}
class DevNullSink<T> extends Sink<T> {