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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2954463002: Refactoring to prepare for kernel based jump targets (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 1411cde5d64c673b8c6e71bcfea960ebf49d508d..08a9b757fe2203f9a58adc57bccba79d57b128a4 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1707,6 +1707,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ elements.getTargetDefinition(node),
buildInitializer,
buildCondition,
buildUpdate,
@@ -1723,6 +1724,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ elements.getTargetDefinition(node),
() {},
buildCondition,
() {}, () {
@@ -1737,11 +1739,11 @@ class SsaAstGraphBuilder extends ast.Visitor
closureDataLookup.getClosureRepresentationInfoForLoop(node);
localsHandler.startLoop(loopClosureInfo);
loopDepth++;
- JumpHandler jumpHandler = loopHandler.beginLoopHeader(node);
+ JumpTarget target = elements.getTargetDefinition(node);
+ JumpHandler jumpHandler = loopHandler.beginLoopHeader(node, target);
HLoopInformation loopInfo = current.loopInformation;
HBasicBlock loopEntryBlock = current;
HBasicBlock bodyEntryBlock = current;
- JumpTarget target = elements.getTargetDefinition(node);
bool hasContinues = target != null && target.isContinueTarget;
if (hasContinues) {
// Add extra block to hang labels on.
@@ -1854,8 +1856,8 @@ class SsaAstGraphBuilder extends ast.Visitor
// to the body.
SubGraph bodyGraph = new SubGraph(bodyEntryBlock, bodyExitBlock);
JumpTarget target = elements.getTargetDefinition(node);
- LabelDefinition label = target.addLabel(null, 'loop');
- label.setBreakTarget();
+ LabelDefinition label =
+ target.addLabel(null, 'loop', isBreakTarget: true);
HLabeledBlockInformation info = new HLabeledBlockInformation(
new HSubGraphBlockInformation(bodyGraph), <LabelDefinition>[label]);
loopEntryBlock.setBlockFlow(info, current);
@@ -5378,18 +5380,18 @@ class SsaAstGraphBuilder extends ast.Visitor
* to distinguish the synthesized loop created for a switch statement with
* continue statements from simple switch statements.
*/
- JumpHandler createJumpHandler(ast.Statement node, {bool isLoopJump}) {
- JumpTarget element = elements.getTargetDefinition(node);
- if (element == null || !identical(element.statement, node)) {
+ JumpHandler createJumpHandler(ast.Statement node, JumpTarget jumpTarget,
+ {bool isLoopJump}) {
+ if (jumpTarget == null || !identical(jumpTarget.statement, node)) {
// No breaks or continues to this node.
return new NullJumpHandler(reporter);
}
if (isLoopJump && node is ast.SwitchStatement) {
// Create a special jump handler for loops created for switch statements
// with continue statements.
- return new AstSwitchCaseJumpHandler(this, element, node);
+ return new AstSwitchCaseJumpHandler(this, jumpTarget, node);
}
- return new JumpHandler(this, element);
+ return new JumpHandler(this, jumpTarget);
}
visitAsyncForIn(ast.AsyncForIn node) {
@@ -5445,6 +5447,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ elements.getTargetDefinition(node),
buildInitializer,
buildCondition,
buildUpdate,
@@ -5517,6 +5520,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ elements.getTargetDefinition(node),
buildInitializer,
buildCondition,
() {},
@@ -5641,6 +5645,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ elements.getTargetDefinition(node),
buildInitializer,
buildCondition,
buildUpdate,
@@ -5840,7 +5845,9 @@ class SsaAstGraphBuilder extends ast.Visitor
*/
void buildSimpleSwitchStatement(
ast.SwitchStatement node, Map<ast.CaseMatch, ConstantValue> constants) {
- JumpHandler jumpHandler = createJumpHandler(node, isLoopJump: false);
+ JumpHandler jumpHandler = createJumpHandler(
+ node, elements.getTargetDefinition(node),
+ isLoopJump: false);
HInstruction buildExpression() {
visit(node.expression);
return pop();
@@ -5910,7 +5917,8 @@ class SsaAstGraphBuilder extends ast.Visitor
HInstruction initialValue = graph.addConstantNull(closedWorld);
localsHandler.updateLocal(switchTarget, initialValue);
- JumpHandler jumpHandler = createJumpHandler(node, isLoopJump: false);
+ JumpHandler jumpHandler =
+ createJumpHandler(node, switchTarget, isLoopJump: false);
dynamic switchCases = node.cases;
if (!hasDefault) {
// Use [:null:] as the marker for a synthetic default clause.
@@ -5994,6 +6002,7 @@ class SsaAstGraphBuilder extends ast.Visitor
loopHandler.handleLoop(
node,
closureDataLookup.getClosureRepresentationInfoForLoop(node),
+ switchTarget,
() {},
buildCondition,
() {},
« no previous file with comments | « pkg/compiler/lib/src/serialization/resolved_ast_serialization.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