OLD | NEW |
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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 // Build the initializers in the context of the new constructor. | 1002 // Build the initializers in the context of the new constructor. |
1003 ResolvedAst oldResolvedAst = resolvedAst; | 1003 ResolvedAst oldResolvedAst = resolvedAst; |
1004 resolvedAst = callee.resolvedAst; | 1004 resolvedAst = callee.resolvedAst; |
1005 final oldElementInferenceResults = elementInferenceResults; | 1005 final oldElementInferenceResults = elementInferenceResults; |
1006 elementInferenceResults = globalInferenceResults.resultOfMember(callee); | 1006 elementInferenceResults = globalInferenceResults.resultOfMember(callee); |
1007 ScopeInfo oldScopeInfo = localsHandler.scopeInfo; | 1007 ScopeInfo oldScopeInfo = localsHandler.scopeInfo; |
1008 ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(callee); | 1008 ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(callee); |
1009 localsHandler.scopeInfo = newScopeInfo; | 1009 localsHandler.scopeInfo = newScopeInfo; |
1010 if (resolvedAst.kind == ResolvedAstKind.PARSED) { | 1010 if (resolvedAst.kind == ResolvedAstKind.PARSED) { |
1011 localsHandler.enterScope( | 1011 localsHandler.enterScope( |
1012 closureDataLookup.getClosureAnalysisInfo(resolvedAst.node), | 1012 closureDataLookup.getClosureBase(resolvedAst.node), |
1013 forGenerativeConstructorBody: callee.isGenerativeConstructorBody); | 1013 forGenerativeConstructorBody: callee.isGenerativeConstructorBody); |
1014 } | 1014 } |
1015 buildInitializers(callee, constructorResolvedAsts, fieldValues); | 1015 buildInitializers(callee, constructorResolvedAsts, fieldValues); |
1016 localsHandler.scopeInfo = oldScopeInfo; | 1016 localsHandler.scopeInfo = oldScopeInfo; |
1017 resolvedAst = oldResolvedAst; | 1017 resolvedAst = oldResolvedAst; |
1018 elementInferenceResults = oldElementInferenceResults; | 1018 elementInferenceResults = oldElementInferenceResults; |
1019 }); | 1019 }); |
1020 } | 1020 } |
1021 | 1021 |
1022 void buildInitializers( | 1022 void buildInitializers( |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 // If [parameter] is boxed, it will be a field in the box passed as the | 1358 // If [parameter] is boxed, it will be a field in the box passed as the |
1359 // last parameter. So no need to directly pass it. | 1359 // last parameter. So no need to directly pass it. |
1360 if (!localsHandler.isBoxed(parameter)) { | 1360 if (!localsHandler.isBoxed(parameter)) { |
1361 bodyCallInputs.add(localsHandler.readLocal(parameter)); | 1361 bodyCallInputs.add(localsHandler.readLocal(parameter)); |
1362 } | 1362 } |
1363 }); | 1363 }); |
1364 | 1364 |
1365 // If there are locals that escape (ie mutated in closures), we | 1365 // If there are locals that escape (ie mutated in closures), we |
1366 // pass the box to the constructor. | 1366 // pass the box to the constructor. |
1367 // The box must be passed before any type variable. | 1367 // The box must be passed before any type variable. |
1368 ClosureAnalysisInfo scopeData = | 1368 ClosureBase scopeData = closureDataLookup.getClosureBase(node); |
1369 closureDataLookup.getClosureAnalysisInfo(node); | |
1370 if (scopeData.requiresContextBox) { | 1369 if (scopeData.requiresContextBox) { |
1371 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); | 1370 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); |
1372 } | 1371 } |
1373 | 1372 |
1374 // Type variables arguments must come after the box (if there is one). | 1373 // Type variables arguments must come after the box (if there is one). |
1375 ClassElement currentClass = constructor.enclosingClass; | 1374 ClassElement currentClass = constructor.enclosingClass; |
1376 if (rtiNeed.classNeedsRti(currentClass)) { | 1375 if (rtiNeed.classNeedsRti(currentClass)) { |
1377 // If [currentClass] needs RTI, we add the type variables as | 1376 // If [currentClass] needs RTI, we add the type variables as |
1378 // parameters of the generative constructor body. | 1377 // parameters of the generative constructor body. |
1379 currentClass.typeVariables.forEach((_argument) { | 1378 currentClass.typeVariables.forEach((_argument) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 element.functionSignature.orderedForEachParameter((_parameter) { | 1419 element.functionSignature.orderedForEachParameter((_parameter) { |
1421 ParameterElement parameter = _parameter; | 1420 ParameterElement parameter = _parameter; |
1422 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter( | 1421 parameters[parameter] = TypeMaskFactory.inferredTypeForParameter( |
1423 parameter, globalInferenceResults); | 1422 parameter, globalInferenceResults); |
1424 }); | 1423 }); |
1425 } | 1424 } |
1426 | 1425 |
1427 localsHandler.startFunction( | 1426 localsHandler.startFunction( |
1428 element, | 1427 element, |
1429 closureDataLookup.getScopeInfo(element), | 1428 closureDataLookup.getScopeInfo(element), |
1430 closureDataLookup.getClosureAnalysisInfo(node), | 1429 closureDataLookup.getClosureBase(node), |
1431 parameters, | 1430 parameters, |
1432 isGenerativeConstructorBody: element.isGenerativeConstructorBody); | 1431 isGenerativeConstructorBody: element.isGenerativeConstructorBody); |
1433 close(new HGoto()).addSuccessor(block); | 1432 close(new HGoto()).addSuccessor(block); |
1434 | 1433 |
1435 open(block); | 1434 open(block); |
1436 | 1435 |
1437 // Add the type parameters of the class as parameters of this method. This | 1436 // Add the type parameters of the class as parameters of this method. This |
1438 // must be done before adding the normal parameters, because their types | 1437 // must be done before adding the normal parameters, because their types |
1439 // may contain references to type variables. | 1438 // may contain references to type variables. |
1440 ClassElement cls = element.enclosingClass; | 1439 ClassElement cls = element.enclosingClass; |
(...skipping 13 matching lines...) Expand all Loading... |
1454 FunctionSignature signature = functionElement.functionSignature; | 1453 FunctionSignature signature = functionElement.functionSignature; |
1455 | 1454 |
1456 // Put the type checks in the first successor of the entry, | 1455 // Put the type checks in the first successor of the entry, |
1457 // because that is where the type guards will also be inserted. | 1456 // because that is where the type guards will also be inserted. |
1458 // This way we ensure that a type guard will dominate the type | 1457 // This way we ensure that a type guard will dominate the type |
1459 // check. | 1458 // check. |
1460 signature.orderedForEachParameter((_parameterElement) { | 1459 signature.orderedForEachParameter((_parameterElement) { |
1461 ParameterElement parameterElement = _parameterElement; | 1460 ParameterElement parameterElement = _parameterElement; |
1462 if (element.isGenerativeConstructorBody) { | 1461 if (element.isGenerativeConstructorBody) { |
1463 if (closureDataLookup | 1462 if (closureDataLookup |
1464 .getClosureAnalysisInfo(node) | 1463 .getClosureBase(node) |
1465 .isCaptured(parameterElement)) { | 1464 .isBoxed(parameterElement)) { |
1466 // The parameter will be a field in the box passed as the | 1465 // The parameter will be a field in the box passed as the |
1467 // last parameter. So no need to have it. | 1466 // last parameter. So no need to have it. |
1468 return; | 1467 return; |
1469 } | 1468 } |
1470 } | 1469 } |
1471 HInstruction newParameter = | 1470 HInstruction newParameter = |
1472 localsHandler.directLocals[parameterElement]; | 1471 localsHandler.directLocals[parameterElement]; |
1473 if (!element.isConstructor || | 1472 if (!element.isConstructor || |
1474 !(element as ConstructorElement).isRedirectingFactory) { | 1473 !(element as ConstructorElement).isRedirectingFactory) { |
1475 // Redirection factories must not check their argument types. | 1474 // Redirection factories must not check their argument types. |
(...skipping 5372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6848 this.oldReturnLocal, | 6847 this.oldReturnLocal, |
6849 this.oldReturnType, | 6848 this.oldReturnType, |
6850 this.oldResolvedAst, | 6849 this.oldResolvedAst, |
6851 this.oldStack, | 6850 this.oldStack, |
6852 this.oldLocalsHandler, | 6851 this.oldLocalsHandler, |
6853 this.inTryStatement, | 6852 this.inTryStatement, |
6854 this.allFunctionsCalledOnce, | 6853 this.allFunctionsCalledOnce, |
6855 this.oldElementInferenceResults) | 6854 this.oldElementInferenceResults) |
6856 : super(function); | 6855 : super(function); |
6857 } | 6856 } |
OLD | NEW |