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

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

Issue 3003593002: [vm] Cleanup Instruction::Effects(), prepare to cleanup Dependencies() (Closed)
Patch Set: Address review comment Created 3 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/flow_graph.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 GrowableArray<BitVector*> available_after(block_count); 1435 GrowableArray<BitVector*> available_after(block_count);
1436 1436
1437 // Discover all blocks with side-effects. 1437 // Discover all blocks with side-effects.
1438 for (BlockIterator it = flow_graph->postorder_iterator(); !it.Done(); 1438 for (BlockIterator it = flow_graph->postorder_iterator(); !it.Done();
1439 it.Advance()) { 1439 it.Advance()) {
1440 available_at_.Add(NULL); 1440 available_at_.Add(NULL);
1441 available_after.Add(NULL); 1441 available_after.Add(NULL);
1442 1442
1443 BlockEntryInstr* block = it.Current(); 1443 BlockEntryInstr* block = it.Current();
1444 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) { 1444 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
1445 if (!it.Current()->Effects().IsNone()) { 1445 if (it.Current()->HasUnknownSideEffects()) {
1446 kill->Add(block->postorder_number()); 1446 kill->Add(block->postorder_number());
1447 break; 1447 break;
1448 } 1448 }
1449 } 1449 }
1450 } 1450 }
1451 1451
1452 BitVector* temp = new (zone) BitVector(zone, block_count); 1452 BitVector* temp = new (zone) BitVector(zone, block_count);
1453 1453
1454 // Recompute available-at based on predecessors' available-after until the fix 1454 // Recompute available-at based on predecessors' available-after until the fix
1455 // point is reached. 1455 // point is reached.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 available_after[block_num]->Add(block_num); 1493 available_after[block_num]->Add(block_num);
1494 } 1494 }
1495 changed = true; 1495 changed = true;
1496 } 1496 }
1497 } 1497 }
1498 } while (changed); 1498 } while (changed);
1499 } 1499 }
1500 1500
1501 bool BlockEffects::IsAvailableAt(Instruction* instr, 1501 bool BlockEffects::IsAvailableAt(Instruction* instr,
1502 BlockEntryInstr* block) const { 1502 BlockEntryInstr* block) const {
1503 return (instr->Dependencies().IsNone()) || 1503 ASSERT(instr->AllowsCSE());
1504 IsSideEffectFreePath(instr->GetBlock(), block); 1504 ASSERT(instr->Dependencies().IsNone());
1505 return true; // TODO(dartbug.com/30474): cleanup
1505 } 1506 }
1506 1507
1507 bool BlockEffects::CanBeMovedTo(Instruction* instr, 1508 bool BlockEffects::CanBeMovedTo(Instruction* instr,
1508 BlockEntryInstr* block) const { 1509 BlockEntryInstr* block) const {
1509 return (instr->Dependencies().IsNone()) || 1510 ASSERT(instr->AllowsCSE());
1510 IsSideEffectFreePath(block, instr->GetBlock()); 1511 ASSERT(instr->Dependencies().IsNone());
1512 return true; // TODO(dartbug.com/30474): cleanup
1511 } 1513 }
1512 1514
1513 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1515 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1514 BlockEntryInstr* to) const { 1516 BlockEntryInstr* to) const {
1515 return available_at_[to->postorder_number()]->Contains( 1517 return available_at_[to->postorder_number()]->Contains(
1516 from->postorder_number()); 1518 from->postorder_number());
1517 } 1519 }
1518 1520
1519 // Quick access to the current zone. 1521 // Quick access to the current zone.
1520 #define Z (zone()) 1522 #define Z (zone())
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 intptr_t index, 2266 intptr_t index,
2265 Representation rep, 2267 Representation rep,
2266 intptr_t cid) { 2268 intptr_t cid) {
2267 ExtractNthOutputInstr* extract = 2269 ExtractNthOutputInstr* extract =
2268 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); 2270 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid);
2269 instr->ReplaceUsesWith(extract); 2271 instr->ReplaceUsesWith(extract);
2270 InsertAfter(instr, extract, NULL, FlowGraph::kValue); 2272 InsertAfter(instr, extract, NULL, FlowGraph::kValue);
2271 } 2273 }
2272 2274
2273 } // namespace dart 2275 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698