Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Side by Side Diff: pkg/compiler/lib/src/resolution/resolution.dart

Issue 1394923003: Use WorldImpact for element dependencies in deferred_load (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.resolution; 5 library dart2js.resolution;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show 10 import '../common/names.dart' show
11 Identifiers; 11 Identifiers;
12 import '../common/resolution.dart' show 12 import '../common/resolution.dart' show
13 Parsing, 13 Parsing,
14 Resolution, 14 Resolution,
15 ResolutionWorldImpact; 15 ResolutionImpact;
16 import '../common/tasks.dart' show 16 import '../common/tasks.dart' show
17 CompilerTask, 17 CompilerTask,
18 DeferredAction; 18 DeferredAction;
19 import '../compiler.dart' show 19 import '../compiler.dart' show
20 Compiler; 20 Compiler;
21 import '../compile_time_constants.dart' show 21 import '../compile_time_constants.dart' show
22 ConstantCompiler; 22 ConstantCompiler;
23 import '../constants/values.dart' show 23 import '../constants/values.dart' show
24 ConstantValue; 24 ConstantValue;
25 import '../dart_types.dart'; 25 import '../dart_types.dart';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 final ConstantCompiler constantCompiler; 63 final ConstantCompiler constantCompiler;
64 64
65 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); 65 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler);
66 66
67 String get name => 'Resolver'; 67 String get name => 'Resolver';
68 68
69 Resolution get resolution => compiler.resolution; 69 Resolution get resolution => compiler.resolution;
70 70
71 Parsing get parsing => compiler.parsing; 71 Parsing get parsing => compiler.parsing;
72 72
73 ResolutionWorldImpact resolve(Element element) { 73 ResolutionImpact resolve(Element element) {
74 return measure(() { 74 return measure(() {
75 if (Elements.isErroneous(element)) { 75 if (Elements.isErroneous(element)) {
76 // TODO(johnniwinther): Add a predicate for this. 76 // TODO(johnniwinther): Add a predicate for this.
77 assert(invariant(element, element is! ErroneousElement, 77 assert(invariant(element, element is! ErroneousElement,
78 message: "Element $element expected to have parse errors.")); 78 message: "Element $element expected to have parse errors."));
79 _ensureTreeElements(element); 79 _ensureTreeElements(element);
80 return const ResolutionWorldImpact(); 80 return const ResolutionImpact();
81 } 81 }
82 82
83 WorldImpact processMetadata([WorldImpact result]) { 83 WorldImpact processMetadata([WorldImpact result]) {
84 for (MetadataAnnotation metadata in element.implementation.metadata) { 84 for (MetadataAnnotation metadata in element.implementation.metadata) {
85 metadata.ensureResolved(resolution); 85 metadata.ensureResolved(resolution);
86 } 86 }
87 return result; 87 return result;
88 } 88 }
89 89
90 ElementKind kind = element.kind; 90 ElementKind kind = element.kind;
91 if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR) || 91 if (identical(kind, ElementKind.GENERATIVE_CONSTRUCTOR) ||
92 identical(kind, ElementKind.FUNCTION) || 92 identical(kind, ElementKind.FUNCTION) ||
93 identical(kind, ElementKind.GETTER) || 93 identical(kind, ElementKind.GETTER) ||
94 identical(kind, ElementKind.SETTER)) { 94 identical(kind, ElementKind.SETTER)) {
95 return processMetadata(resolveMethodElement(element)); 95 return processMetadata(resolveMethodElement(element));
96 } 96 }
97 97
98 if (identical(kind, ElementKind.FIELD)) { 98 if (identical(kind, ElementKind.FIELD)) {
99 return processMetadata(resolveField(element)); 99 return processMetadata(resolveField(element));
100 } 100 }
101 if (element.isClass) { 101 if (element.isClass) {
102 ClassElement cls = element; 102 ClassElement cls = element;
103 cls.ensureResolved(resolution); 103 cls.ensureResolved(resolution);
104 return processMetadata(const ResolutionWorldImpact()); 104 return processMetadata(const ResolutionImpact());
105 } else if (element.isTypedef) { 105 } else if (element.isTypedef) {
106 TypedefElement typdef = element; 106 TypedefElement typdef = element;
107 return processMetadata(resolveTypedef(typdef)); 107 return processMetadata(resolveTypedef(typdef));
108 } 108 }
109 109
110 compiler.unimplemented(element, "resolve($element)"); 110 compiler.unimplemented(element, "resolve($element)");
111 }); 111 });
112 } 112 }
113 113
114 void resolveRedirectingConstructor(InitializerResolver resolver, 114 void resolveRedirectingConstructor(InitializerResolver resolver,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 WorldImpact resolveMethodElement(FunctionElementX element) { 279 WorldImpact resolveMethodElement(FunctionElementX element) {
280 assert(invariant(element, element.isDeclaration)); 280 assert(invariant(element, element.isDeclaration));
281 return reporter.withCurrentElement(element, () { 281 return reporter.withCurrentElement(element, () {
282 if (compiler.enqueuer.resolution.hasBeenProcessed(element)) { 282 if (compiler.enqueuer.resolution.hasBeenProcessed(element)) {
283 // TODO(karlklose): Remove the check for [isConstructor]. [elememts] 283 // TODO(karlklose): Remove the check for [isConstructor]. [elememts]
284 // should never be non-null, not even for constructors. 284 // should never be non-null, not even for constructors.
285 assert(invariant(element, element.isConstructor, 285 assert(invariant(element, element.isConstructor,
286 message: 'Non-constructor element $element ' 286 message: 'Non-constructor element $element '
287 'has already been analyzed.')); 287 'has already been analyzed.'));
288 return const ResolutionWorldImpact(); 288 return const ResolutionImpact();
289 } 289 }
290 if (element.isSynthesized) { 290 if (element.isSynthesized) {
291 if (element.isGenerativeConstructor) { 291 if (element.isGenerativeConstructor) {
292 ResolutionRegistry registry = 292 ResolutionRegistry registry =
293 new ResolutionRegistry(compiler, _ensureTreeElements(element)); 293 new ResolutionRegistry(compiler, _ensureTreeElements(element));
294 ConstructorElement constructor = element.asFunctionElement(); 294 ConstructorElement constructor = element.asFunctionElement();
295 ConstructorElement target = constructor.definingConstructor; 295 ConstructorElement target = constructor.definingConstructor;
296 // Ensure the signature of the synthesized element is 296 // Ensure the signature of the synthesized element is
297 // resolved. This is the only place where the resolver is 297 // resolved. This is the only place where the resolver is
298 // seeing this element. 298 // seeing this element.
299 element.computeType(resolution); 299 element.computeType(resolution);
300 if (!target.isErroneous) { 300 if (!target.isErroneous) {
301 registry.registerStaticUse(target); 301 registry.registerStaticUse(target);
302 registry.registerImplicitSuperCall(target); 302 registry.registerImplicitSuperCall(target);
303 } 303 }
304 return registry.worldImpact; 304 return registry.worldImpact;
305 } else { 305 } else {
306 assert(element.isDeferredLoaderGetter || element.isErroneous); 306 assert(element.isDeferredLoaderGetter || element.isErroneous);
307 _ensureTreeElements(element); 307 _ensureTreeElements(element);
308 return const ResolutionWorldImpact(); 308 return const ResolutionImpact();
309 } 309 }
310 } else { 310 } else {
311 element.parseNode(resolution.parsing); 311 element.parseNode(resolution.parsing);
312 element.computeType(resolution); 312 element.computeType(resolution);
313 FunctionElementX implementation = element; 313 FunctionElementX implementation = element;
314 if (element.isExternal) { 314 if (element.isExternal) {
315 implementation = compiler.backend.resolveExternalFunction(element); 315 implementation = compiler.backend.resolveExternalFunction(element);
316 } 316 }
317 return resolveMethodElementImplementation( 317 return resolveMethodElementImplementation(
318 implementation, implementation.node); 318 implementation, implementation.node);
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 FunctionExpression node = element.parseNode(parsing); 980 FunctionExpression node = element.parseNode(parsing);
981 return measure(() => SignatureResolver.analyze( 981 return measure(() => SignatureResolver.analyze(
982 compiler, node.parameters, node.returnType, element, 982 compiler, node.parameters, node.returnType, element,
983 new ResolutionRegistry(compiler, _ensureTreeElements(element)), 983 new ResolutionRegistry(compiler, _ensureTreeElements(element)),
984 defaultValuesError: defaultValuesError, 984 defaultValuesError: defaultValuesError,
985 createRealParameters: true)); 985 createRealParameters: true));
986 }); 986 });
987 } 987 }
988 988
989 WorldImpact resolveTypedef(TypedefElementX element) { 989 WorldImpact resolveTypedef(TypedefElementX element) {
990 if (element.isResolved) return const ResolutionWorldImpact(); 990 if (element.isResolved) return const ResolutionImpact();
991 compiler.world.allTypedefs.add(element); 991 compiler.world.allTypedefs.add(element);
992 return _resolveTypeDeclaration(element, () { 992 return _resolveTypeDeclaration(element, () {
993 ResolutionRegistry registry = new ResolutionRegistry( 993 ResolutionRegistry registry = new ResolutionRegistry(
994 compiler, _ensureTreeElements(element)); 994 compiler, _ensureTreeElements(element));
995 return reporter.withCurrentElement(element, () { 995 return reporter.withCurrentElement(element, () {
996 return measure(() { 996 return measure(() {
997 assert(element.resolutionState == STATE_NOT_STARTED); 997 assert(element.resolutionState == STATE_NOT_STARTED);
998 element.resolutionState = STATE_STARTED; 998 element.resolutionState = STATE_STARTED;
999 Typedef node = element.parseNode(parsing); 999 Typedef node = element.parseNode(parsing);
1000 TypedefResolverVisitor visitor = 1000 TypedefResolverVisitor visitor =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 TreeElements get treeElements { 1068 TreeElements get treeElements {
1069 assert(invariant(this, _treeElements !=null, 1069 assert(invariant(this, _treeElements !=null,
1070 message: "TreeElements have not been computed for $this.")); 1070 message: "TreeElements have not been computed for $this."));
1071 return _treeElements; 1071 return _treeElements;
1072 } 1072 }
1073 1073
1074 void reuseElement() { 1074 void reuseElement() {
1075 _treeElements = null; 1075 _treeElements = null;
1076 } 1076 }
1077 } 1077 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698