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

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

Issue 2949293002: Add ScopeInfo class for variable information that doesn't actually involve closures. (Closed)
Patch Set: . Created 3 years, 5 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
« no previous file with comments | « pkg/compiler/lib/src/kernel/closure.dart ('k') | pkg/compiler/lib/src/ssa/builder_kernel.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) 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 * updated in the [localsHandler]. This function creates such an element and 829 * updated in the [localsHandler]. This function creates such an element and
830 * stores it in the [returnLocal] field. 830 * stores it in the [returnLocal] field.
831 */ 831 */
832 void setupStateForInlining( 832 void setupStateForInlining(
833 MethodElement function, List<HInstruction> compiledArguments, 833 MethodElement function, List<HInstruction> compiledArguments,
834 {ResolutionInterfaceType instanceType}) { 834 {ResolutionInterfaceType instanceType}) {
835 ResolvedAst resolvedAst = function.resolvedAst; 835 ResolvedAst resolvedAst = function.resolvedAst;
836 assert(resolvedAst != null); 836 assert(resolvedAst != null);
837 localsHandler = new LocalsHandler(this, function, function.memberContext, 837 localsHandler = new LocalsHandler(this, function, function.memberContext,
838 function.contextClass, instanceType, nativeData, interceptorData); 838 function.contextClass, instanceType, nativeData, interceptorData);
839 localsHandler.closureData = 839 localsHandler.scopeInfo = closureDataLookup.getScopeInfo(function);
840 closureDataLookup.getClosureRepresentationInfo(function);
841 returnLocal = 840 returnLocal =
842 new SyntheticLocal("result", function, function.memberContext); 841 new SyntheticLocal("result", function, function.memberContext);
843 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld)); 842 localsHandler.updateLocal(returnLocal, graph.addConstantNull(closedWorld));
844 843
845 inTryStatement = false; // TODO(lry): why? Document. 844 inTryStatement = false; // TODO(lry): why? Document.
846 845
847 int argumentIndex = 0; 846 int argumentIndex = 0;
848 if (function.isInstanceMember) { 847 if (function.isInstanceMember) {
849 localsHandler.updateLocal(localsHandler.closureData.thisLocal, 848 localsHandler.updateLocal(localsHandler.scopeInfo.thisLocal,
850 compiledArguments[argumentIndex++]); 849 compiledArguments[argumentIndex++]);
851 } 850 }
852 851
853 FunctionSignature signature = function.functionSignature; 852 FunctionSignature signature = function.functionSignature;
854 signature.orderedForEachParameter((_parameter) { 853 signature.orderedForEachParameter((_parameter) {
855 ParameterElement parameter = _parameter; 854 ParameterElement parameter = _parameter;
856 HInstruction argument = compiledArguments[argumentIndex++]; 855 HInstruction argument = compiledArguments[argumentIndex++];
857 localsHandler.updateLocal(parameter, argument); 856 localsHandler.updateLocal(parameter, argument);
858 }); 857 });
859 858
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 InitializingFormalElement fieldParameterElement = parameter; 997 InitializingFormalElement fieldParameterElement = parameter;
999 fieldValues[fieldParameterElement.fieldElement] = argument; 998 fieldValues[fieldParameterElement.fieldElement] = argument;
1000 } 999 }
1001 }); 1000 });
1002 1001
1003 // Build the initializers in the context of the new constructor. 1002 // Build the initializers in the context of the new constructor.
1004 ResolvedAst oldResolvedAst = resolvedAst; 1003 ResolvedAst oldResolvedAst = resolvedAst;
1005 resolvedAst = callee.resolvedAst; 1004 resolvedAst = callee.resolvedAst;
1006 final oldElementInferenceResults = elementInferenceResults; 1005 final oldElementInferenceResults = elementInferenceResults;
1007 elementInferenceResults = globalInferenceResults.resultOfMember(callee); 1006 elementInferenceResults = globalInferenceResults.resultOfMember(callee);
1008 ClosureRepresentationInfo oldClosureData = localsHandler.closureData; 1007 ScopeInfo oldScopeInfo = localsHandler.scopeInfo;
1009 ClosureRepresentationInfo newClosureData = 1008 ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(callee);
1010 closureDataLookup.getClosureRepresentationInfo(callee); 1009 localsHandler.scopeInfo = newScopeInfo;
1011 localsHandler.closureData = newClosureData;
1012 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 1010 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
1013 localsHandler.enterScope( 1011 localsHandler.enterScope(
1014 closureDataLookup.getClosureAnalysisInfo(resolvedAst.node), 1012 closureDataLookup.getClosureAnalysisInfo(resolvedAst.node),
1015 forGenerativeConstructorBody: callee.isGenerativeConstructorBody); 1013 forGenerativeConstructorBody: callee.isGenerativeConstructorBody);
1016 } 1014 }
1017 buildInitializers(callee, constructorResolvedAsts, fieldValues); 1015 buildInitializers(callee, constructorResolvedAsts, fieldValues);
1018 localsHandler.closureData = oldClosureData; 1016 localsHandler.scopeInfo = oldScopeInfo;
1019 resolvedAst = oldResolvedAst; 1017 resolvedAst = oldResolvedAst;
1020 elementInferenceResults = oldElementInferenceResults; 1018 elementInferenceResults = oldElementInferenceResults;
1021 }); 1019 });
1022 } 1020 }
1023 1021
1024 void buildInitializers( 1022 void buildInitializers(
1025 ConstructorElement constructor, 1023 ConstructorElement constructor,
1026 List<ResolvedAst> constructorResolvedAsts, 1024 List<ResolvedAst> constructorResolvedAsts,
1027 Map<Element, HInstruction> fieldValues) { 1025 Map<Element, HInstruction> fieldValues) {
1028 assert( 1026 assert(
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1417
1420 Map<Local, TypeMask> parameters = <Local, TypeMask>{}; 1418 Map<Local, TypeMask> parameters = <Local, TypeMask>{};
1421 if (element is MethodElement) { 1419 if (element is MethodElement) {
1422 element.functionSignature.orderedForEachParameter((_parameter) { 1420 element.functionSignature.orderedForEachParameter((_parameter) {
1423 ParameterElement parameter = _parameter; 1421 ParameterElement parameter = _parameter;
1424 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter( 1422 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter(
1425 parameter, globalInferenceResults); 1423 parameter, globalInferenceResults);
1426 }); 1424 });
1427 } 1425 }
1428 1426
1429 ClosureRepresentationInfo closureData = 1427 localsHandler.startFunction(
1430 closureDataLookup.getClosureRepresentationInfo(element); 1428 element,
1431 localsHandler.startFunction(element, closureData, 1429 closureDataLookup.getScopeInfo(element),
1432 closureDataLookup.getClosureAnalysisInfo(node), parameters, 1430 closureDataLookup.getClosureAnalysisInfo(node),
1431 parameters,
1433 isGenerativeConstructorBody: element.isGenerativeConstructorBody); 1432 isGenerativeConstructorBody: element.isGenerativeConstructorBody);
1434 close(new HGoto()).addSuccessor(block); 1433 close(new HGoto()).addSuccessor(block);
1435 1434
1436 open(block); 1435 open(block);
1437 1436
1438 // Add the type parameters of the class as parameters of this method. This 1437 // Add the type parameters of the class as parameters of this method. This
1439 // must be done before adding the normal parameters, because their types 1438 // must be done before adding the normal parameters, because their types
1440 // may contain references to type variables. 1439 // may contain references to type variables.
1441 ClassElement cls = element.enclosingClass; 1440 ClassElement cls = element.enclosingClass;
1442 if ((element.isConstructor || element.isGenerativeConstructorBody) && 1441 if ((element.isConstructor || element.isGenerativeConstructorBody) &&
(...skipping 5406 matching lines...) Expand 10 before | Expand all | Expand 10 after
6849 this.oldReturnLocal, 6848 this.oldReturnLocal,
6850 this.oldReturnType, 6849 this.oldReturnType,
6851 this.oldResolvedAst, 6850 this.oldResolvedAst,
6852 this.oldStack, 6851 this.oldStack,
6853 this.oldLocalsHandler, 6852 this.oldLocalsHandler,
6854 this.inTryStatement, 6853 this.inTryStatement,
6855 this.allFunctionsCalledOnce, 6854 this.allFunctionsCalledOnce,
6856 this.oldElementInferenceResults) 6855 this.oldElementInferenceResults)
6857 : super(function); 6856 : super(function);
6858 } 6857 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/closure.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