| 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 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 5 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 6 import '../common/names.dart' show Selectors; | 6 import '../common/names.dart' show Selectors; |
| 7 import '../common/tasks.dart' show CompilerTask; | 7 import '../common/tasks.dart' show CompilerTask; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 741 } |
| 742 | 742 |
| 743 if (type.isObject || type.treatAsDynamic) { | 743 if (type.isObject || type.treatAsDynamic) { |
| 744 return graph.addConstantBool(true, closedWorld); | 744 return graph.addConstantBool(true, closedWorld); |
| 745 } | 745 } |
| 746 | 746 |
| 747 HInstruction expression = node.expression; | 747 HInstruction expression = node.expression; |
| 748 if (expression.isInteger(closedWorld)) { | 748 if (expression.isInteger(closedWorld)) { |
| 749 if (element == commonElements.intClass || | 749 if (element == commonElements.intClass || |
| 750 element == commonElements.numClass || | 750 element == commonElements.numClass || |
| 751 Elements.isNumberOrStringSupertype(element, commonElements)) { | 751 commonElements.isNumberOrStringSupertype(element)) { |
| 752 return graph.addConstantBool(true, closedWorld); | 752 return graph.addConstantBool(true, closedWorld); |
| 753 } else if (element == commonElements.doubleClass) { | 753 } else if (element == commonElements.doubleClass) { |
| 754 // We let the JS semantics decide for that check. Currently | 754 // We let the JS semantics decide for that check. Currently |
| 755 // the code we emit will always return true. | 755 // the code we emit will always return true. |
| 756 return node; | 756 return node; |
| 757 } else { | 757 } else { |
| 758 return graph.addConstantBool(false, closedWorld); | 758 return graph.addConstantBool(false, closedWorld); |
| 759 } | 759 } |
| 760 } else if (expression.isDouble(closedWorld)) { | 760 } else if (expression.isDouble(closedWorld)) { |
| 761 if (element == commonElements.doubleClass || | 761 if (element == commonElements.doubleClass || |
| 762 element == commonElements.numClass || | 762 element == commonElements.numClass || |
| 763 Elements.isNumberOrStringSupertype(element, commonElements)) { | 763 commonElements.isNumberOrStringSupertype(element)) { |
| 764 return graph.addConstantBool(true, closedWorld); | 764 return graph.addConstantBool(true, closedWorld); |
| 765 } else if (element == commonElements.intClass) { | 765 } else if (element == commonElements.intClass) { |
| 766 // We let the JS semantics decide for that check. Currently | 766 // We let the JS semantics decide for that check. Currently |
| 767 // the code we emit will return true for a double that can be | 767 // the code we emit will return true for a double that can be |
| 768 // represented as a 31-bit integer and for -0.0. | 768 // represented as a 31-bit integer and for -0.0. |
| 769 return node; | 769 return node; |
| 770 } else { | 770 } else { |
| 771 return graph.addConstantBool(false, closedWorld); | 771 return graph.addConstantBool(false, closedWorld); |
| 772 } | 772 } |
| 773 } else if (expression.isNumber(closedWorld)) { | 773 } else if (expression.isNumber(closedWorld)) { |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2299 void visitFieldSet(HFieldSet instruction) { | 2299 void visitFieldSet(HFieldSet instruction) { |
| 2300 HInstruction receiver = instruction.getDartReceiver(closedWorld).nonCheck(); | 2300 HInstruction receiver = instruction.getDartReceiver(closedWorld).nonCheck(); |
| 2301 memorySet.registerFieldValueUpdate( | 2301 memorySet.registerFieldValueUpdate( |
| 2302 instruction.element, receiver, instruction.inputs.last); | 2302 instruction.element, receiver, instruction.inputs.last); |
| 2303 } | 2303 } |
| 2304 | 2304 |
| 2305 void visitCreate(HCreate instruction) { | 2305 void visitCreate(HCreate instruction) { |
| 2306 memorySet.registerAllocation(instruction); | 2306 memorySet.registerAllocation(instruction); |
| 2307 if (shouldTrackInitialValues(instruction)) { | 2307 if (shouldTrackInitialValues(instruction)) { |
| 2308 int argumentIndex = 0; | 2308 int argumentIndex = 0; |
| 2309 instruction.element.forEachInstanceField((_, FieldElement member) { | 2309 compiler.codegenWorld.forEachInstanceField(instruction.element, |
| 2310 (_, FieldElement member) { |
| 2310 if (compiler.elementHasCompileTimeError(member)) return; | 2311 if (compiler.elementHasCompileTimeError(member)) return; |
| 2311 memorySet.registerFieldValue( | 2312 memorySet.registerFieldValue( |
| 2312 member, instruction, instruction.inputs[argumentIndex++]); | 2313 member, instruction, instruction.inputs[argumentIndex++]); |
| 2313 }, includeSuperAndInjectedMembers: true); | 2314 }); |
| 2314 } | 2315 } |
| 2315 // In case this instruction has as input non-escaping objects, we | 2316 // In case this instruction has as input non-escaping objects, we |
| 2316 // need to mark these objects as escaping. | 2317 // need to mark these objects as escaping. |
| 2317 memorySet.killAffectedBy(instruction); | 2318 memorySet.killAffectedBy(instruction); |
| 2318 } | 2319 } |
| 2319 | 2320 |
| 2320 bool shouldTrackInitialValues(HCreate instruction) { | 2321 bool shouldTrackInitialValues(HCreate instruction) { |
| 2321 // Don't track initial field values of an allocation that are | 2322 // Don't track initial field values of an allocation that are |
| 2322 // unprofitable. We search the chain of single uses in allocations for a | 2323 // unprofitable. We search the chain of single uses in allocations for a |
| 2323 // limited depth. | 2324 // limited depth. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 | 2743 |
| 2743 keyedValues.forEach((receiver, values) { | 2744 keyedValues.forEach((receiver, values) { |
| 2744 result.keyedValues[receiver] = | 2745 result.keyedValues[receiver] = |
| 2745 new Map<HInstruction, HInstruction>.from(values); | 2746 new Map<HInstruction, HInstruction>.from(values); |
| 2746 }); | 2747 }); |
| 2747 | 2748 |
| 2748 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2749 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2749 return result; | 2750 return result; |
| 2750 } | 2751 } |
| 2751 } | 2752 } |
| OLD | NEW |