| 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 final bool getter; | 1163 final bool getter; |
| 1164 | 1164 |
| 1165 HInvokeInterceptor(Selector selector, | 1165 HInvokeInterceptor(Selector selector, |
| 1166 SourceString this.name, | 1166 SourceString this.name, |
| 1167 bool this.getter, | 1167 bool this.getter, |
| 1168 List<HInstruction> inputs) | 1168 List<HInstruction> inputs) |
| 1169 : super(selector, inputs); | 1169 : super(selector, inputs); |
| 1170 toString() => 'invoke interceptor: ${element.name}'; | 1170 toString() => 'invoke interceptor: ${element.name}'; |
| 1171 accept(HVisitor visitor) => visitor.visitInvokeInterceptor(this); | 1171 accept(HVisitor visitor) => visitor.visitInvokeInterceptor(this); |
| 1172 | 1172 |
| 1173 | |
| 1174 String get builtinJsName() { | 1173 String get builtinJsName() { |
| 1175 if (getter | 1174 if (getter |
| 1176 && name == const SourceString('length') | 1175 && name == const SourceString('length') |
| 1177 && inputs[1].isStringOrArray()) { | 1176 && inputs[1].isStringOrArray()) { |
| 1178 return 'length'; | 1177 return 'length'; |
| 1179 } else if (name == const SourceString('add') && inputs[1].isArray()) { | 1178 } else if (name == const SourceString('add') && inputs[1].isArray()) { |
| 1180 return 'push'; | 1179 return 'push'; |
| 1181 } else if (name == const SourceString('removeLast') | 1180 } else if (name == const SourceString('removeLast') |
| 1182 && inputs[1].isArray()) { | 1181 && inputs[1].isArray()) { |
| 1183 return 'pop'; | 1182 return 'pop'; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 setUseGvn(); | 1306 setUseGvn(); |
| 1308 } else { | 1307 } else { |
| 1309 setAllSideEffects(); | 1308 setAllSideEffects(); |
| 1310 } | 1309 } |
| 1311 } | 1310 } |
| 1312 | 1311 |
| 1313 bool get builtin() => left.isNumber() && right.isNumber(); | 1312 bool get builtin() => left.isNumber() && right.isNumber(); |
| 1314 | 1313 |
| 1315 HType computeType() { | 1314 HType computeType() { |
| 1316 HType inputsType = computeInputsType(); | 1315 HType inputsType = computeInputsType(); |
| 1317 if (!inputsType.isUnknown()) return inputsType; | 1316 if (inputsType.isKnown()) return inputsType; |
| 1318 if (left.isNumber()) return HType.NUMBER; | 1317 if (left.isNumber()) return HType.NUMBER; |
| 1319 return HType.UNKNOWN; | 1318 return HType.UNKNOWN; |
| 1320 } | 1319 } |
| 1321 | 1320 |
| 1322 HType computeDesiredInputType(HInstruction input) { | 1321 HType computeDesiredInputType(HInstruction input) { |
| 1323 // TODO(floitsch): we want the target to be a function. | 1322 // TODO(floitsch): we want the target to be a function. |
| 1324 if (input == target) return HType.UNKNOWN; | 1323 if (input == target) return HType.UNKNOWN; |
| 1325 if (isNumber() || left.isNumber() || right.isNumber()) return HType.NUMBER; | 1324 if (isNumber() || left.isNumber() || right.isNumber()) return HType.NUMBER; |
| 1326 if (type.isUnknown()) return HType.NUMBER; | 1325 if (type.isUnknown()) return HType.NUMBER; |
| 1327 return HType.UNKNOWN; | 1326 return HType.UNKNOWN; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1339 | 1338 |
| 1340 bool get builtin() { | 1339 bool get builtin() { |
| 1341 return (left.isNumber() && right.isNumber()) | 1340 return (left.isNumber() && right.isNumber()) |
| 1342 || (left.isString() && right.isString()) | 1341 || (left.isString() && right.isString()) |
| 1343 || (left.isString() && right is HConstant); | 1342 || (left.isString() && right is HConstant); |
| 1344 } | 1343 } |
| 1345 | 1344 |
| 1346 HType computeType() { | 1345 HType computeType() { |
| 1347 HType computedType = computeInputsType(); | 1346 HType computedType = computeInputsType(); |
| 1348 if (computedType.isConflicting() && left.isString()) return HType.STRING; | 1347 if (computedType.isConflicting() && left.isString()) return HType.STRING; |
| 1349 if (!computedType.isUnknown()) return computedType; | 1348 if (computedType.isKnown()) return computedType; |
| 1350 if (left.isNumber()) return HType.NUMBER; | 1349 if (left.isNumber()) return HType.NUMBER; |
| 1351 return HType.UNKNOWN; | 1350 return HType.UNKNOWN; |
| 1352 } | 1351 } |
| 1353 | 1352 |
| 1354 bool hasExpectedType() => builtin || type.isUnknown() || left.isString(); | 1353 bool hasExpectedType() => builtin || type.isUnknown() || left.isString(); |
| 1355 | 1354 |
| 1356 HType computeDesiredInputType(HInstruction input) { | 1355 HType computeDesiredInputType(HInstruction input) { |
| 1357 // TODO(floitsch): we want the target to be a function. | 1356 // TODO(floitsch): we want the target to be a function. |
| 1358 if (input == target) return HType.UNKNOWN; | 1357 if (input == target) return HType.UNKNOWN; |
| 1359 if (isString() || left.isString()) { | 1358 if (isString() || left.isString()) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 // TODO(floitsch): Should HBinaryArithmetic really be the super class of | 1438 // TODO(floitsch): Should HBinaryArithmetic really be the super class of |
| 1440 // HBinaryBitOp? | 1439 // HBinaryBitOp? |
| 1441 class HBinaryBitOp extends HBinaryArithmetic { | 1440 class HBinaryBitOp extends HBinaryArithmetic { |
| 1442 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) | 1441 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) |
| 1443 : super(target, left, right); | 1442 : super(target, left, right); |
| 1444 | 1443 |
| 1445 bool get builtin() => left.isInteger() && right.isInteger(); | 1444 bool get builtin() => left.isInteger() && right.isInteger(); |
| 1446 | 1445 |
| 1447 HType computeType() { | 1446 HType computeType() { |
| 1448 HType inputsType = computeInputsType(); | 1447 HType inputsType = computeInputsType(); |
| 1449 if (!inputsType.isUnknown()) return inputsType; | 1448 if (inputsType.isKnown()) return inputsType; |
| 1450 if (left.isInteger()) return HType.INTEGER; | 1449 if (left.isInteger()) return HType.INTEGER; |
| 1451 return HType.UNKNOWN; | 1450 return HType.UNKNOWN; |
| 1452 } | 1451 } |
| 1453 | 1452 |
| 1454 HType computeDesiredInputType(HInstruction input) { | 1453 HType computeDesiredInputType(HInstruction input) { |
| 1455 // TODO(floitsch): we want the target to be a function. | 1454 // TODO(floitsch): we want the target to be a function. |
| 1456 if (input == target) return HType.UNKNOWN; | 1455 if (input == target) return HType.UNKNOWN; |
| 1457 return HType.INTEGER; | 1456 return HType.INTEGER; |
| 1458 } | 1457 } |
| 1459 | 1458 |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 class HIfBlockInformation { | 2057 class HIfBlockInformation { |
| 2059 final HIf branch; | 2058 final HIf branch; |
| 2060 final SubGraph thenGraph; | 2059 final SubGraph thenGraph; |
| 2061 final SubGraph elseGraph; | 2060 final SubGraph elseGraph; |
| 2062 final HBasicBlock joinBlock; | 2061 final HBasicBlock joinBlock; |
| 2063 HIfBlockInformation(this.branch, | 2062 HIfBlockInformation(this.branch, |
| 2064 this.thenGraph, | 2063 this.thenGraph, |
| 2065 this.elseGraph, | 2064 this.elseGraph, |
| 2066 this.joinBlock); | 2065 this.joinBlock); |
| 2067 } | 2066 } |
| OLD | NEW |