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

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

Issue 1182913003: Split TypedSelector into Selector and TypeMask. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 6 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 | « pkg/compiler/lib/src/use_unused_api.dart ('k') | tests/compiler/dart2js/compiler_helper.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 part of dart2js; 5 part of dart2js;
6 6
7 abstract class ClassWorld { 7 abstract class ClassWorld {
8 // TODO(johnniwinther): Refine this into a `BackendClasses` interface. 8 // TODO(johnniwinther): Refine this into a `BackendClasses` interface.
9 Backend get backend; 9 Backend get backend;
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 class World implements ClassWorld { 105 class World implements ClassWorld {
106 ClassElement get objectClass => compiler.objectClass; 106 ClassElement get objectClass => compiler.objectClass;
107 ClassElement get functionClass => compiler.functionClass; 107 ClassElement get functionClass => compiler.functionClass;
108 ClassElement get boolClass => compiler.boolClass; 108 ClassElement get boolClass => compiler.boolClass;
109 ClassElement get numClass => compiler.numClass; 109 ClassElement get numClass => compiler.numClass;
110 ClassElement get intClass => compiler.intClass; 110 ClassElement get intClass => compiler.intClass;
111 ClassElement get doubleClass => compiler.doubleClass; 111 ClassElement get doubleClass => compiler.doubleClass;
112 ClassElement get stringClass => compiler.stringClass; 112 ClassElement get stringClass => compiler.stringClass;
113 113
114 Map<Selector, Map<ti.TypeMask, TypedSelector>> canonicalizedValues = 114 /// Cache of [ti.FlatTypeMask]s grouped by the 8 possible values of the
115 new Map<Selector, Map<ti.TypeMask, TypedSelector>>(); 115 /// [ti.FlatTypeMask.flags] property.
116 List<Map<ClassElement, ti.TypeMask>> canonicalizedTypeMasks =
117 new List<Map<ClassElement, ti.TypeMask>>.filled(8, null);
116 118
117 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) { 119 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) {
118 return 120 return
119 invariant(cls, cls.isDeclaration, 121 invariant(cls, cls.isDeclaration,
120 message: '$cls must be the declaration.') && 122 message: '$cls must be the declaration.') &&
121 invariant(cls, cls.isResolved, 123 invariant(cls, cls.isResolved,
122 message: '$cls must be resolved.') && 124 message: '$cls must be resolved.') &&
123 (!mustBeInstantiated || 125 (!mustBeInstantiated ||
124 invariant(cls, isInstantiated(cls), 126 invariant(cls, isInstantiated(cls),
125 message: '$cls is not instantiated.')); 127 message: '$cls is not instantiated.'));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 ClassElement mixin) { 400 ClassElement mixin) {
399 // TODO(johnniwinther): Add map restricted to live classes. 401 // TODO(johnniwinther): Add map restricted to live classes.
400 // We don't support patch classes as mixin. 402 // We don't support patch classes as mixin.
401 assert(mixin.isDeclaration); 403 assert(mixin.isDeclaration);
402 List<MixinApplicationElement> users = 404 List<MixinApplicationElement> users =
403 _mixinUses.putIfAbsent(mixin, () => 405 _mixinUses.putIfAbsent(mixin, () =>
404 new List<MixinApplicationElement>()); 406 new List<MixinApplicationElement>());
405 users.add(mixinApplication); 407 users.add(mixinApplication);
406 } 408 }
407 409
408 bool hasAnyUserDefinedGetter(Selector selector) { 410 bool hasAnyUserDefinedGetter(Selector selector, ti.TypeMask mask) {
409 return allFunctions.filter(selector).any((each) => each.isGetter); 411 return allFunctions.filter(selector, mask).any((each) => each.isGetter);
410 } 412 }
411 413
412 void registerUsedElement(Element element) { 414 void registerUsedElement(Element element) {
413 if (element.isInstanceMember && !element.isAbstract) { 415 if (element.isInstanceMember && !element.isAbstract) {
414 allFunctions.add(element); 416 allFunctions.add(element);
415 } 417 }
416 } 418 }
417 419
418 VariableElement locateSingleField(Selector selector) { 420 VariableElement locateSingleField(Selector selector, ti.TypeMask mask) {
419 Element result = locateSingleElement(selector); 421 Element result = locateSingleElement(selector, mask);
420 return (result != null && result.isField) ? result : null; 422 return (result != null && result.isField) ? result : null;
421 } 423 }
422 424
423 Element locateSingleElement(Selector selector) { 425 Element locateSingleElement(Selector selector, ti.TypeMask mask) {
424 ti.TypeMask mask = selector.mask == null 426 mask = mask == null
425 ? compiler.typesTask.dynamicType 427 ? compiler.typesTask.dynamicType
426 : selector.mask; 428 : mask;
427 return mask.locateSingleElement(selector, compiler); 429 return mask.locateSingleElement(selector, mask, compiler);
430 }
431
432 ti.TypeMask extendMaskIfReachesAll(Selector selector, ti.TypeMask mask) {
433 bool canReachAll = true;
434 if (mask != null) {
435 canReachAll =
436 compiler.enabledInvokeOn &&
437 mask.needsNoSuchMethodHandling(selector, this);
438 }
439 return canReachAll ? compiler.typesTask.dynamicType : mask;
428 } 440 }
429 441
430 void addFunctionCalledInLoop(Element element) { 442 void addFunctionCalledInLoop(Element element) {
431 functionsCalledInLoop.add(element.declaration); 443 functionsCalledInLoop.add(element.declaration);
432 } 444 }
433 445
434 bool isCalledInLoop(Element element) { 446 bool isCalledInLoop(Element element) {
435 return functionsCalledInLoop.contains(element.declaration); 447 return functionsCalledInLoop.contains(element.declaration);
436 } 448 }
437 449
(...skipping 30 matching lines...) Expand all
468 void registerSideEffects(Element element, SideEffects effects) { 480 void registerSideEffects(Element element, SideEffects effects) {
469 if (sideEffectsFreeElements.contains(element)) return; 481 if (sideEffectsFreeElements.contains(element)) return;
470 sideEffects[element.declaration] = effects; 482 sideEffects[element.declaration] = effects;
471 } 483 }
472 484
473 void registerSideEffectsFree(Element element) { 485 void registerSideEffectsFree(Element element) {
474 sideEffects[element.declaration] = new SideEffects.empty(); 486 sideEffects[element.declaration] = new SideEffects.empty();
475 sideEffectsFreeElements.add(element); 487 sideEffectsFreeElements.add(element);
476 } 488 }
477 489
478 SideEffects getSideEffectsOfSelector(Selector selector) { 490 SideEffects getSideEffectsOfSelector(Selector selector, ti.TypeMask mask) {
479 // We're not tracking side effects of closures. 491 // We're not tracking side effects of closures.
480 if (selector.isClosureCall) return new SideEffects(); 492 if (selector.isClosureCall) return new SideEffects();
481 SideEffects sideEffects = new SideEffects.empty(); 493 SideEffects sideEffects = new SideEffects.empty();
482 for (Element e in allFunctions.filter(selector)) { 494 for (Element e in allFunctions.filter(selector, mask)) {
483 if (e.isField) { 495 if (e.isField) {
484 if (selector.isGetter) { 496 if (selector.isGetter) {
485 if (!fieldNeverChanges(e)) { 497 if (!fieldNeverChanges(e)) {
486 sideEffects.setDependsOnInstancePropertyStore(); 498 sideEffects.setDependsOnInstancePropertyStore();
487 } 499 }
488 } else if (selector.isSetter) { 500 } else if (selector.isSetter) {
489 sideEffects.setChangesInstanceProperty(); 501 sideEffects.setChangesInstanceProperty();
490 } else { 502 } else {
491 assert(selector.isCall); 503 assert(selector.isCall);
492 sideEffects.setAllSideEffects(); 504 sideEffects.setAllSideEffects();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // function expressions's element. 536 // function expressions's element.
525 // TODO(herhut): Generate classes for function expressions earlier. 537 // TODO(herhut): Generate classes for function expressions earlier.
526 if (element is closureMapping.SynthesizedCallMethodElementX) { 538 if (element is closureMapping.SynthesizedCallMethodElementX) {
527 return getMightBePassedToApply(element.expression); 539 return getMightBePassedToApply(element.expression);
528 } 540 }
529 return functionsThatMightBePassedToApply.contains(element); 541 return functionsThatMightBePassedToApply.contains(element);
530 } 542 }
531 543
532 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; 544 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport;
533 } 545 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/use_unused_api.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698