Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: pkg/compiler/lib/src/ssa/invoke_dynamic_specializers.dart

Issue 2569733002: Even less reliance on Compiler.closedWorld (Closed)
Patch Set: Updated cf. comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ClosedWorld; 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 {
24 const InvokeDynamicSpecializer(); 24 const InvokeDynamicSpecializer();
25 25
26 TypeMask computeTypeFromInputTypes( 26 TypeMask computeTypeFromInputTypes(
27 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { 27 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) {
28 return TypeMaskFactory.inferredTypeForSelector( 28 return TypeMaskFactory.inferredTypeForSelector(instruction.selector,
29 instruction.selector, instruction.mask, compiler); 29 instruction.mask, compiler.globalInference.results);
30 } 30 }
31 31
32 HInstruction tryConvertToBuiltin( 32 HInstruction tryConvertToBuiltin(
33 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { 33 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) {
34 return null; 34 return null;
35 } 35 }
36 36
37 void clearAllSideEffects(HInstruction instruction) { 37 void clearAllSideEffects(HInstruction instruction) {
38 instruction.sideEffects.clearAllSideEffects(); 38 instruction.sideEffects.clearAllSideEffects();
39 instruction.sideEffects.clearAllDependencies(); 39 instruction.sideEffects.clearAllDependencies();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 HInstruction tryConvertToBuiltin( 105 HInstruction tryConvertToBuiltin(
106 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { 106 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) {
107 if (!instruction.inputs[1].isIndexablePrimitive(closedWorld)) return null; 107 if (!instruction.inputs[1].isIndexablePrimitive(closedWorld)) return null;
108 if (!instruction.inputs[2].isInteger(closedWorld) && 108 if (!instruction.inputs[2].isInteger(closedWorld) &&
109 compiler.options.enableTypeAssertions) { 109 compiler.options.enableTypeAssertions) {
110 // We want the right checked mode error. 110 // We want the right checked mode error.
111 return null; 111 return null;
112 } 112 }
113 TypeMask receiverType = 113 TypeMask receiverType =
114 instruction.getDartReceiver(compiler).instructionType; 114 instruction.getDartReceiver(closedWorld).instructionType;
115 TypeMask type = TypeMaskFactory.inferredTypeForSelector( 115 TypeMask type = TypeMaskFactory.inferredTypeForSelector(
116 instruction.selector, receiverType, compiler); 116 instruction.selector, receiverType, compiler.globalInference.results);
117 return new HIndex(instruction.inputs[1], instruction.inputs[2], 117 return new HIndex(instruction.inputs[1], instruction.inputs[2],
118 instruction.selector, type); 118 instruction.selector, type);
119 } 119 }
120 } 120 }
121 121
122 class BitNotSpecializer extends InvokeDynamicSpecializer { 122 class BitNotSpecializer extends InvokeDynamicSpecializer {
123 const BitNotSpecializer(); 123 const BitNotSpecializer();
124 124
125 UnaryOperation operation(ConstantSystem constantSystem) { 125 UnaryOperation operation(ConstantSystem constantSystem) {
126 return constantSystem.bitNot; 126 return constantSystem.bitNot;
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 const CodeUnitAtSpecializer(); 747 const CodeUnitAtSpecializer();
748 748
749 BinaryOperation operation(ConstantSystem constantSystem) { 749 BinaryOperation operation(ConstantSystem constantSystem) {
750 return constantSystem.codeUnitAt; 750 return constantSystem.codeUnitAt;
751 } 751 }
752 752
753 HInstruction tryConvertToBuiltin( 753 HInstruction tryConvertToBuiltin(
754 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { 754 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) {
755 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index 755 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index
756 // bounds checking optimizations as for HIndex. 756 // bounds checking optimizations as for HIndex.
757 HInstruction receiver = instruction.getDartReceiver(compiler); 757 HInstruction receiver = instruction.getDartReceiver(closedWorld);
758 if (receiver.isStringOrNull(closedWorld)) { 758 if (receiver.isStringOrNull(closedWorld)) {
759 // Even if there is no builtin equivalent instruction, we know 759 // Even if there is no builtin equivalent instruction, we know
760 // String.codeUnitAt does not have any side effect (other than throwing), 760 // String.codeUnitAt does not have any side effect (other than throwing),
761 // and that it can be GVN'ed. 761 // and that it can be GVN'ed.
762 clearAllSideEffects(instruction); 762 clearAllSideEffects(instruction);
763 } 763 }
764 return null; 764 return null;
765 } 765 }
766 } 766 }
767 767
768 class RoundSpecializer extends InvokeDynamicSpecializer { 768 class RoundSpecializer extends InvokeDynamicSpecializer {
769 const RoundSpecializer(); 769 const RoundSpecializer();
770 770
771 UnaryOperation operation(ConstantSystem constantSystem) { 771 UnaryOperation operation(ConstantSystem constantSystem) {
772 return constantSystem.round; 772 return constantSystem.round;
773 } 773 }
774 774
775 HInstruction tryConvertToBuiltin( 775 HInstruction tryConvertToBuiltin(
776 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) { 776 HInvokeDynamic instruction, Compiler compiler, ClosedWorld closedWorld) {
777 HInstruction receiver = instruction.getDartReceiver(compiler); 777 HInstruction receiver = instruction.getDartReceiver(closedWorld);
778 if (receiver.isNumberOrNull(closedWorld)) { 778 if (receiver.isNumberOrNull(closedWorld)) {
779 // Even if there is no builtin equivalent instruction, we know the 779 // Even if there is no builtin equivalent instruction, we know the
780 // instruction does not have any side effect, and that it can be GVN'ed. 780 // instruction does not have any side effect, and that it can be GVN'ed.
781 clearAllSideEffects(instruction); 781 clearAllSideEffects(instruction);
782 } 782 }
783 return null; 783 return null;
784 } 784 }
785 } 785 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/interceptor_simplifier.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698