| 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 WorldImpact worldImpact = | 1605 return impactTransformer.transformCodegenImpact(work.registry.worldImpact); |
| 1606 impactTransformer.transformCodegenImpact(work.registry.worldImpact); | |
| 1607 compiler.dumpInfoTask.registerImpact(element, worldImpact); | |
| 1608 return worldImpact; | |
| 1609 } | 1606 } |
| 1610 | 1607 |
| 1611 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { | 1608 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { |
| 1612 return new native.NativeResolutionEnqueuer(world, compiler); | 1609 return new native.NativeResolutionEnqueuer(world, compiler); |
| 1613 } | 1610 } |
| 1614 | 1611 |
| 1615 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { | 1612 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { |
| 1616 return new native.NativeCodegenEnqueuer(world, compiler, emitter); | 1613 return new native.NativeCodegenEnqueuer(world, compiler, emitter); |
| 1617 } | 1614 } |
| 1618 | 1615 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 "typed_data": "_internal/js_runtime/lib/typed_data_patch.dart", | 2604 "typed_data": "_internal/js_runtime/lib/typed_data_patch.dart", |
| 2608 "_internal": "_internal/js_runtime/lib/internal_patch.dart" | 2605 "_internal": "_internal/js_runtime/lib/internal_patch.dart" |
| 2609 }; | 2606 }; |
| 2610 | 2607 |
| 2611 @override | 2608 @override |
| 2612 Uri resolvePatchUri(String libraryName, Uri platformConfigUri) { | 2609 Uri resolvePatchUri(String libraryName, Uri platformConfigUri) { |
| 2613 String patchLocation = _patchLocations[libraryName]; | 2610 String patchLocation = _patchLocations[libraryName]; |
| 2614 if (patchLocation == null) return null; | 2611 if (patchLocation == null) return null; |
| 2615 return platformConfigUri.resolve(patchLocation); | 2612 return platformConfigUri.resolve(patchLocation); |
| 2616 } | 2613 } |
| 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 } | |
| 2628 } | 2614 } |
| 2629 | 2615 |
| 2630 /// Handling of special annotations for tests. | 2616 /// Handling of special annotations for tests. |
| 2631 class Annotations { | 2617 class Annotations { |
| 2632 static final Uri PACKAGE_EXPECT = | 2618 static final Uri PACKAGE_EXPECT = |
| 2633 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 2619 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
| 2634 | 2620 |
| 2635 final Compiler compiler; | 2621 final Compiler compiler; |
| 2636 | 2622 |
| 2637 ClassElement expectNoInlineClass; | 2623 ClassElement expectNoInlineClass; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3086 } | 3072 } |
| 3087 } | 3073 } |
| 3088 | 3074 |
| 3089 /// Records that [constant] is used by the element behind [registry]. | 3075 /// Records that [constant] is used by the element behind [registry]. |
| 3090 class Dependency { | 3076 class Dependency { |
| 3091 final ConstantValue constant; | 3077 final ConstantValue constant; |
| 3092 final Element annotatedElement; | 3078 final Element annotatedElement; |
| 3093 | 3079 |
| 3094 const Dependency(this.constant, this.annotatedElement); | 3080 const Dependency(this.constant, this.annotatedElement); |
| 3095 } | 3081 } |
| 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 resolution.uncacheWorldImpact(element); | |
| 3124 } else if (impactUse == DumpInfoTask.IMPACT_USE) { | |
| 3125 impact.apply(visitor); | |
| 3126 dumpInfoTask.unregisterImpact(element); | |
| 3127 } else { | |
| 3128 impact.apply(visitor); | |
| 3129 } | |
| 3130 } | |
| 3131 } | |
| OLD | NEW |