| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry; | 9 import '../common/codegen.dart' show CodegenRegistry; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Provide the parameters to the generative constructor body. | 344 // Provide the parameters to the generative constructor body. |
| 345 body.function.positionalParameters.forEach(handleParameter); | 345 body.function.positionalParameters.forEach(handleParameter); |
| 346 body.function.namedParameters.toList() | 346 body.function.namedParameters.toList() |
| 347 ..sort(namedOrdering) | 347 ..sort(namedOrdering) |
| 348 ..forEach(handleParameter); | 348 ..forEach(handleParameter); |
| 349 | 349 |
| 350 // If there are locals that escape (i.e. mutated in closures), we pass the | 350 // If there are locals that escape (i.e. mutated in closures), we pass the |
| 351 // box to the constructor. | 351 // box to the constructor. |
| 352 ClosureAnalysisInfo scopeData = closureDataLookup | 352 ClosureBase scopeData = |
| 353 .getClosureAnalysisInfo(constructorElement.resolvedAst.node); | 353 closureDataLookup.getClosureBase(constructorElement.resolvedAst.node); |
| 354 if (scopeData.requiresContextBox) { | 354 if (scopeData.requiresContextBox) { |
| 355 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); | 355 bodyCallInputs.add(localsHandler.readLocal(scopeData.context)); |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Pass type arguments. | 358 // Pass type arguments. |
| 359 ir.Class currentClass = body.enclosingClass; | 359 ir.Class currentClass = body.enclosingClass; |
| 360 if (backend.rtiNeed.classNeedsRti(_elementMap.getClass(currentClass))) { | 360 if (backend.rtiNeed.classNeedsRti(_elementMap.getClass(currentClass))) { |
| 361 for (ir.DartType typeParameter in currentClass.thisType.typeArguments) { | 361 for (ir.DartType typeParameter in currentClass.thisType.typeArguments) { |
| 362 HInstruction argument = localsHandler.readLocal(localsHandler | 362 HInstruction argument = localsHandler.readLocal(localsHandler |
| 363 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter) | 363 .getTypeVariableAsLocal(_elementMap.getDartType(typeParameter) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 ConstructorEntity astElement = _elementMap.getConstructor(constructor); | 607 ConstructorEntity astElement = _elementMap.getConstructor(constructor); |
| 608 ClosureRepresentationInfo oldScopeInfo = localsHandler.scopeInfo; | 608 ClosureRepresentationInfo oldScopeInfo = localsHandler.scopeInfo; |
| 609 ClosureRepresentationInfo newScopeInfo = | 609 ClosureRepresentationInfo newScopeInfo = |
| 610 closureDataLookup.getScopeInfo(astElement); | 610 closureDataLookup.getScopeInfo(astElement); |
| 611 if (astElement is ConstructorElement) { | 611 if (astElement is ConstructorElement) { |
| 612 // TODO(johnniwinther): Support constructor (body) entities. | 612 // TODO(johnniwinther): Support constructor (body) entities. |
| 613 ResolvedAst resolvedAst = astElement.resolvedAst; | 613 ResolvedAst resolvedAst = astElement.resolvedAst; |
| 614 localsHandler.scopeInfo = newScopeInfo; | 614 localsHandler.scopeInfo = newScopeInfo; |
| 615 if (resolvedAst.kind == ResolvedAstKind.PARSED) { | 615 if (resolvedAst.kind == ResolvedAstKind.PARSED) { |
| 616 localsHandler.enterScope( | 616 localsHandler.enterScope( |
| 617 closureDataLookup.getClosureAnalysisInfo(resolvedAst.node), | 617 closureDataLookup.getClosureBase(resolvedAst.node), |
| 618 forGenerativeConstructorBody: | 618 forGenerativeConstructorBody: |
| 619 astElement.isGenerativeConstructorBody); | 619 astElement.isGenerativeConstructorBody); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 inlinedFrom(astElement, () { | 622 inlinedFrom(astElement, () { |
| 623 _buildInitializers(constructor, constructorChain, fieldValues); | 623 _buildInitializers(constructor, constructorChain, fieldValues); |
| 624 }); | 624 }); |
| 625 localsHandler.scopeInfo = oldScopeInfo; | 625 localsHandler.scopeInfo = oldScopeInfo; |
| 626 } | 626 } |
| 627 | 627 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 ..sort(namedOrdering) | 699 ..sort(namedOrdering) |
| 700 ..forEach(handleParameter); | 700 ..forEach(handleParameter); |
| 701 } | 701 } |
| 702 | 702 |
| 703 HBasicBlock block = graph.addNewBlock(); | 703 HBasicBlock block = graph.addNewBlock(); |
| 704 open(graph.entry); | 704 open(graph.entry); |
| 705 | 705 |
| 706 localsHandler.startFunction( | 706 localsHandler.startFunction( |
| 707 targetElement, | 707 targetElement, |
| 708 closureDataLookup.getScopeInfo(targetElement), | 708 closureDataLookup.getScopeInfo(targetElement), |
| 709 closureDataLookup.getClosureAnalysisInfo(functionNode), | 709 closureDataLookup.getClosureBase(functionNode), |
| 710 parameterMap, | 710 parameterMap, |
| 711 isGenerativeConstructorBody: _targetIsConstructorBody); | 711 isGenerativeConstructorBody: _targetIsConstructorBody); |
| 712 close(new HGoto()).addSuccessor(block); | 712 close(new HGoto()).addSuccessor(block); |
| 713 | 713 |
| 714 open(block); | 714 open(block); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void closeFunction() { | 717 void closeFunction() { |
| 718 if (!isAborted()) closeAndGotoExit(new HGoto()); | 718 if (!isAborted()) closeAndGotoExit(new HGoto()); |
| 719 graph.finalize(); | 719 graph.finalize(); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 () {}, () { | 1194 () {}, () { |
| 1195 whileStatement.body.accept(this); | 1195 whileStatement.body.accept(this); |
| 1196 }); | 1196 }); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 @override | 1199 @override |
| 1200 visitDoStatement(ir.DoStatement doStatement) { | 1200 visitDoStatement(ir.DoStatement doStatement) { |
| 1201 // TODO(efortuna): I think this can be rewritten using | 1201 // TODO(efortuna): I think this can be rewritten using |
| 1202 // LoopHandler.handleLoop with some tricks about when the "update" happens. | 1202 // LoopHandler.handleLoop with some tricks about when the "update" happens. |
| 1203 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); | 1203 LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); |
| 1204 LoopClosureRepresentationInfo loopClosureInfo = localsMap | 1204 ClosureBase loopClosureInfo = localsMap.getClosureRepresentationInfoForLoop( |
| 1205 .getClosureRepresentationInfoForLoop(closureDataLookup, doStatement); | 1205 closureDataLookup, doStatement); |
| 1206 localsHandler.startLoop(loopClosureInfo); | 1206 localsHandler.startLoop(loopClosureInfo); |
| 1207 JumpHandler jumpHandler = loopHandler.beginLoopHeader(doStatement); | 1207 JumpHandler jumpHandler = loopHandler.beginLoopHeader(doStatement); |
| 1208 HLoopInformation loopInfo = current.loopInformation; | 1208 HLoopInformation loopInfo = current.loopInformation; |
| 1209 HBasicBlock loopEntryBlock = current; | 1209 HBasicBlock loopEntryBlock = current; |
| 1210 HBasicBlock bodyEntryBlock = current; | 1210 HBasicBlock bodyEntryBlock = current; |
| 1211 JumpTarget target = localsMap.getJumpTarget(doStatement); | 1211 JumpTarget target = localsMap.getJumpTarget(doStatement); |
| 1212 bool hasContinues = target != null && target.isContinueTarget; | 1212 bool hasContinues = target != null && target.isContinueTarget; |
| 1213 if (hasContinues) { | 1213 if (hasContinues) { |
| 1214 // Add extra block to hang labels on. | 1214 // Add extra block to hang labels on. |
| 1215 // It doesn't currently work if they are on the same block as the | 1215 // It doesn't currently work if they are on the same block as the |
| (...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 enterBlock.setBlockFlow( | 3487 enterBlock.setBlockFlow( |
| 3488 new HTryBlockInformation( | 3488 new HTryBlockInformation( |
| 3489 kernelBuilder.wrapStatementGraph(bodyGraph), | 3489 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3490 exception, | 3490 exception, |
| 3491 kernelBuilder.wrapStatementGraph(catchGraph), | 3491 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3492 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3492 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3493 exitBlock); | 3493 exitBlock); |
| 3494 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3494 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3495 } | 3495 } |
| 3496 } | 3496 } |
| OLD | NEW |