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

Commit 4db0f55

Browse files
author
Dart CI
committed
Version 2.13.0-39.0.dev
Merge commit '02f0f53ddf6c91a2bed4614d95743ee56cff8077' into 'dev'
2 parents 39dc634 + 02f0f53 commit 4db0f55

File tree

11 files changed

+168
-26
lines changed

11 files changed

+168
-26
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2021, 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+
/*library: nnbd=true*/
6+
7+
typedef Typedef1 = void Function();
8+
typedef Typedef2 = dynamic Function();
9+
10+
/*class: A:A,Object*/
11+
abstract class A {
12+
/*member: A.method1:void Function(void Function())*/
13+
void method1(void Function() f);
14+
15+
/*member: A.method2:void Function(void Function())*/
16+
void method2(Typedef1 f);
17+
18+
/*member: A.method3:void Function(void Function())*/
19+
void method3(Typedef1 f);
20+
21+
/*member: A.method4:void Function(void Function())*/
22+
void method4(void Function() f);
23+
}
24+
25+
/*class: B:B,Object*/
26+
abstract class B {
27+
/*member: B.method1:void Function(dynamic Function())*/
28+
void method1(dynamic Function() f);
29+
30+
/*member: B.method2:void Function(dynamic Function())*/
31+
void method2(Typedef2 f);
32+
33+
/*member: B.method3:void Function(dynamic Function())*/
34+
void method3(dynamic Function() f);
35+
36+
/*member: B.method4:void Function(dynamic Function())*/
37+
void method4(Typedef2 f);
38+
}
39+
40+
/*class: C:A,B,C,Object*/
41+
abstract class C implements A, B {
42+
/*member: C.method1:void Function(Object? Function())*/
43+
/*member: C.method2:void Function(Object? Function())*/
44+
/*member: C.method3:void Function(Object? Function())*/
45+
/*member: C.method4:void Function(Object? Function())*/
46+
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
library fasta.incremental_compiler;
88

9+
import 'dart:async' show Completer;
10+
911
import 'package:_fe_analyzer_shared/src/scanner/abstract_scanner.dart'
1012
show ScannerConfiguration;
1113

@@ -167,6 +169,10 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
167169
IncrementalKernelTarget userCode;
168170
Set<Library> previousSourceBuilders;
169171

172+
/// Guard against multiple computeDelta calls at the same time (possibly
173+
/// caused by lacking awaits etc).
174+
Completer currentlyCompiling;
175+
170176
IncrementalCompiler.fromComponent(
171177
this.context, this.componentToInitializeFrom,
172178
[bool outlineOnly, this.incrementalSerializer])
@@ -216,6 +222,10 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
216222
@override
217223
Future<Component> computeDelta(
218224
{List<Uri> entryPoints, bool fullComponent: false}) async {
225+
while (currentlyCompiling != null) {
226+
await currentlyCompiling.future;
227+
}
228+
currentlyCompiling = new Completer();
219229
if (resetTicker) {
220230
ticker.reset();
221231
}
@@ -365,10 +375,17 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
365375
NonNullableByDefaultCompiledMode compiledMode = componentWithDill == null
366376
? data.component?.mode
367377
: componentWithDill.mode;
368-
return context.options.target.configureComponent(
378+
Component result = context.options.target.configureComponent(
369379
new Component(libraries: outputLibraries, uriToSource: uriToSource))
370380
..setMainMethodAndMode(mainMethod?.reference, true, compiledMode)
371381
..problemsAsJson = problemsAsJson;
382+
383+
// We're now done. Allow any waiting compile to start.
384+
Completer currentlyCompilingLocal = currentlyCompiling;
385+
currentlyCompiling = null;
386+
currentlyCompilingLocal.complete();
387+
388+
return result;
372389
});
373390
}
374391

