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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 99303004: Remove unused API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 : id = idCounter++, usedBy = <HInstruction>[] { 788 : id = idCounter++, usedBy = <HInstruction>[] {
789 assert(inputs.every((e) => e != null)); 789 assert(inputs.every((e) => e != null));
790 } 790 }
791 791
792 int get hashCode => id; 792 int get hashCode => id;
793 793
794 bool useGvn() => _useGvn; 794 bool useGvn() => _useGvn;
795 void setUseGvn() { _useGvn = true; } 795 void setUseGvn() { _useGvn = true; }
796 void clearUseGvn() { _useGvn = false; } 796 void clearUseGvn() { _useGvn = false; }
797 797
798 void updateInput(int i, HInstruction insn) {
799 assert(insn != null);
800 inputs[i] = insn;
801 }
802
803 /** 798 /**
804 * A pure instruction is an instruction that does not have any side 799 * A pure instruction is an instruction that does not have any side
805 * effect, nor any dependency. They can be moved anywhere in the 800 * effect, nor any dependency. They can be moved anywhere in the
806 * graph. 801 * graph.
807 */ 802 */
808 bool isPure() { 803 bool isPure() {
809 return !sideEffects.hasSideEffects() 804 return !sideEffects.hasSideEffects()
810 && !sideEffects.dependsOnSomething() 805 && !sideEffects.dependsOnSomething()
811 && !canThrow(); 806 && !canThrow();
812 } 807 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 * Type of the unstruction. 969 * Type of the unstruction.
975 */ 970 */
976 TypeMask instructionType; 971 TypeMask instructionType;
977 972
978 Selector get selector => null; 973 Selector get selector => null;
979 HInstruction getDartReceiver(Compiler compiler) => null; 974 HInstruction getDartReceiver(Compiler compiler) => null;
980 bool onlyThrowsNSM() => false; 975 bool onlyThrowsNSM() => false;
981 976
982 bool isInBasicBlock() => block != null; 977 bool isInBasicBlock() => block != null;
983 978
984 String inputsToString() {
985 void addAsCommaSeparated(StringBuffer buffer, List<HInstruction> list) {
986 for (int i = 0; i < list.length; i++) {
987 if (i != 0) buffer.write(', ');
988 buffer.write("@${list[i].id}");
989 }
990 }
991
992 StringBuffer buffer = new StringBuffer();
993 buffer.write('(');
994 addAsCommaSeparated(buffer, inputs);
995 buffer.write(') - used at [');
996 addAsCommaSeparated(buffer, usedBy);
997 buffer.write(']');
998 return buffer.toString();
999 }
1000
1001 bool gvnEquals(HInstruction other) { 979 bool gvnEquals(HInstruction other) {
1002 assert(useGvn() && other.useGvn()); 980 assert(useGvn() && other.useGvn());
1003 // Check that the type and the sideEffects match. 981 // Check that the type and the sideEffects match.
1004 bool hasSameType = typeEquals(other); 982 bool hasSameType = typeEquals(other);
1005 assert(hasSameType == (typeCode() == other.typeCode())); 983 assert(hasSameType == (typeCode() == other.typeCode()));
1006 if (!hasSameType) return false; 984 if (!hasSameType) return false;
1007 if (sideEffects != other.sideEffects) return false; 985 if (sideEffects != other.sideEffects) return false;
1008 // Check that the inputs match. 986 // Check that the inputs match.
1009 final int inputsLength = inputs.length; 987 final int inputsLength = inputs.length;
1010 final List<HInstruction> otherInputs = other.inputs; 988 final List<HInstruction> otherInputs = other.inputs;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 1357
1380 class HInvokeDynamicMethod extends HInvokeDynamic { 1358 class HInvokeDynamicMethod extends HInvokeDynamic {
1381 HInvokeDynamicMethod(Selector selector, 1359 HInvokeDynamicMethod(Selector selector,
1382 List<HInstruction> inputs, 1360 List<HInstruction> inputs,
1383 TypeMask type, 1361 TypeMask type,
1384 [bool isIntercepted = false]) 1362 [bool isIntercepted = false])
1385 : super(selector, null, inputs, type, isIntercepted); 1363 : super(selector, null, inputs, type, isIntercepted);
1386 1364
1387 String toString() => 'invoke dynamic method: $selector'; 1365 String toString() => 'invoke dynamic method: $selector';
1388 accept(HVisitor visitor) => visitor.visitInvokeDynamicMethod(this); 1366 accept(HVisitor visitor) => visitor.visitInvokeDynamicMethod(this);
1389
1390 bool isIndexOperatorOnIndexablePrimitive(Compiler compiler) {
1391 return isInterceptedCall
1392 && selector.kind == SelectorKind.INDEX
1393 && selector.name == '[]'
1394 && inputs[1].isIndexablePrimitive(compiler);
1395 }
1396 } 1367 }
1397 1368
1398 abstract class HInvokeDynamicField extends HInvokeDynamic { 1369 abstract class HInvokeDynamicField extends HInvokeDynamic {
1399 HInvokeDynamicField( 1370 HInvokeDynamicField(
1400 Selector selector, Element element, List<HInstruction> inputs, 1371 Selector selector, Element element, List<HInstruction> inputs,
1401 TypeMask type) 1372 TypeMask type)
1402 : super(selector, element, inputs, type); 1373 : super(selector, element, inputs, type);
1403 toString() => 'invoke dynamic field: $selector'; 1374 toString() => 'invoke dynamic field: $selector';
1404 } 1375 }
1405 1376
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 1868
1898 class HLoopBranch extends HConditionalBranch { 1869 class HLoopBranch extends HConditionalBranch {
1899 static const int CONDITION_FIRST_LOOP = 0; 1870 static const int CONDITION_FIRST_LOOP = 0;
1900 static const int DO_WHILE_LOOP = 1; 1871 static const int DO_WHILE_LOOP = 1;
1901 1872
1902 final int kind; 1873 final int kind;
1903 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) 1874 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP])
1904 : super(<HInstruction>[condition]); 1875 : super(<HInstruction>[condition]);
1905 toString() => 'loop-branch'; 1876 toString() => 'loop-branch';
1906 accept(HVisitor visitor) => visitor.visitLoopBranch(this); 1877 accept(HVisitor visitor) => visitor.visitLoopBranch(this);
1907
1908 bool isDoWhile() {
1909 return identical(kind, DO_WHILE_LOOP);
1910 }
1911
1912 HBasicBlock computeLoopHeader() {
1913 HBasicBlock result;
1914 if (isDoWhile()) {
1915 // In case of a do/while, the successor is a block that avoids
1916 // a critical edge and branchs to the loop header.
1917 result = block.successors[0].successors[0];
1918 } else {
1919 // For other loops, the loop header might be up the dominator
1920 // tree if the loop condition has control flow.
1921 result = block;
1922 while (!result.isLoopHeader()) result = result.dominator;
1923 }
1924
1925 assert(result.isLoopHeader());
1926 return result;
1927 }
1928 } 1878 }
1929 1879
1930 class HConstant extends HInstruction { 1880 class HConstant extends HInstruction {
1931 final Constant constant; 1881 final Constant constant;
1932 HConstant.internal(this.constant, TypeMask constantType) 1882 HConstant.internal(this.constant, TypeMask constantType)
1933 : super(<HInstruction>[], constantType); 1883 : super(<HInstruction>[], constantType);
1934 1884
1935 toString() => 'literal: $constant'; 1885 toString() => 'literal: $constant';
1936 accept(HVisitor visitor) => visitor.visitConstant(this); 1886 accept(HVisitor visitor) => visitor.visitConstant(this);
1937 1887
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 HPhi.manyInputs(Element element, List<HInstruction> inputs, TypeMask type) 1967 HPhi.manyInputs(Element element, List<HInstruction> inputs, TypeMask type)
2018 : this(element, inputs, type); 1968 : this(element, inputs, type);
2019 1969
2020 void addInput(HInstruction input) { 1970 void addInput(HInstruction input) {
2021 assert(isInBasicBlock()); 1971 assert(isInBasicBlock());
2022 inputs.add(input); 1972 inputs.add(input);
2023 assert(inputs.length <= block.predecessors.length); 1973 assert(inputs.length <= block.predecessors.length);
2024 input.usedBy.add(this); 1974 input.usedBy.add(this);
2025 } 1975 }
2026 1976
2027 bool isLogicalOperator() => logicalOperatorType != IS_NOT_LOGICAL_OPERATOR;
2028
2029 String logicalOperator() {
2030 assert(isLogicalOperator());
2031 if (logicalOperatorType == IS_AND) return "&&";
2032 assert(logicalOperatorType == IS_OR);
2033 return "||";
2034 }
2035
2036 toString() => 'phi'; 1977 toString() => 'phi';
2037 accept(HVisitor visitor) => visitor.visitPhi(this); 1978 accept(HVisitor visitor) => visitor.visitPhi(this);
2038 } 1979 }
2039 1980
2040 abstract class HRelational extends HInvokeBinary { 1981 abstract class HRelational extends HInvokeBinary {
2041 bool usesBoolifiedInterceptor = false; 1982 bool usesBoolifiedInterceptor = false;
2042 HRelational(left, right, selector, type) : super(left, right, selector, type); 1983 HRelational(left, right, selector, type) : super(left, right, selector, type);
2043 } 1984 }
2044 1985
2045 class HIdentity extends HRelational { 1986 class HIdentity extends HRelational {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 if (identical(parentHeader, header)) { 2484 if (identical(parentHeader, header)) {
2544 // Nothing to do in this case. 2485 // Nothing to do in this case.
2545 } else if (parentHeader != null) { 2486 } else if (parentHeader != null) {
2546 workQueue.add(parentHeader); 2487 workQueue.add(parentHeader);
2547 } else { 2488 } else {
2548 block.parentLoopHeader = header; 2489 block.parentLoopHeader = header;
2549 blocks.add(block); 2490 blocks.add(block);
2550 workQueue.addAll(block.predecessors); 2491 workQueue.addAll(block.predecessors);
2551 } 2492 }
2552 } 2493 }
2553
2554 HBasicBlock getLastBackEdge() {
2555 int maxId = -1;
2556 HBasicBlock result = null;
2557 for (int i = 0, length = backEdges.length; i < length; i++) {
2558 HBasicBlock current = backEdges[i];
2559 if (current.id > maxId) {
2560 maxId = current.id;
2561 result = current;
2562 }
2563 }
2564 return result;
2565 }
2566 } 2494 }
2567 2495
2568 2496
2569 /** 2497 /**
2570 * Embedding of a [HBlockInformation] for block-structure based traversal 2498 * Embedding of a [HBlockInformation] for block-structure based traversal
2571 * in a dominator based flow traversal by attaching it to a basic block. 2499 * in a dominator based flow traversal by attaching it to a basic block.
2572 * To go back to dominator-based traversal, a [HSubGraphBlockInformation] 2500 * To go back to dominator-based traversal, a [HSubGraphBlockInformation]
2573 * structure can be added in the block structure. 2501 * structure can be added in the block structure.
2574 */ 2502 */
2575 class HBlockFlow { 2503 class HBlockFlow {
(...skipping 29 matching lines...) Expand all
2605 HInstruction get conditionExpression; 2533 HInstruction get conditionExpression;
2606 } 2534 }
2607 2535
2608 2536
2609 abstract class HStatementInformationVisitor { 2537 abstract class HStatementInformationVisitor {
2610 bool visitLabeledBlockInfo(HLabeledBlockInformation info); 2538 bool visitLabeledBlockInfo(HLabeledBlockInformation info);
2611 bool visitLoopInfo(HLoopBlockInformation info); 2539 bool visitLoopInfo(HLoopBlockInformation info);
2612 bool visitIfInfo(HIfBlockInformation info); 2540 bool visitIfInfo(HIfBlockInformation info);
2613 bool visitTryInfo(HTryBlockInformation info); 2541 bool visitTryInfo(HTryBlockInformation info);
2614 bool visitSwitchInfo(HSwitchBlockInformation info); 2542 bool visitSwitchInfo(HSwitchBlockInformation info);
2615 bool visitSequenceInfo(HStatementSequenceInformation info);
Johnni Winther 2013/12/03 11:52:31 Only remove this together with HStatementSequenceI
ahe 2013/12/04 11:45:43 Keeping these for now and I'll use it to implement
2616 // Pseudo-structure embedding a dominator-based traversal into 2543 // Pseudo-structure embedding a dominator-based traversal into
2617 // the block-structure traversal. This will eventually go away. 2544 // the block-structure traversal. This will eventually go away.
2618 bool visitSubGraphInfo(HSubGraphBlockInformation info); 2545 bool visitSubGraphInfo(HSubGraphBlockInformation info);
2619 } 2546 }
2620 2547
2621 2548
2622 abstract class HExpressionInformationVisitor { 2549 abstract class HExpressionInformationVisitor {
2623 bool visitAndOrInfo(HAndOrBlockInformation info);
Johnni Winther 2013/12/03 11:52:31 Only remove this together with HAndOrBlockInformat
2624 bool visitSubExpressionInfo(HSubExpressionBlockInformation info); 2550 bool visitSubExpressionInfo(HSubExpressionBlockInformation info);
2625 } 2551 }
2626 2552
2627 2553
2628 abstract class HBlockInformationVisitor 2554 abstract class HBlockInformationVisitor
2629 implements HStatementInformationVisitor, HExpressionInformationVisitor { 2555 implements HStatementInformationVisitor, HExpressionInformationVisitor {
2630 } 2556 }
2631 2557
2632 2558
2633 /** 2559 /**
2634 * Generic class wrapping a [SubGraph] as a block-information until 2560 * Generic class wrapping a [SubGraph] as a block-information until
2635 * all structures are handled properly. 2561 * all structures are handled properly.
2636 */ 2562 */
2637 class HSubGraphBlockInformation implements HStatementInformation { 2563 class HSubGraphBlockInformation implements HStatementInformation {
2638 final SubGraph subGraph; 2564 final SubGraph subGraph;
2639 HSubGraphBlockInformation(this.subGraph); 2565 HSubGraphBlockInformation(this.subGraph);
2640 2566
2641 HBasicBlock get start => subGraph.start; 2567 HBasicBlock get start => subGraph.start;
2642 HBasicBlock get end => subGraph.end; 2568 HBasicBlock get end => subGraph.end;
2643 2569
2644 bool accept(HStatementInformationVisitor visitor) => 2570 bool accept(HStatementInformationVisitor visitor) =>
2645 visitor.visitSubGraphInfo(this); 2571 visitor.visitSubGraphInfo(this);
2646 } 2572 }
2647 2573
2648
2649 /** 2574 /**
2650 * Generic class wrapping a [SubExpression] as a block-information until 2575 * Generic class wrapping a [SubExpression] as a block-information until
2651 * expressions structures are handled properly. 2576 * expressions structures are handled properly.
2652 */ 2577 */
2653 class HSubExpressionBlockInformation implements HExpressionInformation { 2578 class HSubExpressionBlockInformation implements HExpressionInformation {
2654 final SubExpression subExpression; 2579 final SubExpression subExpression;
2655 HSubExpressionBlockInformation(this.subExpression); 2580 HSubExpressionBlockInformation(this.subExpression);
2656 2581
2657 HBasicBlock get start => subExpression.start; 2582 HBasicBlock get start => subExpression.start;
2658 HBasicBlock get end => subExpression.end; 2583 HBasicBlock get end => subExpression.end;
2659 2584
2660 HInstruction get conditionExpression => subExpression.conditionExpression; 2585 HInstruction get conditionExpression => subExpression.conditionExpression;
2661 2586
2662 bool accept(HExpressionInformationVisitor visitor) => 2587 bool accept(HExpressionInformationVisitor visitor) =>
2663 visitor.visitSubExpressionInfo(this); 2588 visitor.visitSubExpressionInfo(this);
2664 } 2589 }
2665 2590
2666
2667 /** A sequence of separate statements. */ 2591 /** A sequence of separate statements. */
2668 class HStatementSequenceInformation implements HStatementInformation { 2592 class HStatementSequenceInformation implements HStatementInformation {
2669 final List<HStatementInformation> statements; 2593 final List<HStatementInformation> statements;
2670 HStatementSequenceInformation(this.statements); 2594 HStatementSequenceInformation(this.statements);
2671 2595
2672 HBasicBlock get start => statements[0].start; 2596 HBasicBlock get start => statements[0].start;
2673 HBasicBlock get end => statements.last.end; 2597 HBasicBlock get end => statements.last.end;
2674
2675 bool accept(HStatementInformationVisitor visitor) =>
Johnni Winther 2013/12/03 11:52:31 Needed if HStatementSequenceInformation is needed.
2676 visitor.visitSequenceInfo(this);
2677 } 2598 }
2678 2599
2679
2680 class HLabeledBlockInformation implements HStatementInformation { 2600 class HLabeledBlockInformation implements HStatementInformation {
2681 final HStatementInformation body; 2601 final HStatementInformation body;
2682 final List<LabelElement> labels; 2602 final List<LabelElement> labels;
2683 final TargetElement target; 2603 final TargetElement target;
2684 final bool isContinue; 2604 final bool isContinue;
2685 2605
2686 HLabeledBlockInformation(this.body, 2606 HLabeledBlockInformation(this.body,
2687 List<LabelElement> labels, 2607 List<LabelElement> labels,
2688 {this.isContinue: false}) : 2608 {this.isContinue: false}) :
2689 this.labels = labels, this.target = labels[0].target; 2609 this.labels = labels, this.target = labels[0].target;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2759 if (kind == DO_WHILE_LOOP && condition != null) { 2679 if (kind == DO_WHILE_LOOP && condition != null) {
2760 return condition.end; 2680 return condition.end;
2761 } 2681 }
2762 return body.end; 2682 return body.end;
2763 } 2683 }
2764 2684
2765 static int loopType(Node node) { 2685 static int loopType(Node node) {
2766 return node.accept(const LoopTypeVisitor()); 2686 return node.accept(const LoopTypeVisitor());
2767 } 2687 }
2768 2688
2769 bool isDoWhile() => kind == DO_WHILE_LOOP;
2770
2771 bool accept(HStatementInformationVisitor visitor) => 2689 bool accept(HStatementInformationVisitor visitor) =>
2772 visitor.visitLoopInfo(this); 2690 visitor.visitLoopInfo(this);
2773 } 2691 }
2774 2692
2775 class HIfBlockInformation implements HStatementInformation { 2693 class HIfBlockInformation implements HStatementInformation {
2776 final HExpressionInformation condition; 2694 final HExpressionInformation condition;
2777 final HStatementInformation thenGraph; 2695 final HStatementInformation thenGraph;
2778 final HStatementInformation elseGraph; 2696 final HStatementInformation elseGraph;
2779 HIfBlockInformation(this.condition, 2697 HIfBlockInformation(this.condition,
2780 this.thenGraph, 2698 this.thenGraph,
(...skipping 14 matching lines...) Expand all
2795 this.left, 2713 this.left,
2796 this.right); 2714 this.right);
2797 2715
2798 HBasicBlock get start => left.start; 2716 HBasicBlock get start => left.start;
2799 HBasicBlock get end => right.end; 2717 HBasicBlock get end => right.end;
2800 2718
2801 // We don't currently use HAndOrBlockInformation. 2719 // We don't currently use HAndOrBlockInformation.
2802 HInstruction get conditionExpression { 2720 HInstruction get conditionExpression {
2803 return null; 2721 return null;
2804 } 2722 }
2805 bool accept(HExpressionInformationVisitor visitor) =>
Johnni Winther 2013/12/03 11:52:31 Needed if HAndOrBlockInformation is needed.
2806 visitor.visitAndOrInfo(this);
2807 } 2723 }
2808 2724
2809 class HTryBlockInformation implements HStatementInformation { 2725 class HTryBlockInformation implements HStatementInformation {
2810 final HStatementInformation body; 2726 final HStatementInformation body;
2811 final HLocalValue catchVariable; 2727 final HLocalValue catchVariable;
2812 final HStatementInformation catchBlock; 2728 final HStatementInformation catchBlock;
2813 final HStatementInformation finallyBlock; 2729 final HStatementInformation finallyBlock;
2814 HTryBlockInformation(this.body, 2730 HTryBlockInformation(this.body,
2815 this.catchVariable, 2731 this.catchVariable,
2816 this.catchBlock, 2732 this.catchBlock,
(...skipping 23 matching lines...) Expand all
2840 HBasicBlock get start => expression.start; 2756 HBasicBlock get start => expression.start;
2841 HBasicBlock get end { 2757 HBasicBlock get end {
2842 // We don't create a switch block if there are no cases. 2758 // We don't create a switch block if there are no cases.
2843 assert(!statements.isEmpty); 2759 assert(!statements.isEmpty);
2844 return statements.last.end; 2760 return statements.last.end;
2845 } 2761 }
2846 2762
2847 bool accept(HStatementInformationVisitor visitor) => 2763 bool accept(HStatementInformationVisitor visitor) =>
2848 visitor.visitSwitchInfo(this); 2764 visitor.visitSwitchInfo(this);
2849 } 2765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698