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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/constant_propagator.h" 5 #include "vm/constant_propagator.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
10 #include "vm/flow_graph_range_analysis.h" 10 #include "vm/flow_graph_range_analysis.h"
11 #include "vm/il_printer.h" 11 #include "vm/il_printer.h"
12 #include "vm/intermediate_language.h" 12 #include "vm/intermediate_language.h"
13 #include "vm/parser.h" 13 #include "vm/parser.h"
14 #include "vm/symbols.h" 14 #include "vm/symbols.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 DEFINE_FLAG(bool, remove_redundant_phis, true, "Remove redundant phis."); 18 DEFINE_FLAG(bool, remove_redundant_phis, true, "Remove redundant phis.");
19 DEFINE_FLAG(bool, trace_constant_propagation, false, 19 DEFINE_FLAG(bool, trace_constant_propagation, false,
20 "Print constant propagation and useless code elimination."); 20 "Print constant propagation and useless code elimination.");
21 21
22 DECLARE_FLAG(bool, fields_may_be_reset);
23
22 // Quick access to the current zone and isolate. 24 // Quick access to the current zone and isolate.
23 #define I (isolate()) 25 #define I (isolate())
24 #define Z (graph_->zone()) 26 #define Z (graph_->zone())
25 27
26 28
27 ConstantPropagator::ConstantPropagator( 29 ConstantPropagator::ConstantPropagator(
28 FlowGraph* graph, 30 FlowGraph* graph,
29 const GrowableArray<BlockEntryInstr*>& ignored) 31 const GrowableArray<BlockEntryInstr*>& ignored)
30 : FlowGraphVisitor(ignored), 32 : FlowGraphVisitor(ignored),
31 graph_(graph), 33 graph_(graph),
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 SetValue(instr, instr->value()->definition()->constant_value()); 699 SetValue(instr, instr->value()->definition()->constant_value());
698 } 700 }
699 701
700 702
701 void ConstantPropagator::VisitInitStaticField(InitStaticFieldInstr* instr) { 703 void ConstantPropagator::VisitInitStaticField(InitStaticFieldInstr* instr) {
702 // Nothing to do. 704 // Nothing to do.
703 } 705 }
704 706
705 707
706 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { 708 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) {
707 const Field& field = instr->StaticField(); 709 if (!FLAG_fields_may_be_reset) {
708 ASSERT(field.is_static()); 710 const Field& field = instr->StaticField();
709 Instance& obj = Instance::Handle(Z, field.StaticValue()); 711 ASSERT(field.is_static());
710 if (field.is_final() && (obj.raw() != Object::sentinel().raw()) && 712 Instance& obj = Instance::Handle(Z, field.StaticValue());
711 (obj.raw() != Object::transition_sentinel().raw())) { 713 if (field.is_final() && (obj.raw() != Object::sentinel().raw()) &&
712 if (obj.IsSmi() || obj.IsOld()) { 714 (obj.raw() != Object::transition_sentinel().raw())) {
713 SetValue(instr, obj); 715 if (obj.IsSmi() || obj.IsOld()) {
714 return; 716 SetValue(instr, obj);
717 return;
718 }
715 } 719 }
716 } 720 }
717 SetValue(instr, non_constant_); 721 SetValue(instr, non_constant_);
718 } 722 }
719 723
720 724
721 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { 725 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) {
722 SetValue(instr, instr->value()->definition()->constant_value()); 726 SetValue(instr, instr->value()->definition()->constant_value());
723 } 727 }
724 728
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 graph_->MergeBlocks(); 1683 graph_->MergeBlocks();
1680 GrowableArray<BitVector*> dominance_frontier; 1684 GrowableArray<BitVector*> dominance_frontier;
1681 graph_->ComputeDominators(&dominance_frontier); 1685 graph_->ComputeDominators(&dominance_frontier);
1682 1686
1683 if (FLAG_trace_constant_propagation) { 1687 if (FLAG_trace_constant_propagation) {
1684 FlowGraphPrinter::PrintGraph("After CP", graph_); 1688 FlowGraphPrinter::PrintGraph("After CP", graph_);
1685 } 1689 }
1686 } 1690 }
1687 1691
1688 } // namespace dart 1692 } // namespace dart
OLDNEW
« 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