| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 if (logicalOperatorType == IS_AND) return "&&"; | 1892 if (logicalOperatorType == IS_AND) return "&&"; |
| 1893 assert(logicalOperatorType == IS_OR); | 1893 assert(logicalOperatorType == IS_OR); |
| 1894 return "||"; | 1894 return "||"; |
| 1895 } | 1895 } |
| 1896 | 1896 |
| 1897 toString() => 'phi'; | 1897 toString() => 'phi'; |
| 1898 accept(HVisitor visitor) => visitor.visitPhi(this); | 1898 accept(HVisitor visitor) => visitor.visitPhi(this); |
| 1899 } | 1899 } |
| 1900 | 1900 |
| 1901 class HRelational extends HInvokeBinary { | 1901 class HRelational extends HInvokeBinary { |
| 1902 bool usesBoolifiedInterceptor = false; |
| 1902 HRelational(HStatic target, HInstruction left, HInstruction right) | 1903 HRelational(HStatic target, HInstruction left, HInstruction right) |
| 1903 : super(target, left, right); | 1904 : super(target, left, right); |
| 1904 | 1905 |
| 1905 void prepareGvn() { | 1906 void prepareGvn() { |
| 1906 // Relational expressions can take part in global value numbering | 1907 // Relational expressions can take part in global value numbering |
| 1907 // and do not have any side-effects if we know all the inputs are | 1908 // and do not have any side-effects if we know all the inputs are |
| 1908 // numbers. This can be improved for at least equality. | 1909 // numbers. This can be improved for at least equality. |
| 1909 if (builtin) { | 1910 if (builtin) { |
| 1910 clearAllSideEffects(); | 1911 clearAllSideEffects(); |
| 1911 setUseGvn(); | 1912 setUseGvn(); |
| 1912 } else { | 1913 } else { |
| 1913 setAllSideEffects(); | 1914 setAllSideEffects(); |
| 1914 } | 1915 } |
| 1915 } | 1916 } |
| 1916 | 1917 |
| 1917 HType computeTypeFromInputTypes() { | 1918 HType computeTypeFromInputTypes() { |
| 1918 if (left.isNumber()) return HType.BOOLEAN; | 1919 if (left.isNumber() || usesBoolifiedInterceptor) return HType.BOOLEAN; |
| 1919 return HType.UNKNOWN; | 1920 return HType.UNKNOWN; |
| 1920 } | 1921 } |
| 1921 | 1922 |
| 1922 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1923 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1923 // For all relational operations exept HEquals, we expect to get numbers | 1924 // For all relational operations exept HEquals, we expect to get numbers |
| 1924 // only. With numbers the outgoing type is a boolean. If something else | 1925 // only. With numbers the outgoing type is a boolean. If something else |
| 1925 // is desired, then numbers are incorrect, though. | 1926 // is desired, then numbers are incorrect, though. |
| 1926 if (propagatedType.isUnknown() || propagatedType.isBoolean()) { | 1927 if (propagatedType.isUnknown() || propagatedType.isBoolean()) { |
| 1927 if (left.isTypeUnknown() || left.isNumber()) return HType.NUMBER; | 1928 if (left.isTypeUnknown() || left.isNumber()) return HType.NUMBER; |
| 1928 } | 1929 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1942 accept(HVisitor visitor) => visitor.visitEquals(this); | 1943 accept(HVisitor visitor) => visitor.visitEquals(this); |
| 1943 | 1944 |
| 1944 bool get builtin() { | 1945 bool get builtin() { |
| 1945 // All useful types have === semantics. | 1946 // All useful types have === semantics. |
| 1946 // Note that this includes all constants except the user-constructed | 1947 // Note that this includes all constants except the user-constructed |
| 1947 // objects. | 1948 // objects. |
| 1948 return left.isConstantNull() || left.propagatedType.isUseful(); | 1949 return left.isConstantNull() || left.propagatedType.isUseful(); |
| 1949 } | 1950 } |
| 1950 | 1951 |
| 1951 HType computeTypeFromInputTypes() { | 1952 HType computeTypeFromInputTypes() { |
| 1952 if (builtin) return HType.BOOLEAN; | 1953 if (builtin || usesBoolifiedInterceptor) return HType.BOOLEAN; |
| 1953 return HType.UNKNOWN; | 1954 return HType.UNKNOWN; |
| 1954 } | 1955 } |
| 1955 | 1956 |
| 1956 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1957 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1957 if (input == left && right.propagatedType.isUseful()) { | 1958 if (input == left && right.propagatedType.isUseful()) { |
| 1958 // All our useful types have === semantics. But we don't want to | 1959 // All our useful types have === semantics. But we don't want to |
| 1959 // speculatively test for all possible types. Therefore we try to match | 1960 // speculatively test for all possible types. Therefore we try to match |
| 1960 // the two types. That is, if we see x == 3, then we speculatively test | 1961 // the two types. That is, if we see x == 3, then we speculatively test |
| 1961 // if x is a number and bailout if it isn't. | 1962 // if x is a number and bailout if it isn't. |
| 1962 if (right.isNumber()) return HType.NUMBER; // No need to be more precise. | 1963 if (right.isNumber()) return HType.NUMBER; // No need to be more precise. |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 final bool isAnd; | 2305 final bool isAnd; |
| 2305 final SubExpression left; | 2306 final SubExpression left; |
| 2306 final SubExpression right; | 2307 final SubExpression right; |
| 2307 final HBasicBlock joinBlock; | 2308 final HBasicBlock joinBlock; |
| 2308 HAndOrBlockInformation(this.isAnd, | 2309 HAndOrBlockInformation(this.isAnd, |
| 2309 this.left, | 2310 this.left, |
| 2310 this.right, | 2311 this.right, |
| 2311 this.joinBlock); | 2312 this.joinBlock); |
| 2312 bool accept(HBlockInformationVisitor visitor) => visitor.visitAndOrInfo(this); | 2313 bool accept(HBlockInformationVisitor visitor) => visitor.visitAndOrInfo(this); |
| 2313 } | 2314 } |
| OLD | NEW |