pkg/front_end/lib/src/fasta/kernel/combined_member_signature.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ abstract class CombinedMemberSignatureBase<T> {
332332
_coreTypes,
333333
_combinedMemberSignatureType,
334334
norm(_coreTypes, getMemberType(index)));
335+
assert(
336+
_combinedMemberSignatureType != null,
337+
"No combined member signature found for "
338+
"${_mutualSubtypes.values.map((int i) => getMemberType(i))}");
335339
}
336340
}
337341
_neededNnbdTopMerge =
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2021, 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+
// @dart = 2.9
6+
7+
import 'dart:io';
8+
9+
import 'package:front_end/src/api_unstable/vm.dart';
10+
import 'package:front_end/src/fasta/incremental_compiler.dart';
11+
import 'package:kernel/ast.dart';
12+
13+
import 'incremental_load_from_dill_suite.dart' show getOptions;
14+
15+
main() async {
16+
Uri compileTarget = Platform.script.resolve("binary_md_dill_reader.dart");
17+
if (!(new File.fromUri(compileTarget)).existsSync()) {
18+
throw "$compileTarget doesn't exist";
19+
}
20+
21+
List<Future> futures = [];
22+
List<int> compilesLeft = new List<int>.filled(5, 8);
23+
for (int i = 0; i < compilesLeft.length; i++) {
24+
Future<Component> compileAgain() async {
25+
print("$i has ${compilesLeft[i]} left.");
26+
if (compilesLeft[i] > 0) {
27+
compilesLeft[i]--;
28+
return compile(i, compileTarget).then((value) => compileAgain());
29+
}
30+
return null;
31+
}
32+
33+
print("Starting first compile for $i");
34+
futures.add(compile(i, compileTarget).then((value) => compileAgain()));
35+
}
36+
await Future.wait(futures);
37+
38+
print("Checkpoint #1: Can compiles several at once "
39+
"(with different compilers!)");
40+
41+
for (int i = 0; i < 5; i++) {
42+
futures.clear();
43+
for (int j = 0; j < 10; j++) {
44+
futures.add(compile(0, compileTarget));
45+
}
46+
await Future.wait(futures);
47+
}
48+
49+
print("Checkpoint #2: Can compiles several at once "
50+
"(with the same compiler) (without crashing)");
51+
}
52+
53+
List<IncrementalCompiler> compilers = [];
54+
55+
Future<Component> compile(int compilerNum, Uri uri) async {
56+
if (compilers.length <= compilerNum) {
57+
compilers.length = compilerNum + 1;
58+
}
59+
IncrementalCompiler compiler = compilers[compilerNum];
60+
if (compiler == null) {
61+
var options = getOptions();
62+
compiler = new IncrementalCompiler(new CompilerContext(
63+
new ProcessedOptions(options: options, inputs: [uri])));
64+
compilers[compilerNum] = compiler;
65+
} else {
66+
compiler.invalidateAllSources();
67+
}
68+
Component result = await compiler.computeDelta();
69+
print("Now compile is done!");
70+
return result;
71+
}

pkg/front_end/test/spell_checking_list_code.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ automagically
7575
auxiliary
7676
awaited
7777
awaiting
78+
awaits
7879
b
7980
b0i
8081
b0m
@@ -1334,6 +1335,7 @@ vn
13341335
vs
13351336
vtab
13361337
w
1338+
waiting
13371339
waste
13381340
wasted
13391341
watch

