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 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
6 | 6 |
7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
8 | 8 |
9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 case BELOW_EQUAL: return unsigned_left <= unsigned_right; | 1020 case BELOW_EQUAL: return unsigned_left <= unsigned_right; |
1021 case ABOVE: return unsigned_left > unsigned_right; | 1021 case ABOVE: return unsigned_left > unsigned_right; |
1022 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; | 1022 case ABOVE_EQUAL: return unsigned_left >= unsigned_right; |
1023 default: | 1023 default: |
1024 UNIMPLEMENTED(); | 1024 UNIMPLEMENTED(); |
1025 return false; | 1025 return false; |
1026 } | 1026 } |
1027 } | 1027 } |
1028 | 1028 |
1029 | 1029 |
| 1030 intptr_t FlowGraphCompiler::ElementSizeFor(intptr_t cid) { |
| 1031 switch (cid) { |
| 1032 case kArrayCid: |
| 1033 case kImmutableArrayCid: |
| 1034 return Array::kBytesPerElement; |
| 1035 case kFloat32ArrayCid: |
| 1036 return Float32Array::kBytesPerElement; |
| 1037 case kFloat64ArrayCid: |
| 1038 return Float64Array::kBytesPerElement; |
| 1039 case kUint8ArrayCid: |
| 1040 return Uint8Array::kBytesPerElement; |
| 1041 case kUint8ClampedArrayCid: |
| 1042 return Uint8ClampedArray::kBytesPerElement; |
| 1043 case kOneByteStringCid: |
| 1044 return OneByteString::kBytesPerElement; |
| 1045 case kTwoByteStringCid: |
| 1046 return TwoByteString::kBytesPerElement; |
| 1047 default: |
| 1048 UNIMPLEMENTED(); |
| 1049 return 0; |
| 1050 } |
| 1051 } |
| 1052 |
| 1053 |
| 1054 intptr_t FlowGraphCompiler::DataOffsetFor(intptr_t cid) { |
| 1055 switch (cid) { |
| 1056 case kArrayCid: |
| 1057 case kImmutableArrayCid: |
| 1058 return Array::data_offset(); |
| 1059 case kFloat32ArrayCid: |
| 1060 return Float32Array::data_offset(); |
| 1061 case kFloat64ArrayCid: |
| 1062 return Float64Array::data_offset(); |
| 1063 case kUint8ArrayCid: |
| 1064 return Uint8Array::data_offset(); |
| 1065 case kUint8ClampedArrayCid: |
| 1066 return Uint8ClampedArray::data_offset(); |
| 1067 case kOneByteStringCid: |
| 1068 return OneByteString::data_offset(); |
| 1069 case kTwoByteStringCid: |
| 1070 return TwoByteString::data_offset(); |
| 1071 default: |
| 1072 UNIMPLEMENTED(); |
| 1073 return Array::data_offset(); |
| 1074 } |
| 1075 } |
| 1076 |
| 1077 |
1030 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid, | 1078 FieldAddress FlowGraphCompiler::ElementAddressForIntIndex(intptr_t cid, |
1031 Register array, | 1079 Register array, |
1032 intptr_t offset) { | 1080 intptr_t index) { |
1033 switch (cid) { | 1081 const intptr_t disp = index * ElementSizeFor(cid) + DataOffsetFor(cid); |
1034 case kArrayCid: | 1082 ASSERT(Utils::IsInt(31, disp)); |
1035 case kImmutableArrayCid: { | 1083 return FieldAddress(array, disp); |
1036 const intptr_t disp = offset * kWordSize + sizeof(RawArray); | |
1037 ASSERT(Utils::IsInt(31, disp)); | |
1038 return FieldAddress(array, disp); | |
1039 } | |
1040 case kFloat32ArrayCid: { | |
1041 const intptr_t disp = | |
1042 offset * kFloatSize + Float32Array::data_offset(); | |
1043 ASSERT(Utils::IsInt(31, disp)); | |
1044 return FieldAddress(array, disp); | |
1045 } | |
1046 case kFloat64ArrayCid: { | |
1047 const intptr_t disp = | |
1048 offset * kDoubleSize + Float64Array::data_offset(); | |
1049 ASSERT(Utils::IsInt(31, disp)); | |
1050 return FieldAddress(array, disp); | |
1051 } | |
1052 case kUint8ArrayCid: { | |
1053 const intptr_t disp = offset + Uint8Array::data_offset(); | |
1054 ASSERT(Utils::IsInt(31, disp)); | |
1055 return FieldAddress(array, disp); | |
1056 } | |
1057 case kUint8ClampedArrayCid: { | |
1058 const intptr_t disp = offset + Uint8ClampedArray::data_offset(); | |
1059 ASSERT(Utils::IsInt(31, disp)); | |
1060 return FieldAddress(array, disp); | |
1061 } | |
1062 default: | |
1063 UNIMPLEMENTED(); | |
1064 return FieldAddress(SPREG, 0); | |
1065 } | |
1066 } | 1084 } |
1067 | 1085 |
1068 | 1086 |
1069 FieldAddress FlowGraphCompiler::ElementAddressForRegIndex(intptr_t cid, | 1087 FieldAddress FlowGraphCompiler::ElementAddressForRegIndex(intptr_t cid, |
1070 Register array, | 1088 Register array, |
1071 Register index) { | 1089 Register index) { |
1072 // Note that index is Smi, i.e, times 2. | 1090 // Note that index is smi-tagged, (i.e, times 2) for all arrays with element |
| 1091 // size > 1. For Uint8Array and OneByteString the index is expected to be |
| 1092 // untagged before accessing. |
1073 ASSERT(kSmiTagShift == 1); | 1093 ASSERT(kSmiTagShift == 1); |
1074 switch (cid) { | 1094 switch (cid) { |
1075 case kArrayCid: | 1095 case kArrayCid: |
1076 case kImmutableArrayCid: | 1096 case kImmutableArrayCid: |
1077 return FieldAddress(array, index, TIMES_HALF_WORD_SIZE, sizeof(RawArray)); | 1097 return FieldAddress( |
| 1098 array, index, TIMES_HALF_WORD_SIZE, Array::data_offset()); |
1078 case kFloat32ArrayCid: | 1099 case kFloat32ArrayCid: |
1079 return FieldAddress(array, index, TIMES_2, Float32Array::data_offset()); | 1100 return FieldAddress(array, index, TIMES_2, Float32Array::data_offset()); |
1080 case kFloat64ArrayCid: | 1101 case kFloat64ArrayCid: |
1081 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset()); | 1102 return FieldAddress(array, index, TIMES_4, Float64Array::data_offset()); |
1082 case kUint8ArrayCid: | 1103 case kUint8ArrayCid: |
1083 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset()); | 1104 return FieldAddress(array, index, TIMES_1, Uint8Array::data_offset()); |
1084 case kUint8ClampedArrayCid: | 1105 case kUint8ClampedArrayCid: |
1085 return | 1106 return |
1086 FieldAddress(array, index, TIMES_1, Uint8ClampedArray::data_offset()); | 1107 FieldAddress(array, index, TIMES_1, Uint8ClampedArray::data_offset()); |
| 1108 case kOneByteStringCid: |
| 1109 return FieldAddress(array, index, TIMES_1, OneByteString::data_offset()); |
| 1110 case kTwoByteStringCid: |
| 1111 return FieldAddress(array, index, TIMES_1, TwoByteString::data_offset()); |
1087 default: | 1112 default: |
1088 UNIMPLEMENTED(); | 1113 UNIMPLEMENTED(); |
1089 return FieldAddress(SPREG, 0); | 1114 return FieldAddress(SPREG, 0); |
1090 } | 1115 } |
1091 } | 1116 } |
1092 | 1117 |
1093 | 1118 |
1094 // Returns true if checking against this type is a direct class id comparison. | 1119 // Returns true if checking against this type is a direct class id comparison. |
1095 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { | 1120 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) { |
1096 ASSERT(type.IsFinalized() && !type.IsMalformed()); | 1121 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
(...skipping 13 matching lines...) Expand all Loading... |
1110 const AbstractTypeArguments& type_arguments = | 1135 const AbstractTypeArguments& type_arguments = |
1111 AbstractTypeArguments::Handle(type.arguments()); | 1136 AbstractTypeArguments::Handle(type.arguments()); |
1112 const bool is_raw_type = type_arguments.IsNull() || | 1137 const bool is_raw_type = type_arguments.IsNull() || |
1113 type_arguments.IsRaw(type_arguments.Length()); | 1138 type_arguments.IsRaw(type_arguments.Length()); |
1114 return is_raw_type; | 1139 return is_raw_type; |
1115 } | 1140 } |
1116 return true; | 1141 return true; |
1117 } | 1142 } |
1118 | 1143 |
1119 } // namespace dart | 1144 } // namespace dart |
OLD | NEW |