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

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

Issue 2395623002: Improvement to SsaLoadElimination (Closed)
Patch Set: format Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CodegenRegistry, CodegenWorkItem; 5 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
6 import '../common/names.dart' show Selectors; 6 import '../common/names.dart' show Selectors;
7 import '../common/tasks.dart' show CompilerTask; 7 import '../common/tasks.dart' show CompilerTask;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 return phi; 2597 return phi;
2598 } 2598 }
2599 } 2599 }
2600 2600
2601 /** 2601 /**
2602 * Returns the intersection between [this] and [other]. 2602 * Returns the intersection between [this] and [other].
2603 */ 2603 */
2604 MemorySet intersectionFor( 2604 MemorySet intersectionFor(
2605 MemorySet other, HBasicBlock block, int predecessorIndex) { 2605 MemorySet other, HBasicBlock block, int predecessorIndex) {
2606 MemorySet result = new MemorySet(compiler); 2606 MemorySet result = new MemorySet(compiler);
2607 if (other == null) return result; 2607 if (other == null) {
2608 // This is the first visit to a loop header ([other] is `null` because we
2609 // have not visited the back edge). Copy the nonEscapingReceivers that are
2610 // guaranteed to survive the loop because they are not escaped before
2611 // method exit.
2612 // TODO(sra): We should do a proper dataflow to find the maximal
2613 // nonEscapingReceivers (a variant of Available-Expressions), which must
2614 // converge before we edit the program in [findCommonInstruction].
2615 for (HInstruction instruction in nonEscapingReceivers) {
2616 bool isNonEscapingUse(HInstruction use) {
2617 if (use is HReturn) return true; // Escapes, but so does control.
2618 if (use is HFieldGet) return true;
2619 if (use is HFieldSet &&
2620 use.receiver.nonCheck() == instruction &&
2621 use.value.nonCheck() != instruction) {
2622 return true;
2623 }
2624 if (use is HTypeInfoReadVariable) return true;
2625 return false;
2626 }
2627
2628 if (instruction.usedBy.every(isNonEscapingUse)) {
2629 result.nonEscapingReceivers.add(instruction);
2630 }
2631 }
2632 return result;
2633 }
2608 2634
2609 fieldValues.forEach((element, values) { 2635 fieldValues.forEach((element, values) {
2610 var otherValues = other.fieldValues[element]; 2636 var otherValues = other.fieldValues[element];
2611 if (otherValues == null) return; 2637 if (otherValues == null) return;
2612 values.forEach((receiver, value) { 2638 values.forEach((receiver, value) {
2613 HInstruction instruction = findCommonInstruction( 2639 HInstruction instruction = findCommonInstruction(
2614 value, otherValues[receiver], block, predecessorIndex); 2640 value, otherValues[receiver], block, predecessorIndex);
2615 if (instruction != null) { 2641 if (instruction != null) {
2616 result.registerFieldValue(element, receiver, instruction); 2642 result.registerFieldValue(element, receiver, instruction);
2617 } 2643 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 2677
2652 keyedValues.forEach((receiver, values) { 2678 keyedValues.forEach((receiver, values) {
2653 result.keyedValues[receiver] = 2679 result.keyedValues[receiver] =
2654 new Map<HInstruction, HInstruction>.from(values); 2680 new Map<HInstruction, HInstruction>.from(values);
2655 }); 2681 });
2656 2682
2657 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2683 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2658 return result; 2684 return result;
2659 } 2685 }
2660 } 2686 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698