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

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

Issue 1020853003: Split HForeign into HForeignCode and abstract base class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Formatting Created 5 years, 9 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 | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | pkg/compiler/lib/src/ssa/ssa_tracer.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);
11 R visitBitNot(HBitNot node); 11 R visitBitNot(HBitNot node);
12 R visitBitOr(HBitOr node); 12 R visitBitOr(HBitOr node);
13 R visitBitXor(HBitXor node); 13 R visitBitXor(HBitXor node);
14 R visitBoolify(HBoolify node); 14 R visitBoolify(HBoolify node);
15 R visitBoundsCheck(HBoundsCheck node); 15 R visitBoundsCheck(HBoundsCheck node);
16 R visitBreak(HBreak node); 16 R visitBreak(HBreak node);
17 R visitConstant(HConstant node); 17 R visitConstant(HConstant node);
18 R visitContinue(HContinue node); 18 R visitContinue(HContinue node);
19 R visitDivide(HDivide node); 19 R visitDivide(HDivide node);
20 R visitExit(HExit node); 20 R visitExit(HExit node);
21 R visitExitTry(HExitTry node); 21 R visitExitTry(HExitTry node);
22 R visitFieldGet(HFieldGet node); 22 R visitFieldGet(HFieldGet node);
23 R visitFieldSet(HFieldSet node); 23 R visitFieldSet(HFieldSet node);
24 R visitForeign(HForeign node); 24 R visitForeignCode(HForeignCode node);
25 R visitForeignNew(HForeignNew node); 25 R visitForeignNew(HForeignNew node);
26 R visitGoto(HGoto node); 26 R visitGoto(HGoto node);
27 R visitGreater(HGreater node); 27 R visitGreater(HGreater node);
28 R visitGreaterEqual(HGreaterEqual node); 28 R visitGreaterEqual(HGreaterEqual node);
29 R visitIdentity(HIdentity node); 29 R visitIdentity(HIdentity node);
30 R visitIf(HIf node); 30 R visitIf(HIf node);
31 R visitIndex(HIndex node); 31 R visitIndex(HIndex node);
32 R visitIndexAssign(HIndexAssign node); 32 R visitIndexAssign(HIndexAssign node);
33 R visitInterceptor(HInterceptor node); 33 R visitInterceptor(HInterceptor node);
34 R visitInvokeClosure(HInvokeClosure node); 34 R visitInvokeClosure(HInvokeClosure node);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 visitBoundsCheck(HBoundsCheck node) => visitCheck(node); 285 visitBoundsCheck(HBoundsCheck node) => visitCheck(node);
286 visitBreak(HBreak node) => visitJump(node); 286 visitBreak(HBreak node) => visitJump(node);
287 visitContinue(HContinue node) => visitJump(node); 287 visitContinue(HContinue node) => visitJump(node);
288 visitCheck(HCheck node) => visitInstruction(node); 288 visitCheck(HCheck node) => visitInstruction(node);
289 visitConstant(HConstant node) => visitInstruction(node); 289 visitConstant(HConstant node) => visitInstruction(node);
290 visitDivide(HDivide node) => visitBinaryArithmetic(node); 290 visitDivide(HDivide node) => visitBinaryArithmetic(node);
291 visitExit(HExit node) => visitControlFlow(node); 291 visitExit(HExit node) => visitControlFlow(node);
292 visitExitTry(HExitTry node) => visitControlFlow(node); 292 visitExitTry(HExitTry node) => visitControlFlow(node);
293 visitFieldGet(HFieldGet node) => visitFieldAccess(node); 293 visitFieldGet(HFieldGet node) => visitFieldAccess(node);
294 visitFieldSet(HFieldSet node) => visitFieldAccess(node); 294 visitFieldSet(HFieldSet node) => visitFieldAccess(node);
295 visitForeign(HForeign node) => visitInstruction(node); 295 visitForeignCode(HForeignCode node) => visitInstruction(node);
296 visitForeignNew(HForeignNew node) => visitForeign(node); 296 visitForeignNew(HForeignNew node) => visitInstruction(node);
297 visitGoto(HGoto node) => visitControlFlow(node); 297 visitGoto(HGoto node) => visitControlFlow(node);
298 visitGreater(HGreater node) => visitRelational(node); 298 visitGreater(HGreater node) => visitRelational(node);
299 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); 299 visitGreaterEqual(HGreaterEqual node) => visitRelational(node);
300 visitIdentity(HIdentity node) => visitRelational(node); 300 visitIdentity(HIdentity node) => visitRelational(node);
301 visitIf(HIf node) => visitConditionalBranch(node); 301 visitIf(HIf node) => visitConditionalBranch(node);
302 visitIndex(HIndex node) => visitInstruction(node); 302 visitIndex(HIndex node) => visitInstruction(node);
303 visitIndexAssign(HIndexAssign node) => visitInstruction(node); 303 visitIndexAssign(HIndexAssign node) => visitInstruction(node);
304 visitInterceptor(HInterceptor node) => visitInstruction(node); 304 visitInterceptor(HInterceptor node) => visitInstruction(node);
305 visitInvokeClosure(HInvokeClosure node) 305 visitInvokeClosure(HInvokeClosure node)
306 => visitInvokeDynamic(node); 306 => visitInvokeDynamic(node);
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 : super(variable, <HInstruction>[local, value], 1691 : super(variable, <HInstruction>[local, value],
1692 const TypeMask.nonNullEmpty()); 1692 const TypeMask.nonNullEmpty());
1693 1693
1694 accept(HVisitor visitor) => visitor.visitLocalSet(this); 1694 accept(HVisitor visitor) => visitor.visitLocalSet(this);
1695 1695
1696 HLocalValue get local => inputs[0]; 1696 HLocalValue get local => inputs[0];
1697 HInstruction get value => inputs[1]; 1697 HInstruction get value => inputs[1];
1698 bool isJsStatement() => true; 1698 bool isJsStatement() => true;
1699 } 1699 }
1700 1700
1701 class HForeign extends HInstruction { 1701 abstract class HForeign extends HInstruction {
1702 HForeign(TypeMask type, List<HInstruction> inputs) : super(inputs, type);
1703
1704 bool get isStatement => false;
1705 native.NativeBehavior get nativeBehavior => null;
1706
1707 bool canThrow() {
1708 return sideEffects.hasSideEffects()
1709 || sideEffects.dependsOnSomething();
1710 }
1711 }
1712
1713 class HForeignCode extends HForeign {
1702 final js.Template codeTemplate; 1714 final js.Template codeTemplate;
1703 final bool isStatement; 1715 final bool isStatement;
1704 final bool _canThrow; 1716 final bool _canThrow;
1705 final native.NativeBehavior nativeBehavior; 1717 final native.NativeBehavior nativeBehavior;
1706 1718
1707 HForeign(this.codeTemplate, 1719 HForeignCode(this.codeTemplate,
1708 TypeMask type, 1720 TypeMask type,
1709 List<HInstruction> inputs, 1721 List<HInstruction> inputs,
1710 {this.isStatement: false, 1722 {this.isStatement: false,
1711 SideEffects effects, 1723 SideEffects effects,
1712 native.NativeBehavior nativeBehavior, 1724 native.NativeBehavior nativeBehavior,
1713 canThrow: false}) 1725 canThrow: false})
1714 : this.nativeBehavior = nativeBehavior, 1726 : this.nativeBehavior = nativeBehavior,
1715 this._canThrow = canThrow, 1727 this._canThrow = canThrow,
1716 super(inputs, type) { 1728 super(type, inputs) {
1729 if(codeTemplate == null) throw this;
sra1 2015/03/24 03:00:47 space after 'if'
herhut 2015/05/26 14:32:18 This has been fixed in the meanwhile.
1717 if (effects == null && nativeBehavior != null) { 1730 if (effects == null && nativeBehavior != null) {
1718 effects = nativeBehavior.sideEffects; 1731 effects = nativeBehavior.sideEffects;
1719 } 1732 }
1720 if (effects != null) sideEffects.add(effects); 1733 if (effects != null) sideEffects.add(effects);
1721 } 1734 }
1722 1735
1723 HForeign.statement(codeTemplate, List<HInstruction> inputs, 1736 HForeignCode.statement(codeTemplate, List<HInstruction> inputs,
1724 SideEffects effects, 1737 SideEffects effects,
1725 native.NativeBehavior nativeBehavior, 1738 native.NativeBehavior nativeBehavior,
1726 TypeMask type) 1739 TypeMask type)
1727 : this(codeTemplate, type, inputs, isStatement: true, 1740 : this(codeTemplate, type, inputs, isStatement: true,
1728 effects: effects, nativeBehavior: nativeBehavior); 1741 effects: effects, nativeBehavior: nativeBehavior);
1729 1742
1730 accept(HVisitor visitor) => visitor.visitForeign(this); 1743 accept(HVisitor visitor) => visitor.visitForeignCode(this);
1731 1744
1732 bool isJsStatement() => isStatement; 1745 bool isJsStatement() => isStatement;
1733 bool canThrow() { 1746 bool canThrow() => _canThrow || super.canThrow();
1734 return _canThrow
1735 || sideEffects.hasSideEffects()
1736 || sideEffects.dependsOnSomething();
1737 }
1738 } 1747 }
1739 1748
1740 class HForeignNew extends HForeign { 1749 class HForeignNew extends HForeign {
1741 ClassElement element; 1750 ClassElement element;
1742 1751
1743 /// If this field is not `null`, this call is from an inlined constructor and 1752 /// If this field is not `null`, this call is from an inlined constructor and
1744 /// we have to register the instantiated type in the code generator. The 1753 /// we have to register the instantiated type in the code generator. The
1745 /// [instructionType] of this node is not enough, because we also need the 1754 /// [instructionType] of this node is not enough, because we also need the
1746 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. 1755 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations].
1747 List<DartType> instantiatedTypes; 1756 List<DartType> instantiatedTypes;
1748 1757
1749 HForeignNew(this.element, TypeMask type, List<HInstruction> inputs, 1758 HForeignNew(this.element, TypeMask type, List<HInstruction> inputs,
1750 [this.instantiatedTypes]) 1759 [this.instantiatedTypes])
1751 : super(null, type, inputs); 1760 : super(type, inputs);
1752 1761
1753 accept(HVisitor visitor) => visitor.visitForeignNew(this); 1762 accept(HVisitor visitor) => visitor.visitForeignNew(this);
1754 } 1763 }
1755 1764
1756 abstract class HInvokeBinary extends HInstruction { 1765 abstract class HInvokeBinary extends HInstruction {
1757 final Selector selector; 1766 final Selector selector;
1758 HInvokeBinary(HInstruction left, HInstruction right, this.selector, type) 1767 HInvokeBinary(HInstruction left, HInstruction right, this.selector, type)
1759 : super(<HInstruction>[left, right], type) { 1768 : super(<HInstruction>[left, right], type) {
1760 sideEffects.clearAllSideEffects(); 1769 sideEffects.clearAllSideEffects();
1761 sideEffects.clearAllDependencies(); 1770 sideEffects.clearAllDependencies();
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 class HDynamicType extends HRuntimeType { 3131 class HDynamicType extends HRuntimeType {
3123 HDynamicType(DynamicType dartType, TypeMask instructionType) 3132 HDynamicType(DynamicType dartType, TypeMask instructionType)
3124 : super(const <HInstruction>[], dartType, instructionType); 3133 : super(const <HInstruction>[], dartType, instructionType);
3125 3134
3126 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3135 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3127 3136
3128 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3137 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3129 3138
3130 bool typeEquals(HInstruction other) => other is HDynamicType; 3139 bool typeEquals(HInstruction other) => other is HDynamicType;
3131 } 3140 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/codegen.dart ('k') | pkg/compiler/lib/src/ssa/ssa_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698