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 '../compiler.dart' show Compiler; | 5 import '../compiler.dart' show Compiler; |
6 import '../constants/constant_system.dart'; | 6 import '../constants/constant_system.dart'; |
7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 import '../js_backend/js_backend.dart'; | 9 import '../js_backend/js_backend.dart'; |
10 import '../types/types.dart'; | 10 import '../types/types.dart'; |
11 import '../universe/call_structure.dart'; | 11 import '../universe/call_structure.dart'; |
12 import '../universe/selector.dart'; | 12 import '../universe/selector.dart'; |
13 import '../world.dart' show World; | 13 import '../world.dart' show ClosedWorld; |
14 import 'nodes.dart'; | 14 import 'nodes.dart'; |
15 import 'types.dart'; | 15 import 'types.dart'; |
16 | 16 |
17 /** | 17 /** |
18 * [InvokeDynamicSpecializer] and its subclasses are helpers to | 18 * [InvokeDynamicSpecializer] and its subclasses are helpers to |
19 * optimize intercepted dynamic calls. It knows what input types | 19 * optimize intercepted dynamic calls. It knows what input types |
20 * would be beneficial for performance, and how to change a invoke | 20 * would be beneficial for performance, and how to change a invoke |
21 * dynamic to a builtin instruction (e.g. HIndex, HBitNot). | 21 * dynamic to a builtin instruction (e.g. HIndex, HBitNot). |
22 */ | 22 */ |
23 class InvokeDynamicSpecializer { | 23 class InvokeDynamicSpecializer { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 const EqualsSpecializer(); | 653 const EqualsSpecializer(); |
654 | 654 |
655 HInstruction tryConvertToBuiltin( | 655 HInstruction tryConvertToBuiltin( |
656 HInvokeDynamic instruction, Compiler compiler) { | 656 HInvokeDynamic instruction, Compiler compiler) { |
657 HInstruction left = instruction.inputs[1]; | 657 HInstruction left = instruction.inputs[1]; |
658 HInstruction right = instruction.inputs[2]; | 658 HInstruction right = instruction.inputs[2]; |
659 TypeMask instructionType = left.instructionType; | 659 TypeMask instructionType = left.instructionType; |
660 if (right.isConstantNull() || left.isPrimitiveOrNull(compiler)) { | 660 if (right.isConstantNull() || left.isPrimitiveOrNull(compiler)) { |
661 return newBuiltinVariant(instruction, compiler); | 661 return newBuiltinVariant(instruction, compiler); |
662 } | 662 } |
663 World world = compiler.world; | 663 ClosedWorld world = compiler.closedWorld; |
664 JavaScriptBackend backend = compiler.backend; | 664 JavaScriptBackend backend = compiler.backend; |
665 Iterable<Element> matches = | 665 Iterable<Element> matches = |
666 world.allFunctions.filter(instruction.selector, instructionType); | 666 world.allFunctions.filter(instruction.selector, instructionType); |
667 // This test relies the on `Object.==` and `Interceptor.==` always being | 667 // This test relies the on `Object.==` and `Interceptor.==` always being |
668 // implemented because if the selector matches by subtype, it still will be | 668 // implemented because if the selector matches by subtype, it still will be |
669 // a regular object or an interceptor. | 669 // a regular object or an interceptor. |
670 if (matches.every(backend.isDefaultEqualityImplementation)) { | 670 if (matches.every(backend.isDefaultEqualityImplementation)) { |
671 return newBuiltinVariant(instruction, compiler); | 671 return newBuiltinVariant(instruction, compiler); |
672 } | 672 } |
673 return null; | 673 return null; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 return constantSystem.codeUnitAt; | 752 return constantSystem.codeUnitAt; |
753 } | 753 } |
754 | 754 |
755 HInstruction tryConvertToBuiltin( | 755 HInstruction tryConvertToBuiltin( |
756 HInvokeDynamic instruction, Compiler compiler) { | 756 HInvokeDynamic instruction, Compiler compiler) { |
757 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index | 757 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index |
758 // bounds checking optimizations as for HIndex. | 758 // bounds checking optimizations as for HIndex. |
759 return null; | 759 return null; |
760 } | 760 } |
761 } | 761 } |
OLD | NEW |