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

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

Issue 1559653002: Investigate & fix issues around usage_count and deoptimization_count (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: y Created 4 years, 11 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
« no previous file with comments | « no previous file | runtime/vm/code_generator.cc » ('j') | runtime/vm/compiler.cc » ('J')
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/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 17 matching lines...) Expand all
28 GrowableObjectArray::Handle(object_store->pending_classes()); 28 GrowableObjectArray::Handle(object_store->pending_classes());
29 return classes.Length() == 0; 29 return classes.Length() == 0;
30 } 30 }
31 31
32 32
33 // Removes optimized code once we load more classes, since CHA based 33 // Removes optimized code once we load more classes, since CHA based
34 // optimizations may have become invalid. 34 // optimizations may have become invalid.
35 // Only methods which owner classes where subclasses can be invalid. 35 // Only methods which owner classes where subclasses can be invalid.
36 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. 36 // TODO(srdjan): Be even more precise by recording the exact CHA optimization.
37 static void RemoveCHAOptimizedCode( 37 static void RemoveCHAOptimizedCode(
38 const Class& subclass,
38 const GrowableArray<intptr_t>& added_subclass_to_cids) { 39 const GrowableArray<intptr_t>& added_subclass_to_cids) {
39 ASSERT(FLAG_use_cha_deopt); 40 ASSERT(FLAG_use_cha_deopt);
40 if (added_subclass_to_cids.is_empty()) return; 41 if (added_subclass_to_cids.is_empty()) {
42 return;
43 }
41 // Switch all functions' code to unoptimized. 44 // Switch all functions' code to unoptimized.
42 const ClassTable& class_table = *Isolate::Current()->class_table(); 45 const ClassTable& class_table = *Isolate::Current()->class_table();
43 Class& cls = Class::Handle(); 46 Class& cls = Class::Handle();
44 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) { 47 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) {
45 intptr_t cid = added_subclass_to_cids[i]; 48 intptr_t cid = added_subclass_to_cids[i];
46 cls = class_table.At(cid); 49 cls = class_table.At(cid);
47 ASSERT(!cls.IsNull()); 50 ASSERT(!cls.IsNull());
48 cls.DisableCHAOptimizedCode(); 51 cls.DisableCHAOptimizedCode(subclass);
49 } 52 }
50 } 53 }
51 54
52 55
53 void AddSuperType(const AbstractType& type, 56 void AddSuperType(const AbstractType& type,
54 GrowableArray<intptr_t>* finalized_super_classes) { 57 GrowableArray<intptr_t>* finalized_super_classes) {
55 ASSERT(type.HasResolvedTypeClass()); 58 ASSERT(type.HasResolvedTypeClass());
56 ASSERT(!type.IsDynamicType()); 59 ASSERT(!type.IsDynamicType());
57 if (type.IsObjectType()) { 60 if (type.IsObjectType()) {
58 return; 61 return;
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 // Resolve and finalize all member types. 2408 // Resolve and finalize all member types.
2406 ResolveAndFinalizeMemberTypes(cls); 2409 ResolveAndFinalizeMemberTypes(cls);
2407 // Run additional checks after all types are finalized. 2410 // Run additional checks after all types are finalized.
2408 if (cls.is_const()) { 2411 if (cls.is_const()) {
2409 CheckForLegalConstClass(cls); 2412 CheckForLegalConstClass(cls);
2410 } 2413 }
2411 if (FLAG_use_cha_deopt) { 2414 if (FLAG_use_cha_deopt) {
2412 GrowableArray<intptr_t> cids; 2415 GrowableArray<intptr_t> cids;
2413 CollectFinalizedSuperClasses(cls, &cids); 2416 CollectFinalizedSuperClasses(cls, &cids);
2414 CollectImmediateSuperInterfaces(cls, &cids); 2417 CollectImmediateSuperInterfaces(cls, &cids);
2415 RemoveCHAOptimizedCode(cids); 2418 RemoveCHAOptimizedCode(cls, cids);
2416 } 2419 }
2417 if (cls.is_enum_class()) { 2420 if (cls.is_enum_class()) {
2418 AllocateEnumValues(cls); 2421 AllocateEnumValues(cls);
2419 } 2422 }
2420 } 2423 }
2421 2424
2422 2425
2423 // Allocate instances for each enumeration value, and populate the 2426 // Allocate instances for each enumeration value, and populate the
2424 // static field 'values'. 2427 // static field 'values'.
2425 // By allocating the instances programmatically, we save an implicit final 2428 // By allocating the instances programmatically, we save an implicit final
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); 3223 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields());
3221 field ^= fields_array.At(0); 3224 field ^= fields_array.At(0);
3222 ASSERT(field.Offset() == ByteBuffer::data_offset()); 3225 ASSERT(field.Offset() == ByteBuffer::data_offset());
3223 name ^= field.name(); 3226 name ^= field.name();
3224 expected_name ^= String::New("_data"); 3227 expected_name ^= String::New("_data");
3225 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 3228 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
3226 #endif 3229 #endif
3227 } 3230 }
3228 3231
3229 } // namespace dart 3232 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator.cc » ('j') | runtime/vm/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698