| OLD | NEW |
| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
| 8 | 8 |
| 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 * (unintercepted) classes. | 316 * (unintercepted) classes. |
| 317 */ | 317 */ |
| 318 final Set<ClassElement> classesMixedIntoInterceptedClasses = | 318 final Set<ClassElement> classesMixedIntoInterceptedClasses = |
| 319 new Set<ClassElement>(); | 319 new Set<ClassElement>(); |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * Set of classes whose `operator ==` methods handle `null` themselves. | 322 * Set of classes whose `operator ==` methods handle `null` themselves. |
| 323 */ | 323 */ |
| 324 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); | 324 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); |
| 325 | 325 |
| 326 /** |
| 327 * A Map from classes to the members of superclasses they call via super. |
| 328 */ |
| 329 final Map<ClassElement, Set<Element>> aliasedSuperMembers = |
| 330 new Map<ClassElement, Set<Element>>(); |
| 331 |
| 326 List<CompilerTask> get tasks { | 332 List<CompilerTask> get tasks { |
| 327 return <CompilerTask>[builder, optimizer, generator, emitter]; | 333 return <CompilerTask>[builder, optimizer, generator, emitter]; |
| 328 } | 334 } |
| 329 | 335 |
| 330 final RuntimeTypes rti; | 336 final RuntimeTypes rti; |
| 331 | 337 |
| 332 /// Holds the method "disableTreeShaking" in js_mirrors when | 338 /// Holds the method "disableTreeShaking" in js_mirrors when |
| 333 /// dart:mirrors has been loaded. | 339 /// dart:mirrors has been loaded. |
| 334 FunctionElement disableTreeShakingMarker; | 340 FunctionElement disableTreeShakingMarker; |
| 335 | 341 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 String registerOneShotInterceptor(Selector selector) { | 527 String registerOneShotInterceptor(Selector selector) { |
| 522 Set<ClassElement> classes = getInterceptedClassesOn(selector.name); | 528 Set<ClassElement> classes = getInterceptedClassesOn(selector.name); |
| 523 String name = namer.getOneShotInterceptorName(selector, classes); | 529 String name = namer.getOneShotInterceptorName(selector, classes); |
| 524 if (!oneShotInterceptors.containsKey(name)) { | 530 if (!oneShotInterceptors.containsKey(name)) { |
| 525 registerSpecializedGetInterceptor(classes); | 531 registerSpecializedGetInterceptor(classes); |
| 526 oneShotInterceptors[name] = selector; | 532 oneShotInterceptors[name] = selector; |
| 527 } | 533 } |
| 528 return name; | 534 return name; |
| 529 } | 535 } |
| 530 | 536 |
| 537 void registerAliasedSuperMember(Element method, ClassElement caller) { |
| 538 Set<Element> methods = |
| 539 aliasedSuperMembers.putIfAbsent(caller, () => new Setlet<Element>()); |
| 540 methods.add(method); |
| 541 } |
| 542 |
| 543 Set<Element> getAliasedSuperMembers(ClassElement subclass) { |
| 544 Set<Element> aliases = aliasedSuperMembers[subclass]; |
| 545 if (aliases == null) return const ImmutableEmptySet<Element>(); |
| 546 return aliases; |
| 547 } |
| 548 |
| 531 bool isInterceptedMethod(Element element) { | 549 bool isInterceptedMethod(Element element) { |
| 532 if (!element.isInstanceMember) return false; | 550 if (!element.isInstanceMember) return false; |
| 533 if (element.isGenerativeConstructorBody) { | 551 if (element.isGenerativeConstructorBody) { |
| 534 return Elements.isNativeOrExtendsNative(element.enclosingClass); | 552 return Elements.isNativeOrExtendsNative(element.enclosingClass); |
| 535 } | 553 } |
| 536 return interceptedElements[element.name] != null; | 554 return interceptedElements[element.name] != null; |
| 537 } | 555 } |
| 538 | 556 |
| 539 bool fieldHasInterceptedGetter(Element element) { | 557 bool fieldHasInterceptedGetter(Element element) { |
| 540 assert(element.isField); | 558 assert(element.isField); |
| (...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 } | 2459 } |
| 2442 } | 2460 } |
| 2443 | 2461 |
| 2444 /// Records that [constant] is used by the element behind [registry]. | 2462 /// Records that [constant] is used by the element behind [registry]. |
| 2445 class Dependency { | 2463 class Dependency { |
| 2446 final ConstantValue constant; | 2464 final ConstantValue constant; |
| 2447 final Element annotatedElement; | 2465 final Element annotatedElement; |
| 2448 | 2466 |
| 2449 const Dependency(this.constant, this.annotatedElement); | 2467 const Dependency(this.constant, this.annotatedElement); |
| 2450 } | 2468 } |
| OLD | NEW |