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 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2812 class Annotations { | 2812 class Annotations { |
2813 static final Uri PACKAGE_EXPECT = | 2813 static final Uri PACKAGE_EXPECT = |
2814 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 2814 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
2815 | 2815 |
2816 final Compiler compiler; | 2816 final Compiler compiler; |
2817 | 2817 |
2818 ClassElement expectNoInlineClass; | 2818 ClassElement expectNoInlineClass; |
2819 ClassElement expectTrustTypeAnnotationsClass; | 2819 ClassElement expectTrustTypeAnnotationsClass; |
2820 ClassElement expectAssumeDynamicClass; | 2820 ClassElement expectAssumeDynamicClass; |
2821 | 2821 |
| 2822 JavaScriptBackend get backend => compiler.backend; |
| 2823 |
2822 Annotations(this.compiler); | 2824 Annotations(this.compiler); |
2823 | 2825 |
2824 void onLibraryScanned(LibraryElement library) { | 2826 void onLibraryScanned(LibraryElement library) { |
2825 if (library.canonicalUri == PACKAGE_EXPECT) { | 2827 if (library.canonicalUri == PACKAGE_EXPECT) { |
2826 expectNoInlineClass = library.find('NoInline'); | 2828 expectNoInlineClass = library.find('NoInline'); |
2827 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); | 2829 expectTrustTypeAnnotationsClass = library.find('TrustTypeAnnotations'); |
2828 expectAssumeDynamicClass = library.find('AssumeDynamic'); | 2830 expectAssumeDynamicClass = library.find('AssumeDynamic'); |
2829 if (expectNoInlineClass == null || | 2831 if (expectNoInlineClass == null || |
2830 expectTrustTypeAnnotationsClass == null || | 2832 expectTrustTypeAnnotationsClass == null || |
2831 expectAssumeDynamicClass == null) { | 2833 expectAssumeDynamicClass == null) { |
2832 // This is not the package you're looking for. | 2834 // This is not the package you're looking for. |
2833 expectNoInlineClass = null; | 2835 expectNoInlineClass = null; |
2834 expectTrustTypeAnnotationsClass = null; | 2836 expectTrustTypeAnnotationsClass = null; |
2835 expectAssumeDynamicClass = null; | 2837 expectAssumeDynamicClass = null; |
2836 } | 2838 } |
2837 } | 2839 } |
2838 } | 2840 } |
2839 | 2841 |
2840 /// Returns `true` if inlining is disabled for [element]. | 2842 /// Returns `true` if inlining is disabled for [element]. |
2841 bool noInline(Element element) { | 2843 bool noInline(Element element) { |
2842 // TODO(floitsch): restrict to test directory. | 2844 if (_hasAnnotation(element, expectNoInlineClass)) { |
2843 return _hasAnnotation(element, expectNoInlineClass); | 2845 // TODO(floitsch): restrict to elements from the test directory. |
| 2846 return true; |
| 2847 } |
| 2848 return _hasAnnotation(element, backend.noInlineClass); |
2844 } | 2849 } |
2845 | 2850 |
2846 /// Returns `true` if parameter and returns types should be trusted for | 2851 /// Returns `true` if parameter and returns types should be trusted for |
2847 /// [element]. | 2852 /// [element]. |
2848 bool trustTypeAnnotations(Element element) { | 2853 bool trustTypeAnnotations(Element element) { |
2849 return _hasAnnotation(element, expectTrustTypeAnnotationsClass); | 2854 return _hasAnnotation(element, expectTrustTypeAnnotationsClass); |
2850 } | 2855 } |
2851 | 2856 |
2852 /// Returns `true` if inference of parameter types is disabled for [element]. | 2857 /// Returns `true` if inference of parameter types is disabled for [element]. |
2853 bool assumeDynamic(Element element) { | 2858 bool assumeDynamic(Element element) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3097 } | 3102 } |
3098 } | 3103 } |
3099 | 3104 |
3100 /// Records that [constant] is used by the element behind [registry]. | 3105 /// Records that [constant] is used by the element behind [registry]. |
3101 class Dependency { | 3106 class Dependency { |
3102 final ConstantValue constant; | 3107 final ConstantValue constant; |
3103 final Element annotatedElement; | 3108 final Element annotatedElement; |
3104 | 3109 |
3105 const Dependency(this.constant, this.annotatedElement); | 3110 const Dependency(this.constant, this.annotatedElement); |
3106 } | 3111 } |
OLD | NEW |