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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2915523003: Create new interface instead of ClosureClassMap for variable usage information that is not Element-…
Patch Set: . Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 1fa39bcdd218b567d919c95b485e8b9dc76d62bc..7088c51c1ac09a52295b69bc07247e98f540f80d 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1367,8 +1367,6 @@ class SsaBuilder extends ast.Visitor
}
bodyCallInputs.add(newObject);
ast.Node node = constructorResolvedAst.node;
- ClosureClassMap parameterClosureData =
- closureToClassMapper.getMemberMap(constructor);
FunctionSignature functionSignature = body.functionSignature;
// Provide the parameters to the generative constructor body.
@@ -1383,9 +1381,11 @@ class SsaBuilder extends ast.Visitor
// If there are locals that escape (ie mutated in closures), we
// pass the box to the constructor.
// The box must be passed before any type variable.
- ClosureScope scopeData = parameterClosureData.capturingScopes[node];
- if (scopeData != null) {
- bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement));
+ CapturedVariableInfo scopeData =
+ closureToClassMapper.getCapturedVariableInfo(node);
+ if (scopeData.hasCapturedVariables()) {
+ bodyCallInputs.add(localsHandler
+ .readLocal(closureToClassMapper.getExecutableContext(node)));
}
// Type variables arguments must come after the box (if there is one).
@@ -1460,11 +1460,11 @@ class SsaBuilder extends ast.Visitor
// because that is where the type guards will also be inserted.
// This way we ensure that a type guard will dominate the type
// check.
- ClosureScope scopeData = localsHandler.closureData.capturingScopes[node];
signature.orderedForEachParameter((ParameterElement parameterElement) {
if (element.isGenerativeConstructorBody) {
- if (scopeData != null &&
- scopeData.isCapturedVariable(parameterElement)) {
+ if (closureToClassMapper
+ .getCapturedVariableInfo(node)
+ .isCaptured(parameterElement)) {
// The parameter will be a field in the box passed as the
// last parameter. So no need to have it.
return;
@@ -1861,25 +1861,22 @@ class SsaBuilder extends ast.Visitor
visitFunctionExpression(ast.FunctionExpression node) {
LocalFunctionElement methodElement = elements[node];
- ClosureClassMap nestedClosureData =
- closureToClassMapper.getLocalFunctionMap(methodElement);
- assert(nestedClosureData != null);
- assert(nestedClosureData.closureClassElement != null);
- ClosureClassElement closureClassElement =
- nestedClosureData.closureClassElement;
- MethodElement callElement = nestedClosureData.callElement;
+ ClassEntity closureClassElement =
+ closureToClassMapper.getClosureClassEntity(methodElement);
List<HInstruction> capturedVariables = <HInstruction>[];
- closureClassElement.closureFields.forEach((ClosureFieldElement field) {
+ closureToClassMapper.forEachClosureClassFieldEntity(methodElement,
+ (ClosureFieldElement field) {
Local capturedLocal =
- nestedClosureData.getLocalVariableForClosureField(field);
+ closureToClassMapper.getLocalVarForClosureField(methodElement, field);
assert(capturedLocal != null);
capturedVariables.add(localsHandler.readLocal(capturedLocal));
});
TypeMask type = new TypeMask.nonNullExact(closureClassElement, closedWorld);
push(new HCreate(closureClassElement, capturedVariables, type,
- callMethod: callElement, localFunction: methodElement)
+ callMethod: closureToClassMapper.getCallEntity(methodElement),
+ localFunction: methodElement)
..sourceInformation = sourceInformationBuilder.buildCreate(node));
}

Powered by Google App Engine
This is Rietveld 408576698