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

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

Issue 2975573002: Lookup getClosureScope by member instead of node (Closed)
Patch Set: Cleanup 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
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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1004
1005 // Build the initializers in the context of the new constructor. 1005 // Build the initializers in the context of the new constructor.
1006 ResolvedAst oldResolvedAst = resolvedAst; 1006 ResolvedAst oldResolvedAst = resolvedAst;
1007 resolvedAst = callee.resolvedAst; 1007 resolvedAst = callee.resolvedAst;
1008 final oldElementInferenceResults = elementInferenceResults; 1008 final oldElementInferenceResults = elementInferenceResults;
1009 elementInferenceResults = globalInferenceResults.resultOfMember(callee); 1009 elementInferenceResults = globalInferenceResults.resultOfMember(callee);
1010 ScopeInfo oldScopeInfo = localsHandler.scopeInfo; 1010 ScopeInfo oldScopeInfo = localsHandler.scopeInfo;
1011 ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(callee); 1011 ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(callee);
1012 localsHandler.scopeInfo = newScopeInfo; 1012 localsHandler.scopeInfo = newScopeInfo;
1013 if (resolvedAst.kind == ResolvedAstKind.PARSED) { 1013 if (resolvedAst.kind == ResolvedAstKind.PARSED) {
1014 localsHandler.enterScope( 1014 localsHandler.enterScope(closureDataLookup.getClosureScope(callee),
1015 closureDataLookup.getClosureScope(resolvedAst.node),
1016 forGenerativeConstructorBody: callee.isGenerativeConstructorBody); 1015 forGenerativeConstructorBody: callee.isGenerativeConstructorBody);
1017 } 1016 }
1018 buildInitializers(callee, constructorResolvedAsts, fieldValues); 1017 buildInitializers(callee, constructorResolvedAsts, fieldValues);
1019 localsHandler.scopeInfo = oldScopeInfo; 1018 localsHandler.scopeInfo = oldScopeInfo;
1020 resolvedAst = oldResolvedAst; 1019 resolvedAst = oldResolvedAst;
1021 elementInferenceResults = oldElementInferenceResults; 1020 elementInferenceResults = oldElementInferenceResults;
1022 }); 1021 });
1023 } 1022 }
1024 1023
1025 void buildInitializers( 1024 void buildInitializers(
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 1344
1346 List bodyCallInputs = <HInstruction>[]; 1345 List bodyCallInputs = <HInstruction>[];
1347 if (isNativeUpgradeFactory) { 1346 if (isNativeUpgradeFactory) {
1348 if (interceptor == null) { 1347 if (interceptor == null) {
1349 ConstantValue constant = new InterceptorConstantValue(classElement); 1348 ConstantValue constant = new InterceptorConstantValue(classElement);
1350 interceptor = graph.addConstant(constant, closedWorld); 1349 interceptor = graph.addConstant(constant, closedWorld);
1351 } 1350 }
1352 bodyCallInputs.add(interceptor); 1351 bodyCallInputs.add(interceptor);
1353 } 1352 }
1354 bodyCallInputs.add(newObject); 1353 bodyCallInputs.add(newObject);
1355 ast.Node node = constructorResolvedAst.node;
1356 1354
1357 FunctionSignature functionSignature = body.functionSignature; 1355 FunctionSignature functionSignature = body.functionSignature;
1358 // Provide the parameters to the generative constructor body. 1356 // Provide the parameters to the generative constructor body.
1359 functionSignature.orderedForEachParameter((_parameter) { 1357 functionSignature.orderedForEachParameter((_parameter) {
1360 ParameterElement parameter = _parameter; 1358 ParameterElement parameter = _parameter;
1361 // If [parameter] is boxed, it will be a field in the box passed as the 1359 // If [parameter] is boxed, it will be a field in the box passed as the
1362 // last parameter. So no need to directly pass it. 1360 // last parameter. So no need to directly pass it.
1363 if (!localsHandler.isBoxed(parameter)) { 1361 if (!localsHandler.isBoxed(parameter)) {
1364 bodyCallInputs.add(localsHandler.readLocal(parameter)); 1362 bodyCallInputs.add(localsHandler.readLocal(parameter));
1365 } 1363 }
1366 }); 1364 });
1367 1365
1368 // If there are locals that escape (ie mutated in closures), we 1366 // If there are locals that escape (ie mutated in closures), we
1369 // pass the box to the constructor. 1367 // pass the box to the constructor.
1370 // The box must be passed before any type variable. 1368 // The box must be passed before any type variable.
1371 ClosureScope scopeData = closureDataLookup.getClosureScope(node); 1369 ClosureScope scopeData = closureDataLookup.getClosureScope(constructor);
1372 if (scopeData.requiresContextBox) { 1370 if (scopeData.requiresContextBox) {
1373 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); 1371 bodyCallInputs.add(localsHandler.readLocal(scopeData.context));
1374 } 1372 }
1375 1373
1376 // Type variables arguments must come after the box (if there is one). 1374 // Type variables arguments must come after the box (if there is one).
1377 ClassElement currentClass = constructor.enclosingClass; 1375 ClassElement currentClass = constructor.enclosingClass;
1378 if (rtiNeed.classNeedsRti(currentClass)) { 1376 if (rtiNeed.classNeedsRti(currentClass)) {
1379 // If [currentClass] needs RTI, we add the type variables as 1377 // If [currentClass] needs RTI, we add the type variables as
1380 // parameters of the generative constructor body. 1378 // parameters of the generative constructor body.
1381 currentClass.typeVariables.forEach((_argument) { 1379 currentClass.typeVariables.forEach((_argument) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 localsHandler.startFunction( 1427 localsHandler.startFunction(
1430 element, 1428 element,
1431 closureDataLookup.getScopeInfo(element), 1429 closureDataLookup.getScopeInfo(element),
1432 closureDataLookup.getClosureScope(node), 1430 closureDataLookup.getClosureScope(element),
1433 parameters, 1431 parameters,
1434 isGenerativeConstructorBody: element.isGenerativeConstructorBody); 1432 isGenerativeConstructorBody: element.isGenerativeConstructorBody);
1435 close(new HGoto()).addSuccessor(block); 1433 close(new HGoto()).addSuccessor(block);
1436 1434
1437 open(block); 1435 open(block);
1438 1436
1439 // 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
1440 // must be done before adding the normal parameters, because their types 1438 // must be done before adding the normal parameters, because their types
1441 // may contain references to type variables. 1439 // may contain references to type variables.
1442 ClassElement cls = element.enclosingClass; 1440 ClassElement cls = element.enclosingClass;
(...skipping 13 matching lines...) Expand all
1456 FunctionSignature signature = functionElement.functionSignature; 1454 FunctionSignature signature = functionElement.functionSignature;
1457 1455
1458 // Put the type checks in the first successor of the entry, 1456 // Put the type checks in the first successor of the entry,
1459 // because that is where the type guards will also be inserted. 1457 // because that is where the type guards will also be inserted.
1460 // This way we ensure that a type guard will dominate the type 1458 // This way we ensure that a type guard will dominate the type
1461 // check. 1459 // check.
1462 signature.orderedForEachParameter((_parameterElement) { 1460 signature.orderedForEachParameter((_parameterElement) {
1463 ParameterElement parameterElement = _parameterElement; 1461 ParameterElement parameterElement = _parameterElement;
1464 if (element.isGenerativeConstructorBody) { 1462 if (element.isGenerativeConstructorBody) {
1465 if (closureDataLookup 1463 if (closureDataLookup
1466 .getClosureScope(node) 1464 .getClosureScope(element)
1467 .isBoxed(parameterElement)) { 1465 .isBoxed(parameterElement)) {
1468 // The parameter will be a field in the box passed as the 1466 // The parameter will be a field in the box passed as the
1469 // last parameter. So no need to have it. 1467 // last parameter. So no need to have it.
1470 return; 1468 return;
1471 } 1469 }
1472 } 1470 }
1473 HInstruction newParameter = 1471 HInstruction newParameter =
1474 localsHandler.directLocals[parameterElement]; 1472 localsHandler.directLocals[parameterElement];
1475 if (!element.isConstructor || 1473 if (!element.isConstructor ||
1476 !(element as ConstructorElement).isRedirectingFactory) { 1474 !(element as ConstructorElement).isRedirectingFactory) {
(...skipping 5370 matching lines...) Expand 10 before | Expand all | Expand 10 after
6847 this.oldReturnLocal, 6845 this.oldReturnLocal,
6848 this.oldReturnType, 6846 this.oldReturnType,
6849 this.oldResolvedAst, 6847 this.oldResolvedAst,
6850 this.oldStack, 6848 this.oldStack,
6851 this.oldLocalsHandler, 6849 this.oldLocalsHandler,
6852 this.inTryStatement, 6850 this.inTryStatement,
6853 this.allFunctionsCalledOnce, 6851 this.allFunctionsCalledOnce,
6854 this.oldElementInferenceResults) 6852 this.oldElementInferenceResults)
6855 : super(function); 6853 : super(function);
6856 } 6854 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_model/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