| 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 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 for (int i = 0; i < fields.length; i++) { | 1344 for (int i = 0; i < fields.length; i++) { |
| 1345 add(new HFieldSet(fields[i], newObject, constructorArguments[i])); | 1345 add(new HFieldSet(fields[i], newObject, constructorArguments[i])); |
| 1346 } | 1346 } |
| 1347 } | 1347 } |
| 1348 removeInlinedInstantiation(type); | 1348 removeInlinedInstantiation(type); |
| 1349 | 1349 |
| 1350 // Generate calls to the constructor bodies. | 1350 // Generate calls to the constructor bodies. |
| 1351 HInstruction interceptor = null; | 1351 HInstruction interceptor = null; |
| 1352 for (int index = constructorResolvedAsts.length - 1; index >= 0; index--) { | 1352 for (int index = constructorResolvedAsts.length - 1; index >= 0; index--) { |
| 1353 ResolvedAst constructorResolvedAst = constructorResolvedAsts[index]; | 1353 ResolvedAst constructorResolvedAst = constructorResolvedAsts[index]; |
| 1354 ConstructorElement constructor = |
| 1355 constructorResolvedAst.element.implementation; |
| 1354 ConstructorBodyElement body = | 1356 ConstructorBodyElement body = |
| 1355 ConstructorBodyElementX.createFromResolvedAst(constructorResolvedAst); | 1357 ConstructorBodyElementX.createFromResolvedAst(constructorResolvedAst); |
| 1356 if (body == null) continue; | 1358 if (body == null) continue; |
| 1357 | 1359 |
| 1358 List bodyCallInputs = <HInstruction>[]; | 1360 List bodyCallInputs = <HInstruction>[]; |
| 1359 if (isNativeUpgradeFactory) { | 1361 if (isNativeUpgradeFactory) { |
| 1360 if (interceptor == null) { | 1362 if (interceptor == null) { |
| 1361 ConstantValue constant = new InterceptorConstantValue(classElement); | 1363 ConstantValue constant = new InterceptorConstantValue(classElement); |
| 1362 interceptor = graph.addConstant(constant, closedWorld); | 1364 interceptor = graph.addConstant(constant, closedWorld); |
| 1363 } | 1365 } |
| 1364 bodyCallInputs.add(interceptor); | 1366 bodyCallInputs.add(interceptor); |
| 1365 } | 1367 } |
| 1366 bodyCallInputs.add(newObject); | 1368 bodyCallInputs.add(newObject); |
| 1367 ast.Node node = constructorResolvedAst.node; | 1369 ast.Node node = constructorResolvedAst.node; |
| 1368 ClosureClassMap parameterClosureData = | 1370 ClosureClassMap parameterClosureData = |
| 1369 closureToClassMapper.getMemberMap(functionElement); | 1371 closureToClassMapper.getMemberMap(constructor); |
| 1370 | 1372 |
| 1371 FunctionSignature functionSignature = body.functionSignature; | 1373 FunctionSignature functionSignature = body.functionSignature; |
| 1372 // Provide the parameters to the generative constructor body. | 1374 // Provide the parameters to the generative constructor body. |
| 1373 functionSignature.orderedForEachParameter((ParameterElement parameter) { | 1375 functionSignature.orderedForEachParameter((ParameterElement parameter) { |
| 1374 // If [parameter] is boxed, it will be a field in the box passed as the | 1376 // If [parameter] is boxed, it will be a field in the box passed as the |
| 1375 // last parameter. So no need to directly pass it. | 1377 // last parameter. So no need to directly pass it. |
| 1376 if (!localsHandler.isBoxed(parameter)) { | 1378 if (!localsHandler.isBoxed(parameter)) { |
| 1377 bodyCallInputs.add(localsHandler.readLocal(parameter)); | 1379 bodyCallInputs.add(localsHandler.readLocal(parameter)); |
| 1378 } | 1380 } |
| 1379 }); | 1381 }); |
| 1380 | 1382 |
| 1381 // If there are locals that escape (ie mutated in closures), we | 1383 // If there are locals that escape (ie mutated in closures), we |
| 1382 // pass the box to the constructor. | 1384 // pass the box to the constructor. |
| 1383 // The box must be passed before any type variable. | 1385 // The box must be passed before any type variable. |
| 1384 ClosureScope scopeData = parameterClosureData.capturingScopes[node]; | 1386 ClosureScope scopeData = parameterClosureData.capturingScopes[node]; |
| 1385 if (scopeData != null) { | 1387 if (scopeData != null) { |
| 1386 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); | 1388 bodyCallInputs.add(localsHandler.readLocal(scopeData.boxElement)); |
| 1387 } | 1389 } |
| 1388 | 1390 |
| 1389 // Type variables arguments must come after the box (if there is one). | 1391 // Type variables arguments must come after the box (if there is one). |
| 1390 ConstructorElement constructor = | |
| 1391 constructorResolvedAst.element.implementation; | |
| 1392 ClassElement currentClass = constructor.enclosingClass; | 1392 ClassElement currentClass = constructor.enclosingClass; |
| 1393 if (rtiNeed.classNeedsRti(currentClass)) { | 1393 if (rtiNeed.classNeedsRti(currentClass)) { |
| 1394 // If [currentClass] needs RTI, we add the type variables as | 1394 // If [currentClass] needs RTI, we add the type variables as |
| 1395 // parameters of the generative constructor body. | 1395 // parameters of the generative constructor body. |
| 1396 currentClass.typeVariables | 1396 currentClass.typeVariables |
| 1397 .forEach((ResolutionTypeVariableType argument) { | 1397 .forEach((ResolutionTypeVariableType argument) { |
| 1398 // TODO(johnniwinther): Substitute [argument] with | 1398 // TODO(johnniwinther): Substitute [argument] with |
| 1399 // `localsHandler.substInContext(argument)`. | 1399 // `localsHandler.substInContext(argument)`. |
| 1400 bodyCallInputs.add(localsHandler | 1400 bodyCallInputs.add(localsHandler |
| 1401 .readLocal(localsHandler.getTypeVariableAsLocal(argument))); | 1401 .readLocal(localsHandler.getTypeVariableAsLocal(argument))); |
| (...skipping 5410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6812 this.oldReturnLocal, | 6812 this.oldReturnLocal, |
| 6813 this.oldReturnType, | 6813 this.oldReturnType, |
| 6814 this.oldResolvedAst, | 6814 this.oldResolvedAst, |
| 6815 this.oldStack, | 6815 this.oldStack, |
| 6816 this.oldLocalsHandler, | 6816 this.oldLocalsHandler, |
| 6817 this.inTryStatement, | 6817 this.inTryStatement, |
| 6818 this.allFunctionsCalledOnce, | 6818 this.allFunctionsCalledOnce, |
| 6819 this.oldElementInferenceResults) | 6819 this.oldElementInferenceResults) |
| 6820 : super(function); | 6820 : super(function); |
| 6821 } | 6821 } |
| OLD | NEW |