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

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: Add SelectorMask for FunctionSetNode.cache 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
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 List<Map<ClassElement, ti.TypeMask>> canonicalizedTypeMasks =
115 new Map<Selector, Map<ti.TypeMask, TypedSelector>>(); 115 new List<Map<ClassElement, ti.TypeMask>>.filled(8, null);
herhut 2015/06/24 15:19:29 I don't like the magic 8 here but I also have no s
Johnni Winther 2015/06/25 07:25:28 Added a comment explaining the relation.
116 116
117 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) { 117 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) {
118 return 118 return
119 invariant(cls, cls.isDeclaration, 119 invariant(cls, cls.isDeclaration,
120 message: '$cls must be the declaration.') && 120 message: '$cls must be the declaration.') &&
121 invariant(cls, cls.isResolved, 121 invariant(cls, cls.isResolved,
122 message: '$cls must be resolved.') && 122 message: '$cls must be resolved.') &&
123 (!mustBeInstantiated || 123 (!mustBeInstantiated ||
124 invariant(cls, isInstantiated(cls), 124 invariant(cls, isInstantiated(cls),
125 message: '$cls is not instantiated.')); 125 message: '$cls is not instantiated.'));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 ClassElement mixin) { 398 ClassElement mixin) {
399 // TODO(johnniwinther): Add map restricted to live classes. 399 // TODO(johnniwinther): Add map restricted to live classes.
400 // We don't support patch classes as mixin. 400 // We don't support patch classes as mixin.
401 assert(mixin.isDeclaration); 401 assert(mixin.isDeclaration);
402 List<MixinApplicationElement> users = 402 List<MixinApplicationElement> users =
403 _mixinUses.putIfAbsent(mixin, () => 403 _mixinUses.putIfAbsent(mixin, () =>
404 new List<MixinApplicationElement>()); 404 new List<MixinApplicationElement>());
405 users.add(mixinApplication); 405 users.add(mixinApplication);
406 } 406 }
407 407
408 bool hasAnyUserDefinedGetter(Selector selector) { 408 bool hasAnyUserDefinedGetter(Selector selector, ti.TypeMask mask) {
409 return allFunctions.filter(selector).any((each) => each.isGetter); 409 return allFunctions.filter(selector, mask).any((each) => each.isGetter);
410 } 410 }
411 411
412 void registerUsedElement(Element element) { 412 void registerUsedElement(Element element) {
413 if (element.isInstanceMember && !element.isAbstract) { 413 if (element.isInstanceMember && !element.isAbstract) {
414 allFunctions.add(element); 414 allFunctions.add(element);
415 } 415 }
416 } 416 }
417 417
418 VariableElement locateSingleField(Selector selector) { 418 VariableElement locateSingleField(Selector selector, ti.TypeMask mask) {
419 Element result = locateSingleElement(selector); 419 Element result = locateSingleElement(selector, mask);
420 return (result != null && result.isField) ? result : null; 420 return (result != null && result.isField) ? result : null;
421 } 421 }
422 422
423 Element locateSingleElement(Selector selector) { 423 Element locateSingleElement(Selector selector, ti.TypeMask mask) {
424 ti.TypeMask mask = selector.mask == null 424 mask = mask == null
425 ? compiler.typesTask.dynamicType 425 ? compiler.typesTask.dynamicType
426 : selector.mask; 426 : mask;
427 return mask.locateSingleElement(selector, compiler); 427 return mask.locateSingleElement(selector, mask, compiler);
428 }
429
430 ti.TypeMask extendMaskIfReachesAll(Selector selector, ti.TypeMask mask) {
431 bool canReachAll = true;
432 if (mask != null) {
433 canReachAll =
434 compiler.enabledInvokeOn &&
435 mask.needsNoSuchMethodHandling(selector, this);
436 }
437 return canReachAll ? compiler.typesTask.dynamicType : mask;
428 } 438 }
429 439
430 void addFunctionCalledInLoop(Element element) { 440 void addFunctionCalledInLoop(Element element) {
431 functionsCalledInLoop.add(element.declaration); 441 functionsCalledInLoop.add(element.declaration);
432 } 442 }
433 443
434 bool isCalledInLoop(Element element) { 444 bool isCalledInLoop(Element element) {
435 return functionsCalledInLoop.contains(element.declaration); 445 return functionsCalledInLoop.contains(element.declaration);
436 } 446 }
437 447
(...skipping 30 matching lines...) Expand all
468 void registerSideEffects(Element element, SideEffects effects) { 478 void registerSideEffects(Element element, SideEffects effects) {
469 if (sideEffectsFreeElements.contains(element)) return; 479 if (sideEffectsFreeElements.contains(element)) return;
470 sideEffects[element.declaration] = effects; 480 sideEffects[element.declaration] = effects;
471 } 481 }
472 482
473 void registerSideEffectsFree(Element element) { 483 void registerSideEffectsFree(Element element) {
474 sideEffects[element.declaration] = new SideEffects.empty(); 484 sideEffects[element.declaration] = new SideEffects.empty();
475 sideEffectsFreeElements.add(element); 485 sideEffectsFreeElements.add(element);
476 } 486 }
477 487
478 SideEffects getSideEffectsOfSelector(Selector selector) { 488 SideEffects getSideEffectsOfSelector(Selector selector, ti.TypeMask mask) {
479 // We're not tracking side effects of closures. 489 // We're not tracking side effects of closures.
480 if (selector.isClosureCall) return new SideEffects(); 490 if (selector.isClosureCall) return new SideEffects();
481 SideEffects sideEffects = new SideEffects.empty(); 491 SideEffects sideEffects = new SideEffects.empty();
482 for (Element e in allFunctions.filter(selector)) { 492 for (Element e in allFunctions.filter(selector, mask)) {
483 if (e.isField) { 493 if (e.isField) {
484 if (selector.isGetter) { 494 if (selector.isGetter) {
485 if (!fieldNeverChanges(e)) { 495 if (!fieldNeverChanges(e)) {
486 sideEffects.setDependsOnInstancePropertyStore(); 496 sideEffects.setDependsOnInstancePropertyStore();
487 } 497 }
488 } else if (selector.isSetter) { 498 } else if (selector.isSetter) {
489 sideEffects.setChangesInstanceProperty(); 499 sideEffects.setChangesInstanceProperty();
490 } else { 500 } else {
491 assert(selector.isCall); 501 assert(selector.isCall);
492 sideEffects.setAllSideEffects(); 502 sideEffects.setAllSideEffects();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 // function expressions's element. 534 // function expressions's element.
525 // TODO(herhut): Generate classes for function expressions earlier. 535 // TODO(herhut): Generate classes for function expressions earlier.
526 if (element is closureMapping.SynthesizedCallMethodElementX) { 536 if (element is closureMapping.SynthesizedCallMethodElementX) {
527 return getMightBePassedToApply(element.expression); 537 return getMightBePassedToApply(element.expression);
528 } 538 }
529 return functionsThatMightBePassedToApply.contains(element); 539 return functionsThatMightBePassedToApply.contains(element);
530 } 540 }
531 541
532 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; 542 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport;
533 } 543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698