summaryrefslogtreecommitdiff
path: root/compiler/optimizing/scheduler_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/scheduler_test.cc')
-rw-r--r--compiler/optimizing/scheduler_test.cc41
1 files changed, 37 insertions, 4 deletions
diff --git a/compiler/optimizing/scheduler_test.cc b/compiler/optimizing/scheduler_test.cc
index e0e265a04c..4c47f2ee57 100644
--- a/compiler/optimizing/scheduler_test.cc
+++ b/compiler/optimizing/scheduler_test.cc
@@ -146,9 +146,7 @@ class SchedulerTest : public OptimizingUnitTest {
environment->SetRawEnvAt(1, mul);
mul->AddEnvUseAt(div_check->GetEnvironment(), 1);
- SchedulingGraph scheduling_graph(scheduler,
- GetScopedAllocator(),
- /* heap_location_collector= */ nullptr);
+ TestSchedulingGraph scheduling_graph(GetScopedAllocator());
// Instructions must be inserted in reverse order into the scheduling graph.
for (HInstruction* instr : ReverseRange(block_instructions)) {
scheduling_graph.AddNode(instr);
@@ -283,7 +281,7 @@ class SchedulerTest : public OptimizingUnitTest {
HeapLocationCollector heap_location_collector(graph_);
heap_location_collector.VisitBasicBlock(entry);
heap_location_collector.BuildAliasingMatrix();
- SchedulingGraph scheduling_graph(scheduler, GetScopedAllocator(), &heap_location_collector);
+ TestSchedulingGraph scheduling_graph(GetScopedAllocator(), &heap_location_collector);
for (HInstruction* instr : ReverseRange(block_instructions)) {
// Build scheduling graph with memory access aliasing information
@@ -357,6 +355,41 @@ class SchedulerTest : public OptimizingUnitTest {
scheduler->Schedule(graph_);
}
+ class TestSchedulingGraph : public SchedulingGraph {
+ public:
+ explicit TestSchedulingGraph(ScopedArenaAllocator* allocator,
+ const HeapLocationCollector *heap_location_collector = nullptr)
+ : SchedulingGraph(allocator, heap_location_collector) {}
+
+ bool HasImmediateDataDependency(const HInstruction* instruction,
+ const HInstruction* other_instruction) const {
+ const SchedulingNode* node = GetNode(instruction);
+ const SchedulingNode* other = GetNode(other_instruction);
+ if (node == nullptr || other == nullptr) {
+ // Both instructions must be in current basic block, i.e. the SchedulingGraph can see their
+ // corresponding SchedulingNode in the graph, and tell whether there is a dependency.
+ // Otherwise there is no dependency from SchedulingGraph's perspective, for example,
+ // instruction and other_instruction are in different basic blocks.
+ return false;
+ }
+ return node->HasDataDependency(other);
+ }
+
+ bool HasImmediateOtherDependency(const HInstruction* instruction,
+ const HInstruction* other_instruction) const {
+ const SchedulingNode* node = GetNode(instruction);
+ const SchedulingNode* other = GetNode(other_instruction);
+ if (node == nullptr || other == nullptr) {
+ // Both instructions must be in current basic block, i.e. the SchedulingGraph can see their
+ // corresponding SchedulingNode in the graph, and tell whether there is a dependency.
+ // Otherwise there is no dependency from SchedulingGraph's perspective, for example,
+ // instruction and other_instruction are in different basic blocks.
+ return false;
+ }
+ return node->HasOtherDependency(other);
+ }
+ };
+
HGraph* graph_;
};