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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 NoSuchMethodRegistry noSuchMethodRegistry; | 609 NoSuchMethodRegistry noSuchMethodRegistry; |
610 | 610 |
611 JavaScriptConstantTask constantCompilerTask; | 611 JavaScriptConstantTask constantCompilerTask; |
612 | 612 |
613 JavaScriptResolutionCallbacks resolutionCallbacks; | 613 JavaScriptResolutionCallbacks resolutionCallbacks; |
614 | 614 |
615 PatchResolverTask patchResolverTask; | 615 PatchResolverTask patchResolverTask; |
616 | 616 |
617 bool enabledNoSuchMethod = false; | 617 bool enabledNoSuchMethod = false; |
618 | 618 |
| 619 final SourceInformationStrategy sourceInformationStrategy; |
| 620 |
619 JavaScriptBackend(Compiler compiler, | 621 JavaScriptBackend(Compiler compiler, |
620 SourceInformationFactory sourceInformationFactory, | |
621 {bool generateSourceMap: true}) | 622 {bool generateSourceMap: true}) |
622 : namer = determineNamer(compiler), | 623 : namer = determineNamer(compiler), |
623 oneShotInterceptors = new Map<String, Selector>(), | 624 oneShotInterceptors = new Map<String, Selector>(), |
624 interceptedElements = new Map<String, Set<Element>>(), | 625 interceptedElements = new Map<String, Set<Element>>(), |
625 rti = new RuntimeTypes(compiler), | 626 rti = new RuntimeTypes(compiler), |
626 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), | 627 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), |
627 annotations = new Annotations(compiler), | 628 annotations = new Annotations(compiler), |
| 629 this.sourceInformationStrategy = |
| 630 generateSourceMap |
| 631 ? (USE_NEW_SOURCE_INFO |
| 632 ? const PositionSourceInformationStrategy() |
| 633 : const StartEndSourceInformationStrategy()) |
| 634 : const JavaScriptSourceInformationStrategy(), |
628 super(compiler) { | 635 super(compiler) { |
629 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); | 636 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); |
630 typeVariableHandler = new TypeVariableHandler(compiler); | 637 typeVariableHandler = new TypeVariableHandler(compiler); |
631 customElementsAnalysis = new CustomElementsAnalysis(this); | 638 customElementsAnalysis = new CustomElementsAnalysis(this); |
632 noSuchMethodRegistry = new NoSuchMethodRegistry(this); | 639 noSuchMethodRegistry = new NoSuchMethodRegistry(this); |
633 constantCompilerTask = new JavaScriptConstantTask(compiler); | 640 constantCompilerTask = new JavaScriptConstantTask(compiler); |
634 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); | 641 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); |
635 patchResolverTask = new PatchResolverTask(compiler); | 642 patchResolverTask = new PatchResolverTask(compiler); |
636 functionCompiler = compiler.useCpsIr | 643 functionCompiler = compiler.useCpsIr |
637 ? new CpsFunctionCompiler( | 644 ? new CpsFunctionCompiler( |
638 compiler, this, sourceInformationFactory) | 645 compiler, this, sourceInformationStrategy) |
639 : new SsaFunctionCompiler(this, sourceInformationFactory); | 646 : new SsaFunctionCompiler(this, sourceInformationStrategy); |
640 } | 647 } |
641 | 648 |
642 ConstantSystem get constantSystem => constants.constantSystem; | 649 ConstantSystem get constantSystem => constants.constantSystem; |
643 | 650 |
644 /// Returns constant environment for the JavaScript interpretation of the | 651 /// Returns constant environment for the JavaScript interpretation of the |
645 /// constants. | 652 /// constants. |
646 JavaScriptConstantCompiler get constants { | 653 JavaScriptConstantCompiler get constants { |
647 return constantCompilerTask.jsConstantCompiler; | 654 return constantCompilerTask.jsConstantCompiler; |
648 } | 655 } |
649 | 656 |
(...skipping 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 } | 2982 } |
2976 } | 2983 } |
2977 | 2984 |
2978 /// Records that [constant] is used by the element behind [registry]. | 2985 /// Records that [constant] is used by the element behind [registry]. |
2979 class Dependency { | 2986 class Dependency { |
2980 final ConstantValue constant; | 2987 final ConstantValue constant; |
2981 final Element annotatedElement; | 2988 final Element annotatedElement; |
2982 | 2989 |
2983 const Dependency(this.constant, this.annotatedElement); | 2990 const Dependency(this.constant, this.annotatedElement); |
2984 } | 2991 } |
OLD | NEW |