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

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

Issue 1079803002: Make HForeignCode 'isAllocation' property available to optimization (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/optimize.dart » ('j') | 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 part of ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitAwait(HAwait node); 9 R visitAwait(HAwait node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 * A pure instruction is an instruction that does not have any side 835 * A pure instruction is an instruction that does not have any side
836 * effect, nor any dependency. They can be moved anywhere in the 836 * effect, nor any dependency. They can be moved anywhere in the
837 * graph. 837 * graph.
838 */ 838 */
839 bool isPure() { 839 bool isPure() {
840 return !sideEffects.hasSideEffects() 840 return !sideEffects.hasSideEffects()
841 && !sideEffects.dependsOnSomething() 841 && !sideEffects.dependsOnSomething()
842 && !canThrow(); 842 && !canThrow();
843 } 843 }
844 844
845 /// An instruction is an 'allocation' is it is the sole alias for an object.
846 /// This applies to to instructions that allocate new objects and can be
847 /// extended to methods that return other allocations without escaping them.
848 bool isAllocation() => false;
849
845 /// Overridden by [HCheck] to return the actual non-[HCheck] 850 /// Overridden by [HCheck] to return the actual non-[HCheck]
846 /// instruction it checks against. 851 /// instruction it checks against.
847 HInstruction nonCheck() => this; 852 HInstruction nonCheck() => this;
848 853
849 /// Can this node throw an exception? 854 /// Can this node throw an exception?
850 bool canThrow() => false; 855 bool canThrow() => false;
851 856
852 /// Does this node potentially affect control flow. 857 /// Does this node potentially affect control flow.
853 bool isControlFlow() => false; 858 bool isControlFlow() => false;
854 859
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 SideEffects effects, 1749 SideEffects effects,
1745 native.NativeBehavior nativeBehavior, 1750 native.NativeBehavior nativeBehavior,
1746 TypeMask type) 1751 TypeMask type)
1747 : this(codeTemplate, type, inputs, isStatement: true, 1752 : this(codeTemplate, type, inputs, isStatement: true,
1748 effects: effects, nativeBehavior: nativeBehavior); 1753 effects: effects, nativeBehavior: nativeBehavior);
1749 1754
1750 accept(HVisitor visitor) => visitor.visitForeignCode(this); 1755 accept(HVisitor visitor) => visitor.visitForeignCode(this);
1751 1756
1752 bool isJsStatement() => isStatement; 1757 bool isJsStatement() => isStatement;
1753 bool canThrow() => throwBehavior.canThrow; 1758 bool canThrow() => throwBehavior.canThrow;
1759
1760 bool isAllocation() => nativeBehavior != null &&
floitsch 2015/04/13 07:54:56 this is a getter name. -> should be a getter. same
sra1 2015/04/13 17:12:43 Done. At first I thought I might need an argument
1761 nativeBehavior.isAllocation &&
1762 !canBeNull();
1754 } 1763 }
1755 1764
1756 class HForeignNew extends HForeign { 1765 class HForeignNew extends HForeign {
1757 ClassElement element; 1766 ClassElement element;
1758 1767
1759 /// If this field is not `null`, this call is from an inlined constructor and 1768 /// If this field is not `null`, this call is from an inlined constructor and
1760 /// we have to register the instantiated type in the code generator. The 1769 /// we have to register the instantiated type in the code generator. The
1761 /// [instructionType] of this node is not enough, because we also need the 1770 /// [instructionType] of this node is not enough, because we also need the
1762 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. 1771 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations].
1763 List<DartType> instantiatedTypes; 1772 List<DartType> instantiatedTypes;
1764 1773
1765 HForeignNew(this.element, TypeMask type, List<HInstruction> inputs, 1774 HForeignNew(this.element, TypeMask type, List<HInstruction> inputs,
1766 [this.instantiatedTypes]) 1775 [this.instantiatedTypes])
1767 : super(type, inputs); 1776 : super(type, inputs);
1768 1777
1769 accept(HVisitor visitor) => visitor.visitForeignNew(this); 1778 accept(HVisitor visitor) => visitor.visitForeignNew(this);
1779
1780 bool isAllocation() => true;
1770 } 1781 }
1771 1782
1772 abstract class HInvokeBinary extends HInstruction { 1783 abstract class HInvokeBinary extends HInstruction {
1773 final Selector selector; 1784 final Selector selector;
1774 HInvokeBinary(HInstruction left, HInstruction right, this.selector, type) 1785 HInvokeBinary(HInstruction left, HInstruction right, this.selector, type)
1775 : super(<HInstruction>[left, right], type) { 1786 : super(<HInstruction>[left, right], type) {
1776 sideEffects.clearAllSideEffects(); 1787 sideEffects.clearAllSideEffects();
1777 sideEffects.clearAllDependencies(); 1788 sideEffects.clearAllDependencies();
1778 setUseGvn(); 1789 setUseGvn();
1779 } 1790 }
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 int typeCode() => HInstruction.STATIC_STORE_TYPECODE; 2415 int typeCode() => HInstruction.STATIC_STORE_TYPECODE;
2405 bool typeEquals(other) => other is HStaticStore; 2416 bool typeEquals(other) => other is HStaticStore;
2406 bool dataEquals(HStaticStore other) => element == other.element; 2417 bool dataEquals(HStaticStore other) => element == other.element;
2407 bool isJsStatement() => true; 2418 bool isJsStatement() => true;
2408 } 2419 }
2409 2420
2410 class HLiteralList extends HInstruction { 2421 class HLiteralList extends HInstruction {
2411 HLiteralList(List<HInstruction> inputs, TypeMask type) : super(inputs, type); 2422 HLiteralList(List<HInstruction> inputs, TypeMask type) : super(inputs, type);
2412 toString() => 'literal list'; 2423 toString() => 'literal list';
2413 accept(HVisitor visitor) => visitor.visitLiteralList(this); 2424 accept(HVisitor visitor) => visitor.visitLiteralList(this);
2425
2426 bool isAllocation() => true;
2414 } 2427 }
2415 2428
2416 /** 2429 /**
2417 * The primitive array indexing operation. Note that this instruction 2430 * The primitive array indexing operation. Note that this instruction
2418 * does not throw because we generate the checks explicitly. 2431 * does not throw because we generate the checks explicitly.
2419 */ 2432 */
2420 class HIndex extends HInstruction { 2433 class HIndex extends HInstruction {
2421 final Selector selector; 2434 final Selector selector;
2422 HIndex(HInstruction receiver, HInstruction index, this.selector, type) 2435 HIndex(HInstruction receiver, HInstruction index, this.selector, type)
2423 : super(<HInstruction>[receiver, index], type) { 2436 : super(<HInstruction>[receiver, index], type) {
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 class HDynamicType extends HRuntimeType { 3171 class HDynamicType extends HRuntimeType {
3159 HDynamicType(DynamicType dartType, TypeMask instructionType) 3172 HDynamicType(DynamicType dartType, TypeMask instructionType)
3160 : super(const <HInstruction>[], dartType, instructionType); 3173 : super(const <HInstruction>[], dartType, instructionType);
3161 3174
3162 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3175 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3163 3176
3164 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3177 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3165 3178
3166 bool typeEquals(HInstruction other) => other is HDynamicType; 3179 bool typeEquals(HInstruction other) => other is HDynamicType;
3167 } 3180 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698