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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 : id = idCounter++, usedBy = <HInstruction>[] { | 809 : id = idCounter++, usedBy = <HInstruction>[] { |
810 assert(inputs.every((e) => e != null)); | 810 assert(inputs.every((e) => e != null)); |
811 } | 811 } |
812 | 812 |
813 int get hashCode => id; | 813 int get hashCode => id; |
814 | 814 |
815 bool useGvn() => _useGvn; | 815 bool useGvn() => _useGvn; |
816 void setUseGvn() { _useGvn = true; } | 816 void setUseGvn() { _useGvn = true; } |
817 void clearUseGvn() { _useGvn = false; } | 817 void clearUseGvn() { _useGvn = false; } |
818 | 818 |
819 bool get isMovable => useGvn(); | |
820 | |
819 /** | 821 /** |
820 * A pure instruction is an instruction that does not have any side | 822 * A pure instruction is an instruction that does not have any side |
821 * effect, nor any dependency. They can be moved anywhere in the | 823 * effect, nor any dependency. They can be moved anywhere in the |
822 * graph. | 824 * graph. |
823 */ | 825 */ |
824 bool isPure() { | 826 bool isPure() { |
825 return !sideEffects.hasSideEffects() | 827 return !sideEffects.hasSideEffects() |
826 && !sideEffects.dependsOnSomething() | 828 && !sideEffects.dependsOnSomething() |
827 && !canThrow(); | 829 && !canThrow(); |
828 } | 830 } |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2464 bool dataEquals(HTypeConversion other) { | 2466 bool dataEquals(HTypeConversion other) { |
2465 return kind == other.kind | 2467 return kind == other.kind |
2466 && typeExpression == other.typeExpression | 2468 && typeExpression == other.typeExpression |
2467 && checkedType == other.checkedType; | 2469 && checkedType == other.checkedType; |
2468 } | 2470 } |
2469 } | 2471 } |
2470 | 2472 |
2471 /// The [HTypeKnown] instruction marks a value with a refined type. | 2473 /// The [HTypeKnown] instruction marks a value with a refined type. |
2472 class HTypeKnown extends HCheck { | 2474 class HTypeKnown extends HCheck { |
2473 TypeMask knownType; | 2475 TypeMask knownType; |
2474 HTypeKnown(TypeMask knownType, HInstruction input) | 2476 bool _isMovable; |
2477 | |
2478 HTypeKnown.pinned(TypeMask knownType, HInstruction input) | |
2475 : this.knownType = knownType, | 2479 : this.knownType = knownType, |
2480 this._isMovable = false, | |
2476 super(<HInstruction>[input], knownType); | 2481 super(<HInstruction>[input], knownType); |
2482 | |
2483 HTypeKnown.witnessed(TypeMask knownType, HInstruction input, | |
2484 HInstruction witness) | |
floitsch
2014/03/20 16:07:25
nit: I prefer aligning with the first argument.
herhut
2014/03/20 16:25:11
Done.
| |
2485 : this.knownType = knownType, | |
2486 this._isMovable = true, | |
2487 super(<HInstruction>[input, witness], knownType); | |
2488 | |
2477 toString() => 'TypeKnown $knownType'; | 2489 toString() => 'TypeKnown $knownType'; |
2478 accept(HVisitor visitor) => visitor.visitTypeKnown(this); | 2490 accept(HVisitor visitor) => visitor.visitTypeKnown(this); |
2479 | 2491 |
2480 bool isJsStatement() => false; | 2492 bool isJsStatement() => false; |
2481 bool isControlFlow() => false; | 2493 bool isControlFlow() => false; |
2482 bool canThrow() => false; | 2494 bool canThrow() => false; |
2483 | 2495 |
2484 int typeCode() => HInstruction.TYPE_KNOWN_TYPECODE; | 2496 int typeCode() => HInstruction.TYPE_KNOWN_TYPECODE; |
2485 bool typeEquals(HInstruction other) => other is HTypeKnown; | 2497 bool typeEquals(HInstruction other) => other is HTypeKnown; |
2486 bool isCodeMotionInvariant() => true; | 2498 bool isCodeMotionInvariant() => true; |
2499 bool get isMovable => _isMovable && useGvn(); | |
2487 | 2500 |
2488 bool dataEquals(HTypeKnown other) { | 2501 bool dataEquals(HTypeKnown other) { |
2489 return knownType == other.knownType | 2502 return knownType == other.knownType |
2490 && instructionType == other.instructionType; | 2503 && instructionType == other.instructionType; |
2491 } | 2504 } |
2492 } | 2505 } |
2493 | 2506 |
2494 class HRangeConversion extends HCheck { | 2507 class HRangeConversion extends HCheck { |
2495 HRangeConversion(HInstruction input, type) | 2508 HRangeConversion(HInstruction input, type) |
2496 : super(<HInstruction>[input], type) { | 2509 : super(<HInstruction>[input], type) { |
2497 sourceElement = input.sourceElement; | 2510 sourceElement = input.sourceElement; |
2498 } | 2511 } |
2512 | |
2513 bool get isMovable => false; | |
2514 | |
2499 accept(HVisitor visitor) => visitor.visitRangeConversion(this); | 2515 accept(HVisitor visitor) => visitor.visitRangeConversion(this); |
2500 } | 2516 } |
2501 | 2517 |
2502 class HStringConcat extends HInstruction { | 2518 class HStringConcat extends HInstruction { |
2503 final ast.Node node; | 2519 final ast.Node node; |
2504 HStringConcat(HInstruction left, HInstruction right, this.node, TypeMask type) | 2520 HStringConcat(HInstruction left, HInstruction right, this.node, TypeMask type) |
2505 : super(<HInstruction>[left, right], type) { | 2521 : super(<HInstruction>[left, right], type) { |
2506 // TODO(sra): Until Issue 9293 is fixed, this false dependency keeps the | 2522 // TODO(sra): Until Issue 9293 is fixed, this false dependency keeps the |
2507 // concats bunched with stringified inputs for much better looking code with | 2523 // concats bunched with stringified inputs for much better looking code with |
2508 // fewer temps. | 2524 // fewer temps. |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2949 class HDynamicType extends HRuntimeType { | 2965 class HDynamicType extends HRuntimeType { |
2950 HDynamicType(DynamicType dartType, TypeMask instructionType) | 2966 HDynamicType(DynamicType dartType, TypeMask instructionType) |
2951 : super(const <HInstruction>[], dartType, instructionType); | 2967 : super(const <HInstruction>[], dartType, instructionType); |
2952 | 2968 |
2953 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 2969 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
2954 | 2970 |
2955 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 2971 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
2956 | 2972 |
2957 bool typeEquals(HInstruction other) => other is HDynamicType; | 2973 bool typeEquals(HInstruction other) => other is HDynamicType; |
2958 } | 2974 } |
OLD | NEW |