| OLD | NEW |
| 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 '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common/backend_api.dart' show BackendClasses; | 7 import '../common/backend_api.dart' show BackendClasses; |
| 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 26 matching lines...) Expand all Loading... |
| 37 R visitBreak(HBreak node); | 37 R visitBreak(HBreak node); |
| 38 R visitConstant(HConstant node); | 38 R visitConstant(HConstant node); |
| 39 R visitContinue(HContinue node); | 39 R visitContinue(HContinue node); |
| 40 R visitCreate(HCreate node); | 40 R visitCreate(HCreate node); |
| 41 R visitDivide(HDivide node); | 41 R visitDivide(HDivide node); |
| 42 R visitExit(HExit node); | 42 R visitExit(HExit node); |
| 43 R visitExitTry(HExitTry node); | 43 R visitExitTry(HExitTry node); |
| 44 R visitFieldGet(HFieldGet node); | 44 R visitFieldGet(HFieldGet node); |
| 45 R visitFieldSet(HFieldSet node); | 45 R visitFieldSet(HFieldSet node); |
| 46 R visitForeignCode(HForeignCode node); | 46 R visitForeignCode(HForeignCode node); |
| 47 R visitGetLength(HGetLength node); |
| 47 R visitGoto(HGoto node); | 48 R visitGoto(HGoto node); |
| 48 R visitGreater(HGreater node); | 49 R visitGreater(HGreater node); |
| 49 R visitGreaterEqual(HGreaterEqual node); | 50 R visitGreaterEqual(HGreaterEqual node); |
| 50 R visitIdentity(HIdentity node); | 51 R visitIdentity(HIdentity node); |
| 51 R visitIf(HIf node); | 52 R visitIf(HIf node); |
| 52 R visitIndex(HIndex node); | 53 R visitIndex(HIndex node); |
| 53 R visitIndexAssign(HIndexAssign node); | 54 R visitIndexAssign(HIndexAssign node); |
| 54 R visitInterceptor(HInterceptor node); | 55 R visitInterceptor(HInterceptor node); |
| 55 R visitInvokeClosure(HInvokeClosure node); | 56 R visitInvokeClosure(HInvokeClosure node); |
| 56 R visitInvokeDynamicGetter(HInvokeDynamicGetter node); | 57 R visitInvokeDynamicGetter(HInvokeDynamicGetter node); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 visitContinue(HContinue node) => visitJump(node); | 351 visitContinue(HContinue node) => visitJump(node); |
| 351 visitCheck(HCheck node) => visitInstruction(node); | 352 visitCheck(HCheck node) => visitInstruction(node); |
| 352 visitConstant(HConstant node) => visitInstruction(node); | 353 visitConstant(HConstant node) => visitInstruction(node); |
| 353 visitCreate(HCreate node) => visitInstruction(node); | 354 visitCreate(HCreate node) => visitInstruction(node); |
| 354 visitDivide(HDivide node) => visitBinaryArithmetic(node); | 355 visitDivide(HDivide node) => visitBinaryArithmetic(node); |
| 355 visitExit(HExit node) => visitControlFlow(node); | 356 visitExit(HExit node) => visitControlFlow(node); |
| 356 visitExitTry(HExitTry node) => visitControlFlow(node); | 357 visitExitTry(HExitTry node) => visitControlFlow(node); |
| 357 visitFieldGet(HFieldGet node) => visitFieldAccess(node); | 358 visitFieldGet(HFieldGet node) => visitFieldAccess(node); |
| 358 visitFieldSet(HFieldSet node) => visitFieldAccess(node); | 359 visitFieldSet(HFieldSet node) => visitFieldAccess(node); |
| 359 visitForeignCode(HForeignCode node) => visitInstruction(node); | 360 visitForeignCode(HForeignCode node) => visitInstruction(node); |
| 361 visitGetLength(HGetLength node) => visitInstruction(node); |
| 360 visitGoto(HGoto node) => visitControlFlow(node); | 362 visitGoto(HGoto node) => visitControlFlow(node); |
| 361 visitGreater(HGreater node) => visitRelational(node); | 363 visitGreater(HGreater node) => visitRelational(node); |
| 362 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); | 364 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); |
| 363 visitIdentity(HIdentity node) => visitRelational(node); | 365 visitIdentity(HIdentity node) => visitRelational(node); |
| 364 visitIf(HIf node) => visitConditionalBranch(node); | 366 visitIf(HIf node) => visitConditionalBranch(node); |
| 365 visitIndex(HIndex node) => visitInstruction(node); | 367 visitIndex(HIndex node) => visitInstruction(node); |
| 366 visitIndexAssign(HIndexAssign node) => visitInstruction(node); | 368 visitIndexAssign(HIndexAssign node) => visitInstruction(node); |
| 367 visitInterceptor(HInterceptor node) => visitInstruction(node); | 369 visitInterceptor(HInterceptor node) => visitInstruction(node); |
| 368 visitInvokeClosure(HInvokeClosure node) => visitInvokeDynamic(node); | 370 visitInvokeClosure(HInvokeClosure node) => visitInvokeDynamic(node); |
| 369 visitInvokeConstructorBody(HInvokeConstructorBody node) => | 371 visitInvokeConstructorBody(HInvokeConstructorBody node) => |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 static const int DYNAMIC_TYPE_TYPECODE = 35; | 887 static const int DYNAMIC_TYPE_TYPECODE = 35; |
| 886 static const int TRUNCATING_DIVIDE_TYPECODE = 36; | 888 static const int TRUNCATING_DIVIDE_TYPECODE = 36; |
| 887 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37; | 889 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37; |
| 888 | 890 |
| 889 static const int TYPE_INFO_READ_RAW_TYPECODE = 38; | 891 static const int TYPE_INFO_READ_RAW_TYPECODE = 38; |
| 890 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39; | 892 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39; |
| 891 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40; | 893 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40; |
| 892 | 894 |
| 893 static const int FOREIGN_CODE_TYPECODE = 41; | 895 static const int FOREIGN_CODE_TYPECODE = 41; |
| 894 static const int REMAINDER_TYPECODE = 42; | 896 static const int REMAINDER_TYPECODE = 42; |
| 897 static const int GET_LENGTH_TYPECODE = 43; |
| 895 | 898 |
| 896 HInstruction(this.inputs, this.instructionType) | 899 HInstruction(this.inputs, this.instructionType) |
| 897 : id = idCounter++, | 900 : id = idCounter++, |
| 898 usedBy = <HInstruction>[] { | 901 usedBy = <HInstruction>[] { |
| 899 assert(inputs.every((e) => e != null)); | 902 assert(inputs.every((e) => e != null)); |
| 900 } | 903 } |
| 901 | 904 |
| 902 int get hashCode => id; | 905 int get hashCode => id; |
| 903 | 906 |
| 904 bool useGvn() => _useGvn; | 907 bool useGvn() => _useGvn; |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 // The 'inputs' are | 1690 // The 'inputs' are |
| 1688 // [receiver, arg1, ..., argN] or | 1691 // [receiver, arg1, ..., argN] or |
| 1689 // [interceptor, receiver, arg1, ... argN]. | 1692 // [interceptor, receiver, arg1, ... argN]. |
| 1690 HInvokeConstructorBody(element, inputs, type) : super(element, inputs, type); | 1693 HInvokeConstructorBody(element, inputs, type) : super(element, inputs, type); |
| 1691 | 1694 |
| 1692 String toString() => 'invoke constructor body: ${element.name}'; | 1695 String toString() => 'invoke constructor body: ${element.name}'; |
| 1693 accept(HVisitor visitor) => visitor.visitInvokeConstructorBody(this); | 1696 accept(HVisitor visitor) => visitor.visitInvokeConstructorBody(this); |
| 1694 } | 1697 } |
| 1695 | 1698 |
| 1696 abstract class HFieldAccess extends HInstruction { | 1699 abstract class HFieldAccess extends HInstruction { |
| 1697 // TODO(johnniwinther): This should be a [FieldLike] but JSIndexable.length is | 1700 final FieldEntity element; |
| 1698 // encoded using a [HFieldGet]. | |
| 1699 final MemberEntity element; | |
| 1700 | 1701 |
| 1701 HFieldAccess(this.element, List<HInstruction> inputs, TypeMask type) | 1702 HFieldAccess(this.element, List<HInstruction> inputs, TypeMask type) |
| 1702 : super(inputs, type); | 1703 : super(inputs, type); |
| 1703 | 1704 |
| 1704 HInstruction get receiver => inputs[0]; | 1705 HInstruction get receiver => inputs[0]; |
| 1705 } | 1706 } |
| 1706 | 1707 |
| 1707 class HFieldGet extends HFieldAccess { | 1708 class HFieldGet extends HFieldAccess { |
| 1708 final bool isAssignable; | 1709 final bool isAssignable; |
| 1709 | 1710 |
| 1710 HFieldGet(MemberEntity element, HInstruction receiver, TypeMask type, | 1711 HFieldGet(FieldEntity element, HInstruction receiver, TypeMask type, |
| 1711 {bool isAssignable}) | 1712 {bool isAssignable}) |
| 1712 : this.isAssignable = | 1713 : this.isAssignable = |
| 1713 (isAssignable != null) ? isAssignable : element.isAssignable, | 1714 (isAssignable != null) ? isAssignable : element.isAssignable, |
| 1714 super(element, <HInstruction>[receiver], type) { | 1715 super(element, <HInstruction>[receiver], type) { |
| 1715 sideEffects.clearAllSideEffects(); | 1716 sideEffects.clearAllSideEffects(); |
| 1716 sideEffects.clearAllDependencies(); | 1717 sideEffects.clearAllDependencies(); |
| 1717 setUseGvn(); | 1718 setUseGvn(); |
| 1718 if (this.isAssignable) { | 1719 if (this.isAssignable) { |
| 1719 sideEffects.setDependsOnInstancePropertyStore(); | 1720 sideEffects.setDependsOnInstancePropertyStore(); |
| 1720 } | 1721 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1741 | 1742 |
| 1742 accept(HVisitor visitor) => visitor.visitFieldGet(this); | 1743 accept(HVisitor visitor) => visitor.visitFieldGet(this); |
| 1743 | 1744 |
| 1744 int typeCode() => HInstruction.FIELD_GET_TYPECODE; | 1745 int typeCode() => HInstruction.FIELD_GET_TYPECODE; |
| 1745 bool typeEquals(other) => other is HFieldGet; | 1746 bool typeEquals(other) => other is HFieldGet; |
| 1746 bool dataEquals(HFieldGet other) => element == other.element; | 1747 bool dataEquals(HFieldGet other) => element == other.element; |
| 1747 String toString() => "FieldGet $element"; | 1748 String toString() => "FieldGet $element"; |
| 1748 } | 1749 } |
| 1749 | 1750 |
| 1750 class HFieldSet extends HFieldAccess { | 1751 class HFieldSet extends HFieldAccess { |
| 1751 HFieldSet(MemberEntity element, HInstruction receiver, HInstruction value) | 1752 HFieldSet(FieldEntity element, HInstruction receiver, HInstruction value) |
| 1752 : super(element, <HInstruction>[receiver, value], | 1753 : super(element, <HInstruction>[receiver, value], |
| 1753 const TypeMask.nonNullEmpty()) { | 1754 const TypeMask.nonNullEmpty()) { |
| 1754 sideEffects.clearAllSideEffects(); | 1755 sideEffects.clearAllSideEffects(); |
| 1755 sideEffects.clearAllDependencies(); | 1756 sideEffects.clearAllDependencies(); |
| 1756 sideEffects.setChangesInstanceProperty(); | 1757 sideEffects.setChangesInstanceProperty(); |
| 1757 } | 1758 } |
| 1758 | 1759 |
| 1759 bool canThrow() => receiver.canBeNull(); | 1760 bool canThrow() => receiver.canBeNull(); |
| 1760 | 1761 |
| 1761 HInstruction getDartReceiver(ClosedWorld closedWorld) => receiver; | 1762 HInstruction getDartReceiver(ClosedWorld closedWorld) => receiver; |
| 1762 bool onlyThrowsNSM() => true; | 1763 bool onlyThrowsNSM() => true; |
| 1763 | 1764 |
| 1764 HInstruction get value => inputs[1]; | 1765 HInstruction get value => inputs[1]; |
| 1765 accept(HVisitor visitor) => visitor.visitFieldSet(this); | 1766 accept(HVisitor visitor) => visitor.visitFieldSet(this); |
| 1766 | 1767 |
| 1767 bool isJsStatement() => true; | 1768 bool isJsStatement() => true; |
| 1768 String toString() => "FieldSet $element"; | 1769 String toString() => "FieldSet $element"; |
| 1769 } | 1770 } |
| 1770 | 1771 |
| 1772 class HGetLength extends HInstruction { |
| 1773 final bool isAssignable; |
| 1774 HGetLength(HInstruction receiver, TypeMask type, {bool this.isAssignable}) |
| 1775 : super(<HInstruction>[receiver], type) { |
| 1776 assert(isAssignable != null); |
| 1777 sideEffects.clearAllSideEffects(); |
| 1778 sideEffects.clearAllDependencies(); |
| 1779 setUseGvn(); |
| 1780 if (this.isAssignable) { |
| 1781 sideEffects.setDependsOnInstancePropertyStore(); |
| 1782 } |
| 1783 } |
| 1784 |
| 1785 HInstruction get receiver => inputs.single; |
| 1786 |
| 1787 bool canThrow() => receiver.canBeNull(); |
| 1788 |
| 1789 HInstruction getDartReceiver(ClosedWorld closedWorld) => receiver; |
| 1790 bool onlyThrowsNSM() => true; |
| 1791 |
| 1792 accept(HVisitor visitor) => visitor.visitGetLength(this); |
| 1793 |
| 1794 int typeCode() => HInstruction.GET_LENGTH_TYPECODE; |
| 1795 bool typeEquals(other) => other is HGetLength; |
| 1796 bool dataEquals(HGetLength other) => true; |
| 1797 String toString() => "GetLength()"; |
| 1798 } |
| 1799 |
| 1771 /** | 1800 /** |
| 1772 * HReadModifyWrite is a late stage instruction for a field (property) update | 1801 * HReadModifyWrite is a late stage instruction for a field (property) update |
| 1773 * via an assignment operation or pre- or post-increment. | 1802 * via an assignment operation or pre- or post-increment. |
| 1774 */ | 1803 */ |
| 1775 class HReadModifyWrite extends HLateInstruction { | 1804 class HReadModifyWrite extends HLateInstruction { |
| 1776 static const ASSIGN_OP = 0; | 1805 static const ASSIGN_OP = 0; |
| 1777 static const PRE_OP = 1; | 1806 static const PRE_OP = 1; |
| 1778 static const POST_OP = 2; | 1807 static const POST_OP = 2; |
| 1779 final FieldEntity element; | 1808 final FieldEntity element; |
| 1780 final String jsOp; | 1809 final String jsOp; |
| (...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3470 class HDynamicType extends HRuntimeType { | 3499 class HDynamicType extends HRuntimeType { |
| 3471 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3500 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3472 : super(const <HInstruction>[], dartType, instructionType); | 3501 : super(const <HInstruction>[], dartType, instructionType); |
| 3473 | 3502 |
| 3474 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3503 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3475 | 3504 |
| 3476 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3505 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3477 | 3506 |
| 3478 bool typeEquals(HInstruction other) => other is HDynamicType; | 3507 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3479 } | 3508 } |
| OLD | NEW |