Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: pkg/compiler/lib/src/ssa/locals_handler.dart

Issue 2569733002: Even less reliance on Compiler.closedWorld (Closed)
Patch Set: Updated cf. comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | pkg/compiler/lib/src/ssa/nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../compiler.dart' show Compiler; 7 import '../compiler.dart' show Compiler;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart'; 10 import '../io/source_information.dart';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 InterfaceType instanceType, this._compiler) 67 InterfaceType instanceType, this._compiler)
68 : this.instanceType = 68 : this.instanceType =
69 instanceType == null || instanceType.containsTypeVariables 69 instanceType == null || instanceType.containsTypeVariables
70 ? null 70 ? null
71 : instanceType; 71 : instanceType;
72 72
73 ClosedWorld get closedWorld => builder.closedWorld; 73 ClosedWorld get closedWorld => builder.closedWorld;
74 74
75 CommonMasks get commonMasks => closedWorld.commonMasks; 75 CommonMasks get commonMasks => closedWorld.commonMasks;
76 76
77 GlobalTypeInferenceResults get _globalInferenceResults =>
78 _compiler.globalInference.results;
79
77 /// Substituted type variables occurring in [type] into the context of 80 /// Substituted type variables occurring in [type] into the context of
78 /// [contextClass]. 81 /// [contextClass].
79 DartType substInContext(DartType type) { 82 DartType substInContext(DartType type) {
80 if (contextClass != null) { 83 if (contextClass != null) {
81 ClassElement typeContext = Types.getClassContext(type); 84 ClassElement typeContext = Types.getClassContext(type);
82 if (typeContext != null) { 85 if (typeContext != null) {
83 type = type.substByContext(contextClass.asInstanceOf(typeContext)); 86 type = type.substByContext(contextClass.asInstanceOf(typeContext));
84 } 87 }
85 } 88 }
86 if (instanceType != null) { 89 if (instanceType != null) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (scopeData != null && 202 if (scopeData != null &&
200 scopeData.isCapturedVariable(parameterElement)) { 203 scopeData.isCapturedVariable(parameterElement)) {
201 // The parameter will be a field in the box passed as the 204 // The parameter will be a field in the box passed as the
202 // last parameter. So no need to have it. 205 // last parameter. So no need to have it.
203 return; 206 return;
204 } 207 }
205 } 208 }
206 HInstruction parameter = builder.addParameter( 209 HInstruction parameter = builder.addParameter(
207 parameterElement, 210 parameterElement,
208 TypeMaskFactory.inferredTypeForElement( 211 TypeMaskFactory.inferredTypeForElement(
209 parameterElement, _compiler)); 212 parameterElement, _globalInferenceResults));
210 builder.parameters[parameterElement] = parameter; 213 builder.parameters[parameterElement] = parameter;
211 directLocals[parameterElement] = parameter; 214 directLocals[parameterElement] = parameter;
212 }); 215 });
213 } 216 }
214 217
215 enterScope(node, element); 218 enterScope(node, element);
216 219
217 // If the freeVariableMapping is not empty, then this function was a 220 // If the freeVariableMapping is not empty, then this function was a
218 // nested closure that captures variables. Redirect the captured 221 // nested closure that captures variables. Redirect the captured
219 // variables to fields in the closure. 222 // variables to fields in the closure.
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 636 }
634 return result; 637 return result;
635 } 638 }
636 639
637 Map<Element, TypeMask> cachedTypesOfCapturedVariables = 640 Map<Element, TypeMask> cachedTypesOfCapturedVariables =
638 new Map<Element, TypeMask>(); 641 new Map<Element, TypeMask>();
639 642
640 TypeMask getTypeOfCapturedVariable(Element element) { 643 TypeMask getTypeOfCapturedVariable(Element element) {
641 assert(element.isField); 644 assert(element.isField);
642 return cachedTypesOfCapturedVariables.putIfAbsent(element, () { 645 return cachedTypesOfCapturedVariables.putIfAbsent(element, () {
643 return TypeMaskFactory.inferredTypeForElement(element, _compiler); 646 return TypeMaskFactory.inferredTypeForElement(
647 element, _globalInferenceResults);
644 }); 648 });
645 } 649 }
646 650
647 /// Variables stored in the current activation. These variables are 651 /// Variables stored in the current activation. These variables are
648 /// being updated in try/catch blocks, and should be 652 /// being updated in try/catch blocks, and should be
649 /// accessed indirectly through [HLocalGet] and [HLocalSet]. 653 /// accessed indirectly through [HLocalGet] and [HLocalSet].
650 Map<Local, HLocalValue> activationVariables = <Local, HLocalValue>{}; 654 Map<Local, HLocalValue> activationVariables = <Local, HLocalValue>{};
651 } 655 }
652 656
653 /// A synthetic local variable only used with the SSA graph. 657 /// A synthetic local variable only used with the SSA graph.
654 /// 658 ///
655 /// For instance used for holding return value of function or the exception of a 659 /// For instance used for holding return value of function or the exception of a
656 /// try-catch statement. 660 /// try-catch statement.
657 class SyntheticLocal extends Local { 661 class SyntheticLocal extends Local {
658 final String name; 662 final String name;
659 final ExecutableElement executableContext; 663 final ExecutableElement executableContext;
660 664
661 // Avoid slow Object.hashCode. 665 // Avoid slow Object.hashCode.
662 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); 666 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30);
663 static int _nextHashCode = 0; 667 static int _nextHashCode = 0;
664 668
665 SyntheticLocal(this.name, this.executableContext); 669 SyntheticLocal(this.name, this.executableContext);
666 670
667 toString() => 'SyntheticLocal($name)'; 671 toString() => 'SyntheticLocal($name)';
668 } 672 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | pkg/compiler/lib/src/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698