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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 1327383002: Don't optimize away static field initialization when precompiling. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/flow_graph_compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 8754ecfe48fe31b2a08e3ff188e891276f82b49b..b8db54da4961e5745f9fe3a68ae5a7f49e43fc06 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -37,6 +37,8 @@ DEFINE_FLAG(bool, two_args_smi_icd, true,
"Generate special IC stubs for two args Smi operations");
DEFINE_FLAG(bool, unbox_numeric_fields, true,
"Support unboxed double and float32x4 fields.");
+DEFINE_FLAG(bool, fields_may_be_reset, false,
+ "Don't optimize away static field initialization");
DECLARE_FLAG(bool, eliminate_type_checks);
DECLARE_FLAG(bool, trace_optimization);
DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
@@ -385,7 +387,11 @@ Instruction* InitStaticFieldInstr::Canonicalize(FlowGraph* flow_graph) {
const bool is_initialized =
(field_.StaticValue() != Object::sentinel().raw()) &&
(field_.StaticValue() != Object::transition_sentinel().raw());
- return is_initialized ? NULL : this;
+ // When precompiling, the fact that a field is currently initialized does not
+ // make it safe to omit code that checks if the field needs initialization
+ // because the field will be reset so it starts uninitialized in the process
+ // running the precompiled code. We must be prepared to reinitialize fields.
+ return is_initialized && !FLAG_fields_may_be_reset ? NULL : this;
}
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698