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

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

Issue 81363002: Improve type test and type equality for generics (issue 15148). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 // Requires CHA, which can be applied in optimized code only, 1181 // Requires CHA, which can be applied in optimized code only,
1182 if (!FLAG_use_cha || !is_optimizing()) return false; 1182 if (!FLAG_use_cha || !is_optimizing()) return false;
1183 if (!type.IsInstantiated()) return false; 1183 if (!type.IsInstantiated()) return false;
1184 const Class& type_class = Class::Handle(type.type_class()); 1184 const Class& type_class = Class::Handle(type.type_class());
1185 // Signature classes have different type checking rules. 1185 // Signature classes have different type checking rules.
1186 if (type_class.IsSignatureClass()) return false; 1186 if (type_class.IsSignatureClass()) return false;
1187 // Could be an interface check? 1187 // Could be an interface check?
1188 if (type_class.is_implemented()) return false; 1188 if (type_class.is_implemented()) return false;
1189 const intptr_t type_cid = type_class.id(); 1189 const intptr_t type_cid = type_class.id();
1190 if (CHA::HasSubclasses(type_cid)) return false; 1190 if (CHA::HasSubclasses(type_cid)) return false;
1191 if (type_class.NumTypeArguments() > 0) { 1191 const intptr_t num_type_args = type_class.NumTypeArguments();
1192 if (num_type_args > 0) {
1192 // Only raw types can be directly compared, thus disregarding type 1193 // Only raw types can be directly compared, thus disregarding type
1193 // arguments. 1194 // arguments.
1195 const intptr_t num_type_params = type_class.NumTypeParameters();
1196 const intptr_t from_index = num_type_args - num_type_params;
1194 const AbstractTypeArguments& type_arguments = 1197 const AbstractTypeArguments& type_arguments =
1195 AbstractTypeArguments::Handle(type.arguments()); 1198 AbstractTypeArguments::Handle(type.arguments());
1196 const bool is_raw_type = type_arguments.IsNull() || 1199 const bool is_raw_type = type_arguments.IsNull() ||
1197 type_arguments.IsRaw(type_arguments.Length()); 1200 type_arguments.IsRaw(from_index, num_type_params);
1198 return is_raw_type; 1201 return is_raw_type;
1199 } 1202 }
1200 return true; 1203 return true;
1201 } 1204 }
1202 1205
1203 1206
1204 static int HighestCountFirst(const CidTarget* a, const CidTarget* b) { 1207 static int HighestCountFirst(const CidTarget* a, const CidTarget* b) {
1205 // Negative if 'a' should sort before 'b'. 1208 // Negative if 'a' should sort before 'b'.
1206 return b->count - a->count; 1209 return b->count - a->count;
1207 } 1210 }
1208 1211
1209 1212
1210 // Returns 'sorted' array in decreasing count order. 1213 // Returns 'sorted' array in decreasing count order.
1211 // The expected number of elements to sort is less than 10. 1214 // The expected number of elements to sort is less than 10.
1212 void FlowGraphCompiler::SortICDataByCount(const ICData& ic_data, 1215 void FlowGraphCompiler::SortICDataByCount(const ICData& ic_data,
1213 GrowableArray<CidTarget>* sorted) { 1216 GrowableArray<CidTarget>* sorted) {
1214 ASSERT(ic_data.num_args_tested() == 1); 1217 ASSERT(ic_data.num_args_tested() == 1);
1215 const intptr_t len = ic_data.NumberOfChecks(); 1218 const intptr_t len = ic_data.NumberOfChecks();
1216 sorted->Clear(); 1219 sorted->Clear();
1217 1220
1218 for (int i = 0; i < len; i++) { 1221 for (int i = 0; i < len; i++) {
1219 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), 1222 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i),
1220 &Function::ZoneHandle(ic_data.GetTargetAt(i)), 1223 &Function::ZoneHandle(ic_data.GetTargetAt(i)),
1221 ic_data.GetCountAt(i))); 1224 ic_data.GetCountAt(i)));
1222 } 1225 }
1223 sorted->Sort(HighestCountFirst); 1226 sorted->Sort(HighestCountFirst);
1224 } 1227 }
1225 1228
1226 } // namespace dart 1229 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698