pkg/kernel/lib/ast.dart

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ abstract class TreeNode extends Node {
162162
///
163163
/// Has no effect if [child] is not actually a child of this node.
164164
///
165-
/// If [replacement] is `null`, this will [remove] the [child] node.
165+
/// [replacement] must be non-null.
166166
void replaceChild(TreeNode child, TreeNode replacement) {
167+
assert(replacement != null);
167168
transformChildren(new _ChildReplacer(child, replacement));
168169
}
169170

@@ -173,21 +174,13 @@ abstract class TreeNode extends Node {
173174
/// particular, [replacement] should be an orphan or be part of an orphaned
174175
/// subtree.
175176
///
176-
/// If [replacement] is `null`, this will [remove] the node.
177+
/// [replacement] must be non-null.
177178
void replaceWith(TreeNode replacement) {
179+
assert(replacement != null);
178180
parent.replaceChild(this, replacement);
179181
parent = null;
180182
}
181183

182-
/// Removes this node from the [List] it is currently stored in, or assigns
183-
/// `null` to the field on the parent currently pointing to the node.
184-
///
185-
/// Has no effect if the node is orphaned or if the parent pointer is stale.
186-
void remove() {
187-
parent?.replaceChild(this, null);
188-
parent = null;
189-
}
190-
191184
Component get enclosingComponent => parent?.enclosingComponent;
192185

193186
/// Returns the best known source location of the given AST node, or `null` if
@@ -11559,3 +11552,7 @@ const DartType dartTypeDummy = const DynamicType();
1155911552
/// `List.filled` constructor.
1156011553
const NamedType namedTypeDummy =
1156111554
const NamedType('', dartTypeDummy, isRequired: false);
11555+
11556+
/// Non-nullable `Member` value to be used as a dummy initial value for the
11557+
/// `List.filled` constructor.
11558+
final Member dummyMember = new Field.mutable(new _PublicName(''));

pkg/kernel/lib/class_hierarchy.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ abstract class ClassHierarchy implements ClassHierarchyBase {
248248
List<Member> first, List<Member> second) {
249249
if (first.isEmpty) return second;
250250
if (second.isEmpty) return first;
251-
List<Member> result = <Member>[]..length = first.length + second.length;
251+
List<Member> result = new List<Member>.filled(
252+
first.length + second.length, dummyMember,
253+
growable: true);
252254
int storeIndex = 0;
253255
int i = 0, j = 0;
254256
while (i < first.length && j < second.length) {
@@ -1282,8 +1284,9 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
12821284
static List<Member> _inheritMembers(
12831285
List<Member> declared, List<Member> inherited,
12841286
{bool skipAbstractMembers: false}) {
1285-
List<Member> result = <Member>[]..length =
1286-
declared.length + inherited.length;
1287+
List<Member> result = new List<Member>.filled(
1288+
declared.length + inherited.length, dummyMember,
1289+
growable: true);
12871290
// Since both lists are sorted, we can fuse them like in merge sort.
12881291
int storeIndex = 0;
12891292
int i = 0, j = 0;
@@ -1333,7 +1336,8 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
13331336
/// The input lists must be sorted, and the returned list is sorted.
13341337
static List<Member> _getUnshadowedInheritedMembers(
13351338
List<Member> declared, List<Member> inherited) {
1336-
List<Member> result = <Member>[]..length = inherited.length;
1339+
List<Member> result =
1340+
new List<Member>.filled(inherited.length, dummyMember, growable: true);
13371341
int storeIndex = 0;
13381342
int i = 0, j = 0;
13391343
while (i < declared.length && j < inherited.length) {
@@ -1433,10 +1437,8 @@ class ClosedWorldClassHierarchy implements ClassHierarchy {
14331437
for (Class class_ in _infoMap.keys) {
14341438
_ClassInfo info = _infoMap[class_]!;
14351439
int intervals = info.supertypeIntervalList.length ~/ 2;
1436-
if (intervals >= result.length) {
1437-
int oldLength = result.length;
1438-
result.length = intervals + 1;
1439-
result.fillRange(oldLength, result.length, 0);
1440+
while (result.length <= intervals) {
1441+
result.add(0);
14401442
}
14411443
result[intervals] += 1;
14421444
}

pkg/kernel/lib/src/merge_visitor.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ class MergeVisitor implements DartTypeVisitor1<DartType?, DartType> {
115115
newNamedParameters[i] = newNamedType;
116116
}
117117
TypedefType? newTypedefType;
118-
if (a.typedefType != null) {
118+
if (a.typedefType != null && b.typedefType != null) {
119119
newTypedefType = mergeTypes(a.typedefType, b.typedefType) as TypedefType?;
120-
if (newTypedefType == null) return null;
120+
// If the typedef couldn't be merged we just omit it from the resulting
121+
// function type since the typedef type is only informational.
121122
}
122123

123124
return new FunctionType(newPositionalParameters, newReturnType, nullability,

pkg/vm/bin/kernel_service.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ class IncrementalCompilerWrapper extends Compiler {
350350
experimentalFlags: experimentalFlags,
351351
packageConfig: packageConfig,
352352
invocationModes: invocationModes);
353-
353+
// TODO(VM TEAM): This does not seem safe. What if cloning while having
354+
// pending deltas for instance?
354355
generator.resetDeltaState();
355356
Component fullComponent = await generator.compile();
356357

pkg/vm/lib/transformations/ffi_definitions.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ class _FfiDefinitionTransformer extends FfiTransformer {
348348
}
349349
// Remove initializers referring to fields to prevent cascading errors.
350350
for (final Initializer i in toRemove) {
351-
i.remove();
351+
final Constructor c = i.parent;
352+
c.initializers.remove(i);
352353
}
353354

354355
// Add a constructor which 'load' can use.
@@ -444,7 +445,7 @@ class _FfiDefinitionTransformer extends FfiTransformer {
444445
}
445446

446447
for (final Field f in fields.values) {
447-
f.remove();
448+
node.fields.remove(f);
448449
}
449450

450451
for (final i in getters.keys) {

0 commit comments

Comments
 (0)