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

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

Issue 2306423002: Further separate CodegenEnqueuer from ResolutionEnqueuer (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.enqueue; 5 library dart2js.enqueue;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import 'common/names.dart' show Identifiers; 9 import 'common/names.dart' show Identifiers;
10 import 'common/resolution.dart' show Resolution; 10 import 'common/resolution.dart' show Resolution;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 302
303 void processInstantiatedClass(ClassElement cls) { 303 void processInstantiatedClass(ClassElement cls) {
304 task.measure(() { 304 task.measure(() {
305 if (_processedClasses.contains(cls)) return; 305 if (_processedClasses.contains(cls)) return;
306 // The class must be resolved to compute the set of all 306 // The class must be resolved to compute the set of all
307 // supertypes. 307 // supertypes.
308 cls.ensureResolved(resolution); 308 cls.ensureResolved(resolution);
309 309
310 void processClass(ClassElement superclass) { 310 void processClass(ClassElement superclass) {
311 if (_processedClasses.contains(superclass)) return; 311 if (_processedClasses.contains(superclass)) return;
312 // TODO(johnniwinther): Re-insert this invariant when unittests don't
313 // fail. There is already a similar invariant on the members.
314 /*if (!isResolutionQueue) {
315 assert(invariant(superclass,
316 superclass.isClosure ||
317 compiler.enqueuer.resolution.isClassProcessed(superclass),
318 message: "Class $superclass has not been "
319 "processed in resolution."));
320 }*/
321 312
322 _processedClasses.add(superclass); 313 _processedClasses.add(superclass);
323 recentClasses.add(superclass); 314 recentClasses.add(superclass);
324 superclass.ensureResolved(resolution); 315 superclass.ensureResolved(resolution);
325 superclass.implementation.forEachMember(processInstantiatedClassMember); 316 superclass.implementation.forEachMember(processInstantiatedClassMember);
326 if (isResolutionQueue && 317 if (!compiler.serialization.isDeserialized(superclass)) {
327 !compiler.serialization.isDeserialized(superclass)) {
328 compiler.resolver.checkClass(superclass); 318 compiler.resolver.checkClass(superclass);
329 } 319 }
330 // We only tell the backend once that [superclass] was instantiated, so 320 // We only tell the backend once that [superclass] was instantiated, so
331 // any additional dependencies must be treated as global 321 // any additional dependencies must be treated as global
332 // dependencies. 322 // dependencies.
333 compiler.backend.registerInstantiatedClass( 323 compiler.backend.registerInstantiatedClass(
334 superclass, this, compiler.globalDependencies); 324 superclass, this, compiler.globalDependencies);
335 } 325 }
336 326
337 ClassElement superclass = cls; 327 ClassElement superclass = cls;
338 while (superclass != null) { 328 while (superclass != null) {
339 processClass(superclass); 329 processClass(superclass);
340 superclass = superclass.superclass; 330 superclass = superclass.superclass;
341 } 331 }
342 }); 332 });
343 } 333 }
344 334
345 void registerDynamicUse(DynamicUse dynamicUse) { 335 void registerDynamicUse(DynamicUse dynamicUse) {
346 task.measure(() { 336 task.measure(() {
347 if (universe.registerDynamicUse(dynamicUse)) { 337 if (universe.registerDynamicUse(dynamicUse)) {
348 handleUnseenSelector(dynamicUse); 338 handleUnseenSelector(dynamicUse);
349 } 339 }
350 }); 340 });
351 } 341 }
352 342
353 void logEnqueueReflectiveAction(action, [msg = ""]) { 343 void logEnqueueReflectiveAction(action, [msg = ""]) {
354 if (TRACE_MIRROR_ENQUEUING) { 344 if (TRACE_MIRROR_ENQUEUING) {
355 print("MIRROR_ENQUEUE (${isResolutionQueue ? "R" : "C"}): $action $msg"); 345 print("MIRROR_ENQUEUE (R): $action $msg");
356 } 346 }
357 } 347 }
358 348
359 /// Enqeue the constructor [ctor] if it is required for reflection. 349 /// Enqeue the constructor [ctor] if it is required for reflection.
360 /// 350 ///
361 /// [enclosingWasIncluded] provides a hint whether the enclosing element was 351 /// [enclosingWasIncluded] provides a hint whether the enclosing element was
362 /// needed for reflection. 352 /// needed for reflection.
363 void enqueueReflectiveConstructor( 353 void enqueueReflectiveConstructor(
364 ConstructorElement ctor, bool enclosingWasIncluded) { 354 ConstructorElement ctor, bool enclosingWasIncluded) {
365 if (shouldIncludeElementDueToMirrors(ctor, 355 if (shouldIncludeElementDueToMirrors(ctor,
(...skipping 11 matching lines...) Expand all
377 /// 367 ///
378 /// [enclosingWasIncluded] provides a hint whether the enclosing element was 368 /// [enclosingWasIncluded] provides a hint whether the enclosing element was
379 /// needed for reflection. 369 /// needed for reflection.
380 void enqueueReflectiveMember(Element element, bool enclosingWasIncluded) { 370 void enqueueReflectiveMember(Element element, bool enclosingWasIncluded) {
381 if (shouldIncludeElementDueToMirrors(element, 371 if (shouldIncludeElementDueToMirrors(element,
382 includedEnclosing: enclosingWasIncluded)) { 372 includedEnclosing: enclosingWasIncluded)) {
383 logEnqueueReflectiveAction(element); 373 logEnqueueReflectiveAction(element);
384 if (element.isTypedef) { 374 if (element.isTypedef) {
385 TypedefElement typedef = element; 375 TypedefElement typedef = element;
386 typedef.ensureResolved(resolution); 376 typedef.ensureResolved(resolution);
387 compiler.world.allTypedefs.add(element);
388 } else if (Elements.isStaticOrTopLevel(element)) { 377 } else if (Elements.isStaticOrTopLevel(element)) {
389 registerStaticUse(new StaticUse.foreignUse(element.declaration)); 378 registerStaticUse(new StaticUse.foreignUse(element.declaration));
390 } else if (element.isInstanceMember) { 379 } else if (element.isInstanceMember) {
391 // We need to enqueue all members matching this one in subclasses, as 380 // We need to enqueue all members matching this one in subclasses, as
392 // well. 381 // well.
393 // TODO(herhut): Use TypedSelector.subtype for enqueueing 382 // TODO(herhut): Use TypedSelector.subtype for enqueueing
394 DynamicUse dynamicUse = 383 DynamicUse dynamicUse =
395 new DynamicUse(new Selector.fromElement(element), null); 384 new DynamicUse(new Selector.fromElement(element), null);
396 registerDynamicUse(dynamicUse); 385 registerDynamicUse(dynamicUse);
397 if (element.isField) { 386 if (element.isField) {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 901 }
913 902
914 typedef void _DeferredActionFunction(); 903 typedef void _DeferredActionFunction();
915 904
916 class _DeferredAction { 905 class _DeferredAction {
917 final Element element; 906 final Element element;
918 final _DeferredActionFunction action; 907 final _DeferredActionFunction action;
919 908
920 _DeferredAction(this.element, this.action); 909 _DeferredAction(this.element, this.action);
921 } 910 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698