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 import '../common/codegen.dart' show CodegenWorkItem; | 5 import '../common/codegen.dart' show CodegenWorkItem; |
6 import '../compiler.dart' show Compiler; | 6 import '../compiler.dart' show Compiler; |
7 import '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
10 import '../js_backend/backend_helpers.dart' show BackendHelpers; | 10 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 node == dominator.receiver && | 225 node == dominator.receiver && |
226 useCount(dominator, node) == 1) { | 226 useCount(dominator, node) == 1) { |
227 interceptedClasses = | 227 interceptedClasses = |
228 backend.getInterceptedClassesOn(dominator.selector.name); | 228 backend.getInterceptedClassesOn(dominator.selector.name); |
229 | 229 |
230 // If we found that we need number, we must still go through all | 230 // If we found that we need number, we must still go through all |
231 // uses to check if they require int, or double. | 231 // uses to check if they require int, or double. |
232 if (interceptedClasses.contains(helpers.jsNumberClass) && | 232 if (interceptedClasses.contains(helpers.jsNumberClass) && |
233 !(interceptedClasses.contains(helpers.jsDoubleClass) || | 233 !(interceptedClasses.contains(helpers.jsDoubleClass) || |
234 interceptedClasses.contains(helpers.jsIntClass))) { | 234 interceptedClasses.contains(helpers.jsIntClass))) { |
| 235 Set<ClassElement> required; |
235 for (HInstruction user in node.usedBy) { | 236 for (HInstruction user in node.usedBy) { |
236 if (user is! HInvoke) continue; | 237 if (user is! HInvoke) continue; |
237 Set<ClassElement> intercepted = | 238 Set<ClassElement> intercepted = |
238 backend.getInterceptedClassesOn(user.selector.name); | 239 backend.getInterceptedClassesOn(user.selector.name); |
239 if (intercepted.contains(helpers.jsIntClass)) { | 240 if (intercepted.contains(helpers.jsIntClass)) { |
240 interceptedClasses.add(helpers.jsIntClass); | 241 required ??= new Set<ClassElement>(); |
| 242 required.add(helpers.jsIntClass); |
241 } | 243 } |
242 if (intercepted.contains(helpers.jsDoubleClass)) { | 244 if (intercepted.contains(helpers.jsDoubleClass)) { |
243 interceptedClasses.add(helpers.jsDoubleClass); | 245 required ??= new Set<ClassElement>(); |
| 246 required.add(helpers.jsDoubleClass); |
244 } | 247 } |
245 } | 248 } |
| 249 // Don't modify the result of [backend.getInterceptedClassesOn]. |
| 250 if (required != null) { |
| 251 interceptedClasses = interceptedClasses.union(required); |
| 252 } |
246 } | 253 } |
247 } else { | 254 } else { |
248 interceptedClasses = new Set<ClassElement>(); | 255 interceptedClasses = new Set<ClassElement>(); |
249 for (HInstruction user in node.usedBy) { | 256 for (HInstruction user in node.usedBy) { |
250 if (user is HInvokeDynamic && | 257 if (user is HInvokeDynamic && |
251 user.isCallOnInterceptor(compiler) && | 258 user.isCallOnInterceptor(compiler) && |
252 node == user.receiver && | 259 node == user.receiver && |
253 useCount(user, node) == 1) { | 260 useCount(user, node) == 1) { |
254 interceptedClasses | 261 interceptedClasses |
255 .addAll(backend.getInterceptedClassesOn(user.selector.name)); | 262 .addAll(backend.getInterceptedClassesOn(user.selector.name)); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 instruction = new HInvokeDynamicMethod( | 414 instruction = new HInvokeDynamicMethod( |
408 selector, mask, inputs, node.instructionType, true); | 415 selector, mask, inputs, node.instructionType, true); |
409 } | 416 } |
410 | 417 |
411 HBasicBlock block = node.block; | 418 HBasicBlock block = node.block; |
412 block.addAfter(node, instruction); | 419 block.addAfter(node, instruction); |
413 block.rewrite(node, instruction); | 420 block.rewrite(node, instruction); |
414 return true; | 421 return true; |
415 } | 422 } |
416 } | 423 } |
OLD | NEW |