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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart

Issue 13940015: Allow using native JS []= on typed data lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months 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 | Annotate | Revision Log
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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * [InvokeDynamicSpecializer] and its subclasses are helpers to 8 * [InvokeDynamicSpecializer] and its subclasses are helpers to
9 * optimize intercepted dynamic calls. It knows what input types 9 * optimize intercepted dynamic calls. It knows what input types
10 * would be beneficial for performance, and how to change a invoke 10 * would be beneficial for performance, and how to change a invoke
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 class IndexAssignSpecializer extends InvokeDynamicSpecializer { 82 class IndexAssignSpecializer extends InvokeDynamicSpecializer {
83 const IndexAssignSpecializer(); 83 const IndexAssignSpecializer();
84 84
85 HType computeDesiredTypeForInput(HInvokeDynamic instruction, 85 HType computeDesiredTypeForInput(HInvokeDynamic instruction,
86 HInstruction input, 86 HInstruction input,
87 Compiler compiler) { 87 Compiler compiler) {
88 HInstruction index = instruction.inputs[2]; 88 HInstruction index = instruction.inputs[2];
89 if (input == instruction.inputs[1] && 89 if (input == instruction.inputs[1] &&
90 index.instructionType.canBePrimitiveNumber(compiler)) { 90 index.instructionType.canBePrimitiveNumber(compiler)) {
91 return HType.MUTABLE_ARRAY; 91 return HType.MUTABLE_ARRAY;
kasperl 2013/04/24 10:43:03 I'll try to update this to HType.MUTABLE_INDEXABLE
92 } 92 }
93 // The index should be an int when the receiver is a string or array. 93 // The index should be an int when the receiver is a string or array.
94 // However it turns out that inserting an integer check in the optimized 94 // However it turns out that inserting an integer check in the optimized
95 // version is cheaper than having another bailout case. This is true, 95 // version is cheaper than having another bailout case. This is true,
96 // because the integer check will simply throw if it fails. 96 // because the integer check will simply throw if it fails.
97 return HType.UNKNOWN; 97 return HType.UNKNOWN;
98 } 98 }
99 99
100 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 100 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
101 Compiler compiler) { 101 Compiler compiler) {
102 if (instruction.inputs[1].isMutableArray()) { 102 if (instruction.inputs[1].isMutableIndexable(compiler)) {
103 return new HIndexAssign(instruction.inputs[1], 103 return new HIndexAssign(instruction.inputs[1],
104 instruction.inputs[2], 104 instruction.inputs[2],
105 instruction.inputs[3], 105 instruction.inputs[3],
106 instruction.selector); 106 instruction.selector);
107 } 107 }
108 return null; 108 return null;
109 } 109 }
110 } 110 }
111 111
112 class IndexSpecializer extends InvokeDynamicSpecializer { 112 class IndexSpecializer extends InvokeDynamicSpecializer {
113 const IndexSpecializer(); 113 const IndexSpecializer();
114 114
115 HType computeDesiredTypeForInput(HInvokeDynamic instruction, 115 HType computeDesiredTypeForInput(HInvokeDynamic instruction,
116 HInstruction input, 116 HInstruction input,
117 Compiler compiler) { 117 Compiler compiler) {
118 HInstruction index = instruction.inputs[2]; 118 HInstruction index = instruction.inputs[2];
119 if (input == instruction.inputs[1] && 119 if (input == instruction.inputs[1] &&
120 index.instructionType.canBePrimitiveNumber(compiler)) { 120 index.instructionType.canBePrimitiveNumber(compiler)) {
121 return HType.INDEXABLE_PRIMITIVE; 121 return HType.INDEXABLE_PRIMITIVE;
122 } 122 }
123 // The index should be an int when the receiver is a string or array. 123 // The index should be an int when the receiver is a string or array.
124 // However it turns out that inserting an integer check in the optimized 124 // However it turns out that inserting an integer check in the optimized
125 // version is cheaper than having another bailout case. This is true, 125 // version is cheaper than having another bailout case. This is true,
126 // because the integer check will simply throw if it fails. 126 // because the integer check will simply throw if it fails.
127 return HType.UNKNOWN; 127 return HType.UNKNOWN;
128 } 128 }
129 129
130 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 130 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
131 Compiler compiler) { 131 Compiler compiler) {
132 if (instruction.inputs[1].isIndexablePrimitive()) { 132 if (instruction.inputs[1].isIndexable(compiler)) {
133 return new HIndex( 133 return new HIndex(
134 instruction.inputs[1], instruction.inputs[2], instruction.selector); 134 instruction.inputs[1], instruction.inputs[2], instruction.selector);
135 } 135 }
136 return null; 136 return null;
137 } 137 }
138 } 138 }
139 139
140 class BitNotSpecializer extends InvokeDynamicSpecializer { 140 class BitNotSpecializer extends InvokeDynamicSpecializer {
141 const BitNotSpecializer(); 141 const BitNotSpecializer();
142 142
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 621
622 BinaryOperation operation(ConstantSystem constantSystem) { 622 BinaryOperation operation(ConstantSystem constantSystem) {
623 return constantSystem.lessEqual; 623 return constantSystem.lessEqual;
624 } 624 }
625 625
626 HInstruction newBuiltinVariant(HInvokeDynamic instruction) { 626 HInstruction newBuiltinVariant(HInvokeDynamic instruction) {
627 return new HLessEqual( 627 return new HLessEqual(
628 instruction.inputs[1], instruction.inputs[2], instruction.selector); 628 instruction.inputs[1], instruction.inputs[2], instruction.selector);
629 } 629 }
630 } 630 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698