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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 11370008: Move lazy deoptimization of all optimized code from top level parsing to end of class finalization … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 14866)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -20,8 +20,8 @@
DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization.");
DEFINE_FLAG(bool, trace_type_finalization, false, "Trace type finalization.");
DECLARE_FLAG(bool, enable_type_checks);
+DECLARE_FLAG(bool, use_cha);
-
bool ClassFinalizer::AllClassesFinalized() {
ObjectStore* object_store = Isolate::Current()->object_store();
const GrowableObjectArray& classes =
@@ -30,6 +30,37 @@
}
+// Removes optimized code once we load more classes, since --use_cha based
+// optimizations may have become invalid.
+// TODO(srdjan): Note which functions use which CHA decision and deoptimize
+// only the necessary ones.
+static void RemoveOptimizedCode() {
+ ASSERT(FLAG_use_cha);
+ // Deoptimize all live frames.
+ DeoptimizeAll();
+ // Switch all functions' code to unoptimized.
+ const ClassTable& class_table = *Isolate::Current()->class_table();
+ Class& cls = Class::Handle();
+ Array& array = Array::Handle();
+ Function& function = Function::Handle();
+ const intptr_t num_cids = class_table.NumCids();
+ for (intptr_t i = kInstanceCid; i < num_cids; i++) {
+ if (!class_table.HasValidClassAt(i)) continue;
+ cls = class_table.At(i);
+ ASSERT(!cls.IsNull());
+ array = cls.functions();
+ intptr_t num_functions = array.IsNull() ? 0 : array.Length();
+ for (intptr_t f = 0; f < num_functions; f++) {
+ function ^= array.At(f);
+ ASSERT(!function.IsNull());
+ if (function.HasOptimizedCode()) {
+ function.SwitchToUnoptimizedCode();
+ }
+ }
+ }
+}
+
+
// Class finalization occurs:
// a) when bootstrap process completes (VerifyBootstrapClasses).
// b) after the user classes are loaded (dart_api).
@@ -84,6 +115,9 @@
retval = false;
}
isolate->set_long_jump_base(base);
+ if (FLAG_use_cha) {
+ RemoveOptimizedCode();
+ }
return retval;
}
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698