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

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
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"
(...skipping 12 matching lines...) Expand all
23 #define I (isolate()) 23 #define I (isolate())
24 24
25 25
26 ConstantPropagator::ConstantPropagator( 26 ConstantPropagator::ConstantPropagator(
27 FlowGraph* graph, 27 FlowGraph* graph,
28 const GrowableArray<BlockEntryInstr*>& ignored) 28 const GrowableArray<BlockEntryInstr*>& ignored)
29 : FlowGraphVisitor(ignored), 29 : FlowGraphVisitor(ignored),
30 graph_(graph), 30 graph_(graph),
31 unknown_(Object::unknown_constant()), 31 unknown_(Object::unknown_constant()),
32 non_constant_(Object::non_constant()), 32 non_constant_(Object::non_constant()),
33 reachable_(new(graph->isolate()) BitVector( 33 reachable_(new(graph->zone()) BitVector(
Ivan Posva 2015/01/23 19:49:24 How about defining Z in this file?
koda 2015/01/23 21:12:10 Done.
34 graph->isolate(), graph->preorder().length())), 34 graph->zone(), graph->preorder().length())),
35 marked_phis_(new(graph->isolate()) BitVector( 35 marked_phis_(new(graph->zone()) BitVector(
36 graph->isolate(), graph->max_virtual_register_number())), 36 graph->zone(), graph->max_virtual_register_number())),
37 block_worklist_(), 37 block_worklist_(),
38 definition_worklist_(graph, 10) {} 38 definition_worklist_(graph, 10) {}
39 39
40 40
41 void ConstantPropagator::Optimize(FlowGraph* graph) { 41 void ConstantPropagator::Optimize(FlowGraph* graph) {
42 GrowableArray<BlockEntryInstr*> ignored; 42 GrowableArray<BlockEntryInstr*> ignored;
43 ConstantPropagator cp(graph, ignored); 43 ConstantPropagator cp(graph, ignored);
44 cp.Analyze(); 44 cp.Analyze();
45 cp.Transform(); 45 cp.Transform();
46 } 46 }
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 current = current->next()->AsGoto()->successor(); 1423 current = current->next()->AsGoto()->successor();
1424 } 1424 }
1425 return current; 1425 return current;
1426 } 1426 }
1427 1427
1428 1428
1429 void ConstantPropagator::EliminateRedundantBranches() { 1429 void ConstantPropagator::EliminateRedundantBranches() {
1430 // Canonicalize branches that have no side-effects and where true- and 1430 // Canonicalize branches that have no side-effects and where true- and
1431 // false-targets are the same. 1431 // false-targets are the same.
1432 bool changed = false; 1432 bool changed = false;
1433 BitVector* empty_blocks = new(I) BitVector(I, graph_->preorder().length()); 1433 BitVector* empty_blocks = new(graph_->zone()) BitVector(graph_->zone(),
1434 graph_->preorder().length());
1434 for (BlockIterator b = graph_->postorder_iterator(); 1435 for (BlockIterator b = graph_->postorder_iterator();
1435 !b.Done(); 1436 !b.Done();
1436 b.Advance()) { 1437 b.Advance()) {
1437 BlockEntryInstr* block = b.Current(); 1438 BlockEntryInstr* block = b.Current();
1438 BranchInstr* branch = block->last_instruction()->AsBranch(); 1439 BranchInstr* branch = block->last_instruction()->AsBranch();
1439 empty_blocks->Clear(); 1440 empty_blocks->Clear();
1440 if ((branch != NULL) && branch->Effects().IsNone()) { 1441 if ((branch != NULL) && branch->Effects().IsNone()) {
1441 ASSERT(branch->previous() != NULL); // Not already eliminated. 1442 ASSERT(branch->previous() != NULL); // Not already eliminated.
1442 BlockEntryInstr* if_true = 1443 BlockEntryInstr* if_true =
1443 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks); 1444 FindFirstNonEmptySuccessor(branch->true_successor(), empty_blocks);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 graph_->ComputeDominators(&dominance_frontier); 1636 graph_->ComputeDominators(&dominance_frontier);
1636 1637
1637 if (FLAG_trace_constant_propagation) { 1638 if (FLAG_trace_constant_propagation) {
1638 OS::Print("\n==== After constant propagation ====\n"); 1639 OS::Print("\n==== After constant propagation ====\n");
1639 FlowGraphPrinter printer(*graph_); 1640 FlowGraphPrinter printer(*graph_);
1640 printer.PrintBlocks(); 1641 printer.PrintBlocks();
1641 } 1642 }
1642 } 1643 }
1643 1644
1644 } // namespace dart 1645 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698