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

Unified Diff: runtime/vm/compiler.cc

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/cha_test.cc ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 7685b3cc9ca637489d83babb67de9a6072ab4593..6fc4834dd1ef15ebe67c313fe65f67496976d213 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -613,6 +613,13 @@ NOT_IN_PRODUCT(
THR_Print("--> FAIL: Loading invalidation.");
}
}
+ if (!thread()->cha()->IsConsistentWithCurrentHierarchy()) {
+ code_is_valid = false;
+ if (trace_compiler) {
+ THR_Print("--> FAIL: Class hierarchy has new subclasses.");
+ }
+ }
+
// Setting breakpoints at runtime could make a function non-optimizable.
if (code_is_valid && Compiler::CanOptimizeFunction(thread(), function)) {
const bool is_osr = osr_id() != Compiler::kNoOSRDeoptId;
@@ -632,14 +639,11 @@ NOT_IN_PRODUCT(
}
if (code_was_installed) {
- // Register code with the classes it depends on because of CHA and
- // fields it depends on because of store guards, unless we cannot
- // deopt.
- for (intptr_t i = 0;
- i < thread()->cha()->leaf_classes().length();
- ++i) {
- thread()->cha()->leaf_classes()[i]->RegisterCHACode(code);
- }
+ // The generated code was compiled under certain assumptions about
+ // class hierarchy and field types. Register these dependencies
+ // to ensure that the code will be deoptimized if they are violated.
+ thread()->cha()->RegisterDependencies(code);
+
const ZoneGrowableArray<const Field*>& guarded_fields =
*flow_graph->parsed_function().guarded_fields();
for (intptr_t i = 0; i < guarded_fields.length(); i++) {
« no previous file with comments | « runtime/vm/cha_test.cc ('k') | runtime/vm/flow_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698