| 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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 // go through the builder (below) to generate the lazy initializer for | 1595 // go through the builder (below) to generate the lazy initializer for |
| 1596 // the static variable. | 1596 // the static variable. |
| 1597 // We also need to register the use of the cyclic-error helper. | 1597 // We also need to register the use of the cyclic-error helper. |
| 1598 compiler.enqueuer.codegen.registerStaticUse( | 1598 compiler.enqueuer.codegen.registerStaticUse( |
| 1599 new StaticUse.staticInvoke( | 1599 new StaticUse.staticInvoke( |
| 1600 helpers.cyclicThrowHelper, CallStructure.ONE_ARG)); | 1600 helpers.cyclicThrowHelper, CallStructure.ONE_ARG)); |
| 1601 } | 1601 } |
| 1602 } | 1602 } |
| 1603 | 1603 |
| 1604 generatedCode[element] = functionCompiler.compile(work); | 1604 generatedCode[element] = functionCompiler.compile(work); |
| 1605 return impactTransformer.transformCodegenImpact(work.registry.worldImpact); | 1605 WorldImpact worldImpact = |
| 1606 impactTransformer.transformCodegenImpact(work.registry.worldImpact); |
| 1607 compiler.dumpInfoTask.registerImpact(element, worldImpact); |
| 1608 return worldImpact; |
| 1606 } | 1609 } |
| 1607 | 1610 |
| 1608 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { | 1611 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { |
| 1609 return new native.NativeResolutionEnqueuer(world, compiler); | 1612 return new native.NativeResolutionEnqueuer(world, compiler); |
| 1610 } | 1613 } |
| 1611 | 1614 |
| 1612 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { | 1615 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { |
| 1613 return new native.NativeCodegenEnqueuer(world, compiler, emitter); | 1616 return new native.NativeCodegenEnqueuer(world, compiler, emitter); |
| 1614 } | 1617 } |
| 1615 | 1618 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 "typed_data": "_internal/js_runtime/lib/typed_data_patch.dart", | 2607 "typed_data": "_internal/js_runtime/lib/typed_data_patch.dart", |
| 2605 "_internal": "_internal/js_runtime/lib/internal_patch.dart" | 2608 "_internal": "_internal/js_runtime/lib/internal_patch.dart" |
| 2606 }; | 2609 }; |
| 2607 | 2610 |
| 2608 @override | 2611 @override |
| 2609 Uri resolvePatchUri(String libraryName, Uri platformConfigUri) { | 2612 Uri resolvePatchUri(String libraryName, Uri platformConfigUri) { |
| 2610 String patchLocation = _patchLocations[libraryName]; | 2613 String patchLocation = _patchLocations[libraryName]; |
| 2611 if (patchLocation == null) return null; | 2614 if (patchLocation == null) return null; |
| 2612 return platformConfigUri.resolve(patchLocation); | 2615 return platformConfigUri.resolve(patchLocation); |
| 2613 } | 2616 } |
| 2617 |
| 2618 @override |
| 2619 ImpactStrategy createImpactStrategy( |
| 2620 {bool supportDeferredLoad: true, |
| 2621 bool supportDumpInfo: true}) { |
| 2622 return new JavaScriptImpactStrategy( |
| 2623 resolution, |
| 2624 compiler.dumpInfoTask, |
| 2625 supportDeferredLoad: supportDeferredLoad, |
| 2626 supportDumpInfo: supportDumpInfo); |
| 2627 } |
| 2614 } | 2628 } |
| 2615 | 2629 |
| 2616 /// Handling of special annotations for tests. | 2630 /// Handling of special annotations for tests. |
| 2617 class Annotations { | 2631 class Annotations { |
| 2618 static final Uri PACKAGE_EXPECT = | 2632 static final Uri PACKAGE_EXPECT = |
| 2619 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 2633 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
| 2620 | 2634 |
| 2621 final Compiler compiler; | 2635 final Compiler compiler; |
| 2622 | 2636 |
| 2623 ClassElement expectNoInlineClass; | 2637 ClassElement expectNoInlineClass; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3072 } | 3086 } |
| 3073 } | 3087 } |
| 3074 | 3088 |
| 3075 /// Records that [constant] is used by the element behind [registry]. | 3089 /// Records that [constant] is used by the element behind [registry]. |
| 3076 class Dependency { | 3090 class Dependency { |
| 3077 final ConstantValue constant; | 3091 final ConstantValue constant; |
| 3078 final Element annotatedElement; | 3092 final Element annotatedElement; |
| 3079 | 3093 |
| 3080 const Dependency(this.constant, this.annotatedElement); | 3094 const Dependency(this.constant, this.annotatedElement); |
| 3081 } | 3095 } |
| 3096 |
| 3097 class JavaScriptImpactStrategy extends ImpactStrategy { |
| 3098 final Resolution resolution; |
| 3099 final DumpInfoTask dumpInfoTask; |
| 3100 final bool supportDeferredLoad; |
| 3101 final bool supportDumpInfo; |
| 3102 |
| 3103 JavaScriptImpactStrategy(this.resolution, |
| 3104 this.dumpInfoTask, |
| 3105 {this.supportDeferredLoad, |
| 3106 this.supportDumpInfo}); |
| 3107 |
| 3108 @override |
| 3109 void visitImpact(Element element, |
| 3110 WorldImpact impact, |
| 3111 WorldImpactVisitor visitor, |
| 3112 ImpactUseCase impactUse) { |
| 3113 // TODO(johnniwinther): Compute the application strategy once for each use. |
| 3114 if (impactUse == ResolutionEnqueuer.IMPACT_USE) { |
| 3115 if (supportDeferredLoad) { |
| 3116 impact.apply(visitor); |
| 3117 } else { |
| 3118 impact.apply(visitor); |
| 3119 resolution.uncacheWorldImpact(element); |
| 3120 } |
| 3121 } else if (impactUse == DeferredLoadTask.IMPACT_USE) { |
| 3122 impact.apply(visitor); |
| 3123 // Impacts are uncached globally in [onImpactUsed]. |
| 3124 } else if (impactUse == DumpInfoTask.IMPACT_USE) { |
| 3125 impact.apply(visitor); |
| 3126 dumpInfoTask.unregisterImpact(element); |
| 3127 } else { |
| 3128 impact.apply(visitor); |
| 3129 } |
| 3130 } |
| 3131 |
| 3132 @override |
| 3133 void onImpactUsed(ImpactUseCase impactUse) { |
| 3134 if (impactUse == DeferredLoadTask.IMPACT_USE) { |
| 3135 resolution.emptyCache(); |
| 3136 } |
| 3137 } |
| 3138 } |
| OLD | NEW |