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

Side by Side 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: merge with master 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 * updated in the [localsHandler]. This function creates such an element and 859 * updated in the [localsHandler]. This function creates such an element and
860 * stores it in the [returnLocal] field. 860 * stores it in the [returnLocal] field.
861 */ 861 */
862 void setupStateForInlining( 862 void setupStateForInlining(
863 MethodElement function, List<HInstruction> compiledArguments, 863 MethodElement function, List<HInstruction> compiledArguments,
864 {ResolutionInterfaceType instanceType}) { 864 {ResolutionInterfaceType instanceType}) {
865 ResolvedAst resolvedAst = function.resolvedAst; 865 ResolvedAst resolvedAst = function.resolvedAst;
866 assert(resolvedAst != null); 866 assert(resolvedAst != null);
867 localsHandler = new LocalsHandler(this, function, function.memberContext, 867 localsHandler = new LocalsHandler(this, function, function.memberContext,
868 function.contextClass, instanceType, nativeData, interceptorData); 868 function.contextClass, instanceType, nativeData, interceptorData);
869 localsHandler.closureData = closureToClassMapper.getMemberMap(function); 869 localsHandler.closureData =
870 closureToClassMapper.getClosureRepresentationInfo(function);
870 returnLocal = 871 returnLocal =
871 new SyntheticLocal("result", function, function.memberContext); 872 new SyntheticLocal("result", function, function.memberContext);
872 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld)); 873 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld));
873 874
874 inTryStatement = false; // TODO(lry): why? Document. 875 inTryStatement = false; // TODO(lry): why? Document.
875 876
876 int argumentIndex = 0; 877 int argumentIndex = 0;
877 if (function.isInstanceMember) { 878 if (function.isInstanceMember) {
878 localsHandler.updateLocal(localsHandler.closureData.thisLocal, 879 localsHandler.updateLocal(localsHandler.closureData.thisLocal,
879 compiledArguments[argumentIndex++]); 880 compiledArguments[argumentIndex++]);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 InitializingFormalElement fieldParameterElement = parameter; 1026 InitializingFormalElement fieldParameterElement = parameter;
1026 fieldValues[fieldParameterElement.fieldElement] = argument; 1027 fieldValues[fieldParameterElement.fieldElement] = argument;
1027 } 1028 }
1028 }); 1029 });
1029 1030
1030 // Build the initializers in the context of the new constructor. 1031 // Build the initializers in the context of the new constructor.
1031 ResolvedAst oldResolvedAst = resolvedAst; 1032 ResolvedAst oldResolvedAst = resolvedAst;
1032 resolvedAst = callee.resolvedAst; 1033 resolvedAst = callee.resolvedAst;
1033 final oldElementInferenceResults = elementInferenceResults; 1034 final oldElementInferenceResults = elementInferenceResults;
1034 elementInferenceResults = globalInferenceResults.resultOfMember(callee); 1035 elementInferenceResults = globalInferenceResults.resultOfMember(callee);
1035 ClosureClassMap oldClosureData = localsHandler.closureData; 1036 ClosureRepresentationInfo oldClosureData = localsHandler.closureData;
1036 ClosureClassMap newClosureData = 1037 ClosureRepresentationInfo newClosureData =
1037 closureToClassMapper.getMemberMap(callee); 1038 closureToClassMapper.getClosureRepresentationInfo(callee);
1038 localsHandler.closureData = newClosureData; 1039 localsHandler.closureData = newClosureData;
1039 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 1040 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
1040 // TODO(efortuna): Take out the test below for null once we are no 1041 // TODO(efortuna): Take out the test below for null once we are no
1041 // longer dealing with the ClosureClassMap interface directly. 1042 // longer dealing with the ClosureClassMap interface directly.
1042 if (newClosureData.capturingScopes[resolvedAst.node] != null) { 1043 if (newClosureData.capturingScopes[resolvedAst.node] != null) {
1043 localsHandler.enterScope( 1044 localsHandler.enterScope(
1044 newClosureData.capturingScopes[resolvedAst.node], 1045 closureToClassMapper.getClosureAnalysisInfo(resolvedAst.node),
1045 forGenerativeConstructorBody: callee.isGenerativeConstructorBody); 1046 forGenerativeConstructorBody: callee.isGenerativeConstructorBody);
1046 } 1047 }
1047 } 1048 }
1048 buildInitializers(callee, constructorResolvedAsts, fieldValues); 1049 buildInitializers(callee, constructorResolvedAsts, fieldValues);
1049 localsHandler.closureData = oldClosureData; 1050 localsHandler.closureData = oldClosureData;
1050 resolvedAst = oldResolvedAst; 1051 resolvedAst = oldResolvedAst;
1051 elementInferenceResults = oldElementInferenceResults; 1052 elementInferenceResults = oldElementInferenceResults;
1052 }); 1053 });
1053 } 1054 }
1054 1055
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 1449
1449 Map<Local, TypeMask> parameters = <Local, TypeMask>{}; 1450 Map<Local, TypeMask> parameters = <Local, TypeMask>{};
1450 if (element is MethodElement) { 1451 if (element is MethodElement) {
1451 element.functionSignature 1452 element.functionSignature
1452 .orderedForEachParameter((ParameterElement parameter) { 1453 .orderedForEachParameter((ParameterElement parameter) {
1453 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter( 1454 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter(
1454 parameter, globalInferenceResults); 1455 parameter, globalInferenceResults);
1455 }); 1456 });
1456 } 1457 }
1457 1458
1458 ClosureClassMap closureData = closureToClassMapper.getMemberMap(element);
1459 localsHandler.startFunction( 1459 localsHandler.startFunction(
1460 element, closureData, closureData.capturingScopes[node], parameters, 1460 element,
1461 closureToClassMapper.getClosureRepresentationInfo(element),
1462 closureToClassMapper.getClosureAnalysisInfo(node),
1463 parameters,
1461 isGenerativeConstructorBody: element.isGenerativeConstructorBody); 1464 isGenerativeConstructorBody: element.isGenerativeConstructorBody);
1462 close(new HGoto()).addSuccessor(block); 1465 close(new HGoto()).addSuccessor(block);
1463 1466
1464 open(block); 1467 open(block);
1465 1468
1466 // Add the type parameters of the class as parameters of this method. This 1469 // 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 1470 // must be done before adding the normal parameters, because their types
1468 // may contain references to type variables. 1471 // may contain references to type variables.
1469 ClassElement cls = element.enclosingClass; 1472 ClassElement cls = element.enclosingClass;
1470 if ((element.isConstructor || element.isGenerativeConstructorBody) && 1473 if ((element.isConstructor || element.isGenerativeConstructorBody) &&
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 block.remove(breakInstruction); 1894 block.remove(breakInstruction);
1892 }); 1895 });
1893 } 1896 }
1894 } 1897 }
1895 jumpHandler.close(); 1898 jumpHandler.close();
1896 loopDepth--; 1899 loopDepth--;
1897 } 1900 }
1898 1901
1899 visitFunctionExpression(ast.FunctionExpression node) { 1902 visitFunctionExpression(ast.FunctionExpression node) {
1900 LocalFunctionElement methodElement = elements[node]; 1903 LocalFunctionElement methodElement = elements[node];
1901 ClosureClassMap nestedClosureData = 1904
1902 closureToClassMapper.getLocalFunctionMap(methodElement); 1905 ClosureRepresentationInfo closureInfo =
1903 assert(nestedClosureData != null); 1906 closureToClassMapper.getClosureRepresentationInfo(methodElement);
1904 assert(nestedClosureData.closureClassElement != null); 1907 ClassEntity closureClassElement = closureInfo.closureClassEntity;
1905 ClosureClassElement closureClassElement =
1906 nestedClosureData.closureClassElement;
1907 MethodElement callElement = nestedClosureData.callElement;
1908 1908
1909 List<HInstruction> capturedVariables = <HInstruction>[]; 1909 List<HInstruction> capturedVariables = <HInstruction>[];
1910 closureClassElement.closureFields.forEach((ClosureFieldElement field) { 1910 closureInfo.createdFieldEntities.forEach((Local field) {
1911 Local capturedLocal = 1911 assert(field != null);
1912 nestedClosureData.getLocalVariableForClosureField(field); 1912 capturedVariables.add(localsHandler.readLocal(field));
1913 assert(capturedLocal != null);
1914 capturedVariables.add(localsHandler.readLocal(capturedLocal));
1915 }); 1913 });
1916 1914
1917 TypeMask type = new TypeMask.nonNullExact(closureClassElement, closedWorld); 1915 TypeMask type = new TypeMask.nonNullExact(closureClassElement, closedWorld);
1918 push(new HCreate(closureClassElement, capturedVariables, type, 1916 push(new HCreate(closureClassElement, capturedVariables, type,
1919 callMethod: callElement, localFunction: methodElement) 1917 callMethod: closureInfo.callEntity, localFunction: methodElement)
1920 ..sourceInformation = sourceInformationBuilder.buildCreate(node)); 1918 ..sourceInformation = sourceInformationBuilder.buildCreate(node));
1921 } 1919 }
1922 1920
1923 visitFunctionDeclaration(ast.FunctionDeclaration node) { 1921 visitFunctionDeclaration(ast.FunctionDeclaration node) {
1924 assert(isReachable); 1922 assert(isReachable);
1925 visit(node.function); 1923 visit(node.function);
1926 LocalFunctionElement localFunction = 1924 LocalFunctionElement localFunction =
1927 elements.getFunctionDefinition(node.function); 1925 elements.getFunctionDefinition(node.function);
1928 localsHandler.updateLocal(localFunction, pop()); 1926 localsHandler.updateLocal(localFunction, pop());
1929 } 1927 }
(...skipping 4944 matching lines...) Expand 10 before | Expand all | Expand 10 after
6874 this.oldReturnLocal, 6872 this.oldReturnLocal,
6875 this.oldReturnType, 6873 this.oldReturnType,
6876 this.oldResolvedAst, 6874 this.oldResolvedAst,
6877 this.oldStack, 6875 this.oldStack,
6878 this.oldLocalsHandler, 6876 this.oldLocalsHandler,
6879 this.inTryStatement, 6877 this.inTryStatement,
6880 this.allFunctionsCalledOnce, 6878 this.allFunctionsCalledOnce,
6881 this.oldElementInferenceResults) 6879 this.oldElementInferenceResults)
6882 : super(function); 6880 : super(function);
6883 } 6881 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart ('k') | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698