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

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

Issue 150923002: Mark optimized code that used CHA for optimization so that lazy class 'finalization' does not inval… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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/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 18 matching lines...) Expand all
29 const GrowableObjectArray& classes = 29 const GrowableObjectArray& classes =
30 GrowableObjectArray::Handle(object_store->pending_classes()); 30 GrowableObjectArray::Handle(object_store->pending_classes());
31 return classes.Length() == 0; 31 return classes.Length() == 0;
32 } 32 }
33 33
34 34
35 // Removes optimized code once we load more classes, since --use_cha based 35 // Removes optimized code once we load more classes, since --use_cha based
36 // optimizations may have become invalid. 36 // optimizations may have become invalid.
37 // Only methods which owner classes where subclasses can be invalid. 37 // Only methods which owner classes where subclasses can be invalid.
38 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. 38 // TODO(srdjan): Be even more precise by recording the exact CHA optimization.
39 static void RemoveOptimizedCode( 39 static void RemoveCHAOptimizedCode(
40 const GrowableArray<intptr_t>& added_subclass_to_cids) { 40 const GrowableArray<intptr_t>& added_subclass_to_cids) {
41 ASSERT(FLAG_use_cha); 41 ASSERT(FLAG_use_cha);
42 if (added_subclass_to_cids.is_empty()) return; 42 if (added_subclass_to_cids.is_empty()) return;
43 // Deoptimize all live frames. 43 // Deoptimize all live frames.
44 DeoptimizeIfOwner(added_subclass_to_cids); 44 DeoptimizeIfOwner(added_subclass_to_cids);
45 // Switch all functions' code to unoptimized. 45 // Switch all functions' code to unoptimized.
46 const ClassTable& class_table = *Isolate::Current()->class_table(); 46 const ClassTable& class_table = *Isolate::Current()->class_table();
47 Class& cls = Class::Handle(); 47 Class& cls = Class::Handle();
48 Array& array = Array::Handle(); 48 Array& array = Array::Handle();
49 Function& function = Function::Handle(); 49 Function& function = Function::Handle();
50 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) { 50 for (intptr_t i = 0; i < added_subclass_to_cids.length(); i++) {
51 intptr_t cid = added_subclass_to_cids[i]; 51 intptr_t cid = added_subclass_to_cids[i];
52 cls = class_table.At(cid); 52 cls = class_table.At(cid);
53 ASSERT(!cls.IsNull()); 53 ASSERT(!cls.IsNull());
54 array = cls.functions(); 54 array = cls.functions();
55 const intptr_t num_functions = array.IsNull() ? 0 : array.Length(); 55 const intptr_t num_functions = array.IsNull() ? 0 : array.Length();
56 for (intptr_t f = 0; f < num_functions; f++) { 56 for (intptr_t f = 0; f < num_functions; f++) {
57 function ^= array.At(f); 57 function ^= array.At(f);
58 ASSERT(!function.IsNull()); 58 ASSERT(!function.IsNull());
59 if (function.HasOptimizedCode()) { 59 if (function.HasCode() &&
60 Code::Handle(function.CurrentCode()).has_used_cha()) {
60 function.SwitchToUnoptimizedCode(); 61 function.SwitchToUnoptimizedCode();
61 } 62 }
62 } 63 }
63 } 64 }
64 } 65 }
65 66
66 67
67 void AddSuperType(const AbstractType& type, 68 void AddSuperType(const AbstractType& type,
68 GrowableArray<intptr_t>* finalized_super_classes) { 69 GrowableArray<intptr_t>* finalized_super_classes) {
69 ASSERT(type.HasResolvedTypeClass()); 70 ASSERT(type.HasResolvedTypeClass());
(...skipping 2118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 ASSERT(cls.IsTopLevel() || 2189 ASSERT(cls.IsTopLevel() ||
2189 cls.IsSignatureClass() || 2190 cls.IsSignatureClass() ||
2190 (Array::Handle(cls.functions()).Length() > 0)); 2191 (Array::Handle(cls.functions()).Length() > 0));
2191 // Resolve and finalize all member types. 2192 // Resolve and finalize all member types.
2192 ResolveAndFinalizeMemberTypes(cls); 2193 ResolveAndFinalizeMemberTypes(cls);
2193 // Run additional checks after all types are finalized. 2194 // Run additional checks after all types are finalized.
2194 if (cls.is_const()) { 2195 if (cls.is_const()) {
2195 CheckForLegalConstClass(cls); 2196 CheckForLegalConstClass(cls);
2196 } 2197 }
2197 if (FLAG_use_cha) { 2198 if (FLAG_use_cha) {
2198 RemoveOptimizedCode(added_subclass_to_cids); 2199 RemoveCHAOptimizedCode(added_subclass_to_cids);
2199 } 2200 }
2200 } 2201 }
2201 2202
2202 2203
2203 bool ClassFinalizer::IsSuperCycleFree(const Class& cls) { 2204 bool ClassFinalizer::IsSuperCycleFree(const Class& cls) {
2204 Class& test1 = Class::Handle(cls.raw()); 2205 Class& test1 = Class::Handle(cls.raw());
2205 Class& test2 = Class::Handle(cls.SuperClass()); 2206 Class& test2 = Class::Handle(cls.SuperClass());
2206 // A finalized class has been checked for cycles. 2207 // A finalized class has been checked for cycles.
2207 // Using the hare and tortoise algorithm for locating cycles. 2208 // Using the hare and tortoise algorithm for locating cycles.
2208 while (!test1.is_type_finalized() && 2209 while (!test1.is_type_finalized() &&
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 expected_name ^= String::New("_offset"); 2909 expected_name ^= String::New("_offset");
2909 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); 2910 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name));
2910 field ^= fields_array.At(2); 2911 field ^= fields_array.At(2);
2911 ASSERT(field.Offset() == TypedDataView::length_offset()); 2912 ASSERT(field.Offset() == TypedDataView::length_offset());
2912 name ^= field.name(); 2913 name ^= field.name();
2913 ASSERT(name.Equals("length")); 2914 ASSERT(name.Equals("length"));
2914 #endif 2915 #endif
2915 } 2916 }
2916 2917
2917 } // namespace dart 2918 } // namespace dart
OLDNEW
« runtime/vm/cha.cc ('K') | « runtime/vm/cha.cc ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698