| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 interceptedClasses.add(backend.jsIntClass); | 184 interceptedClasses.add(backend.jsIntClass); |
| 185 } | 185 } |
| 186 if (intercepted.contains(backend.jsDoubleClass)) { | 186 if (intercepted.contains(backend.jsDoubleClass)) { |
| 187 interceptedClasses.add(backend.jsDoubleClass); | 187 interceptedClasses.add(backend.jsDoubleClass); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 } else { | 191 } else { |
| 192 interceptedClasses = new Set<ClassElement>(); | 192 interceptedClasses = new Set<ClassElement>(); |
| 193 for (var user in node.usedBy) { | 193 for (var user in node.usedBy) { |
| 194 if (user is HIs) { |
| 195 // Is-checks can be performed on any intercepted class. |
| 196 interceptedClasses.addAll(backend.interceptedClasses); |
| 197 break; |
| 198 } |
| 194 if (user is! HInvoke) continue; | 199 if (user is! HInvoke) continue; |
| 195 // We don't handle escaping interceptors yet. | 200 // We don't handle escaping interceptors yet. |
| 196 interceptedClasses.addAll( | 201 interceptedClasses.addAll( |
| 197 backend.getInterceptedClassesOn(user.selector.name)); | 202 backend.getInterceptedClassesOn(user.selector.name)); |
| 198 } | 203 } |
| 199 } | 204 } |
| 200 | 205 |
| 201 HInstruction receiver = node.receiver; | 206 HInstruction receiver = node.receiver; |
| 202 HType instructionType = receiver.instructionType; | 207 HType instructionType = receiver.instructionType; |
| 203 if (canUseSelfForInterceptor(instructionType, interceptedClasses)) { | 208 if (canUseSelfForInterceptor(instructionType, interceptedClasses)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 interceptor.sourceElement = user.sourceElement; | 246 interceptor.sourceElement = user.sourceElement; |
| 242 interceptor.instructionType = user.instructionType; | 247 interceptor.instructionType = user.instructionType; |
| 243 | 248 |
| 244 HBasicBlock block = user.block; | 249 HBasicBlock block = user.block; |
| 245 block.addAfter(user, interceptor); | 250 block.addAfter(user, interceptor); |
| 246 block.rewrite(user, interceptor); | 251 block.rewrite(user, interceptor); |
| 247 block.remove(user); | 252 block.remove(user); |
| 248 return true; | 253 return true; |
| 249 } | 254 } |
| 250 | 255 |
| 251 | |
| 252 bool visitOneShotInterceptor(HOneShotInterceptor node) { | 256 bool visitOneShotInterceptor(HOneShotInterceptor node) { |
| 253 HInstruction constant = tryComputeConstantInterceptor( | 257 HInstruction constant = tryComputeConstantInterceptor( |
| 254 node.inputs[1], node.interceptedClasses); | 258 node.inputs[1], node.interceptedClasses); |
| 255 | 259 |
| 256 if (constant == null) return false; | 260 if (constant == null) return false; |
| 257 | 261 |
| 258 Selector selector = node.selector; | 262 Selector selector = node.selector; |
| 259 // TODO(ngeoffray): make one shot interceptors know whether | 263 // TODO(ngeoffray): make one shot interceptors know whether |
| 260 // they have side effects. | 264 // they have side effects. |
| 261 HInstruction instruction; | 265 HInstruction instruction; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 276 inputs[0] = constant; | 280 inputs[0] = constant; |
| 277 instruction = new HInvokeDynamicMethod(selector, inputs, true); | 281 instruction = new HInvokeDynamicMethod(selector, inputs, true); |
| 278 } | 282 } |
| 279 | 283 |
| 280 HBasicBlock block = node.block; | 284 HBasicBlock block = node.block; |
| 281 block.addAfter(node, instruction); | 285 block.addAfter(node, instruction); |
| 282 block.rewrite(node, instruction); | 286 block.rewrite(node, instruction); |
| 283 return true; | 287 return true; |
| 284 } | 288 } |
| 285 } | 289 } |
| OLD | NEW |