| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 interceptor.sourceElement = user.sourceElement; | 249 interceptor.sourceElement = user.sourceElement; |
| 250 | 250 |
| 251 HBasicBlock block = user.block; | 251 HBasicBlock block = user.block; |
| 252 block.addAfter(user, interceptor); | 252 block.addAfter(user, interceptor); |
| 253 block.rewrite(user, interceptor); | 253 block.rewrite(user, interceptor); |
| 254 block.remove(user); | 254 block.remove(user); |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool rewriteToUseSelfAsInterceptor(HInterceptor node, HInstruction receiver) { | 258 bool rewriteToUseSelfAsInterceptor(HInterceptor node, HInstruction receiver) { |
| 259 node.block.rewrite(node, receiver); | 259 for (HInstruction user in node.usedBy.toList()) { |
| 260 if (user is HIs) { |
| 261 user.changeUse(node, receiver); |
| 262 } else { |
| 263 // Use the potentially self-argument as new receiver. Note that the |
| 264 // self-argument could potentially have a tighter type than the |
| 265 // receiver which was the input to the interceptor. |
| 266 assert(user.inputs[0] == node); |
| 267 assert(receiver.nonCheck() == user.inputs[1].nonCheck()); |
| 268 user.changeUse(node, user.inputs[1]); |
| 269 } |
| 270 } |
| 260 return false; | 271 return false; |
| 261 } | 272 } |
| 262 | 273 |
| 263 bool visitOneShotInterceptor(HOneShotInterceptor node) { | 274 bool visitOneShotInterceptor(HOneShotInterceptor node) { |
| 264 HInstruction constant = tryComputeConstantInterceptor( | 275 HInstruction constant = tryComputeConstantInterceptor( |
| 265 node.inputs[1], node.interceptedClasses); | 276 node.inputs[1], node.interceptedClasses); |
| 266 | 277 |
| 267 if (constant == null) return false; | 278 if (constant == null) return false; |
| 268 | 279 |
| 269 Selector selector = node.selector; | 280 Selector selector = node.selector; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 286 instruction = new HInvokeDynamicMethod( | 297 instruction = new HInvokeDynamicMethod( |
| 287 selector, inputs, node.instructionType, true); | 298 selector, inputs, node.instructionType, true); |
| 288 } | 299 } |
| 289 | 300 |
| 290 HBasicBlock block = node.block; | 301 HBasicBlock block = node.block; |
| 291 block.addAfter(node, instruction); | 302 block.addAfter(node, instruction); |
| 292 block.rewrite(node, instruction); | 303 block.rewrite(node, instruction); |
| 293 return true; | 304 return true; |
| 294 } | 305 } |
| 295 } | 306 } |
| OLD | NEW |