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

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

Issue 2320583002: Introduce OpenWorld. (Closed)
Patch Set: Created 4 years, 3 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 '../common/tasks.dart' show CompilerTask; 6 import '../common/tasks.dart' show CompilerTask;
7 import '../compiler.dart' show Compiler; 7 import '../compiler.dart' show Compiler;
8 import '../constants/constant_system.dart'; 8 import '../constants/constant_system.dart';
9 import '../constants/values.dart'; 9 import '../constants/values.dart';
10 import '../core_types.dart' show CoreClasses; 10 import '../core_types.dart' show CoreClasses;
11 import '../dart_types.dart'; 11 import '../dart_types.dart';
12 import '../elements/elements.dart'; 12 import '../elements/elements.dart';
13 import '../js/js.dart' as js; 13 import '../js/js.dart' as js;
14 import '../js_backend/backend_helpers.dart' show BackendHelpers; 14 import '../js_backend/backend_helpers.dart' show BackendHelpers;
15 import '../js_backend/js_backend.dart'; 15 import '../js_backend/js_backend.dart';
16 import '../native/native.dart' as native; 16 import '../native/native.dart' as native;
17 import '../tree/dartstring.dart' as ast; 17 import '../tree/dartstring.dart' as ast;
18 import '../types/types.dart'; 18 import '../types/types.dart';
19 import '../universe/selector.dart' show Selector; 19 import '../universe/selector.dart' show Selector;
20 import '../universe/side_effects.dart' show SideEffects; 20 import '../universe/side_effects.dart' show SideEffects;
21 import '../util/util.dart'; 21 import '../util/util.dart';
22 import '../world.dart' show ClassWorld, World; 22 import '../world.dart' show ClassWorld;
23 import 'interceptor_simplifier.dart'; 23 import 'interceptor_simplifier.dart';
24 import 'nodes.dart'; 24 import 'nodes.dart';
25 import 'types.dart'; 25 import 'types.dart';
26 import 'types_propagation.dart'; 26 import 'types_propagation.dart';
27 import 'value_range_analyzer.dart'; 27 import 'value_range_analyzer.dart';
28 import 'value_set.dart'; 28 import 'value_set.dart';
29 29
30 abstract class OptimizationPhase { 30 abstract class OptimizationPhase {
31 String get name; 31 String get name;
32 void visitGraph(HGraph graph); 32 void visitGraph(HGraph graph);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 node.specializer.tryConvertToBuiltin(node, compiler); 366 node.specializer.tryConvertToBuiltin(node, compiler);
367 if (instruction != null) return instruction; 367 if (instruction != null) return instruction;
368 368
369 Selector selector = node.selector; 369 Selector selector = node.selector;
370 TypeMask mask = node.mask; 370 TypeMask mask = node.mask;
371 HInstruction input = node.inputs[1]; 371 HInstruction input = node.inputs[1];
372 372
373 ClassWorld world = compiler.closedWorld; 373 ClassWorld world = compiler.closedWorld;
374 374
375 bool applies(Element element) { 375 bool applies(Element element) {
376 return selector.applies(element, world) && 376 return selector.applies(element, backend) &&
377 (mask == null || mask.canHit(element, selector, world)); 377 (mask == null || mask.canHit(element, selector, world));
378 } 378 }
379 379
380 if (selector.isCall || selector.isOperator) { 380 if (selector.isCall || selector.isOperator) {
381 Element target; 381 Element target;
382 if (input.isExtendableArray(compiler)) { 382 if (input.isExtendableArray(compiler)) {
383 if (applies(helpers.jsArrayRemoveLast)) { 383 if (applies(helpers.jsArrayRemoveLast)) {
384 target = helpers.jsArrayRemoveLast; 384 target = helpers.jsArrayRemoveLast;
385 } else if (applies(helpers.jsArrayAdd)) { 385 } else if (applies(helpers.jsArrayAdd)) {
386 // The codegen special cases array calls, but does not 386 // The codegen special cases array calls, but does not
(...skipping 28 matching lines...) Expand all
415 // HForeign is too opaque for the SsaCheckInserter (that adds a 415 // HForeign is too opaque for the SsaCheckInserter (that adds a
416 // bounds check on removeLast). Once we start inlining, the 416 // bounds check on removeLast). Once we start inlining, the
417 // bounds check will become explicit, so we won't need this 417 // bounds check will become explicit, so we won't need this
418 // optimization. 418 // optimization.
419 HInvokeDynamicMethod result = new HInvokeDynamicMethod(node.selector, 419 HInvokeDynamicMethod result = new HInvokeDynamicMethod(node.selector,
420 node.mask, node.inputs.sublist(1), node.instructionType); 420 node.mask, node.inputs.sublist(1), node.instructionType);
421 result.element = target; 421 result.element = target;
422 return result; 422 return result;
423 } 423 }
424 } else if (selector.isGetter) { 424 } else if (selector.isGetter) {
425 if (selector.applies(helpers.jsIndexableLength, world)) { 425 if (selector.applies(helpers.jsIndexableLength, backend)) {
426 HInstruction optimized = tryOptimizeLengthInterceptedGetter(node); 426 HInstruction optimized = tryOptimizeLengthInterceptedGetter(node);
427 if (optimized != null) return optimized; 427 if (optimized != null) return optimized;
428 } 428 }
429 } 429 }
430 430
431 return node; 431 return node;
432 } 432 }
433 433
434 HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) { 434 HInstruction visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
435 propagateConstantValueToUses(node); 435 propagateConstantValueToUses(node);
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 2580
2581 keyedValues.forEach((receiver, values) { 2581 keyedValues.forEach((receiver, values) {
2582 result.keyedValues[receiver] = 2582 result.keyedValues[receiver] =
2583 new Map<HInstruction, HInstruction>.from(values); 2583 new Map<HInstruction, HInstruction>.from(values);
2584 }); 2584 });
2585 2585
2586 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2586 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2587 return result; 2587 return result;
2588 } 2588 }
2589 } 2589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698