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

Unified Diff: runtime/vm/cha.h

Issue 2002583002: Background compiler should validate CHA decisions before committing the code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/aot_optimizer.cc ('k') | runtime/vm/cha.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/cha.h
diff --git a/runtime/vm/cha.h b/runtime/vm/cha.h
index a1ea229a2c3816122f2e49440e8e7fefb9fa9701..7aa777487e2564621654290a152fb819141f7233 100644
--- a/runtime/vm/cha.h
+++ b/runtime/vm/cha.h
@@ -21,7 +21,7 @@ class CHA : public StackResource {
explicit CHA(Thread* thread)
: StackResource(thread),
thread_(thread),
- leaf_classes_(thread->zone(), 1),
+ guarded_classes_(thread->zone(), 1),
previous_(thread->cha()) {
thread->set_cha(this);
}
@@ -44,20 +44,42 @@ class CHA : public StackResource {
static bool IsImplemented(const Class& cls);
// Returns true if any subclass of 'cls' contains the function.
- bool HasOverride(const Class& cls, const String& function_name);
+ // If no override was found subclass_count would contain total count of
+ // finalized subclasses that CHA looked at.
+ // This count will be used to validate CHA decision before installing
+ // optimized code compiled in background.
+ bool HasOverride(const Class& cls,
+ const String& function_name,
+ intptr_t* subclass_count);
- const GrowableArray<Class*>& leaf_classes() const {
- return leaf_classes_;
- }
-
- // Adds class 'cls' to the list of guarded leaf classes, deoptimization occurs
- // if any of those leaf classes gets subclassed through later loaded/finalized
+ // Adds class 'cls' to the list of guarded classes, deoptimization occurs
+ // if any of those classes gets subclassed through later loaded/finalized
// libraries. Only classes that were used for CHA optimizations are added.
- void AddToLeafClasses(const Class& cls);
+ void AddToGuardedClasses(const Class& cls, intptr_t subclass_count);
+
+ // When compiling in background we need to check that no new finalized
+ // subclasses were added to guarded classes.
+ bool IsConsistentWithCurrentHierarchy() const;
+
+ void RegisterDependencies(const Code& code) const;
+
+ // Used for testing.
+ bool IsGuardedClass(intptr_t cid) const;
private:
Thread* thread_;
- GrowableArray<Class*> leaf_classes_;
+
+ struct GuardedClassInfo {
+ Class* cls;
+
+ // Number of finalized subclasses that this class had at the moment
+ // when CHA made the first decision based on this class.
+ // Used to validate correctness of background compilation: if
+ // any subclasses were added we will discard compiled code.
+ intptr_t subclass_count;
+ };
+
+ GrowableArray<GuardedClassInfo> guarded_classes_;
CHA* previous_;
};
« no previous file with comments | « runtime/vm/aot_optimizer.cc ('k') | runtime/vm/cha.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698