| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 7 /** |
| 8 * This phase simplifies interceptors in multiple ways: | 8 * This phase simplifies interceptors in multiple ways: |
| 9 * | 9 * |
| 10 * 1) If the interceptor is for an object whose type is known, it | 10 * 1) If the interceptor is for an object whose type is known, it |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 HInstruction constant = tryComputeConstantInterceptor( | 257 HInstruction constant = tryComputeConstantInterceptor( |
| 258 node.inputs[1], node.interceptedClasses); | 258 node.inputs[1], node.interceptedClasses); |
| 259 | 259 |
| 260 if (constant == null) return false; | 260 if (constant == null) return false; |
| 261 | 261 |
| 262 Selector selector = node.selector; | 262 Selector selector = node.selector; |
| 263 // TODO(ngeoffray): make one shot interceptors know whether | 263 // TODO(ngeoffray): make one shot interceptors know whether |
| 264 // they have side effects. | 264 // they have side effects. |
| 265 HInstruction instruction; | 265 HInstruction instruction; |
| 266 if (selector.isGetter()) { | 266 if (selector.isGetter()) { |
| 267 instruction= new HInvokeDynamicGetter( | 267 instruction = new HInvokeDynamicGetter( |
| 268 selector, | 268 selector, |
| 269 node.element, | 269 node.element, |
| 270 <HInstruction>[constant, node.inputs[1]], | 270 <HInstruction>[constant, node.inputs[1]], |
| 271 false); | 271 false); |
| 272 } else if (node.selector.isSetter()) { | 272 } else if (node.selector.isSetter()) { |
| 273 instruction = new HInvokeDynamicSetter( | 273 instruction = new HInvokeDynamicSetter( |
| 274 selector, | 274 selector, |
| 275 node.element, | 275 node.element, |
| 276 <HInstruction>[constant, node.inputs[1], node.inputs[2]], | 276 <HInstruction>[constant, node.inputs[1], node.inputs[2]], |
| 277 false); | 277 false); |
| 278 } else { | 278 } else { |
| 279 List<HInstruction> inputs = new List<HInstruction>.from(node.inputs); | 279 List<HInstruction> inputs = new List<HInstruction>.from(node.inputs); |
| 280 inputs[0] = constant; | 280 inputs[0] = constant; |
| 281 instruction = new HInvokeDynamicMethod(selector, inputs, true); | 281 instruction = new HInvokeDynamicMethod(selector, inputs, true); |
| 282 } | 282 } |
| 283 | 283 |
| 284 HBasicBlock block = node.block; | 284 HBasicBlock block = node.block; |
| 285 block.addAfter(node, instruction); | 285 block.addAfter(node, instruction); |
| 286 block.rewrite(node, instruction); | 286 block.rewrite(node, instruction); |
| 287 return true; | 287 return true; |
| 288 } | 288 } |
| 289 } | 289 } |
| OLD | NEW |