Chromium Code Reviews| 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. | |
|
sra1
2014/05/08 03:34:35
Please add a test/guard against 'use' being an arg
floitsch
2014/05/08 18:21:56
Done.
| |
| 266 user.changeUse(node, user.inputs[1]); | |
| 267 } | |
| 268 } | |
| 260 return false; | 269 return false; |
| 261 } | 270 } |
| 262 | 271 |
| 263 bool visitOneShotInterceptor(HOneShotInterceptor node) { | 272 bool visitOneShotInterceptor(HOneShotInterceptor node) { |
| 264 HInstruction constant = tryComputeConstantInterceptor( | 273 HInstruction constant = tryComputeConstantInterceptor( |
| 265 node.inputs[1], node.interceptedClasses); | 274 node.inputs[1], node.interceptedClasses); |
| 266 | 275 |
| 267 if (constant == null) return false; | 276 if (constant == null) return false; |
| 268 | 277 |
| 269 Selector selector = node.selector; | 278 Selector selector = node.selector; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 286 instruction = new HInvokeDynamicMethod( | 295 instruction = new HInvokeDynamicMethod( |
| 287 selector, inputs, node.instructionType, true); | 296 selector, inputs, node.instructionType, true); |
| 288 } | 297 } |
| 289 | 298 |
| 290 HBasicBlock block = node.block; | 299 HBasicBlock block = node.block; |
| 291 block.addAfter(node, instruction); | 300 block.addAfter(node, instruction); |
| 292 block.rewrite(node, instruction); | 301 block.rewrite(node, instruction); |
| 293 return true; | 302 return true; |
| 294 } | 303 } |
| 295 } | 304 } |
| OLD | NEW |