| 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBailoutTarget(HBailoutTarget node); | 7 R visitBailoutTarget(HBailoutTarget node); |
| 8 R visitBitAnd(HBitAnd node); | 8 R visitBitAnd(HBitAnd node); |
| 9 R visitBitNot(HBitNot node); | 9 R visitBitNot(HBitNot node); |
| 10 R visitBitOr(HBitOr node); | 10 R visitBitOr(HBitOr node); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 return false; | 426 return false; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 class HBasicBlock extends HInstructionList implements Hashable { | 430 class HBasicBlock extends HInstructionList implements Hashable { |
| 431 // The [id] must be such that any successor's id is greater than | 431 // The [id] must be such that any successor's id is greater than |
| 432 // this [id]. The exception are back-edges. | 432 // this [id]. The exception are back-edges. |
| 433 int id; | 433 int id; |
| 434 | 434 |
| 435 static final int STATUS_NEW = 0; | 435 static const int STATUS_NEW = 0; |
| 436 static final int STATUS_OPEN = 1; | 436 static const int STATUS_OPEN = 1; |
| 437 static final int STATUS_CLOSED = 2; | 437 static const int STATUS_CLOSED = 2; |
| 438 int status = STATUS_NEW; | 438 int status = STATUS_NEW; |
| 439 | 439 |
| 440 HInstructionList phis; | 440 HInstructionList phis; |
| 441 | 441 |
| 442 HLoopInformation loopInformation = null; | 442 HLoopInformation loopInformation = null; |
| 443 HBlockFlow blockFlow = null; | 443 HBlockFlow blockFlow = null; |
| 444 HBasicBlock parentLoopHeader = null; | 444 HBasicBlock parentLoopHeader = null; |
| 445 List<HBailoutTarget> bailoutTargets; | 445 List<HBailoutTarget> bailoutTargets; |
| 446 | 446 |
| 447 final List<HBasicBlock> predecessors; | 447 final List<HBasicBlock> predecessors; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 743 |
| 744 final List<HInstruction> inputs; | 744 final List<HInstruction> inputs; |
| 745 final List<HInstruction> usedBy; | 745 final List<HInstruction> usedBy; |
| 746 | 746 |
| 747 HBasicBlock block; | 747 HBasicBlock block; |
| 748 HInstruction previous = null; | 748 HInstruction previous = null; |
| 749 HInstruction next = null; | 749 HInstruction next = null; |
| 750 int flags = 0; | 750 int flags = 0; |
| 751 | 751 |
| 752 // Changes flags. | 752 // Changes flags. |
| 753 static final int FLAG_CHANGES_SOMETHING = 0; | 753 static const int FLAG_CHANGES_SOMETHING = 0; |
| 754 static final int FLAG_CHANGES_COUNT = FLAG_CHANGES_SOMETHING + 1; | 754 static const int FLAG_CHANGES_COUNT = FLAG_CHANGES_SOMETHING + 1; |
| 755 | 755 |
| 756 // Depends flags (one for each changes flag). | 756 // Depends flags (one for each changes flag). |
| 757 static final int FLAG_DEPENDS_ON_SOMETHING = FLAG_CHANGES_COUNT; | 757 static const int FLAG_DEPENDS_ON_SOMETHING = FLAG_CHANGES_COUNT; |
| 758 | 758 |
| 759 // Other flags. | 759 // Other flags. |
| 760 static final int FLAG_USE_GVN = FLAG_DEPENDS_ON_SOMETHING + 1; | 760 static const int FLAG_USE_GVN = FLAG_DEPENDS_ON_SOMETHING + 1; |
| 761 | 761 |
| 762 // Type codes. | 762 // Type codes. |
| 763 static final int UNDEFINED_TYPECODE = -1; | 763 static const int UNDEFINED_TYPECODE = -1; |
| 764 static final int BOOLIFY_TYPECODE = 0; | 764 static const int BOOLIFY_TYPECODE = 0; |
| 765 static final int TYPE_GUARD_TYPECODE = 1; | 765 static const int TYPE_GUARD_TYPECODE = 1; |
| 766 static final int BOUNDS_CHECK_TYPECODE = 2; | 766 static const int BOUNDS_CHECK_TYPECODE = 2; |
| 767 static final int INTEGER_CHECK_TYPECODE = 3; | 767 static const int INTEGER_CHECK_TYPECODE = 3; |
| 768 static final int INVOKE_INTERCEPTOR_TYPECODE = 4; | 768 static const int INVOKE_INTERCEPTOR_TYPECODE = 4; |
| 769 static final int ADD_TYPECODE = 5; | 769 static const int ADD_TYPECODE = 5; |
| 770 static final int DIVIDE_TYPECODE = 6; | 770 static const int DIVIDE_TYPECODE = 6; |
| 771 static final int MODULO_TYPECODE = 7; | 771 static const int MODULO_TYPECODE = 7; |
| 772 static final int MULTIPLY_TYPECODE = 8; | 772 static const int MULTIPLY_TYPECODE = 8; |
| 773 static final int SUBTRACT_TYPECODE = 9; | 773 static const int SUBTRACT_TYPECODE = 9; |
| 774 static final int TRUNCATING_DIVIDE_TYPECODE = 10; | 774 static const int TRUNCATING_DIVIDE_TYPECODE = 10; |
| 775 static final int SHIFT_LEFT_TYPECODE = 11; | 775 static const int SHIFT_LEFT_TYPECODE = 11; |
| 776 static final int SHIFT_RIGHT_TYPECODE = 12; | 776 static const int SHIFT_RIGHT_TYPECODE = 12; |
| 777 static final int BIT_OR_TYPECODE = 13; | 777 static const int BIT_OR_TYPECODE = 13; |
| 778 static final int BIT_AND_TYPECODE = 14; | 778 static const int BIT_AND_TYPECODE = 14; |
| 779 static final int BIT_XOR_TYPECODE = 15; | 779 static const int BIT_XOR_TYPECODE = 15; |
| 780 static final int NEGATE_TYPECODE = 16; | 780 static const int NEGATE_TYPECODE = 16; |
| 781 static final int BIT_NOT_TYPECODE = 17; | 781 static const int BIT_NOT_TYPECODE = 17; |
| 782 static final int NOT_TYPECODE = 18; | 782 static const int NOT_TYPECODE = 18; |
| 783 static final int EQUALS_TYPECODE = 19; | 783 static const int EQUALS_TYPECODE = 19; |
| 784 static final int IDENTITY_TYPECODE = 20; | 784 static const int IDENTITY_TYPECODE = 20; |
| 785 static final int GREATER_TYPECODE = 21; | 785 static const int GREATER_TYPECODE = 21; |
| 786 static final int GREATER_EQUAL_TYPECODE = 22; | 786 static const int GREATER_EQUAL_TYPECODE = 22; |
| 787 static final int LESS_TYPECODE = 23; | 787 static const int LESS_TYPECODE = 23; |
| 788 static final int LESS_EQUAL_TYPECODE = 24; | 788 static const int LESS_EQUAL_TYPECODE = 24; |
| 789 static final int STATIC_TYPECODE = 25; | 789 static const int STATIC_TYPECODE = 25; |
| 790 static final int STATIC_STORE_TYPECODE = 26; | 790 static const int STATIC_STORE_TYPECODE = 26; |
| 791 static final int FIELD_GET_TYPECODE = 27; | 791 static const int FIELD_GET_TYPECODE = 27; |
| 792 static final int TYPE_CONVERSION_TYPECODE = 28; | 792 static const int TYPE_CONVERSION_TYPECODE = 28; |
| 793 static final int BAILOUT_TARGET_TYPECODE = 29; | 793 static const int BAILOUT_TARGET_TYPECODE = 29; |
| 794 static final int INVOKE_STATIC_TYPECODE = 30; | 794 static const int INVOKE_STATIC_TYPECODE = 30; |
| 795 | 795 |
| 796 HInstruction(this.inputs) | 796 HInstruction(this.inputs) |
| 797 : id = idCounter++, | 797 : id = idCounter++, |
| 798 usedBy = <HInstruction>[]; | 798 usedBy = <HInstruction>[]; |
| 799 | 799 |
| 800 int hashCode() => id; | 800 int hashCode() => id; |
| 801 | 801 |
| 802 bool getFlag(int position) => (flags & (1 << position)) != 0; | 802 bool getFlag(int position) => (flags & (1 << position)) != 0; |
| 803 void setFlag(int position) { flags |= (1 << position); } | 803 void setFlag(int position) { flags |= (1 << position); } |
| 804 void clearFlag(int position) { flags &= ~(1 << position); } | 804 void clearFlag(int position) { flags &= ~(1 << position); } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 | 1153 |
| 1154 bool isStatement(HTypeMap types) => isEnabled; | 1154 bool isStatement(HTypeMap types) => isEnabled; |
| 1155 | 1155 |
| 1156 accept(HVisitor visitor) => visitor.visitTypeGuard(this); | 1156 accept(HVisitor visitor) => visitor.visitTypeGuard(this); |
| 1157 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; | 1157 int typeCode() => HInstruction.TYPE_GUARD_TYPECODE; |
| 1158 bool typeEquals(other) => other is HTypeGuard; | 1158 bool typeEquals(other) => other is HTypeGuard; |
| 1159 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; | 1159 bool dataEquals(HTypeGuard other) => guardedType == other.guardedType; |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 class HBoundsCheck extends HCheck { | 1162 class HBoundsCheck extends HCheck { |
| 1163 static final int ALWAYS_FALSE = 0; | 1163 static const int ALWAYS_FALSE = 0; |
| 1164 static final int FULL_CHECK = 1; | 1164 static const int FULL_CHECK = 1; |
| 1165 static final int ALWAYS_ABOVE_ZERO = 2; | 1165 static const int ALWAYS_ABOVE_ZERO = 2; |
| 1166 static final int ALWAYS_TRUE = 3; | 1166 static const int ALWAYS_TRUE = 3; |
| 1167 /** | 1167 /** |
| 1168 * Details which tests have been done statically during compilation. | 1168 * Details which tests have been done statically during compilation. |
| 1169 * Default is that all checks must be performed dynamically. | 1169 * Default is that all checks must be performed dynamically. |
| 1170 */ | 1170 */ |
| 1171 int staticChecks = FULL_CHECK; | 1171 int staticChecks = FULL_CHECK; |
| 1172 | 1172 |
| 1173 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); | 1173 HBoundsCheck(length, index) : super(<HInstruction>[length, index]); |
| 1174 | 1174 |
| 1175 HInstruction get length => inputs[1]; | 1175 HInstruction get length => inputs[1]; |
| 1176 HInstruction get index => inputs[0]; | 1176 HInstruction get index => inputs[0]; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 bool isStatement(HTypeMap types) => true; | 1226 bool isStatement(HTypeMap types) => true; |
| 1227 } | 1227 } |
| 1228 | 1228 |
| 1229 class HInvoke extends HInstruction { | 1229 class HInvoke extends HInstruction { |
| 1230 /** | 1230 /** |
| 1231 * The first argument must be the target: either an [HStatic] node, or | 1231 * The first argument must be the target: either an [HStatic] node, or |
| 1232 * the receiver of a method-call. The remaining inputs are the arguments | 1232 * the receiver of a method-call. The remaining inputs are the arguments |
| 1233 * to the invocation. | 1233 * to the invocation. |
| 1234 */ | 1234 */ |
| 1235 HInvoke(List<HInstruction> inputs) : super(inputs); | 1235 HInvoke(List<HInstruction> inputs) : super(inputs); |
| 1236 static final int ARGUMENTS_OFFSET = 1; | 1236 static const int ARGUMENTS_OFFSET = 1; |
| 1237 | 1237 |
| 1238 // TODO(floitsch): make class abstract instead of adding an abstract method. | 1238 // TODO(floitsch): make class abstract instead of adding an abstract method. |
| 1239 abstract accept(HVisitor visitor); | 1239 abstract accept(HVisitor visitor); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 class HInvokeDynamic extends HInvoke { | 1242 class HInvokeDynamic extends HInvoke { |
| 1243 final Selector selector; | 1243 final Selector selector; |
| 1244 Element element; | 1244 Element element; |
| 1245 | 1245 |
| 1246 HInvokeDynamic(this.selector, this.element, List<HInstruction> inputs) | 1246 HInvokeDynamic(this.selector, this.element, List<HInstruction> inputs) |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 | 1921 |
| 1922 HBasicBlock get elseBlock { | 1922 HBasicBlock get elseBlock { |
| 1923 assert(block.dominatedBlocks[1] === block.successors[1]); | 1923 assert(block.dominatedBlocks[1] === block.successors[1]); |
| 1924 return block.successors[1]; | 1924 return block.successors[1]; |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 HBasicBlock get joinBlock => blockInformation.continuation; | 1927 HBasicBlock get joinBlock => blockInformation.continuation; |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 class HLoopBranch extends HConditionalBranch { | 1930 class HLoopBranch extends HConditionalBranch { |
| 1931 static final int CONDITION_FIRST_LOOP = 0; | 1931 static const int CONDITION_FIRST_LOOP = 0; |
| 1932 static final int DO_WHILE_LOOP = 1; | 1932 static const int DO_WHILE_LOOP = 1; |
| 1933 | 1933 |
| 1934 final int kind; | 1934 final int kind; |
| 1935 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) | 1935 HLoopBranch(HInstruction condition, [this.kind = CONDITION_FIRST_LOOP]) |
| 1936 : super(<HInstruction>[condition]); | 1936 : super(<HInstruction>[condition]); |
| 1937 toString() => 'loop-branch'; | 1937 toString() => 'loop-branch'; |
| 1938 accept(HVisitor visitor) => visitor.visitLoopBranch(this); | 1938 accept(HVisitor visitor) => visitor.visitLoopBranch(this); |
| 1939 | 1939 |
| 1940 bool isDoWhile() { | 1940 bool isDoWhile() { |
| 1941 return kind === DO_WHILE_LOOP; | 1941 return kind === DO_WHILE_LOOP; |
| 1942 } | 1942 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 | 2019 |
| 2020 class HThis extends HParameterValue { | 2020 class HThis extends HParameterValue { |
| 2021 HThis([HType type = HType.UNKNOWN]) : super(null) { | 2021 HThis([HType type = HType.UNKNOWN]) : super(null) { |
| 2022 guaranteedType = type; | 2022 guaranteedType = type; |
| 2023 } | 2023 } |
| 2024 toString() => 'this'; | 2024 toString() => 'this'; |
| 2025 accept(HVisitor visitor) => visitor.visitThis(this); | 2025 accept(HVisitor visitor) => visitor.visitThis(this); |
| 2026 } | 2026 } |
| 2027 | 2027 |
| 2028 class HPhi extends HInstruction { | 2028 class HPhi extends HInstruction { |
| 2029 static final IS_NOT_LOGICAL_OPERATOR = 0; | 2029 static const IS_NOT_LOGICAL_OPERATOR = 0; |
| 2030 static final IS_AND = 1; | 2030 static const IS_AND = 1; |
| 2031 static final IS_OR = 2; | 2031 static const IS_OR = 2; |
| 2032 | 2032 |
| 2033 int logicalOperatorType = IS_NOT_LOGICAL_OPERATOR; | 2033 int logicalOperatorType = IS_NOT_LOGICAL_OPERATOR; |
| 2034 | 2034 |
| 2035 // The order of the [inputs] must correspond to the order of the | 2035 // The order of the [inputs] must correspond to the order of the |
| 2036 // predecessor-edges. That is if an input comes from the first predecessor | 2036 // predecessor-edges. That is if an input comes from the first predecessor |
| 2037 // of the surrounding block, then the input must be the first in the [HPhi]. | 2037 // of the surrounding block, then the input must be the first in the [HPhi]. |
| 2038 HPhi(Element element, List<HInstruction> inputs) : super(inputs) { | 2038 HPhi(Element element, List<HInstruction> inputs) : super(inputs) { |
| 2039 sourceElement = element; | 2039 sourceElement = element; |
| 2040 } | 2040 } |
| 2041 HPhi.noInputs(Element element) : this(element, <HInstruction>[]); | 2041 HPhi.noInputs(Element element) : this(element, <HInstruction>[]); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 | 2420 |
| 2421 accept(HVisitor visitor) => visitor.visitIs(this); | 2421 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2422 | 2422 |
| 2423 toString() => "$expression is $typeExpression"; | 2423 toString() => "$expression is $typeExpression"; |
| 2424 } | 2424 } |
| 2425 | 2425 |
| 2426 class HTypeConversion extends HCheck { | 2426 class HTypeConversion extends HCheck { |
| 2427 HType type; | 2427 HType type; |
| 2428 final int kind; | 2428 final int kind; |
| 2429 | 2429 |
| 2430 static final int NO_CHECK = 0; | 2430 static const int NO_CHECK = 0; |
| 2431 static final int CHECKED_MODE_CHECK = 1; | 2431 static const int CHECKED_MODE_CHECK = 1; |
| 2432 static final int ARGUMENT_TYPE_CHECK = 2; | 2432 static const int ARGUMENT_TYPE_CHECK = 2; |
| 2433 static final int CAST_TYPE_CHECK = 3; | 2433 static const int CAST_TYPE_CHECK = 3; |
| 2434 | 2434 |
| 2435 HTypeConversion(this.type, HInstruction input, [this.kind = NO_CHECK]) | 2435 HTypeConversion(this.type, HInstruction input, [this.kind = NO_CHECK]) |
| 2436 : super(<HInstruction>[input]) { | 2436 : super(<HInstruction>[input]) { |
| 2437 sourceElement = input.sourceElement; | 2437 sourceElement = input.sourceElement; |
| 2438 } | 2438 } |
| 2439 HTypeConversion.checkedModeCheck(HType type, HInstruction input) | 2439 HTypeConversion.checkedModeCheck(HType type, HInstruction input) |
| 2440 : this(type, input, CHECKED_MODE_CHECK); | 2440 : this(type, input, CHECKED_MODE_CHECK); |
| 2441 HTypeConversion.argumentTypeCheck(HType type, HInstruction input) | 2441 HTypeConversion.argumentTypeCheck(HType type, HInstruction input) |
| 2442 : this(type, input, ARGUMENT_TYPE_CHECK); | 2442 : this(type, input, ARGUMENT_TYPE_CHECK); |
| 2443 HTypeConversion.castCheck(HType type, HInstruction input) | 2443 HTypeConversion.castCheck(HType type, HInstruction input) |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 class LoopTypeVisitor extends AbstractVisitor { | 2666 class LoopTypeVisitor extends AbstractVisitor { |
| 2667 const LoopTypeVisitor(); | 2667 const LoopTypeVisitor(); |
| 2668 int visitNode(Node node) => HLoopBlockInformation.NOT_A_LOOP; | 2668 int visitNode(Node node) => HLoopBlockInformation.NOT_A_LOOP; |
| 2669 int visitWhile(While node) => HLoopBlockInformation.WHILE_LOOP; | 2669 int visitWhile(While node) => HLoopBlockInformation.WHILE_LOOP; |
| 2670 int visitFor(For node) => HLoopBlockInformation.FOR_LOOP; | 2670 int visitFor(For node) => HLoopBlockInformation.FOR_LOOP; |
| 2671 int visitDoWhile(DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 2671 int visitDoWhile(DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
| 2672 int visitForIn(ForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 2672 int visitForIn(ForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 2673 } | 2673 } |
| 2674 | 2674 |
| 2675 class HLoopBlockInformation implements HStatementInformation { | 2675 class HLoopBlockInformation implements HStatementInformation { |
| 2676 static final int WHILE_LOOP = 0; | 2676 static const int WHILE_LOOP = 0; |
| 2677 static final int FOR_LOOP = 1; | 2677 static const int FOR_LOOP = 1; |
| 2678 static final int DO_WHILE_LOOP = 2; | 2678 static const int DO_WHILE_LOOP = 2; |
| 2679 static final int FOR_IN_LOOP = 3; | 2679 static const int FOR_IN_LOOP = 3; |
| 2680 static final int NOT_A_LOOP = -1; | 2680 static const int NOT_A_LOOP = -1; |
| 2681 | 2681 |
| 2682 final int kind; | 2682 final int kind; |
| 2683 final HExpressionInformation initializer; | 2683 final HExpressionInformation initializer; |
| 2684 final HExpressionInformation condition; | 2684 final HExpressionInformation condition; |
| 2685 final HStatementInformation body; | 2685 final HStatementInformation body; |
| 2686 final HExpressionInformation updates; | 2686 final HExpressionInformation updates; |
| 2687 final TargetElement target; | 2687 final TargetElement target; |
| 2688 final List<LabelElement> labels; | 2688 final List<LabelElement> labels; |
| 2689 final Node sourcePosition; | 2689 final Node sourcePosition; |
| 2690 | 2690 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 HBasicBlock get start => expression.start; | 2799 HBasicBlock get start => expression.start; |
| 2800 HBasicBlock get end { | 2800 HBasicBlock get end { |
| 2801 // We don't create a switch block if there are no cases. | 2801 // We don't create a switch block if there are no cases. |
| 2802 assert(!statements.isEmpty()); | 2802 assert(!statements.isEmpty()); |
| 2803 return statements.last().end; | 2803 return statements.last().end; |
| 2804 } | 2804 } |
| 2805 | 2805 |
| 2806 bool accept(HStatementInformationVisitor visitor) => | 2806 bool accept(HStatementInformationVisitor visitor) => |
| 2807 visitor.visitSwitchInfo(this); | 2807 visitor.visitSwitchInfo(this); |
| 2808 } | 2808 } |
| OLD | NEW |