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

Side by Side Diff: runtime/vm/flow_graph_compiler.cc

Issue 178193020: Better inlining of type tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
OLDNEW
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/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 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 return OneByteString::data_offset(); 1230 return OneByteString::data_offset();
1231 case kTwoByteStringCid: 1231 case kTwoByteStringCid:
1232 return TwoByteString::data_offset(); 1232 return TwoByteString::data_offset();
1233 default: 1233 default:
1234 UNIMPLEMENTED(); 1234 UNIMPLEMENTED();
1235 return Array::data_offset(); 1235 return Array::data_offset();
1236 } 1236 }
1237 } 1237 }
1238 1238
1239 1239
1240 // Returns true if checking against this type is a direct class id comparison.
1241 bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) {
1242 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
1243 // Requires CHA, which can be applied in optimized code only,
1244 if (!FLAG_use_cha || !is_optimizing()) return false;
1245 if (!type.IsInstantiated()) return false;
1246 const Class& type_class = Class::Handle(type.type_class());
1247 // Signature classes have different type checking rules.
1248 if (type_class.IsSignatureClass()) return false;
1249 // Could be an interface check?
1250 if (type_class.is_implemented()) return false;
1251 const intptr_t type_cid = type_class.id();
1252 if (CHA::HasSubclasses(type_cid)) return false;
1253 const intptr_t num_type_args = type_class.NumTypeArguments();
1254 if (num_type_args > 0) {
1255 // Only raw types can be directly compared, thus disregarding type
1256 // arguments.
1257 const intptr_t num_type_params = type_class.NumTypeParameters();
1258 const intptr_t from_index = num_type_args - num_type_params;
1259 const TypeArguments& type_arguments =
1260 TypeArguments::Handle(type.arguments());
1261 const bool is_raw_type = type_arguments.IsNull() ||
1262 type_arguments.IsRaw(from_index, num_type_params);
1263 return is_raw_type;
1264 }
1265 return true;
1266 }
1267
1268
1269 static int HighestCountFirst(const CidTarget* a, const CidTarget* b) { 1240 static int HighestCountFirst(const CidTarget* a, const CidTarget* b) {
1270 // Negative if 'a' should sort before 'b'. 1241 // Negative if 'a' should sort before 'b'.
1271 return b->count - a->count; 1242 return b->count - a->count;
1272 } 1243 }
1273 1244
1274 1245
1275 // Returns 'sorted' array in decreasing count order. 1246 // Returns 'sorted' array in decreasing count order.
1276 // The expected number of elements to sort is less than 10. 1247 // The expected number of elements to sort is less than 10.
1277 void FlowGraphCompiler::SortICDataByCount(const ICData& ic_data, 1248 void FlowGraphCompiler::SortICDataByCount(const ICData& ic_data,
1278 GrowableArray<CidTarget>* sorted) { 1249 GrowableArray<CidTarget>* sorted) {
1279 ASSERT(ic_data.num_args_tested() == 1); 1250 ASSERT(ic_data.num_args_tested() == 1);
1280 const intptr_t len = ic_data.NumberOfChecks(); 1251 const intptr_t len = ic_data.NumberOfChecks();
1281 sorted->Clear(); 1252 sorted->Clear();
1282 1253
1283 for (int i = 0; i < len; i++) { 1254 for (int i = 0; i < len; i++) {
1284 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), 1255 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i),
1285 &Function::ZoneHandle(ic_data.GetTargetAt(i)), 1256 &Function::ZoneHandle(ic_data.GetTargetAt(i)),
1286 ic_data.GetCountAt(i))); 1257 ic_data.GetCountAt(i)));
1287 } 1258 }
1288 sorted->Sort(HighestCountFirst); 1259 sorted->Sort(HighestCountFirst);
1289 } 1260 }
1290 1261
1291 } // namespace dart 1262 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm.cc » ('j') | runtime/vm/flow_graph_optimizer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698