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

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

Issue 2933363003: Add ClosureRepresentationInfo, the new public face of ClosureClassMap (Closed)
Patch Set: . Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 InitializingFormalElement fieldParameterElement = parameter; 1025 InitializingFormalElement fieldParameterElement = parameter;
1026 fieldValues[fieldParameterElement.fieldElement] = argument; 1026 fieldValues[fieldParameterElement.fieldElement] = argument;
1027 } 1027 }
1028 }); 1028 });
1029 1029
1030 // Build the initializers in the context of the new constructor. 1030 // Build the initializers in the context of the new constructor.
1031 ResolvedAst oldResolvedAst = resolvedAst; 1031 ResolvedAst oldResolvedAst = resolvedAst;
1032 resolvedAst = callee.resolvedAst; 1032 resolvedAst = callee.resolvedAst;
1033 final oldElementInferenceResults = elementInferenceResults; 1033 final oldElementInferenceResults = elementInferenceResults;
1034 elementInferenceResults = globalInferenceResults.resultOfMember(callee); 1034 elementInferenceResults = globalInferenceResults.resultOfMember(callee);
1035 ClosureClassMap oldClosureData = localsHandler.closureData; 1035 ClosureRepresentationInfo oldClosureData = localsHandler.closureData;
1036 ClosureClassMap newClosureData = 1036 ClosureRepresentationInfo newClosureData =
1037 closureToClassMapper.getMemberMap(callee); 1037 closureToClassMapper.getClosureRepresentationInfo(callee);
1038 localsHandler.closureData = newClosureData; 1038 localsHandler.closureData = newClosureData;
1039 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 1039 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
1040 // TODO(efortuna): Take out the test below for null once we are no 1040 localsHandler.enterScope(
1041 // longer dealing with the ClosureClassMap interface directly. 1041 closureToClassMapper.getClosureAnalysisInfo(resolvedAst.node),
1042 if (newClosureData.capturingScopes[resolvedAst.node] != null) { 1042 forGenerativeConstructorBody: callee.isGenerativeConstructorBody);
1043 localsHandler.enterScope(
1044 newClosureData.capturingScopes[resolvedAst.node],
1045 forGenerativeConstructorBody: callee.isGenerativeConstructorBody);
1046 }
1047 } 1043 }
1048 buildInitializers(callee, constructorResolvedAsts, fieldValues); 1044 buildInitializers(callee, constructorResolvedAsts, fieldValues);
1049 localsHandler.closureData = oldClosureData; 1045 localsHandler.closureData = oldClosureData;
1050 resolvedAst = oldResolvedAst; 1046 resolvedAst = oldResolvedAst;
1051 elementInferenceResults = oldElementInferenceResults; 1047 elementInferenceResults = oldElementInferenceResults;
1052 }); 1048 });
1053 } 1049 }
1054 1050
1055 void buildInitializers( 1051 void buildInitializers(
1056 ConstructorElement constructor, 1052 ConstructorElement constructor,
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 1444
1449 Map<Local, TypeMask> parameters = <Local, TypeMask>{}; 1445 Map<Local, TypeMask> parameters = <Local, TypeMask>{};
1450 if (element is MethodElement) { 1446 if (element is MethodElement) {
1451 element.functionSignature 1447 element.functionSignature
1452 .orderedForEachParameter((ParameterElement parameter) { 1448 .orderedForEachParameter((ParameterElement parameter) {
1453 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter( 1449 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter(
1454 parameter, globalInferenceResults); 1450 parameter, globalInferenceResults);
1455 }); 1451 });
1456 } 1452 }
1457 1453
1458 ClosureClassMap closureData = closureToClassMapper.getMemberMap(element); 1454 ClosureRepresentationInfo closureData =
1459 localsHandler.startFunction( 1455 closureToClassMapper.getClosureRepresentationInfo(element);
1460 element, closureData, closureData.capturingScopes[node], parameters, 1456 localsHandler.startFunction(element, closureData,
1457 closureToClassMapper.getClosureAnalysisInfo(node), parameters,
1461 isGenerativeConstructorBody: element.isGenerativeConstructorBody); 1458 isGenerativeConstructorBody: element.isGenerativeConstructorBody);
1462 close(new HGoto()).addSuccessor(block); 1459 close(new HGoto()).addSuccessor(block);
1463 1460
1464 open(block); 1461 open(block);
1465 1462
1466 // Add the type parameters of the class as parameters of this method. This 1463 // Add the type parameters of the class as parameters of this method. This
1467 // must be done before adding the normal parameters, because their types 1464 // must be done before adding the normal parameters, because their types
1468 // may contain references to type variables. 1465 // may contain references to type variables.
1469 ClassElement cls = element.enclosingClass; 1466 ClassElement cls = element.enclosingClass;
1470 if ((element.isConstructor || element.isGenerativeConstructorBody) && 1467 if ((element.isConstructor || element.isGenerativeConstructorBody) &&
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 block.remove(breakInstruction); 1888 block.remove(breakInstruction);
1892 }); 1889 });
1893 } 1890 }
1894 } 1891 }
1895 jumpHandler.close(); 1892 jumpHandler.close();
1896 loopDepth--; 1893 loopDepth--;
1897 } 1894 }
1898 1895
1899 visitFunctionExpression(ast.FunctionExpression node) { 1896 visitFunctionExpression(ast.FunctionExpression node) {
1900 LocalFunctionElement methodElement = elements[node]; 1897 LocalFunctionElement methodElement = elements[node];
1901 ClosureClassMap nestedClosureData = 1898 ClosureRepresentationInfo closureInfo =
1902 closureToClassMapper.getLocalFunctionMap(methodElement); 1899 closureToClassMapper.getClosureRepresentationInfo(methodElement);
1903 assert(nestedClosureData != null); 1900 ClassEntity closureClassEntity = closureInfo.closureClassEntity;
1904 assert(nestedClosureData.closureClassElement != null);
1905 ClosureClassElement closureClassElement =
1906 nestedClosureData.closureClassElement;
1907 MethodElement callElement = nestedClosureData.callElement;
1908 1901
1909 List<HInstruction> capturedVariables = <HInstruction>[]; 1902 List<HInstruction> capturedVariables = <HInstruction>[];
1910 closureClassElement.closureFields.forEach((ClosureFieldElement field) { 1903 closureInfo.createdFieldEntities.forEach((Local field) {
1911 Local capturedLocal = 1904 assert(field != null);
1912 nestedClosureData.getLocalVariableForClosureField(field); 1905 capturedVariables.add(localsHandler.readLocal(field));
1913 assert(capturedLocal != null);
1914 capturedVariables.add(localsHandler.readLocal(capturedLocal));
1915 }); 1906 });
1916 1907
1917 TypeMask type = new TypeMask.nonNullExact(closureClassElement, closedWorld); 1908 TypeMask type = new TypeMask.nonNullExact(closureClassEntity, closedWorld);
1918 push(new HCreate(closureClassElement, capturedVariables, type, 1909 push(new HCreate(closureClassEntity, capturedVariables, type,
1919 callMethod: callElement, localFunction: methodElement) 1910 callMethod: closureInfo.callEntity, localFunction: methodElement)
1920 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); 1911 ..sourceInformation = sourceInformationBuilder.buildCreate(node));
1921 } 1912 }
1922 1913
1923 visitFunctionDeclaration(ast.FunctionDeclaration node) { 1914 visitFunctionDeclaration(ast.FunctionDeclaration node) {
1924 assert(isReachable); 1915 assert(isReachable);
1925 visit(node.function); 1916 visit(node.function);
1926 LocalFunctionElement localFunction = 1917 LocalFunctionElement localFunction =
1927 elements.getFunctionDefinition(node.function); 1918 elements.getFunctionDefinition(node.function);
1928 localsHandler.updateLocal(localFunction, pop()); 1919 localsHandler.updateLocal(localFunction, pop());
1929 } 1920 }
(...skipping 4944 matching lines...) Expand 10 before | Expand all | Expand 10 after
6874 this.oldReturnLocal, 6865 this.oldReturnLocal,
6875 this.oldReturnType, 6866 this.oldReturnType,
6876 this.oldResolvedAst, 6867 this.oldResolvedAst,
6877 this.oldStack, 6868 this.oldStack,
6878 this.oldLocalsHandler, 6869 this.oldLocalsHandler,
6879 this.inTryStatement, 6870 this.inTryStatement,
6880 this.allFunctionsCalledOnce, 6871 this.allFunctionsCalledOnce,
6881 this.oldElementInferenceResults) 6872 this.oldElementInferenceResults)
6882 : super(function); 6873 : super(function);
6883 } 6874 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698