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

Side by Side Diff: runtime/vm/constant_propagator.cc

Issue 868913002: Add Zone-based handle allocation interface and reduce use of Isolate-based interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_allocator.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 // Quick access to the locally defined isolate() method. 22 // Quick access to the current zone and isolate.
23 #define I (isolate()) 23 #define I (isolate())
24 #define Z (graph_->zone())
24 25
25 26
26 ConstantPropagator::ConstantPropagator( 27 ConstantPropagator::ConstantPropagator(
27 FlowGraph* graph, 28 FlowGraph* graph,
28 const GrowableArray<BlockEntryInstr*>& ignored) 29 const GrowableArray<BlockEntryInstr*>& ignored)
29 : FlowGraphVisitor(ignored), 30 : FlowGraphVisitor(ignored),
30 graph_(graph), 31 graph_(graph),
31 unknown_(Object::unknown_constant()), 32 unknown_(Object::unknown_constant()),
32 non_constant_(Object::non_constant()), 33 non_constant_(Object::non_constant()),
33 reachable_(new(graph->isolate()) BitVector( 34 reachable_(new(Z) BitVector(
34 graph->isolate(), graph->preorder().length())), 35 Z, graph->preorder().length())),
35 marked_phis_(new(graph->isolate()) BitVector( 36 marked_phis_(new(Z) BitVector(
36 graph->isolate(), graph->max_virtual_register_number())), 37 Z, graph->max_virtual_register_number())),
37 block_worklist_(), 38 block_worklist_(),
38 definition_worklist_(graph, 10) {} 39 definition_worklist_(graph, 10) {}
39 40
40 41
41 void ConstantPropagator::Optimize(FlowGraph* graph) { 42 void ConstantPropagator::Optimize(FlowGraph* graph) {
42 GrowableArray<BlockEntryInstr*> ignored; 43 GrowableArray<BlockEntryInstr*> ignored;
43 ConstantPropagator cp(graph, ignored); 44 ConstantPropagator cp(graph, ignored);
44 cp.Analyze(); 45 cp.Analyze();
45 cp.Transform(); 46 cp.Transform();
46 } 47 }
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 current = current->next()->AsGoto()->successor(); 1424 current = current->next()->AsGoto()->successor();
1424 } 1425 }
1425 return current; 1426 return current;
1426 } 1427 }
1427 1428
1428 1429
1429 void ConstantPropagator::EliminateRedundantBranches() { 1430 void ConstantPropagator::EliminateRedundantBranches() {
1430 // Canonicalize branches that have no side-effects and where true- and 1431 // Canonicalize branches that have no side-effects and where true- and
1431 // false-targets are the same. 1432 // false-targets are the same.
1432 bool changed = false; 1433 bool changed = false;
1433 BitVector* empty_blocks = new(I) BitVector(I, graph_->preorder().length()); 1434 BitVector* empty_blocks = new(Z) BitVector(Z,
1435 graph_->preorder().length());
1434 for (BlockIterator b = graph_->postorder_iterator(); 1436 for (BlockIterator b = graph_->postorder_iterator();
1435 !b.Done(); 1437 !b.Done();
1436 b.Advance()) { 1438 b.Advance()) {
1437 BlockEntryInstr* block = b.Current(); 1439 BlockEntryInstr* block = b.Current();
1438 BranchInstr* branch = block->last_instruction()->AsBranch(); 1440 BranchInstr* branch = block->last_instruction()->AsBranch();
1439 empty_blocks->Clear(); 1441 empty_blocks->Clear();
1440 if ((branch != NULL) && branch->Effects().IsNone()) { 1442 if ((branch != NULL) && branch->Effects().IsNone()) {
1441 ASSERT(branch->previous() != NULL); // Not already eliminated. 1443 ASSERT(branch->previous() != NULL); // Not already eliminated.
1442 BlockEntryInstr* if_true = 1444 BlockEntryInstr* if_true =
1443 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks); 1445 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 graph_->ComputeDominators(&dominance_frontier); 1637 graph_->ComputeDominators(&dominance_frontier);
1636 1638
1637 if (FLAG_trace_constant_propagation) { 1639 if (FLAG_trace_constant_propagation) {
1638 OS::Print("\n==== After constant propagation ====\n"); 1640 OS::Print("\n==== After constant propagation ====\n");
1639 FlowGraphPrinter printer(*graph_); 1641 FlowGraphPrinter printer(*graph_);
1640 printer.PrintBlocks(); 1642 printer.PrintBlocks();
1641 } 1643 }
1642 } 1644 }
1643 1645
1644 } // namespace dart 1646 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698