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

Unified Diff: runtime/vm/constant_propagator.cc

Issue 1497783002: Fix optimizations on static fields in precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 5 years 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/flow_graph_optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/constant_propagator.cc
diff --git a/runtime/vm/constant_propagator.cc b/runtime/vm/constant_propagator.cc
index 61c09a610eaefdecefea869f93e765cd73937838..5e4f53c47306a1baeae2e36b90ea9a033ccef9f5 100644
--- a/runtime/vm/constant_propagator.cc
+++ b/runtime/vm/constant_propagator.cc
@@ -19,6 +19,8 @@ DEFINE_FLAG(bool, remove_redundant_phis, true, "Remove redundant phis.");
DEFINE_FLAG(bool, trace_constant_propagation, false,
"Print constant propagation and useless code elimination.");
+DECLARE_FLAG(bool, fields_may_be_reset);
+
// Quick access to the current zone and isolate.
#define I (isolate())
#define Z (graph_->zone())
@@ -704,14 +706,16 @@ void ConstantPropagator::VisitInitStaticField(InitStaticFieldInstr* instr) {
void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) {
- const Field& field = instr->StaticField();
- ASSERT(field.is_static());
- Instance& obj = Instance::Handle(Z, field.StaticValue());
- if (field.is_final() && (obj.raw() != Object::sentinel().raw()) &&
- (obj.raw() != Object::transition_sentinel().raw())) {
- if (obj.IsSmi() || obj.IsOld()) {
- SetValue(instr, obj);
- return;
+ if (!FLAG_fields_may_be_reset) {
+ const Field& field = instr->StaticField();
+ ASSERT(field.is_static());
+ Instance& obj = Instance::Handle(Z, field.StaticValue());
+ if (field.is_final() && (obj.raw() != Object::sentinel().raw()) &&
+ (obj.raw() != Object::transition_sentinel().raw())) {
+ if (obj.IsSmi() || obj.IsOld()) {
+ SetValue(instr, obj);
+ return;
+ }
}
}
SetValue(instr, non_constant_);
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698