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

Commit 9d7c40b

Browse files
author
Dart CI
committed
Version 2.14.0-257.0.dev
Merge commit '354d9e256e58cb7d9a472be4f182155d1a480ea6' into 'dev'
2 parents 5103185 + 354d9e2 commit 9d7c40b

File tree

32 files changed

+207491
-16506
lines changed

32 files changed

+207491
-16506
lines changed

DEPS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ vars = {
7373

7474
# Revisions of /third_party/* dependencies.
7575
"args_rev": "d8fea36c10ef96797be02e3d132d572445cd86f4",
76-
"async_rev": "92e7119aa068bfb86a6a9519d44037ffff5eece8",
76+
"async_rev": "b8850b3851026676083413c67fa0a22f63a8edbc",
7777
"bazel_worker_rev": "0885637b037979afbf5bcd05fd748b309fd669c0",
7878
"benchmark_harness_rev": "c546dbd9f639f75cd2f75de8df2eb9f8ea15e8e7",
7979
"boolean_selector_rev": "665e6921ab246569420376f827bff4585dff0b14",
@@ -105,8 +105,8 @@ vars = {
105105
# For more details, see https://github.com/dart-lang/sdk/issues/30164
106106
"dart_style_rev": "f17c23e0eea9a870601c19d904e2a9c1a7c81470",
107107

108-
"dartdoc_rev" : "b733d4952dbd25374d55e28476a5f44bd60ed63f",
109-
"devtools_rev" : "b3bf672474a2bff82f33e1176aa803539baa0d60+1",
108+
"dartdoc_rev" : "b86cddcedf0737763d2e337c7474ad18d973fd4a",
109+
"devtools_rev" : "64cffbed6366329ad05e44d48fa2298367643bb6",
110110
"jsshell_tag": "version:88.0",
111111
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
112112
"fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba",

pkg/analyzer/lib/src/dart/analysis/library_context.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,18 @@ class LibraryContext {
183183
counterUnlinkedLinkedBytes += resolutionBytes.length;
184184

185185
librariesLinkedTimer.stop();
186-
// TODO(scheglov) Uncomment to keep linking elements.
187-
// return;
188186
} else {
189187
// TODO(scheglov) Take / clear parsed units in files.
190188
bytesGet += resolutionBytes.length;
191189
librariesLoaded += cycle.libraries.length;
190+
elementFactory.addBundle(
191+
BundleReader(
192+
elementFactory: elementFactory,
193+
unitsInformativeBytes: unitsInformativeBytes,
194+
resolutionBytes: resolutionBytes,
195+
),
196+
);
192197
}
193-
194-
elementFactory.addBundle(
195-
BundleReader(
196-
elementFactory: elementFactory,
197-
unitsInformativeBytes: unitsInformativeBytes,
198-
resolutionBytes: resolutionBytes,
199-
),
200-
);
201198
}
202199

203200
logger.run('Prepare linked bundles', () {

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,17 @@ class ElementAnnotationImpl implements ElementAnnotation {
18621862
@override
18631863
bool get isOverride => _isDartCoreGetter(_OVERRIDE_VARIABLE_NAME);
18641864

1865+
/// Return `true` if this is an annotation of the form
1866+
/// `@pragma("vm:entry-point")`.
1867+
bool get isPragmaVmEntryPoint {
1868+
if (_isConstructor(libraryName: 'dart.core', className: 'pragma')) {
1869+
var value = computeConstantValue();
1870+
var nameValue = value?.getField('name');
1871+
return nameValue?.toStringValue() == 'vm:entry-point';
1872+
}
1873+
return false;
1874+
}
1875+
18651876
@override
18661877
bool get isProtected => _isPackageMetaGetter(_PROTECTED_VARIABLE_NAME);
18671878

@@ -2221,6 +2232,20 @@ abstract class ElementImpl implements Element {
22212232
return false;
22222233
}
22232234

2235+
/// Return `true` if this element has an annotation of the form
2236+
/// `@pragma("vm:entry-point")`.
2237+
bool get hasPragmaVmEntryPoint {
2238+
final metadata = this.metadata;
2239+
for (var i = 0; i < metadata.length; i++) {
2240+
var annotation = metadata[i];
2241+
if (annotation is ElementAnnotationImpl &&
2242+
annotation.isPragmaVmEntryPoint) {
2243+
return true;
2244+
}
2245+
}
2246+
return false;
2247+
}
2248+
22242249
@override
22252250
bool get hasProtected {
22262251
final metadata = this.metadata;

pkg/analyzer/lib/src/dart/micro/resolve_file.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,17 +908,16 @@ class _LibraryContext {
908908
} else {
909909
performance.getDataInt('bytesGet').add(resolutionBytes.length);
910910
performance.getDataInt('libraryLoadCount').add(cycle.libraries.length);
911+
elementFactory.addBundle(
912+
BundleReader(
913+
elementFactory: elementFactory,
914+
unitsInformativeBytes: unitsInformativeBytes,
915+
resolutionBytes: resolutionBytes as Uint8List,
916+
),
917+
);
911918
}
912919
cycle.resolutionId = resolutionData!.id;
913920

914-
elementFactory.addBundle(
915-
BundleReader(
916-
elementFactory: elementFactory,
917-
unitsInformativeBytes: unitsInformativeBytes,
918-
resolutionBytes: resolutionBytes as Uint8List,
919-
),
920-
);
921-
922921
// We might have just linked dart:core, ensure the type provider.
923922
_createElementFactoryTypeProvider();
924923
}

pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:analyzer/dart/element/element.dart';
1111
import 'package:analyzer/error/error.dart';
1212
import 'package:analyzer/error/listener.dart';
1313
import 'package:analyzer/src/dart/ast/extensions.dart';
14+
import 'package:analyzer/src/dart/element/element.dart';
1415
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
1516
import 'package:analyzer/src/dart/element/member.dart' show ExecutableMember;
1617
import 'package:analyzer/src/error/codes.dart';
@@ -432,6 +433,9 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
432433
if (element.isSynthetic) {
433434
return true;
434435
}
436+
if (_hasPragmaVmEntryPoint(element)) {
437+
return true;
438+
}
435439
if (element is LocalVariableElement ||
436440
element is FunctionElement && !element.isStatic) {
437441
// local variable or function
@@ -470,6 +474,9 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
470474
if (element.isSynthetic) {
471475
return true;
472476
}
477+
if (_hasPragmaVmEntryPoint(element)) {
478+
return true;
479+
}
473480
if (_usedElements.members.contains(element)) {
474481
return true;
475482
}
@@ -625,6 +632,10 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor<void> {
625632
HintCode.UNUSED_ELEMENT, element, [element.displayName]);
626633
}
627634
}
635+
636+
static bool _hasPragmaVmEntryPoint(Element element) {
637+
return element is ElementImpl && element.hasPragmaVmEntryPoint;
638+
}
628639
}
629640

630641
/// A container with sets of used [Element]s.

pkg/analyzer/lib/src/summary2/link.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'package:analyzer/src/summary2/types_builder.dart';
2424
import 'package:analyzer/src/summary2/variance_builder.dart';
2525

2626
var timerLinkingLinkingBundle = Stopwatch();
27-
var timerLinkingRemoveBundle = Stopwatch();
2827

2928
/// Note that AST units and tokens of [inputLibraries] will be damaged.
3029
///
@@ -81,13 +80,6 @@ class Linker {
8180
timerLinkingLinkingBundle.start();
8281
_writeLibraries();
8382
timerLinkingLinkingBundle.stop();
84-
85-
// TODO(scheglov) Remove to keep linking elements.
86-
timerLinkingRemoveBundle.start();
87-
elementFactory.removeBundle(
88-
inputLibraries.map((e) => e.uriStr).toSet(),
89-
);
90-
timerLinkingRemoveBundle.stop();
9183
}
9284

9385
void _buildEnumChildren() {

pkg/analyzer/test/src/diagnostics/unused_element_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,16 @@ class A {
541541
]);
542542
}
543543

544+
test_method_isUsed_hasPragma_vmEntryPoint() async {
545+
pragma;
546+
await assertNoErrorsInCode(r'''
547+
class A {
548+
@pragma('vm:entry-point')
549+
void _foo() {}
550+
}
551+
''');
552+
}
553+
544554
test_method_isUsed_hasReference_implicitThis() async {
545555
await assertNoErrorsInCode(r'''
546556
class A {
@@ -1440,6 +1450,13 @@ int f() {
14401450
''');
14411451
}
14421452

1453+
test_topLevelFunction_isUsed_hasPragma_vmEntryPoint() async {
1454+
await assertNoErrorsInCode(r'''
1455+
@pragma('vm:entry-point')
1456+
void _f() {}
1457+
''');
1458+
}
1459+
14431460
test_topLevelFunction_isUsed_invocation() async {
14441461
await assertNoErrorsInCode(r'''
14451462
_f() {}

pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import 'test_strategies.dart';
2626

2727
main() {
2828
defineReflectiveSuite(() {
29-
defineReflectiveTests(ResynthesizeAst2Test);
29+
defineReflectiveTests(ResynthesizeAstKeepLinkingTest);
30+
defineReflectiveTests(ResynthesizeAstFromBytesTest);
3031
// defineReflectiveTests(ApplyCheckElementTextReplacements);
3132
});
3233
}
@@ -39,11 +40,16 @@ class ApplyCheckElementTextReplacements {
3940
}
4041

4142
@reflectiveTest
42-
class ResynthesizeAst2Test extends AbstractResynthesizeTest
43+
abstract class ResynthesizeAst2Test extends AbstractResynthesizeTest
4344
with ResynthesizeTestCases {
4445
/// The shared SDK bundle, computed once and shared among test invocations.
4546
static _SdkBundle? _sdkBundle;
4647

48+
/// We need to test both cases - when we keep linking libraries (happens for
49+
/// new or invalidated libraries), and when we load libraries from bytes
50+
/// (happens internally in Blaze or when we have cached summaries).
51+
bool get keepLinkingLibraries;
52+
4753
_SdkBundle get sdkBundle {
4854
if (_sdkBundle != null) {
4955
return _sdkBundle!;
@@ -124,14 +130,18 @@ class ResynthesizeAst2Test extends AbstractResynthesizeTest
124130

125131
var linkResult = link(elementFactory, inputLibraries, true);
126132

127-
// TODO(scheglov) Remove to keep linking elements.
128-
elementFactory.addBundle(
129-
BundleReader(
130-
elementFactory: elementFactory,
131-
unitsInformativeBytes: unitsInformativeBytes,
132-
resolutionBytes: linkResult.resolutionBytes,
133-
),
134-
);
133+
if (!keepLinkingLibraries) {
134+
elementFactory.removeBundle(
135+
inputLibraries.map((e) => e.uriStr).toSet(),
136+
);
137+
elementFactory.addBundle(
138+
BundleReader(
139+
elementFactory: elementFactory,
140+
unitsInformativeBytes: unitsInformativeBytes,
141+
resolutionBytes: linkResult.resolutionBytes,
142+
),
143+
);
144+
}
135145

136146
return elementFactory.libraryOfUri('${source.uri}')!;
137147
}
@@ -232,6 +242,18 @@ class ResynthesizeAst2Test extends AbstractResynthesizeTest
232242
}
233243
}
234244

245+
@reflectiveTest
246+
class ResynthesizeAstFromBytesTest extends ResynthesizeAst2Test {
247+
@override
248+
bool get keepLinkingLibraries => false;
249+
}
250+
251+
@reflectiveTest
252+
class ResynthesizeAstKeepLinkingTest extends ResynthesizeAst2Test {
253+
@override
254+
bool get keepLinkingLibraries => true;
255+
}
256+
235257
class _AnalysisSessionForLinking implements AnalysisSessionImpl {
236258
@override
237259
final ClassHierarchy classHierarchy = ClassHierarchy();

pkg/compiler/lib/src/js_emitter/code_emitter_task.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ class CodeEmitterTask extends CompilerTask {
7979
// 'is$' method.
8080
typeTestRegistry.computeRequiredTypeChecks(
8181
_backendStrategy.rtiChecksBuilder, codegenWorld);
82-
// Compute the classes needed by RTI.
83-
typeTestRegistry.computeRtiNeededClasses(
84-
codegen.rtiSubstitutions, _backendStrategy.generatedCode.keys);
8582
}
8683

8784
/// Creates the [Emitter] for this task.
@@ -104,8 +101,7 @@ class CodeEmitterTask extends CompilerTask {
104101
_generateSourceMap);
105102
metadataCollector = new MetadataCollector(
106103
_compiler.reporter, _emitter, codegen.rtiRecipeEncoder);
107-
typeTestRegistry = new TypeTestRegistry(
108-
_compiler.options, closedWorld.elementEnvironment);
104+
typeTestRegistry = new TypeTestRegistry(_compiler.options);
109105
});
110106
}
111107

pkg/compiler/lib/src/js_emitter/program_builder/collector.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ class Collector {
175175
// 4. Find all class types needed for rti.
176176
for (ClassEntity cls in _rtiNeededClasses) {
177177
if (backendTypeHelpers.contains(cls)) continue;
178-
while (cls != null && neededClassTypes.add(cls)) {
179-
cls = _elementEnvironment.getSuperClass(cls);
180-
}
178+
neededClassTypes.add(cls);
181179
}
182180

183181
// 5. Sort classes and add them to their respective OutputUnits.

pkg/compiler/lib/src/js_emitter/type_test_registry.dart

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,20 @@
55
library dart2js.js_emitter.type_test_registry;
66

77
import '../common.dart';
8-
import '../common_elements.dart';
98
import '../elements/entities.dart';
109
import '../js_backend/runtime_types.dart'
1110
show RuntimeTypesChecks, RuntimeTypesChecksBuilder;
12-
import '../js_backend/runtime_types_codegen.dart'
13-
show RuntimeTypesSubstitutions;
1411
import '../options.dart';
1512
import '../universe/codegen_world_builder.dart';
1613

14+
/// TODO(joshualitt): Delete this class and store [RuntimeTypeChecks] on
15+
/// [CodeEmitterTask] directly.
1716
class TypeTestRegistry {
18-
final ElementEnvironment _elementEnvironment;
19-
20-
/// After [computeNeededClasses] this set only contains classes that are only
21-
/// used for RTI.
22-
Set<ClassEntity> _rtiNeededClasses;
23-
2417
final CompilerOptions _options;
2518

2619
RuntimeTypesChecks _rtiChecks;
2720

28-
TypeTestRegistry(this._options, this._elementEnvironment);
21+
TypeTestRegistry(this._options);
2922

3023
RuntimeTypesChecks get rtiChecks {
3124
assert(
@@ -36,35 +29,7 @@ class TypeTestRegistry {
3629
}
3730

3831
Iterable<ClassEntity> get rtiNeededClasses {
39-
assert(
40-
_rtiNeededClasses != null,
41-
failedAt(NO_LOCATION_SPANNABLE,
42-
"rtiNeededClasses has not been computed yet."));
43-
return _rtiNeededClasses;
44-
}
45-
46-
void computeRtiNeededClasses(RuntimeTypesSubstitutions rtiSubstitutions,
47-
Iterable<MemberEntity> liveMembers) {
48-
_rtiNeededClasses = new Set<ClassEntity>();
49-
50-
void addClassWithSuperclasses(ClassEntity cls) {
51-
_rtiNeededClasses.add(cls);
52-
for (ClassEntity superclass = _elementEnvironment.getSuperClass(cls);
53-
superclass != null;
54-
superclass = _elementEnvironment.getSuperClass(superclass)) {
55-
_rtiNeededClasses.add(superclass);
56-
}
57-
}
58-
59-
void addClassesWithSuperclasses(Iterable<ClassEntity> classes) {
60-
for (ClassEntity cls in classes) {
61-
addClassWithSuperclasses(cls);
62-
}
63-
}
64-
65-
// Add classes that are referenced by type arguments or substitutions in
66-
// argument checks.
67-
addClassesWithSuperclasses(rtiChecks.requiredClasses);
32+
return rtiChecks.requiredClasses;
6833
}
6934

7035
void computeRequiredTypeChecks(

0 commit comments

Comments
 (0)