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

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

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
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/selector.dart'; 11 import '../universe/selector.dart';
12 import '../universe/call_structure.dart'; 12 import '../universe/call_structure.dart';
13 import '../world.dart' show ClassWorld, World; 13 import '../world.dart' show ClassWorld, World;
14 14
15 import 'nodes.dart'; 15 import 'nodes.dart';
16 import 'types.dart'; 16 import 'types.dart';
17 17
18 /** 18 /**
19 * [InvokeDynamicSpecializer] and its subclasses are helpers to 19 * [InvokeDynamicSpecializer] and its subclasses are helpers to
20 * optimize intercepted dynamic calls. It knows what input types 20 * optimize intercepted dynamic calls. It knows what input types
21 * would be beneficial for performance, and how to change a invoke 21 * would be beneficial for performance, and how to change a invoke
22 * dynamic to a builtin instruction (e.g. HIndex, HBitNot). 22 * dynamic to a builtin instruction (e.g. HIndex, HBitNot).
23 */ 23 */
24 class InvokeDynamicSpecializer { 24 class InvokeDynamicSpecializer {
25 const InvokeDynamicSpecializer(); 25 const InvokeDynamicSpecializer();
26 26
27 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 27 TypeMask computeTypeFromInputTypes(
28 Compiler compiler) { 28 HInvokeDynamic instruction, Compiler compiler) {
29 return TypeMaskFactory.inferredTypeForSelector( 29 return TypeMaskFactory.inferredTypeForSelector(
30 instruction.selector, instruction.mask, compiler); 30 instruction.selector, instruction.mask, compiler);
31 } 31 }
32 32
33 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 33 HInstruction tryConvertToBuiltin(
34 Compiler compiler) { 34 HInvokeDynamic instruction, Compiler compiler) {
35 return null; 35 return null;
36 } 36 }
37 37
38 Operation operation(ConstantSystem constantSystem) => null; 38 Operation operation(ConstantSystem constantSystem) => null;
39 39
40 static InvokeDynamicSpecializer lookupSpecializer(Selector selector) { 40 static InvokeDynamicSpecializer lookupSpecializer(Selector selector) {
41 if (selector.isIndex) { 41 if (selector.isIndex) {
42 return const IndexSpecializer(); 42 return const IndexSpecializer();
43 } else if (selector.isIndexSet) { 43 } else if (selector.isIndexSet) {
44 return const IndexAssignSpecializer(); 44 return const IndexAssignSpecializer();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 } 88 }
89 } 89 }
90 return const InvokeDynamicSpecializer(); 90 return const InvokeDynamicSpecializer();
91 } 91 }
92 } 92 }
93 93
94 class IndexAssignSpecializer extends InvokeDynamicSpecializer { 94 class IndexAssignSpecializer extends InvokeDynamicSpecializer {
95 const IndexAssignSpecializer(); 95 const IndexAssignSpecializer();
96 96
97 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 97 HInstruction tryConvertToBuiltin(
98 Compiler compiler) { 98 HInvokeDynamic instruction, Compiler compiler) {
99 if (instruction.inputs[1].isMutableIndexable(compiler)) { 99 if (instruction.inputs[1].isMutableIndexable(compiler)) {
100 if (!instruction.inputs[2].isInteger(compiler) 100 if (!instruction.inputs[2].isInteger(compiler) &&
101 && compiler.options.enableTypeAssertions) { 101 compiler.options.enableTypeAssertions) {
102 // We want the right checked mode error. 102 // We want the right checked mode error.
103 return null; 103 return null;
104 } 104 }
105 return new HIndexAssign(instruction.inputs[1], 105 return new HIndexAssign(instruction.inputs[1], instruction.inputs[2],
106 instruction.inputs[2], 106 instruction.inputs[3], instruction.selector);
107 instruction.inputs[3],
108 instruction.selector);
109 } 107 }
110 return null; 108 return null;
111 } 109 }
112 } 110 }
113 111
114 class IndexSpecializer extends InvokeDynamicSpecializer { 112 class IndexSpecializer extends InvokeDynamicSpecializer {
115 const IndexSpecializer(); 113 const IndexSpecializer();
116 114
117 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 115 HInstruction tryConvertToBuiltin(
118 Compiler compiler) { 116 HInvokeDynamic instruction, Compiler compiler) {
119 if (!instruction.inputs[1].isIndexablePrimitive(compiler)) return null; 117 if (!instruction.inputs[1].isIndexablePrimitive(compiler)) return null;
120 if (!instruction.inputs[2].isInteger(compiler) 118 if (!instruction.inputs[2].isInteger(compiler) &&
121 && compiler.options.enableTypeAssertions) { 119 compiler.options.enableTypeAssertions) {
122 // We want the right checked mode error. 120 // We want the right checked mode error.
123 return null; 121 return null;
124 } 122 }
125 TypeMask receiverType = 123 TypeMask receiverType =
126 instruction.getDartReceiver(compiler).instructionType; 124 instruction.getDartReceiver(compiler).instructionType;
127 TypeMask type = TypeMaskFactory.inferredTypeForSelector( 125 TypeMask type = TypeMaskFactory.inferredTypeForSelector(
128 instruction.selector, receiverType, compiler); 126 instruction.selector, receiverType, compiler);
129 return new HIndex( 127 return new HIndex(instruction.inputs[1], instruction.inputs[2],
130 instruction.inputs[1], instruction.inputs[2],
131 instruction.selector, type); 128 instruction.selector, type);
132 } 129 }
133 } 130 }
134 131
135 class BitNotSpecializer extends InvokeDynamicSpecializer { 132 class BitNotSpecializer extends InvokeDynamicSpecializer {
136 const BitNotSpecializer(); 133 const BitNotSpecializer();
137 134
138 UnaryOperation operation(ConstantSystem constantSystem) { 135 UnaryOperation operation(ConstantSystem constantSystem) {
139 return constantSystem.bitNot; 136 return constantSystem.bitNot;
140 } 137 }
141 138
142 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 139 TypeMask computeTypeFromInputTypes(
143 Compiler compiler) { 140 HInvokeDynamic instruction, Compiler compiler) {
144 // All bitwise operations on primitive types either produce an 141 // All bitwise operations on primitive types either produce an
145 // integer or throw an error. 142 // integer or throw an error.
146 JavaScriptBackend backend = compiler.backend; 143 JavaScriptBackend backend = compiler.backend;
147 if (instruction.inputs[1].isPrimitiveOrNull(compiler)) { 144 if (instruction.inputs[1].isPrimitiveOrNull(compiler)) {
148 return backend.uint32Type; 145 return backend.uint32Type;
149 } 146 }
150 return super.computeTypeFromInputTypes(instruction, compiler); 147 return super.computeTypeFromInputTypes(instruction, compiler);
151 } 148 }
152 149
153 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 150 HInstruction tryConvertToBuiltin(
154 Compiler compiler) { 151 HInvokeDynamic instruction, Compiler compiler) {
155 HInstruction input = instruction.inputs[1]; 152 HInstruction input = instruction.inputs[1];
156 if (input.isNumber(compiler)) { 153 if (input.isNumber(compiler)) {
157 return new HBitNot(input, instruction.selector, 154 return new HBitNot(input, instruction.selector,
158 computeTypeFromInputTypes(instruction, compiler)); 155 computeTypeFromInputTypes(instruction, compiler));
159 } 156 }
160 return null; 157 return null;
161 } 158 }
162 } 159 }
163 160
164 class UnaryNegateSpecializer extends InvokeDynamicSpecializer { 161 class UnaryNegateSpecializer extends InvokeDynamicSpecializer {
165 const UnaryNegateSpecializer(); 162 const UnaryNegateSpecializer();
166 163
167 UnaryOperation operation(ConstantSystem constantSystem) { 164 UnaryOperation operation(ConstantSystem constantSystem) {
168 return constantSystem.negate; 165 return constantSystem.negate;
169 } 166 }
170 167
171 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 168 TypeMask computeTypeFromInputTypes(
172 Compiler compiler) { 169 HInvokeDynamic instruction, Compiler compiler) {
173 TypeMask operandType = instruction.inputs[1].instructionType; 170 TypeMask operandType = instruction.inputs[1].instructionType;
174 if (instruction.inputs[1].isNumberOrNull(compiler)) return operandType; 171 if (instruction.inputs[1].isNumberOrNull(compiler)) return operandType;
175 return super.computeTypeFromInputTypes(instruction, compiler); 172 return super.computeTypeFromInputTypes(instruction, compiler);
176 } 173 }
177 174
178 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 175 HInstruction tryConvertToBuiltin(
179 Compiler compiler) { 176 HInvokeDynamic instruction, Compiler compiler) {
180 HInstruction input = instruction.inputs[1]; 177 HInstruction input = instruction.inputs[1];
181 if (input.isNumber(compiler)) { 178 if (input.isNumber(compiler)) {
182 return new HNegate(input, instruction.selector, input.instructionType); 179 return new HNegate(input, instruction.selector, input.instructionType);
183 } 180 }
184 return null; 181 return null;
185 } 182 }
186 } 183 }
187 184
188 abstract class BinaryArithmeticSpecializer extends InvokeDynamicSpecializer { 185 abstract class BinaryArithmeticSpecializer extends InvokeDynamicSpecializer {
189 const BinaryArithmeticSpecializer(); 186 const BinaryArithmeticSpecializer();
190 187
191 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 188 TypeMask computeTypeFromInputTypes(
192 Compiler compiler) { 189 HInvokeDynamic instruction, Compiler compiler) {
193 HInstruction left = instruction.inputs[1]; 190 HInstruction left = instruction.inputs[1];
194 HInstruction right = instruction.inputs[2]; 191 HInstruction right = instruction.inputs[2];
195 JavaScriptBackend backend = compiler.backend; 192 JavaScriptBackend backend = compiler.backend;
196 if (left.isIntegerOrNull(compiler) && right.isIntegerOrNull(compiler)) { 193 if (left.isIntegerOrNull(compiler) && right.isIntegerOrNull(compiler)) {
197 return backend.intType; 194 return backend.intType;
198 } 195 }
199 if (left.isNumberOrNull(compiler)) { 196 if (left.isNumberOrNull(compiler)) {
200 if (left.isDoubleOrNull(compiler) || right.isDoubleOrNull(compiler)) { 197 if (left.isDoubleOrNull(compiler) || right.isDoubleOrNull(compiler)) {
201 return backend.doubleType; 198 return backend.doubleType;
202 } 199 }
203 return backend.numType; 200 return backend.numType;
204 } 201 }
205 return super.computeTypeFromInputTypes(instruction, compiler); 202 return super.computeTypeFromInputTypes(instruction, compiler);
206 } 203 }
207 204
208 bool isBuiltin(HInvokeDynamic instruction, Compiler compiler) { 205 bool isBuiltin(HInvokeDynamic instruction, Compiler compiler) {
209 return instruction.inputs[1].isNumber(compiler) 206 return instruction.inputs[1].isNumber(compiler) &&
210 && instruction.inputs[2].isNumber(compiler); 207 instruction.inputs[2].isNumber(compiler);
211 } 208 }
212 209
213 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 210 HInstruction tryConvertToBuiltin(
214 Compiler compiler) { 211 HInvokeDynamic instruction, Compiler compiler) {
215 if (isBuiltin(instruction, compiler)) { 212 if (isBuiltin(instruction, compiler)) {
216 HInstruction builtin = newBuiltinVariant(instruction, compiler); 213 HInstruction builtin = newBuiltinVariant(instruction, compiler);
217 if (builtin != null) return builtin; 214 if (builtin != null) return builtin;
218 // Even if there is no builtin equivalent instruction, we know 215 // Even if there is no builtin equivalent instruction, we know
219 // the instruction does not have any side effect, and that it 216 // the instruction does not have any side effect, and that it
220 // can be GVN'ed. 217 // can be GVN'ed.
221 clearAllSideEffects(instruction); 218 clearAllSideEffects(instruction);
222 } 219 }
223 return null; 220 return null;
224 } 221 }
225 222
226 void clearAllSideEffects(HInstruction instruction) { 223 void clearAllSideEffects(HInstruction instruction) {
227 instruction.sideEffects.clearAllSideEffects(); 224 instruction.sideEffects.clearAllSideEffects();
228 instruction.sideEffects.clearAllDependencies(); 225 instruction.sideEffects.clearAllDependencies();
229 instruction.setUseGvn(); 226 instruction.setUseGvn();
230 } 227 }
231 228
232 bool inputsArePositiveIntegers(HInstruction instruction, Compiler compiler) { 229 bool inputsArePositiveIntegers(HInstruction instruction, Compiler compiler) {
233 HInstruction left = instruction.inputs[1]; 230 HInstruction left = instruction.inputs[1];
234 HInstruction right = instruction.inputs[2]; 231 HInstruction right = instruction.inputs[2];
235 return left.isPositiveIntegerOrNull(compiler) 232 return left.isPositiveIntegerOrNull(compiler) &&
236 && right.isPositiveIntegerOrNull(compiler); 233 right.isPositiveIntegerOrNull(compiler);
237 } 234 }
238 235
239 bool inputsAreUInt31(HInstruction instruction, Compiler compiler) { 236 bool inputsAreUInt31(HInstruction instruction, Compiler compiler) {
240 HInstruction left = instruction.inputs[1]; 237 HInstruction left = instruction.inputs[1];
241 HInstruction right = instruction.inputs[2]; 238 HInstruction right = instruction.inputs[2];
242 return left.isUInt31(compiler) && right.isUInt31(compiler); 239 return left.isUInt31(compiler) && right.isUInt31(compiler);
243 } 240 }
244 241
245 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler); 242 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler);
246 243
247 Selector renameToOptimizedSelector(String name, 244 Selector renameToOptimizedSelector(
248 Selector selector, 245 String name, Selector selector, Compiler compiler) {
249 Compiler compiler) {
250 if (selector.name == name) return selector; 246 if (selector.name == name) return selector;
251 JavaScriptBackend backend = compiler.backend; 247 JavaScriptBackend backend = compiler.backend;
252 return new Selector.call( 248 return new Selector.call(
253 new Name(name, backend.helpers.interceptorsLibrary), 249 new Name(name, backend.helpers.interceptorsLibrary),
254 new CallStructure(selector.argumentCount)); 250 new CallStructure(selector.argumentCount));
255 } 251 }
256 } 252 }
257 253
258 class AddSpecializer extends BinaryArithmeticSpecializer { 254 class AddSpecializer extends BinaryArithmeticSpecializer {
259 const AddSpecializer(); 255 const AddSpecializer();
260 256
261 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 257 TypeMask computeTypeFromInputTypes(
262 Compiler compiler) { 258 HInvokeDynamic instruction, Compiler compiler) {
263 if (inputsAreUInt31(instruction, compiler)) { 259 if (inputsAreUInt31(instruction, compiler)) {
264 JavaScriptBackend backend = compiler.backend; 260 JavaScriptBackend backend = compiler.backend;
265 return backend.uint32Type; 261 return backend.uint32Type;
266 } 262 }
267 if (inputsArePositiveIntegers(instruction, compiler)) { 263 if (inputsArePositiveIntegers(instruction, compiler)) {
268 JavaScriptBackend backend = compiler.backend; 264 JavaScriptBackend backend = compiler.backend;
269 return backend.positiveIntType; 265 return backend.positiveIntType;
270 } 266 }
271 return super.computeTypeFromInputTypes(instruction, compiler); 267 return super.computeTypeFromInputTypes(instruction, compiler);
272 } 268 }
273 269
274 BinaryOperation operation(ConstantSystem constantSystem) { 270 BinaryOperation operation(ConstantSystem constantSystem) {
275 return constantSystem.add; 271 return constantSystem.add;
276 } 272 }
277 273
278 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 274 HInstruction newBuiltinVariant(
279 Compiler compiler) { 275 HInvokeDynamic instruction, Compiler compiler) {
280 return new HAdd( 276 return new HAdd(instruction.inputs[1], instruction.inputs[2],
281 instruction.inputs[1], instruction.inputs[2],
282 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 277 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
283 } 278 }
284 } 279 }
285 280
286 class DivideSpecializer extends BinaryArithmeticSpecializer { 281 class DivideSpecializer extends BinaryArithmeticSpecializer {
287 const DivideSpecializer(); 282 const DivideSpecializer();
288 283
289 BinaryOperation operation(ConstantSystem constantSystem) { 284 BinaryOperation operation(ConstantSystem constantSystem) {
290 return constantSystem.divide; 285 return constantSystem.divide;
291 } 286 }
292 287
293 TypeMask computeTypeFromInputTypes(HInstruction instruction, 288 TypeMask computeTypeFromInputTypes(
294 Compiler compiler) { 289 HInstruction instruction, Compiler compiler) {
295 HInstruction left = instruction.inputs[1]; 290 HInstruction left = instruction.inputs[1];
296 JavaScriptBackend backend = compiler.backend; 291 JavaScriptBackend backend = compiler.backend;
297 if (left.isNumberOrNull(compiler)) { 292 if (left.isNumberOrNull(compiler)) {
298 return backend.doubleType; 293 return backend.doubleType;
299 } 294 }
300 return super.computeTypeFromInputTypes(instruction, compiler); 295 return super.computeTypeFromInputTypes(instruction, compiler);
301 } 296 }
302 297
303 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 298 HInstruction newBuiltinVariant(
304 Compiler compiler) { 299 HInvokeDynamic instruction, Compiler compiler) {
305 JavaScriptBackend backend = compiler.backend; 300 JavaScriptBackend backend = compiler.backend;
306 return new HDivide( 301 return new HDivide(instruction.inputs[1], instruction.inputs[2],
307 instruction.inputs[1], instruction.inputs[2],
308 instruction.selector, backend.doubleType); 302 instruction.selector, backend.doubleType);
309 } 303 }
310 } 304 }
311 305
312 class ModuloSpecializer extends BinaryArithmeticSpecializer { 306 class ModuloSpecializer extends BinaryArithmeticSpecializer {
313 const ModuloSpecializer(); 307 const ModuloSpecializer();
314 308
315 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 309 TypeMask computeTypeFromInputTypes(
316 Compiler compiler) { 310 HInvokeDynamic instruction, Compiler compiler) {
317 if (inputsArePositiveIntegers(instruction, compiler)) { 311 if (inputsArePositiveIntegers(instruction, compiler)) {
318 JavaScriptBackend backend = compiler.backend; 312 JavaScriptBackend backend = compiler.backend;
319 return backend.positiveIntType; 313 return backend.positiveIntType;
320 } 314 }
321 return super.computeTypeFromInputTypes(instruction, compiler); 315 return super.computeTypeFromInputTypes(instruction, compiler);
322 } 316 }
323 317
324 BinaryOperation operation(ConstantSystem constantSystem) { 318 BinaryOperation operation(ConstantSystem constantSystem) {
325 return constantSystem.modulo; 319 return constantSystem.modulo;
326 } 320 }
327 321
328 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 322 HInstruction newBuiltinVariant(
329 Compiler compiler) { 323 HInvokeDynamic instruction, Compiler compiler) {
330 // Modulo cannot be mapped to the native operator (different semantics). 324 // Modulo cannot be mapped to the native operator (different semantics).
331 // TODO(sra): For non-negative values we can use JavaScript's %. 325 // TODO(sra): For non-negative values we can use JavaScript's %.
332 return null; 326 return null;
333 } 327 }
334 } 328 }
335 329
336 class MultiplySpecializer extends BinaryArithmeticSpecializer { 330 class MultiplySpecializer extends BinaryArithmeticSpecializer {
337 const MultiplySpecializer(); 331 const MultiplySpecializer();
338 332
339 BinaryOperation operation(ConstantSystem constantSystem) { 333 BinaryOperation operation(ConstantSystem constantSystem) {
340 return constantSystem.multiply; 334 return constantSystem.multiply;
341 } 335 }
342 336
343 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 337 TypeMask computeTypeFromInputTypes(
344 Compiler compiler) { 338 HInvokeDynamic instruction, Compiler compiler) {
345 if (inputsArePositiveIntegers(instruction, compiler)) { 339 if (inputsArePositiveIntegers(instruction, compiler)) {
346 JavaScriptBackend backend = compiler.backend; 340 JavaScriptBackend backend = compiler.backend;
347 return backend.positiveIntType; 341 return backend.positiveIntType;
348 } 342 }
349 return super.computeTypeFromInputTypes(instruction, compiler); 343 return super.computeTypeFromInputTypes(instruction, compiler);
350 } 344 }
351 345
352 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 346 HInstruction newBuiltinVariant(
353 Compiler compiler) { 347 HInvokeDynamic instruction, Compiler compiler) {
354 return new HMultiply( 348 return new HMultiply(instruction.inputs[1], instruction.inputs[2],
355 instruction.inputs[1], instruction.inputs[2],
356 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 349 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
357 } 350 }
358 } 351 }
359 352
360 class SubtractSpecializer extends BinaryArithmeticSpecializer { 353 class SubtractSpecializer extends BinaryArithmeticSpecializer {
361 const SubtractSpecializer(); 354 const SubtractSpecializer();
362 355
363 BinaryOperation operation(ConstantSystem constantSystem) { 356 BinaryOperation operation(ConstantSystem constantSystem) {
364 return constantSystem.subtract; 357 return constantSystem.subtract;
365 } 358 }
366 359
367 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 360 HInstruction newBuiltinVariant(
368 Compiler compiler) { 361 HInvokeDynamic instruction, Compiler compiler) {
369 return new HSubtract( 362 return new HSubtract(instruction.inputs[1], instruction.inputs[2],
370 instruction.inputs[1], instruction.inputs[2],
371 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 363 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
372 } 364 }
373 } 365 }
374 366
375 class TruncatingDivideSpecializer extends BinaryArithmeticSpecializer { 367 class TruncatingDivideSpecializer extends BinaryArithmeticSpecializer {
376 const TruncatingDivideSpecializer(); 368 const TruncatingDivideSpecializer();
377 369
378 BinaryOperation operation(ConstantSystem constantSystem) { 370 BinaryOperation operation(ConstantSystem constantSystem) {
379 return constantSystem.truncatingDivide; 371 return constantSystem.truncatingDivide;
380 } 372 }
381 373
382 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 374 TypeMask computeTypeFromInputTypes(
383 Compiler compiler) { 375 HInvokeDynamic instruction, Compiler compiler) {
384 JavaScriptBackend backend = compiler.backend; 376 JavaScriptBackend backend = compiler.backend;
385 if (hasUint31Result(instruction, compiler)) { 377 if (hasUint31Result(instruction, compiler)) {
386 return backend.uint31Type; 378 return backend.uint31Type;
387 } 379 }
388 if (inputsArePositiveIntegers(instruction, compiler)) { 380 if (inputsArePositiveIntegers(instruction, compiler)) {
389 return backend.positiveIntType; 381 return backend.positiveIntType;
390 } 382 }
391 return super.computeTypeFromInputTypes(instruction, compiler); 383 return super.computeTypeFromInputTypes(instruction, compiler);
392 } 384 }
393 385
(...skipping 20 matching lines...) Expand all
414 if (left.isUInt31(compiler) && isNotZero(right, compiler)) { 406 if (left.isUInt31(compiler) && isNotZero(right, compiler)) {
415 return true; 407 return true;
416 } 408 }
417 if (left.isUInt32(compiler) && isTwoOrGreater(right, compiler)) { 409 if (left.isUInt32(compiler) && isTwoOrGreater(right, compiler)) {
418 return true; 410 return true;
419 } 411 }
420 } 412 }
421 return false; 413 return false;
422 } 414 }
423 415
424 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 416 HInstruction tryConvertToBuiltin(
425 Compiler compiler) { 417 HInvokeDynamic instruction, Compiler compiler) {
426 HInstruction right = instruction.inputs[2]; 418 HInstruction right = instruction.inputs[2];
427 if (isBuiltin(instruction, compiler)) { 419 if (isBuiltin(instruction, compiler)) {
428 if (right.isPositiveInteger(compiler) && isNotZero(right, compiler)) { 420 if (right.isPositiveInteger(compiler) && isNotZero(right, compiler)) {
429 if (hasUint31Result(instruction, compiler)) { 421 if (hasUint31Result(instruction, compiler)) {
430 return newBuiltinVariant(instruction, compiler); 422 return newBuiltinVariant(instruction, compiler);
431 } 423 }
432 // We can call _tdivFast because the rhs is a 32bit integer 424 // We can call _tdivFast because the rhs is a 32bit integer
433 // and not 0, nor -1. 425 // and not 0, nor -1.
434 instruction.selector = renameToOptimizedSelector( 426 instruction.selector = renameToOptimizedSelector(
435 '_tdivFast', instruction.selector, compiler); 427 '_tdivFast', instruction.selector, compiler);
436 } 428 }
437 clearAllSideEffects(instruction); 429 clearAllSideEffects(instruction);
438 } 430 }
439 return null; 431 return null;
440 } 432 }
441 433
442 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 434 HInstruction newBuiltinVariant(
443 Compiler compiler) { 435 HInvokeDynamic instruction, Compiler compiler) {
444 return new HTruncatingDivide( 436 return new HTruncatingDivide(instruction.inputs[1], instruction.inputs[2],
445 instruction.inputs[1], instruction.inputs[2],
446 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 437 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
447 } 438 }
448 } 439 }
449 440
450 abstract class BinaryBitOpSpecializer extends BinaryArithmeticSpecializer { 441 abstract class BinaryBitOpSpecializer extends BinaryArithmeticSpecializer {
451 const BinaryBitOpSpecializer(); 442 const BinaryBitOpSpecializer();
452 443
453 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 444 TypeMask computeTypeFromInputTypes(
454 Compiler compiler) { 445 HInvokeDynamic instruction, Compiler compiler) {
455 // All bitwise operations on primitive types either produce an 446 // All bitwise operations on primitive types either produce an
456 // integer or throw an error. 447 // integer or throw an error.
457 HInstruction left = instruction.inputs[1]; 448 HInstruction left = instruction.inputs[1];
458 JavaScriptBackend backend = compiler.backend; 449 JavaScriptBackend backend = compiler.backend;
459 if (left.isPrimitiveOrNull(compiler)) { 450 if (left.isPrimitiveOrNull(compiler)) {
460 return backend.uint32Type; 451 return backend.uint32Type;
461 } 452 }
462 return super.computeTypeFromInputTypes(instruction, compiler); 453 return super.computeTypeFromInputTypes(instruction, compiler);
463 } 454 }
464 455
(...skipping 12 matching lines...) Expand all
477 } 468 }
478 } 469 }
479 470
480 class ShiftLeftSpecializer extends BinaryBitOpSpecializer { 471 class ShiftLeftSpecializer extends BinaryBitOpSpecializer {
481 const ShiftLeftSpecializer(); 472 const ShiftLeftSpecializer();
482 473
483 BinaryOperation operation(ConstantSystem constantSystem) { 474 BinaryOperation operation(ConstantSystem constantSystem) {
484 return constantSystem.shiftLeft; 475 return constantSystem.shiftLeft;
485 } 476 }
486 477
487 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 478 HInstruction tryConvertToBuiltin(
488 Compiler compiler) { 479 HInvokeDynamic instruction, Compiler compiler) {
489 HInstruction left = instruction.inputs[1]; 480 HInstruction left = instruction.inputs[1];
490 HInstruction right = instruction.inputs[2]; 481 HInstruction right = instruction.inputs[2];
491 if (left.isNumber(compiler)) { 482 if (left.isNumber(compiler)) {
492 if (argumentLessThan32(right)) { 483 if (argumentLessThan32(right)) {
493 return newBuiltinVariant(instruction, compiler); 484 return newBuiltinVariant(instruction, compiler);
494 } 485 }
495 // Even if there is no builtin equivalent instruction, we know 486 // Even if there is no builtin equivalent instruction, we know
496 // the instruction does not have any side effect, and that it 487 // the instruction does not have any side effect, and that it
497 // can be GVN'ed. 488 // can be GVN'ed.
498 clearAllSideEffects(instruction); 489 clearAllSideEffects(instruction);
499 if (isPositive(right, compiler)) { 490 if (isPositive(right, compiler)) {
500 instruction.selector = renameToOptimizedSelector( 491 instruction.selector = renameToOptimizedSelector(
501 '_shlPositive', instruction.selector, compiler); 492 '_shlPositive', instruction.selector, compiler);
502 } 493 }
503 } 494 }
504 return null; 495 return null;
505 } 496 }
506 497
507 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 498 HInstruction newBuiltinVariant(
508 Compiler compiler) { 499 HInvokeDynamic instruction, Compiler compiler) {
509 return new HShiftLeft( 500 return new HShiftLeft(instruction.inputs[1], instruction.inputs[2],
510 instruction.inputs[1], instruction.inputs[2],
511 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 501 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
512 } 502 }
513 } 503 }
514 504
515 class ShiftRightSpecializer extends BinaryBitOpSpecializer { 505 class ShiftRightSpecializer extends BinaryBitOpSpecializer {
516 const ShiftRightSpecializer(); 506 const ShiftRightSpecializer();
517 507
518 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 508 TypeMask computeTypeFromInputTypes(
519 Compiler compiler) { 509 HInvokeDynamic instruction, Compiler compiler) {
520 HInstruction left = instruction.inputs[1]; 510 HInstruction left = instruction.inputs[1];
521 if (left.isUInt32(compiler)) return left.instructionType; 511 if (left.isUInt32(compiler)) return left.instructionType;
522 return super.computeTypeFromInputTypes(instruction, compiler); 512 return super.computeTypeFromInputTypes(instruction, compiler);
523 } 513 }
524 514
525 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 515 HInstruction tryConvertToBuiltin(
526 Compiler compiler) { 516 HInvokeDynamic instruction, Compiler compiler) {
527 HInstruction left = instruction.inputs[1]; 517 HInstruction left = instruction.inputs[1];
528 HInstruction right = instruction.inputs[2]; 518 HInstruction right = instruction.inputs[2];
529 if (left.isNumber(compiler)) { 519 if (left.isNumber(compiler)) {
530 if (argumentLessThan32(right) && isPositive(left, compiler)) { 520 if (argumentLessThan32(right) && isPositive(left, compiler)) {
531 return newBuiltinVariant(instruction, compiler); 521 return newBuiltinVariant(instruction, compiler);
532 } 522 }
533 // Even if there is no builtin equivalent instruction, we know 523 // Even if there is no builtin equivalent instruction, we know
534 // the instruction does not have any side effect, and that it 524 // the instruction does not have any side effect, and that it
535 // can be GVN'ed. 525 // can be GVN'ed.
536 clearAllSideEffects(instruction); 526 clearAllSideEffects(instruction);
537 if (isPositive(right, compiler) && isPositive(left, compiler)) { 527 if (isPositive(right, compiler) && isPositive(left, compiler)) {
538 instruction.selector = renameToOptimizedSelector( 528 instruction.selector = renameToOptimizedSelector(
539 '_shrBothPositive', instruction.selector, compiler); 529 '_shrBothPositive', instruction.selector, compiler);
540 } else if (isPositive(left, compiler) && right.isNumber(compiler)) { 530 } else if (isPositive(left, compiler) && right.isNumber(compiler)) {
541 instruction.selector = renameToOptimizedSelector( 531 instruction.selector = renameToOptimizedSelector(
542 '_shrReceiverPositive', instruction.selector, compiler); 532 '_shrReceiverPositive', instruction.selector, compiler);
543 } else if (isPositive(right, compiler)) { 533 } else if (isPositive(right, compiler)) {
544 instruction.selector = renameToOptimizedSelector( 534 instruction.selector = renameToOptimizedSelector(
545 '_shrOtherPositive', instruction.selector, compiler); 535 '_shrOtherPositive', instruction.selector, compiler);
546 } 536 }
547 } 537 }
548 return null; 538 return null;
549 } 539 }
550 540
551 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 541 HInstruction newBuiltinVariant(
552 Compiler compiler) { 542 HInvokeDynamic instruction, Compiler compiler) {
553 return new HShiftRight( 543 return new HShiftRight(instruction.inputs[1], instruction.inputs[2],
554 instruction.inputs[1], instruction.inputs[2],
555 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 544 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
556 } 545 }
557 546
558 BinaryOperation operation(ConstantSystem constantSystem) { 547 BinaryOperation operation(ConstantSystem constantSystem) {
559 return constantSystem.shiftRight; 548 return constantSystem.shiftRight;
560 } 549 }
561 } 550 }
562 551
563 class BitOrSpecializer extends BinaryBitOpSpecializer { 552 class BitOrSpecializer extends BinaryBitOpSpecializer {
564 const BitOrSpecializer(); 553 const BitOrSpecializer();
565 554
566 BinaryOperation operation(ConstantSystem constantSystem) { 555 BinaryOperation operation(ConstantSystem constantSystem) {
567 return constantSystem.bitOr; 556 return constantSystem.bitOr;
568 } 557 }
569 558
570 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 559 TypeMask computeTypeFromInputTypes(
571 Compiler compiler) { 560 HInvokeDynamic instruction, Compiler compiler) {
572 HInstruction left = instruction.inputs[1]; 561 HInstruction left = instruction.inputs[1];
573 HInstruction right = instruction.inputs[2]; 562 HInstruction right = instruction.inputs[2];
574 JavaScriptBackend backend = compiler.backend; 563 JavaScriptBackend backend = compiler.backend;
575 if (left.isUInt31(compiler) && right.isUInt31(compiler)) { 564 if (left.isUInt31(compiler) && right.isUInt31(compiler)) {
576 return backend.uint31Type; 565 return backend.uint31Type;
577 } 566 }
578 return super.computeTypeFromInputTypes(instruction, compiler); 567 return super.computeTypeFromInputTypes(instruction, compiler);
579 } 568 }
580 569
581 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 570 HInstruction newBuiltinVariant(
582 Compiler compiler) { 571 HInvokeDynamic instruction, Compiler compiler) {
583 return new HBitOr( 572 return new HBitOr(instruction.inputs[1], instruction.inputs[2],
584 instruction.inputs[1], instruction.inputs[2],
585 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 573 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
586 } 574 }
587 } 575 }
588 576
589 class BitAndSpecializer extends BinaryBitOpSpecializer { 577 class BitAndSpecializer extends BinaryBitOpSpecializer {
590 const BitAndSpecializer(); 578 const BitAndSpecializer();
591 579
592 BinaryOperation operation(ConstantSystem constantSystem) { 580 BinaryOperation operation(ConstantSystem constantSystem) {
593 return constantSystem.bitAnd; 581 return constantSystem.bitAnd;
594 } 582 }
595 583
596 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 584 TypeMask computeTypeFromInputTypes(
597 Compiler compiler) { 585 HInvokeDynamic instruction, Compiler compiler) {
598 HInstruction left = instruction.inputs[1]; 586 HInstruction left = instruction.inputs[1];
599 HInstruction right = instruction.inputs[2]; 587 HInstruction right = instruction.inputs[2];
600 JavaScriptBackend backend = compiler.backend; 588 JavaScriptBackend backend = compiler.backend;
601 if (left.isPrimitiveOrNull(compiler) && 589 if (left.isPrimitiveOrNull(compiler) &&
602 (left.isUInt31(compiler) || right.isUInt31(compiler))) { 590 (left.isUInt31(compiler) || right.isUInt31(compiler))) {
603 return backend.uint31Type; 591 return backend.uint31Type;
604 } 592 }
605 return super.computeTypeFromInputTypes(instruction, compiler); 593 return super.computeTypeFromInputTypes(instruction, compiler);
606 } 594 }
607 595
608 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 596 HInstruction newBuiltinVariant(
609 Compiler compiler) { 597 HInvokeDynamic instruction, Compiler compiler) {
610 return new HBitAnd( 598 return new HBitAnd(instruction.inputs[1], instruction.inputs[2],
611 instruction.inputs[1], instruction.inputs[2],
612 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 599 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
613 } 600 }
614 } 601 }
615 602
616 class BitXorSpecializer extends BinaryBitOpSpecializer { 603 class BitXorSpecializer extends BinaryBitOpSpecializer {
617 const BitXorSpecializer(); 604 const BitXorSpecializer();
618 605
619 BinaryOperation operation(ConstantSystem constantSystem) { 606 BinaryOperation operation(ConstantSystem constantSystem) {
620 return constantSystem.bitXor; 607 return constantSystem.bitXor;
621 } 608 }
622 609
623 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 610 TypeMask computeTypeFromInputTypes(
624 Compiler compiler) { 611 HInvokeDynamic instruction, Compiler compiler) {
625 HInstruction left = instruction.inputs[1]; 612 HInstruction left = instruction.inputs[1];
626 HInstruction right = instruction.inputs[2]; 613 HInstruction right = instruction.inputs[2];
627 JavaScriptBackend backend = compiler.backend; 614 JavaScriptBackend backend = compiler.backend;
628 if (left.isUInt31(compiler) && right.isUInt31(compiler)) { 615 if (left.isUInt31(compiler) && right.isUInt31(compiler)) {
629 return backend.uint31Type; 616 return backend.uint31Type;
630 } 617 }
631 return super.computeTypeFromInputTypes(instruction, compiler); 618 return super.computeTypeFromInputTypes(instruction, compiler);
632 } 619 }
633 620
634 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 621 HInstruction newBuiltinVariant(
635 Compiler compiler) { 622 HInvokeDynamic instruction, Compiler compiler) {
636 return new HBitXor( 623 return new HBitXor(instruction.inputs[1], instruction.inputs[2],
637 instruction.inputs[1], instruction.inputs[2],
638 instruction.selector, computeTypeFromInputTypes(instruction, compiler)); 624 instruction.selector, computeTypeFromInputTypes(instruction, compiler));
639 } 625 }
640 } 626 }
641 627
642 abstract class RelationalSpecializer extends InvokeDynamicSpecializer { 628 abstract class RelationalSpecializer extends InvokeDynamicSpecializer {
643 const RelationalSpecializer(); 629 const RelationalSpecializer();
644 630
645 TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction, 631 TypeMask computeTypeFromInputTypes(
646 Compiler compiler) { 632 HInvokeDynamic instruction, Compiler compiler) {
647 JavaScriptBackend backend = compiler.backend; 633 JavaScriptBackend backend = compiler.backend;
648 if (instruction.inputs[1].isPrimitiveOrNull(compiler)) { 634 if (instruction.inputs[1].isPrimitiveOrNull(compiler)) {
649 return backend.boolType; 635 return backend.boolType;
650 } 636 }
651 return super.computeTypeFromInputTypes(instruction, compiler); 637 return super.computeTypeFromInputTypes(instruction, compiler);
652 } 638 }
653 639
654 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 640 HInstruction tryConvertToBuiltin(
655 Compiler compiler) { 641 HInvokeDynamic instruction, Compiler compiler) {
656 HInstruction left = instruction.inputs[1]; 642 HInstruction left = instruction.inputs[1];
657 HInstruction right = instruction.inputs[2]; 643 HInstruction right = instruction.inputs[2];
658 if (left.isNumber(compiler) && right.isNumber(compiler)) { 644 if (left.isNumber(compiler) && right.isNumber(compiler)) {
659 return newBuiltinVariant(instruction, compiler); 645 return newBuiltinVariant(instruction, compiler);
660 } 646 }
661 return null; 647 return null;
662 } 648 }
663 649
664 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler); 650 HInstruction newBuiltinVariant(HInvokeDynamic instruction, Compiler compiler);
665 } 651 }
666 652
667 class EqualsSpecializer extends RelationalSpecializer { 653 class EqualsSpecializer extends RelationalSpecializer {
668 const EqualsSpecializer(); 654 const EqualsSpecializer();
669 655
670 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 656 HInstruction tryConvertToBuiltin(
671 Compiler compiler) { 657 HInvokeDynamic instruction, Compiler compiler) {
672 HInstruction left = instruction.inputs[1]; 658 HInstruction left = instruction.inputs[1];
673 HInstruction right = instruction.inputs[2]; 659 HInstruction right = instruction.inputs[2];
674 TypeMask instructionType = left.instructionType; 660 TypeMask instructionType = left.instructionType;
675 if (right.isConstantNull() || left.isPrimitiveOrNull(compiler)) { 661 if (right.isConstantNull() || left.isPrimitiveOrNull(compiler)) {
676 return newBuiltinVariant(instruction, compiler); 662 return newBuiltinVariant(instruction, compiler);
677 } 663 }
678 World world = compiler.world; 664 World world = compiler.world;
679 JavaScriptBackend backend = compiler.backend; 665 JavaScriptBackend backend = compiler.backend;
680 Iterable<Element> matches = world.allFunctions.filter( 666 Iterable<Element> matches =
681 instruction.selector, instructionType); 667 world.allFunctions.filter(instruction.selector, instructionType);
682 // This test relies the on `Object.==` and `Interceptor.==` always being 668 // This test relies the on `Object.==` and `Interceptor.==` always being
683 // implemented because if the selector matches by subtype, it still will be 669 // implemented because if the selector matches by subtype, it still will be
684 // a regular object or an interceptor. 670 // a regular object or an interceptor.
685 if (matches.every(backend.isDefaultEqualityImplementation)) { 671 if (matches.every(backend.isDefaultEqualityImplementation)) {
686 return newBuiltinVariant(instruction, compiler); 672 return newBuiltinVariant(instruction, compiler);
687 } 673 }
688 return null; 674 return null;
689 } 675 }
690 676
691 BinaryOperation operation(ConstantSystem constantSystem) { 677 BinaryOperation operation(ConstantSystem constantSystem) {
692 return constantSystem.equal; 678 return constantSystem.equal;
693 } 679 }
694 680
695 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 681 HInstruction newBuiltinVariant(
696 Compiler compiler) { 682 HInvokeDynamic instruction, Compiler compiler) {
697 JavaScriptBackend backend = compiler.backend; 683 JavaScriptBackend backend = compiler.backend;
698 return new HIdentity( 684 return new HIdentity(instruction.inputs[1], instruction.inputs[2],
699 instruction.inputs[1], instruction.inputs[2],
700 instruction.selector, backend.boolType); 685 instruction.selector, backend.boolType);
701 } 686 }
702 } 687 }
703 688
704 class LessSpecializer extends RelationalSpecializer { 689 class LessSpecializer extends RelationalSpecializer {
705 const LessSpecializer(); 690 const LessSpecializer();
706 691
707 BinaryOperation operation(ConstantSystem constantSystem) { 692 BinaryOperation operation(ConstantSystem constantSystem) {
708 return constantSystem.less; 693 return constantSystem.less;
709 } 694 }
710 695
711 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 696 HInstruction newBuiltinVariant(
712 Compiler compiler) { 697 HInvokeDynamic instruction, Compiler compiler) {
713 JavaScriptBackend backend = compiler.backend; 698 JavaScriptBackend backend = compiler.backend;
714 return new HLess( 699 return new HLess(instruction.inputs[1], instruction.inputs[2],
715 instruction.inputs[1], instruction.inputs[2],
716 instruction.selector, backend.boolType); 700 instruction.selector, backend.boolType);
717 } 701 }
718 } 702 }
719 703
720 class GreaterSpecializer extends RelationalSpecializer { 704 class GreaterSpecializer extends RelationalSpecializer {
721 const GreaterSpecializer(); 705 const GreaterSpecializer();
722 706
723 BinaryOperation operation(ConstantSystem constantSystem) { 707 BinaryOperation operation(ConstantSystem constantSystem) {
724 return constantSystem.greater; 708 return constantSystem.greater;
725 } 709 }
726 710
727 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 711 HInstruction newBuiltinVariant(
728 Compiler compiler) { 712 HInvokeDynamic instruction, Compiler compiler) {
729 JavaScriptBackend backend = compiler.backend; 713 JavaScriptBackend backend = compiler.backend;
730 return new HGreater( 714 return new HGreater(instruction.inputs[1], instruction.inputs[2],
731 instruction.inputs[1], instruction.inputs[2],
732 instruction.selector, backend.boolType); 715 instruction.selector, backend.boolType);
733 } 716 }
734 } 717 }
735 718
736 class GreaterEqualSpecializer extends RelationalSpecializer { 719 class GreaterEqualSpecializer extends RelationalSpecializer {
737 const GreaterEqualSpecializer(); 720 const GreaterEqualSpecializer();
738 721
739 BinaryOperation operation(ConstantSystem constantSystem) { 722 BinaryOperation operation(ConstantSystem constantSystem) {
740 return constantSystem.greaterEqual; 723 return constantSystem.greaterEqual;
741 } 724 }
742 725
743 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 726 HInstruction newBuiltinVariant(
744 Compiler compiler) { 727 HInvokeDynamic instruction, Compiler compiler) {
745 JavaScriptBackend backend = compiler.backend; 728 JavaScriptBackend backend = compiler.backend;
746 return new HGreaterEqual( 729 return new HGreaterEqual(instruction.inputs[1], instruction.inputs[2],
747 instruction.inputs[1], instruction.inputs[2],
748 instruction.selector, backend.boolType); 730 instruction.selector, backend.boolType);
749 } 731 }
750 } 732 }
751 733
752 class LessEqualSpecializer extends RelationalSpecializer { 734 class LessEqualSpecializer extends RelationalSpecializer {
753 const LessEqualSpecializer(); 735 const LessEqualSpecializer();
754 736
755 BinaryOperation operation(ConstantSystem constantSystem) { 737 BinaryOperation operation(ConstantSystem constantSystem) {
756 return constantSystem.lessEqual; 738 return constantSystem.lessEqual;
757 } 739 }
758 740
759 HInstruction newBuiltinVariant(HInvokeDynamic instruction, 741 HInstruction newBuiltinVariant(
760 Compiler compiler) { 742 HInvokeDynamic instruction, Compiler compiler) {
761 JavaScriptBackend backend = compiler.backend; 743 JavaScriptBackend backend = compiler.backend;
762 return new HLessEqual( 744 return new HLessEqual(instruction.inputs[1], instruction.inputs[2],
763 instruction.inputs[1], instruction.inputs[2],
764 instruction.selector, backend.boolType); 745 instruction.selector, backend.boolType);
765 } 746 }
766 } 747 }
767 748
768 class CodeUnitAtSpecializer extends InvokeDynamicSpecializer { 749 class CodeUnitAtSpecializer extends InvokeDynamicSpecializer {
769 const CodeUnitAtSpecializer(); 750 const CodeUnitAtSpecializer();
770 751
771 BinaryOperation operation(ConstantSystem constantSystem) { 752 BinaryOperation operation(ConstantSystem constantSystem) {
772 return constantSystem.codeUnitAt; 753 return constantSystem.codeUnitAt;
773 } 754 }
774 755
775 HInstruction tryConvertToBuiltin(HInvokeDynamic instruction, 756 HInstruction tryConvertToBuiltin(
776 Compiler compiler) { 757 HInvokeDynamic instruction, Compiler compiler) {
777 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index 758 // TODO(sra): Implement a builtin HCodeUnitAt instruction and the same index
778 // bounds checking optimizations as for HIndex. 759 // bounds checking optimizations as for HIndex.
779 return null; 760 return null;
780 } 761 }
781 } 762 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/interceptor_simplifier.dart ('k') | pkg/compiler/lib/src/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698