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 22 matching lines...) Expand all Loading... |
33 static const int _canInlineInLoopMustNotOutside = 2; | 33 static const int _canInlineInLoopMustNotOutside = 2; |
34 // May-inline means that we know that it can be inlined inside a loop, but | 34 // May-inline means that we know that it can be inlined inside a loop, but |
35 // don't know about the general case yet. | 35 // don't know about the general case yet. |
36 static const int _canInlineInLoopMayInlineOutside = 3; | 36 static const int _canInlineInLoopMayInlineOutside = 3; |
37 static const int _canInline = 4; | 37 static const int _canInline = 4; |
38 static const int _mustInline = 5; | 38 static const int _mustInline = 5; |
39 | 39 |
40 final Map<FunctionElement, int> _cachedDecisions = | 40 final Map<FunctionElement, int> _cachedDecisions = |
41 new Map<FunctionElement, int>(); | 41 new Map<FunctionElement, int>(); |
42 | 42 |
| 43 /// Returns the current cache decision. This should only be used for testing. |
| 44 int getCurrentCacheDecisionForTesting(Element element) { |
| 45 return _cachedDecisions[element]; |
| 46 } |
| 47 |
43 // Returns `true`/`false` if we have a cached decision. | 48 // Returns `true`/`false` if we have a cached decision. |
44 // Returns `null` otherwise. | 49 // Returns `null` otherwise. |
45 bool canInline(FunctionElement element, {bool insideLoop}) { | 50 bool canInline(FunctionElement element, {bool insideLoop}) { |
46 int decision = _cachedDecisions[element]; | 51 int decision = _cachedDecisions[element]; |
47 | 52 |
48 if (decision == null) { | 53 if (decision == null) { |
49 // These synthetic elements are not yet present when we initially compute | 54 // These synthetic elements are not yet present when we initially compute |
50 // this cache from metadata annotations, so look for their parent. | 55 // this cache from metadata annotations, so look for their parent. |
51 if (element is ConstructorBodyElement) { | 56 if (element is ConstructorBodyElement) { |
52 ConstructorBodyElement body = element; | 57 ConstructorBodyElement body = element; |
(...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3115 | 3120 |
3116 @override | 3121 @override |
3117 void onImpactUsed(ImpactUseCase impactUse) { | 3122 void onImpactUsed(ImpactUseCase impactUse) { |
3118 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3123 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
3119 // TODO(johnniwinther): Allow emptying when serialization has been | 3124 // TODO(johnniwinther): Allow emptying when serialization has been |
3120 // performed. | 3125 // performed. |
3121 resolution.emptyCache(); | 3126 resolution.emptyCache(); |
3122 } | 3127 } |
3123 } | 3128 } |
3124 } | 3129 } |
OLD | NEW |