Chromium Code Reviews| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 // The result of the update instruction isn't used, and can just | 894 // The result of the update instruction isn't used, and can just |
| 895 // be dropped. | 895 // be dropped. |
| 896 pop(); | 896 pop(); |
| 897 } | 897 } |
| 898 } | 898 } |
| 899 | 899 |
| 900 void buildBody() { | 900 void buildBody() { |
| 901 forStatement.body.accept(this); | 901 forStatement.body.accept(this); |
| 902 } | 902 } |
| 903 | 903 |
| 904 JumpTarget jumpTarget = localsMap.getJumpTargetForFor(forStatement); | |
| 904 loopHandler.handleLoop( | 905 loopHandler.handleLoop( |
| 905 forStatement, | 906 forStatement, |
| 906 localsMap.getClosureRepresentationInfoForLoop( | 907 localsMap.getClosureRepresentationInfoForLoop( |
| 907 closureDataLookup, forStatement), | 908 closureDataLookup, forStatement), |
| 908 localsMap.getJumpTargetForFor(forStatement), | 909 jumpTarget, |
| 909 buildInitializer, | 910 buildInitializer, |
| 910 buildCondition, | 911 buildCondition, |
| 911 buildUpdate, | 912 buildUpdate, |
| 912 buildBody); | 913 buildBody); |
| 913 } | 914 } |
| 914 | 915 |
| 915 @override | 916 @override |
| 916 void visitForInStatement(ir.ForInStatement forInStatement) { | 917 void visitForInStatement(ir.ForInStatement forInStatement) { |
| 917 if (forInStatement.isAsync) { | 918 if (forInStatement.isAsync) { |
| 918 _buildAsyncForIn(forInStatement); | 919 _buildAsyncForIn(forInStatement); |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1459 } | 1460 } |
| 1460 | 1461 |
| 1461 @override | 1462 @override |
| 1462 void visitBreakStatement(ir.BreakStatement breakStatement) { | 1463 void visitBreakStatement(ir.BreakStatement breakStatement) { |
| 1463 assert(!isAborted()); | 1464 assert(!isAborted()); |
| 1464 handleInTryStatement(); | 1465 handleInTryStatement(); |
| 1465 JumpTarget target = localsMap.getJumpTargetForBreak(breakStatement); | 1466 JumpTarget target = localsMap.getJumpTargetForBreak(breakStatement); |
| 1466 assert(target != null); | 1467 assert(target != null); |
| 1467 JumpHandler handler = jumpTargets[target]; | 1468 JumpHandler handler = jumpTargets[target]; |
| 1468 assert(handler != null); | 1469 assert(handler != null); |
| 1469 if (handler.labels.isNotEmpty) { | 1470 if (localsMap.generateContinueForBreak(breakStatement)) { |
| 1470 handler.generateBreak(handler.labels.first); | 1471 if (handler.labels.isNotEmpty) { |
| 1472 handler.generateContinue(handler.labels.first); | |
|
Siggi Cherem (dart-lang)
2017/06/23 21:03:59
is this label in the right place?
or do we need t
Johnni Winther
2017/06/26 11:27:56
It's the responsibility of the jump target (here t
| |
| 1473 } else { | |
| 1474 handler.generateContinue(); | |
| 1475 } | |
| 1471 } else { | 1476 } else { |
| 1472 handler.generateBreak(); | 1477 if (handler.labels.isNotEmpty) { |
| 1478 handler.generateBreak(handler.labels.first); | |
| 1479 } else { | |
| 1480 handler.generateBreak(); | |
| 1481 } | |
| 1473 } | 1482 } |
| 1474 } | 1483 } |
| 1475 | 1484 |
| 1476 @override | 1485 @override |
| 1477 void visitLabeledStatement(ir.LabeledStatement labeledStatement) { | 1486 void visitLabeledStatement(ir.LabeledStatement labeledStatement) { |
| 1478 ir.Statement body = labeledStatement.body; | 1487 ir.Statement body = labeledStatement.body; |
| 1479 if (body is ir.WhileStatement || | 1488 if (body is ir.WhileStatement || |
| 1480 body is ir.DoStatement || | 1489 body is ir.DoStatement || |
| 1481 body is ir.ForStatement || | 1490 body is ir.ForStatement || |
| 1482 body is ir.ForInStatement || | 1491 body is ir.ForInStatement || |
| 1483 body is ir.SwitchStatement) { | 1492 body is ir.SwitchStatement) { |
| 1484 // loops and switches handle breaks on their own | 1493 // loops and switches handle breaks on their own |
| 1485 body.accept(this); | 1494 body.accept(this); |
| 1486 return; | 1495 return; |
| 1487 } | 1496 } |
| 1488 JumpHandler handler = createJumpHandler( | 1497 JumpTarget jumpTarget = localsMap.getJumpTargetForLabel(labeledStatement); |
|
Siggi Cherem (dart-lang)
2017/06/23 21:03:59
I thought eventually the visitor was going to gene
Johnni Winther
2017/06/26 11:27:56
No, only for those that _are_ targets. An untarget
| |
| 1489 labeledStatement, localsMap.getJumpTargetForLabel(labeledStatement)); | 1498 if (jumpTarget == null) { |
| 1499 // The label is not needed. | |
| 1500 body.accept(this); | |
| 1501 return; | |
| 1502 } | |
| 1503 | |
| 1504 JumpHandler handler = createJumpHandler(labeledStatement, jumpTarget); | |
| 1490 | 1505 |
| 1491 LocalsHandler beforeLocals = new LocalsHandler.from(localsHandler); | 1506 LocalsHandler beforeLocals = new LocalsHandler.from(localsHandler); |
| 1492 | 1507 |
| 1493 HBasicBlock newBlock = openNewBlock(); | 1508 HBasicBlock newBlock = openNewBlock(); |
| 1494 body.accept(this); | 1509 body.accept(this); |
| 1495 SubGraph bodyGraph = new SubGraph(newBlock, lastOpenedBlock); | 1510 SubGraph bodyGraph = new SubGraph(newBlock, lastOpenedBlock); |
| 1496 | 1511 |
| 1497 HBasicBlock joinBlock = graph.addNewBlock(); | 1512 HBasicBlock joinBlock = graph.addNewBlock(); |
| 1498 List<LocalsHandler> breakHandlers = <LocalsHandler>[]; | 1513 List<LocalsHandler> breakHandlers = <LocalsHandler>[]; |
| 1499 handler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) { | 1514 handler.forEachBreak((HBreak breakInstruction, LocalsHandler locals) { |
| (...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3468 enterBlock.setBlockFlow( | 3483 enterBlock.setBlockFlow( |
| 3469 new HTryBlockInformation( | 3484 new HTryBlockInformation( |
| 3470 kernelBuilder.wrapStatementGraph(bodyGraph), | 3485 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3471 exception, | 3486 exception, |
| 3472 kernelBuilder.wrapStatementGraph(catchGraph), | 3487 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3473 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3488 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3474 exitBlock); | 3489 exitBlock); |
| 3475 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3490 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3476 } | 3491 } |
| 3477 } | 3492 } |
| OLD | NEW |