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