| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 // If the interceptor is used by multiple instructions, specialize | 162 // If the interceptor is used by multiple instructions, specialize |
| 163 // it with a set of classes it intercepts. | 163 // it with a set of classes it intercepts. |
| 164 Set<ClassElement> interceptedClasses; | 164 Set<ClassElement> interceptedClasses; |
| 165 JavaScriptBackend backend = compiler.backend; | 165 JavaScriptBackend backend = compiler.backend; |
| 166 HInstruction dominator = | 166 HInstruction dominator = |
| 167 findDominator(node.usedBy.where((i) => i is HInvokeDynamic)); | 167 findDominator(node.usedBy.where((i) => i is HInvokeDynamic)); |
| 168 // If there is an instruction that dominates all others, we can | 168 // If there is an instruction that dominates all others, we can |
| 169 // use only the selector of that instruction. | 169 // use only the selector of that instruction. |
| 170 if (dominator != null) { | 170 if (dominator != null) { |
| 171 interceptedClasses = | 171 interceptedClasses = |
| 172 backend.getInterceptedClassesOn(dominator.selector.name); | 172 backend.getInterceptedClassesOn(dominator.selector.name); |
| 173 | 173 |
| 174 // If we found that we need number, we must still go through all | 174 // If we found that we need number, we must still go through all |
| 175 // uses to check if they require int, or double. | 175 // uses to check if they require int, or double. |
| 176 if (interceptedClasses.contains(backend.jsNumberClass) | 176 if (interceptedClasses.contains(backend.jsNumberClass) |
| 177 && !(interceptedClasses.contains(backend.jsDoubleClass) | 177 && !(interceptedClasses.contains(backend.jsDoubleClass) |
| 178 || interceptedClasses.contains(backend.jsIntClass))) { | 178 || interceptedClasses.contains(backend.jsIntClass))) { |
| 179 for (var user in node.usedBy) { | 179 for (var user in node.usedBy) { |
| 180 if (user is! HInvoke) continue; | 180 if (user is! HInvoke) continue; |
| 181 Set<ClassElement> intercepted = | 181 Set<ClassElement> intercepted = |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 inputs[0] = constant; | 276 inputs[0] = constant; |
| 277 instruction = new HInvokeDynamicMethod(selector, inputs, true); | 277 instruction = new HInvokeDynamicMethod(selector, inputs, true); |
| 278 } | 278 } |
| 279 | 279 |
| 280 HBasicBlock block = node.block; | 280 HBasicBlock block = node.block; |
| 281 block.addAfter(node, instruction); | 281 block.addAfter(node, instruction); |
| 282 block.rewrite(node, instruction); | 282 block.rewrite(node, instruction); |
| 283 return true; | 283 return true; |
| 284 } | 284 } |
| 285 } | 285 } |
| OLD | NEW |