Chromium Code Reviews| 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 OptimizationPhase { | 5 interface OptimizationPhase { |
| 6 String get name(); | 6 String get name(); |
| 7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 MapConstant constant = constantInput.constant; | 178 MapConstant constant = constantInput.constant; |
| 179 return graph.addConstantInt(constant.length); | 179 return graph.addConstantInt(constant.length); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (input.isString() | 183 if (input.isString() |
| 184 && node.name == const SourceString('toString')) { | 184 && node.name == const SourceString('toString')) { |
| 185 return node.inputs[1]; | 185 return node.inputs[1]; |
| 186 } | 186 } |
| 187 | 187 |
| 188 if (!input.canBePrimitive() && !node.getter) { | 188 if (!input.canBePrimitive() && !node.getter && !node.setter) { |
| 189 return fromInterceptorToDynamicInvocation(node, node.name); | 189 return fromInterceptorToDynamicInvocation(node, node.name); |
| 190 } | 190 } |
| 191 | 191 |
| 192 return node; | 192 return node; |
| 193 } | 193 } |
| 194 | 194 |
| 195 HInstruction visitInvokeDynamic(HInvokeDynamic node) { | 195 HInstruction visitInvokeDynamic(HInvokeDynamic node) { |
| 196 HType receiverType = node.receiver.propagatedType; | 196 HType receiverType = node.receiver.propagatedType; |
| 197 if (receiverType.isExact()) { | 197 if (receiverType.isExact()) { |
| 198 HExactType type = receiverType; | 198 HExactType type = receiverType; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 } | 579 } |
| 580 | 580 |
| 581 HBoundsCheck insertBoundsCheck(HInstruction node, | 581 HBoundsCheck insertBoundsCheck(HInstruction node, |
| 582 HInstruction receiver, | 582 HInstruction receiver, |
| 583 HInstruction index) { | 583 HInstruction index) { |
| 584 HStatic interceptor = new HStatic(lengthInterceptor); | 584 HStatic interceptor = new HStatic(lengthInterceptor); |
| 585 node.block.addBefore(node, interceptor); | 585 node.block.addBefore(node, interceptor); |
| 586 HInvokeInterceptor length = new HInvokeInterceptor( | 586 HInvokeInterceptor length = new HInvokeInterceptor( |
| 587 Selector.INVOCATION_0, | 587 Selector.INVOCATION_0, |
| 588 const SourceString("length"), | 588 const SourceString("length"), |
| 589 true, | 589 true, |
|
mattsh
2012/05/07 13:58:56
just checking - looks like you need to pass a bool
ngeoffray
2012/05/08 07:43:46
Very good catch! Thanks Matt
| |
| 590 <HInstruction>[interceptor, receiver]); | 590 <HInstruction>[interceptor, receiver]); |
| 591 length.propagatedType = HType.INTEGER; | 591 length.propagatedType = HType.INTEGER; |
| 592 node.block.addBefore(node, length); | 592 node.block.addBefore(node, length); |
| 593 | 593 |
| 594 HBoundsCheck check = new HBoundsCheck(length, index); | 594 HBoundsCheck check = new HBoundsCheck(length, index); |
| 595 node.block.addBefore(node, check); | 595 node.block.addBefore(node, check); |
| 596 return check; | 596 return check; |
| 597 } | 597 } |
| 598 | 598 |
| 599 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { | 599 HIntegerCheck insertIntegerCheck(HInstruction node, HInstruction value) { |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1088 // the if block terminates. So any use of the instruction | 1088 // the if block terminates. So any use of the instruction |
| 1089 // after the join block should be changed to the new | 1089 // after the join block should be changed to the new |
| 1090 // instruction. | 1090 // instruction. |
| 1091 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | 1091 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); |
| 1092 } | 1092 } |
| 1093 // TODO(ngeoffray): Also change uses for the then block on a HType | 1093 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1094 // that knows it is not of a specific Type. | 1094 // that knows it is not of a specific Type. |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| OLD | NEW |