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 '../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 '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 static const int VOID_TYPE_TYPECODE = 33; | 866 static const int VOID_TYPE_TYPECODE = 33; |
867 static const int INTERFACE_TYPE_TYPECODE = 34; | 867 static const int INTERFACE_TYPE_TYPECODE = 34; |
868 static const int DYNAMIC_TYPE_TYPECODE = 35; | 868 static const int DYNAMIC_TYPE_TYPECODE = 35; |
869 static const int TRUNCATING_DIVIDE_TYPECODE = 36; | 869 static const int TRUNCATING_DIVIDE_TYPECODE = 36; |
870 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37; | 870 static const int IS_VIA_INTERCEPTOR_TYPECODE = 37; |
871 | 871 |
872 static const int TYPE_INFO_READ_RAW_TYPECODE = 38; | 872 static const int TYPE_INFO_READ_RAW_TYPECODE = 38; |
873 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39; | 873 static const int TYPE_INFO_READ_VARIABLE_TYPECODE = 39; |
874 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40; | 874 static const int TYPE_INFO_EXPRESSION_TYPECODE = 40; |
875 | 875 |
| 876 static const int FOREIGN_CODE_TYPECODE = 41; |
| 877 |
876 HInstruction(this.inputs, this.instructionType) | 878 HInstruction(this.inputs, this.instructionType) |
877 : id = idCounter++, | 879 : id = idCounter++, |
878 usedBy = <HInstruction>[] { | 880 usedBy = <HInstruction>[] { |
879 assert(inputs.every((e) => e != null)); | 881 assert(inputs.every((e) => e != null)); |
880 } | 882 } |
881 | 883 |
882 int get hashCode => id; | 884 int get hashCode => id; |
883 | 885 |
884 bool useGvn() => _useGvn; | 886 bool useGvn() => _useGvn; |
885 void setUseGvn() { | 887 void setUseGvn() { |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 effects = nativeBehavior.sideEffects; | 1896 effects = nativeBehavior.sideEffects; |
1895 } | 1897 } |
1896 if (this.throwBehavior == null) { | 1898 if (this.throwBehavior == null) { |
1897 this.throwBehavior = (nativeBehavior == null) | 1899 this.throwBehavior = (nativeBehavior == null) |
1898 ? native.NativeThrowBehavior.MAY | 1900 ? native.NativeThrowBehavior.MAY |
1899 : nativeBehavior.throwBehavior; | 1901 : nativeBehavior.throwBehavior; |
1900 } | 1902 } |
1901 assert(this.throwBehavior != null); | 1903 assert(this.throwBehavior != null); |
1902 | 1904 |
1903 if (effects != null) sideEffects.add(effects); | 1905 if (effects != null) sideEffects.add(effects); |
| 1906 if (nativeBehavior != null && nativeBehavior.useGvn) { |
| 1907 setUseGvn(); |
| 1908 } |
1904 } | 1909 } |
1905 | 1910 |
1906 HForeignCode.statement(js.Template codeTemplate, List<HInstruction> inputs, | 1911 HForeignCode.statement(js.Template codeTemplate, List<HInstruction> inputs, |
1907 SideEffects effects, native.NativeBehavior nativeBehavior, TypeMask type) | 1912 SideEffects effects, native.NativeBehavior nativeBehavior, TypeMask type) |
1908 : this(codeTemplate, type, inputs, | 1913 : this(codeTemplate, type, inputs, |
1909 isStatement: true, | 1914 isStatement: true, |
1910 effects: effects, | 1915 effects: effects, |
1911 nativeBehavior: nativeBehavior); | 1916 nativeBehavior: nativeBehavior); |
1912 | 1917 |
1913 accept(HVisitor visitor) => visitor.visitForeignCode(this); | 1918 accept(HVisitor visitor) => visitor.visitForeignCode(this); |
1914 | 1919 |
1915 bool isJsStatement() => isStatement; | 1920 bool isJsStatement() => isStatement; |
1916 bool canThrow() { | 1921 bool canThrow() { |
1917 if (inputs.length > 0) { | 1922 if (inputs.length > 0) { |
1918 return inputs.first.canBeNull() | 1923 return inputs.first.canBeNull() |
1919 ? throwBehavior.canThrow | 1924 ? throwBehavior.canThrow |
1920 : throwBehavior.onNonNull.canThrow; | 1925 : throwBehavior.onNonNull.canThrow; |
1921 } | 1926 } |
1922 return throwBehavior.canThrow; | 1927 return throwBehavior.canThrow; |
1923 } | 1928 } |
1924 | 1929 |
1925 bool onlyThrowsNSM() => throwBehavior.isOnlyNullNSMGuard; | 1930 bool onlyThrowsNSM() => throwBehavior.isOnlyNullNSMGuard; |
1926 | 1931 |
1927 bool get isAllocation => | 1932 bool get isAllocation => |
1928 nativeBehavior != null && nativeBehavior.isAllocation && !canBeNull(); | 1933 nativeBehavior != null && nativeBehavior.isAllocation && !canBeNull(); |
1929 | 1934 |
1930 String toString() => 'HForeignCode("${codeTemplate.source}",$inputs)'; | 1935 int typeCode() => HInstruction.FOREIGN_CODE_TYPECODE; |
| 1936 bool typeEquals(other) => other is HForeignCode; |
| 1937 bool dataEquals(HForeignCode other) { |
| 1938 return codeTemplate.source == other.codeTemplate.source; |
| 1939 } |
| 1940 |
| 1941 String toString() => 'HForeignCode("${codeTemplate.source}", $inputs)'; |
1931 } | 1942 } |
1932 | 1943 |
1933 abstract class HInvokeBinary extends HInstruction { | 1944 abstract class HInvokeBinary extends HInstruction { |
1934 final Selector selector; | 1945 final Selector selector; |
1935 HInvokeBinary( | 1946 HInvokeBinary( |
1936 HInstruction left, HInstruction right, this.selector, TypeMask type) | 1947 HInstruction left, HInstruction right, this.selector, TypeMask type) |
1937 : super(<HInstruction>[left, right], type) { | 1948 : super(<HInstruction>[left, right], type) { |
1938 sideEffects.clearAllSideEffects(); | 1949 sideEffects.clearAllSideEffects(); |
1939 sideEffects.clearAllDependencies(); | 1950 sideEffects.clearAllDependencies(); |
1940 setUseGvn(); | 1951 setUseGvn(); |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3454 class HDynamicType extends HRuntimeType { | 3465 class HDynamicType extends HRuntimeType { |
3455 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3466 HDynamicType(DynamicType dartType, TypeMask instructionType) |
3456 : super(const <HInstruction>[], dartType, instructionType); | 3467 : super(const <HInstruction>[], dartType, instructionType); |
3457 | 3468 |
3458 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3469 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
3459 | 3470 |
3460 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3471 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
3461 | 3472 |
3462 bool typeEquals(HInstruction other) => other is HDynamicType; | 3473 bool typeEquals(HInstruction other) => other is HDynamicType; |
3463 } | 3474 } |
OLD | NEW |