OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Both names are private. Mangle test_name before comparison. | 264 // Both names are private. Mangle test_name before comparison. |
265 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); | 265 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); |
266 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); | 266 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 static bool IsRecognizedLibrary(const Library& library) { | 270 static bool IsRecognizedLibrary(const Library& library) { |
271 // List of libraries where methods can be recognized. | 271 // List of libraries where methods can be recognized. |
272 return (library.raw() == Library::CoreLibrary()) | 272 return (library.raw() == Library::CoreLibrary()) |
273 || (library.raw() == Library::MathLibrary()) | 273 || (library.raw() == Library::MathLibrary()) |
274 || (library.raw() == Library::TypedDataLibrary()) | 274 || (library.raw() == Library::TypedDataLibrary()); |
275 || (library.raw() == Library::ScalarlistLibrary()); | |
276 } | 275 } |
277 | 276 |
278 | 277 |
279 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( | 278 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( |
280 const Function& function) { | 279 const Function& function) { |
281 const Class& function_class = Class::Handle(function.Owner()); | 280 const Class& function_class = Class::Handle(function.Owner()); |
282 const Library& lib = Library::Handle(function_class.library()); | 281 const Library& lib = Library::Handle(function_class.library()); |
283 if (!IsRecognizedLibrary(lib)) { | 282 if (!IsRecognizedLibrary(lib)) { |
284 return kUnknown; | 283 return kUnknown; |
285 } | 284 } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1104 |
1106 Definition* Definition::Canonicalize(FlowGraphOptimizer* optimizer) { | 1105 Definition* Definition::Canonicalize(FlowGraphOptimizer* optimizer) { |
1107 return this; | 1106 return this; |
1108 } | 1107 } |
1109 | 1108 |
1110 | 1109 |
1111 bool LoadFieldInstr::IsImmutableLengthLoad() const { | 1110 bool LoadFieldInstr::IsImmutableLengthLoad() const { |
1112 switch (recognized_kind()) { | 1111 switch (recognized_kind()) { |
1113 case MethodRecognizer::kObjectArrayLength: | 1112 case MethodRecognizer::kObjectArrayLength: |
1114 case MethodRecognizer::kImmutableArrayLength: | 1113 case MethodRecognizer::kImmutableArrayLength: |
1115 case MethodRecognizer::kByteArrayBaseLength: | |
1116 case MethodRecognizer::kTypedDataLength: | 1114 case MethodRecognizer::kTypedDataLength: |
1117 case MethodRecognizer::kStringBaseLength: | 1115 case MethodRecognizer::kStringBaseLength: |
1118 return true; | 1116 return true; |
1119 default: | 1117 default: |
1120 return false; | 1118 return false; |
1121 } | 1119 } |
1122 } | 1120 } |
1123 | 1121 |
1124 | 1122 |
1125 MethodRecognizer::Kind LoadFieldInstr::RecognizedKindFromArrayCid( | 1123 MethodRecognizer::Kind LoadFieldInstr::RecognizedKindFromArrayCid( |
1126 intptr_t cid) { | 1124 intptr_t cid) { |
1127 if (RawObject::IsTypedDataClassId(cid) || | 1125 if (RawObject::IsTypedDataClassId(cid) || |
1128 RawObject::IsExternalTypedDataClassId(cid)) { | 1126 RawObject::IsExternalTypedDataClassId(cid)) { |
1129 return MethodRecognizer::kTypedDataLength; | 1127 return MethodRecognizer::kTypedDataLength; |
1130 } | 1128 } |
1131 switch (cid) { | 1129 switch (cid) { |
1132 case kArrayCid: | 1130 case kArrayCid: |
1133 return MethodRecognizer::kObjectArrayLength; | 1131 return MethodRecognizer::kObjectArrayLength; |
1134 case kImmutableArrayCid: | 1132 case kImmutableArrayCid: |
1135 return MethodRecognizer::kImmutableArrayLength; | 1133 return MethodRecognizer::kImmutableArrayLength; |
1136 case kGrowableObjectArrayCid: | 1134 case kGrowableObjectArrayCid: |
1137 return MethodRecognizer::kGrowableArrayLength; | 1135 return MethodRecognizer::kGrowableArrayLength; |
1138 case kInt8ArrayCid: | |
1139 case kUint8ArrayCid: | |
1140 case kUint8ClampedArrayCid: | |
1141 case kExternalUint8ArrayCid: | |
1142 case kExternalUint8ClampedArrayCid: | |
1143 case kInt16ArrayCid: | |
1144 case kUint16ArrayCid: | |
1145 case kInt32ArrayCid: | |
1146 case kUint32ArrayCid: | |
1147 case kInt64ArrayCid: | |
1148 case kUint64ArrayCid: | |
1149 case kFloat32ArrayCid: | |
1150 case kFloat64ArrayCid: | |
1151 return MethodRecognizer::kByteArrayBaseLength; | |
1152 default: | 1136 default: |
1153 UNREACHABLE(); | 1137 UNREACHABLE(); |
1154 return MethodRecognizer::kUnknown; | 1138 return MethodRecognizer::kUnknown; |
1155 } | 1139 } |
1156 } | 1140 } |
1157 | 1141 |
1158 | 1142 |
1159 bool LoadFieldInstr::IsFixedLengthArrayCid(intptr_t cid) { | 1143 bool LoadFieldInstr::IsFixedLengthArrayCid(intptr_t cid) { |
1160 switch (cid) { | 1144 switch (cid) { |
1161 case kArrayCid: | 1145 case kArrayCid: |
1162 case kImmutableArrayCid: | 1146 case kImmutableArrayCid: |
1163 case kInt8ArrayCid: | 1147 case kTypedDataInt8ArrayCid: |
1164 case kUint8ArrayCid: | 1148 case kTypedDataUint8ArrayCid: |
1165 case kUint8ClampedArrayCid: | 1149 case kTypedDataUint8ClampedArrayCid: |
1166 case kInt16ArrayCid: | 1150 case kTypedDataInt16ArrayCid: |
1167 case kUint16ArrayCid: | 1151 case kTypedDataUint16ArrayCid: |
1168 case kInt32ArrayCid: | 1152 case kTypedDataInt32ArrayCid: |
1169 case kUint32ArrayCid: | 1153 case kTypedDataUint32ArrayCid: |
1170 case kInt64ArrayCid: | 1154 case kTypedDataInt64ArrayCid: |
1171 case kUint64ArrayCid: | 1155 case kTypedDataUint64ArrayCid: |
1172 case kFloat32ArrayCid: | 1156 case kTypedDataFloat32ArrayCid: |
1173 case kFloat64ArrayCid: | 1157 case kTypedDataFloat64ArrayCid: |
1174 return true; | 1158 return true; |
1175 default: | 1159 default: |
1176 return false; | 1160 return false; |
1177 } | 1161 } |
1178 } | 1162 } |
1179 | 1163 |
1180 | 1164 |
1181 Definition* ConstantInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | 1165 Definition* ConstantInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
1182 return HasUses() ? this : NULL; | 1166 return HasUses() ? this : NULL; |
1183 } | 1167 } |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 | 1907 |
1924 void LoadFieldInstr::InferRange() { | 1908 void LoadFieldInstr::InferRange() { |
1925 if ((range_ == NULL) && | 1909 if ((range_ == NULL) && |
1926 ((recognized_kind() == MethodRecognizer::kObjectArrayLength) || | 1910 ((recognized_kind() == MethodRecognizer::kObjectArrayLength) || |
1927 (recognized_kind() == MethodRecognizer::kImmutableArrayLength))) { | 1911 (recognized_kind() == MethodRecognizer::kImmutableArrayLength))) { |
1928 range_ = new Range(RangeBoundary::FromConstant(0), | 1912 range_ = new Range(RangeBoundary::FromConstant(0), |
1929 RangeBoundary::FromConstant(Array::kMaxElements)); | 1913 RangeBoundary::FromConstant(Array::kMaxElements)); |
1930 return; | 1914 return; |
1931 } | 1915 } |
1932 if ((range_ == NULL) && | 1916 if ((range_ == NULL) && |
1933 (recognized_kind() == MethodRecognizer::kByteArrayBaseLength || | 1917 (recognized_kind() == MethodRecognizer::kTypedDataLength)) { |
1934 recognized_kind() == MethodRecognizer::kTypedDataLength)) { | |
1935 range_ = new Range(RangeBoundary::FromConstant(0), RangeBoundary::MaxSmi()); | 1918 range_ = new Range(RangeBoundary::FromConstant(0), RangeBoundary::MaxSmi()); |
1936 return; | 1919 return; |
1937 } | 1920 } |
1938 if ((range_ == NULL) && | 1921 if ((range_ == NULL) && |
1939 (recognized_kind() == MethodRecognizer::kStringBaseLength)) { | 1922 (recognized_kind() == MethodRecognizer::kStringBaseLength)) { |
1940 range_ = new Range(RangeBoundary::FromConstant(0), | 1923 range_ = new Range(RangeBoundary::FromConstant(0), |
1941 RangeBoundary::FromConstant(String::kMaxElements)); | 1924 RangeBoundary::FromConstant(String::kMaxElements)); |
1942 return; | 1925 return; |
1943 } | 1926 } |
1944 Definition::InferRange(); | 1927 Definition::InferRange(); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 default: | 2306 default: |
2324 UNREACHABLE(); | 2307 UNREACHABLE(); |
2325 } | 2308 } |
2326 return kPowRuntimeEntry; | 2309 return kPowRuntimeEntry; |
2327 } | 2310 } |
2328 | 2311 |
2329 | 2312 |
2330 #undef __ | 2313 #undef __ |
2331 | 2314 |
2332 } // namespace dart | 2315 } // namespace dart |
OLD | NEW |