Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 45ae006

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
Migrate pkg/vm to null safety, part 4
TEST=ci Issue: dart-lang/sdk#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>
1 parent ccd063b commit 45ae006

File tree

10 files changed

+141
-150
lines changed

10 files changed

+141
-150
lines changed

pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class IncrementalKernelGenerator {
4242
/// Notice that the component has to include the platform, and that no other
4343
/// platform will be loaded.
4444
factory IncrementalKernelGenerator.fromComponent(
45-
CompilerOptions options, Uri entryPoint, Component component,
45+
CompilerOptions options, Uri entryPoint, Component? component,
4646
[bool? outlineOnly, IncrementalSerializer? incrementalSerializer]) {
4747
return new IncrementalCompiler.fromComponent(
4848
new CompilerContext(
@@ -72,7 +72,7 @@ abstract class IncrementalKernelGenerator {
7272

7373
/// Returns a component whose libraries are the recompiled libraries,
7474
/// or - in the case of [fullComponent] - a full Component.
75-
Future<Component> computeDelta({List<Uri> entryPoints, bool fullComponent});
75+
Future<Component> computeDelta({List<Uri>? entryPoints, bool fullComponent});
7676

7777
/// Returns [CoreTypes] used during compilation.
7878
/// Valid after [computeDelta] is called.
@@ -136,7 +136,7 @@ abstract class IncrementalKernelGenerator {
136136
List<TypeParameter> typeDefinitions,
137137
String syntheticProcedureName,
138138
Uri libraryUri,
139-
[String className,
139+
[String? className,
140140
bool isStatic = false]);
141141

142142
/// Sets experimental features.

pkg/front_end/lib/src/api_unstable/bazel_worker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export 'compiler_state.dart' show InitializedCompilerState;
5858
/// Re-uses cached components from [oldState.workerInputCache], and reloads them
5959
/// as necessary based on [workerInputDigests].
6060
Future<InitializedCompilerState> initializeIncrementalCompiler(
61-
InitializedCompilerState oldState,
61+
InitializedCompilerState? oldState,
6262
Set<String> tags,
6363
Uri sdkSummary,
6464
Uri packagesFile,
@@ -99,7 +99,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
9999
}
100100

101101
Future<InitializedCompilerState> initializeCompiler(
102-
InitializedCompilerState oldState,
102+
InitializedCompilerState? oldState,
103103
Uri sdkSummary,
104104
Uri librariesSpecificationUri,
105105
Uri packagesFile,

pkg/vm/lib/incremental_compiler.dart

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart=2.9
6-
75
/// Defines wrapper class around incremental compiler to support
86
/// the flow, where incremental deltas can be rejected by VM.
97
import 'dart:async';
@@ -20,23 +18,23 @@ const String kDebugProcedureName = ":Eval";
2018
/// deltas and combines them together into resultant program until it is
2119
/// accepted.
2220
class IncrementalCompiler {
23-
IncrementalKernelGenerator _generator;
24-
IncrementalSerializer incrementalSerializer;
21+
late IncrementalKernelGenerator _generator;
22+
IncrementalSerializer? incrementalSerializer;
2523

2624
// Component that reflect the state that was most recently accepted by the
2725
// client. Is [null], if no compilation results were accepted by the client.
28-
Component _lastKnownGood;
29-
List<Component> _pendingDeltas;
26+
Component? _lastKnownGood;
27+
late List<Component> _pendingDeltas;
3028
CompilerOptions _compilerOptions;
3129
bool initialized = false;
3230
bool fullComponent = false;
33-
Uri initializeFromDillUri;
31+
Uri? initializeFromDillUri;
3432
Uri _entryPoint;
3533
final bool forExpressionCompilationOnly;
3634

3735
Uri get entryPoint => _entryPoint;
3836
IncrementalKernelGenerator get generator => _generator;
39-
Component get lastKnownGoodComponent => _lastKnownGood;
37+
Component? get lastKnownGoodComponent => _lastKnownGood;
4038

4139
IncrementalCompiler(this._compilerOptions, this._entryPoint,
4240
{this.initializeFromDillUri, bool incrementalSerialization: true})
@@ -61,12 +59,12 @@ class IncrementalCompiler {
6159
///
6260
/// If [entryPoint] is specified, that points to new entry point for the
6361
/// compilation. Otherwise, previously set entryPoint is used.
64-
Future<Component> compile({Uri entryPoint}) async {
62+
Future<Component> compile({Uri? entryPoint}) async {
6563
final task = new TimelineTask();
6664
try {
6765
task.start("IncrementalCompiler.compile");
6866
_entryPoint = entryPoint ?? _entryPoint;
69-
List<Uri> entryPoints;
67+
List<Uri>? entryPoints;
7068
if (entryPoint != null) entryPoints = [entryPoint];
7169
Component component = await _generator.computeDelta(
7270
entryPoints: entryPoints, fullComponent: fullComponent);
@@ -80,8 +78,9 @@ class IncrementalCompiler {
8078
}
8179

8280
_combinePendingDeltas(bool includePlatform) {
83-
Procedure mainMethod;
84-
NonNullableByDefaultCompiledMode compilationMode;
81+
Procedure? mainMethod;
82+
NonNullableByDefaultCompiledMode compilationMode =
83+
NonNullableByDefaultCompiledMode.Invalid;
8584
Map<Uri, Library> combined = <Uri, Library>{};
8685
Map<Uri, Source> uriToSource = new Map<Uri, Source>();
8786
for (Component delta in _pendingDeltas) {
@@ -104,8 +103,8 @@ class IncrementalCompiler {
104103
..setMainMethodAndMode(mainMethod?.reference, true, compilationMode);
105104
}
106105

107-
CoreTypes getCoreTypes() => _generator.getCoreTypes();
108-
ClassHierarchy getClassHierarchy() => _generator.getClassHierarchy();
106+
CoreTypes? getCoreTypes() => _generator.getCoreTypes();
107+
ClassHierarchy? getClassHierarchy() => _generator.getClassHierarchy();
109108

110109
/// This lets incremental compiler know that results of last [compile] call
111110
/// were accepted, don't need to be included into subsequent [compile] calls
@@ -118,13 +117,14 @@ class IncrementalCompiler {
118117
Map<Uri, Library> combined = <Uri, Library>{};
119118
Map<Uri, Source> uriToSource = <Uri, Source>{};
120119

121-
if (_lastKnownGood != null) {
120+
Component? lastKnownGood = _lastKnownGood;
121+
if (lastKnownGood != null) {
122122
// TODO(aam): Figure out how to skip no-longer-used libraries from
123123
// [_lastKnownGood] libraries.
124-
for (Library library in _lastKnownGood.libraries) {
124+
for (Library library in lastKnownGood.libraries) {
125125
combined[library.importUri] = library;
126126
}
127-
uriToSource.addAll(_lastKnownGood.uriToSource);
127+
uriToSource.addAll(lastKnownGood.uriToSource);
128128
}
129129

130130
Component candidate = _combinePendingDeltas(true);
@@ -133,13 +133,13 @@ class IncrementalCompiler {
133133
}
134134
uriToSource.addAll(candidate.uriToSource);
135135

136-
_lastKnownGood = new Component(
136+
_lastKnownGood = lastKnownGood = new Component(
137137
libraries: combined.values.toList(),
138138
uriToSource: uriToSource,
139139
)..setMainMethodAndMode(
140140
candidate.mainMethod?.reference, true, candidate.mode);
141141
for (final repo in candidate.metadata.values) {
142-
_lastKnownGood.addMetadataRepository(repo);
142+
lastKnownGood.addMetadataRepository(repo);
143143
}
144144
_pendingDeltas.clear();
145145
}
@@ -182,12 +182,12 @@ class IncrementalCompiler {
182182
fullComponent = true;
183183
}
184184

185-
Future<Procedure> compileExpression(
185+
Future<Procedure?> compileExpression(
186186
String expression,
187187
List<String> definitions,
188188
List<String> typeDefinitions,
189189
String libraryUri,
190-
String klass,
190+
String? klass,
191191
bool isStatic) {
192192
Map<String, DartType> completeDefinitions = {};
193193
for (String name in definitions) {
@@ -202,7 +202,6 @@ class IncrementalCompiler {
202202
}
203203

204204
Uri library = Uri.parse(libraryUri);
205-
if (library == null) return null;
206205

207206
return _generator.compileExpression(expression, completeDefinitions,
208207
typeParameters, kDebugProcedureName, library, klass, isStatic);

0 commit comments

Comments
 (0)