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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
9 R visitBitAnd(HBitAnd node); | 9 R visitBitAnd(HBitAnd node); |
10 R visitBitNot(HBitNot node); | 10 R visitBitNot(HBitNot node); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 R visitStringConcat(HStringConcat node); | 60 R visitStringConcat(HStringConcat node); |
61 R visitStringify(HStringify node); | 61 R visitStringify(HStringify node); |
62 R visitSubtract(HSubtract node); | 62 R visitSubtract(HSubtract node); |
63 R visitSwitch(HSwitch node); | 63 R visitSwitch(HSwitch node); |
64 R visitThis(HThis node); | 64 R visitThis(HThis node); |
65 R visitThrow(HThrow node); | 65 R visitThrow(HThrow node); |
66 R visitThrowExpression(HThrowExpression node); | 66 R visitThrowExpression(HThrowExpression node); |
67 R visitTry(HTry node); | 67 R visitTry(HTry node); |
68 R visitTypeConversion(HTypeConversion node); | 68 R visitTypeConversion(HTypeConversion node); |
69 R visitTypeKnown(HTypeKnown node); | 69 R visitTypeKnown(HTypeKnown node); |
70 R visitFunctionType(HFunctionType node); | |
71 R visitReadTypeVariable(HReadTypeVariable node); | |
70 } | 72 } |
71 | 73 |
72 abstract class HGraphVisitor { | 74 abstract class HGraphVisitor { |
73 visitDominatorTree(HGraph graph) { | 75 visitDominatorTree(HGraph graph) { |
74 void visitBasicBlockAndSuccessors(HBasicBlock block) { | 76 void visitBasicBlockAndSuccessors(HBasicBlock block) { |
75 visitBasicBlock(block); | 77 visitBasicBlock(block); |
76 List dominated = block.dominatedBlocks; | 78 List dominated = block.dominatedBlocks; |
77 for (int i = 0; i < dominated.length; i++) { | 79 for (int i = 0; i < dominated.length; i++) { |
78 visitBasicBlockAndSuccessors(dominated[i]); | 80 visitBasicBlockAndSuccessors(dominated[i]); |
79 } | 81 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 visitStaticStore(HStaticStore node) => visitInstruction(node); | 341 visitStaticStore(HStaticStore node) => visitInstruction(node); |
340 visitStringConcat(HStringConcat node) => visitInstruction(node); | 342 visitStringConcat(HStringConcat node) => visitInstruction(node); |
341 visitStringify(HStringify node) => visitInstruction(node); | 343 visitStringify(HStringify node) => visitInstruction(node); |
342 visitThis(HThis node) => visitParameterValue(node); | 344 visitThis(HThis node) => visitParameterValue(node); |
343 visitThrow(HThrow node) => visitControlFlow(node); | 345 visitThrow(HThrow node) => visitControlFlow(node); |
344 visitThrowExpression(HThrowExpression node) => visitInstruction(node); | 346 visitThrowExpression(HThrowExpression node) => visitInstruction(node); |
345 visitTry(HTry node) => visitControlFlow(node); | 347 visitTry(HTry node) => visitControlFlow(node); |
346 visitIs(HIs node) => visitInstruction(node); | 348 visitIs(HIs node) => visitInstruction(node); |
347 visitTypeConversion(HTypeConversion node) => visitCheck(node); | 349 visitTypeConversion(HTypeConversion node) => visitCheck(node); |
348 visitTypeKnown(HTypeKnown node) => visitCheck(node); | 350 visitTypeKnown(HTypeKnown node) => visitCheck(node); |
351 visitFunctionType(HFunctionType node) => visitInstruction(node); | |
352 visitReadTypeVariable(HReadTypeVariable node) => visitInstruction(node); | |
349 } | 353 } |
350 | 354 |
351 class SubGraph { | 355 class SubGraph { |
352 // The first and last block of the sub-graph. | 356 // The first and last block of the sub-graph. |
353 final HBasicBlock start; | 357 final HBasicBlock start; |
354 final HBasicBlock end; | 358 final HBasicBlock end; |
355 | 359 |
356 const SubGraph(this.start, this.end); | 360 const SubGraph(this.start, this.end); |
357 | 361 |
358 bool contains(HBasicBlock block) { | 362 bool contains(HBasicBlock block) { |
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2710 this.finallyBlock); | 2714 this.finallyBlock); |
2711 | 2715 |
2712 HBasicBlock get start => body.start; | 2716 HBasicBlock get start => body.start; |
2713 HBasicBlock get end => | 2717 HBasicBlock get end => |
2714 finallyBlock == null ? catchBlock.end : finallyBlock.end; | 2718 finallyBlock == null ? catchBlock.end : finallyBlock.end; |
2715 | 2719 |
2716 bool accept(HStatementInformationVisitor visitor) => | 2720 bool accept(HStatementInformationVisitor visitor) => |
2717 visitor.visitTryInfo(this); | 2721 visitor.visitTryInfo(this); |
2718 } | 2722 } |
2719 | 2723 |
2720 | |
2721 | |
2722 class HSwitchBlockInformation implements HStatementInformation { | 2724 class HSwitchBlockInformation implements HStatementInformation { |
2723 final HExpressionInformation expression; | 2725 final HExpressionInformation expression; |
2724 final List<List<Constant>> matchExpressions; | 2726 final List<List<Constant>> matchExpressions; |
2725 final List<HStatementInformation> statements; | 2727 final List<HStatementInformation> statements; |
2726 final TargetElement target; | 2728 final TargetElement target; |
2727 final List<LabelElement> labels; | 2729 final List<LabelElement> labels; |
2728 | 2730 |
2729 HSwitchBlockInformation(this.expression, | 2731 HSwitchBlockInformation(this.expression, |
2730 this.matchExpressions, | 2732 this.matchExpressions, |
2731 this.statements, | 2733 this.statements, |
2732 this.target, | 2734 this.target, |
2733 this.labels); | 2735 this.labels); |
2734 | 2736 |
2735 HBasicBlock get start => expression.start; | 2737 HBasicBlock get start => expression.start; |
2736 HBasicBlock get end { | 2738 HBasicBlock get end { |
2737 // We don't create a switch block if there are no cases. | 2739 // We don't create a switch block if there are no cases. |
2738 assert(!statements.isEmpty); | 2740 assert(!statements.isEmpty); |
2739 return statements.last.end; | 2741 return statements.last.end; |
2740 } | 2742 } |
2741 | 2743 |
2742 bool accept(HStatementInformationVisitor visitor) => | 2744 bool accept(HStatementInformationVisitor visitor) => |
2743 visitor.visitSwitchInfo(this); | 2745 visitor.visitSwitchInfo(this); |
2744 } | 2746 } |
2747 | |
2748 class HReadTypeVariable extends HInstruction { | |
2749 /// The type variable being read. | |
2750 final TypeVariableType dartType; | |
2751 | |
2752 final bool hasReceiver; | |
2753 | |
2754 HReadTypeVariable(this.dartType, HInstruction receiver) | |
2755 : hasReceiver = true, | |
2756 super(<HInstruction>[receiver]); | |
2757 | |
2758 HReadTypeVariable.noReceiver(this.dartType, HInstruction typeArguments) | |
2759 : hasReceiver = false, | |
2760 super(<HInstruction>[typeArguments]); | |
2761 | |
2762 accept(HVisitor visitor) => visitor.visitReadTypeVariable(this); | |
2763 } | |
2764 | |
2765 class HFunctionType extends HInstruction { | |
ngeoffray
2013/11/01 13:54:02
Could you remind me why can't you just do a new li
ahe
2013/11/04 17:23:45
I'm not sure how this interacts with GVN. Also, I'
| |
2766 final FunctionType dartType; | |
2767 | |
2768 HFunctionType(List<HInstruction> typeVariables, this.dartType) | |
2769 : super(typeVariables) { | |
2770 /* Element */ sourceElement = null; | |
2771 /* SourceFileLocation */ sourcePosition = null; | |
2772 } | |
2773 | |
2774 accept(HVisitor visitor) => visitor.visitFunctionType(this); | |
2775 } | |
OLD | NEW |