summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/nodes_test.cc')
-rw-r--r--compiler/optimizing/nodes_test.cc23
1 files changed, 5 insertions, 18 deletions
diff --git a/compiler/optimizing/nodes_test.cc b/compiler/optimizing/nodes_test.cc
index 01e12a061f..1a1d9ac7da 100644
--- a/compiler/optimizing/nodes_test.cc
+++ b/compiler/optimizing/nodes_test.cc
@@ -147,13 +147,7 @@ TEST_F(NodeTest, RemoveInstruction) {
HInstruction* parameter = MakeParam(DataType::Type::kReference);
- HInstruction* null_check = MakeNullCheck(main, parameter);
-
- HEnvironment* environment = new (GetAllocator()) HEnvironment(
- GetAllocator(), 1, graph_->GetArtMethod(), 0, null_check);
- null_check->SetRawEnvironment(environment);
- environment->SetRawEnvAt(0, parameter);
- parameter->AddEnvUseAt(null_check->GetEnvironment(), 0);
+ HInstruction* null_check = MakeNullCheck(main, parameter, /*env=*/ {parameter});
ASSERT_TRUE(parameter->HasEnvironmentUses());
ASSERT_TRUE(parameter->HasUses());
@@ -209,38 +203,31 @@ TEST_F(NodeTest, ParentEnvironment) {
graph->AddBlock(entry);
graph->SetEntryBlock(entry);
HInstruction* parameter1 = MakeParam(DataType::Type::kReference);
- HInstruction* with_environment = MakeNullCheck(entry, parameter1);
+ HInstruction* with_environment = MakeNullCheck(entry, parameter1, /*env=*/ {parameter1});
MakeExit(entry);
ASSERT_TRUE(parameter1->HasUses());
ASSERT_TRUE(parameter1->GetUses().HasExactlyOneElement());
- HEnvironment* environment = new (GetAllocator()) HEnvironment(
- GetAllocator(), 1, graph->GetArtMethod(), 0, with_environment);
- HInstruction* const array[] = { parameter1 };
-
- environment->CopyFrom(ArrayRef<HInstruction* const>(array));
- with_environment->SetRawEnvironment(environment);
-
ASSERT_TRUE(parameter1->HasEnvironmentUses());
ASSERT_TRUE(parameter1->GetEnvUses().HasExactlyOneElement());
HEnvironment* parent1 = new (GetAllocator()) HEnvironment(
GetAllocator(), 1, graph->GetArtMethod(), 0, nullptr);
- parent1->CopyFrom(ArrayRef<HInstruction* const>(array));
+ parent1->CopyFrom(ArrayRef<HInstruction* const>(&parameter1, 1u));
ASSERT_EQ(parameter1->GetEnvUses().SizeSlow(), 2u);
HEnvironment* parent2 = new (GetAllocator()) HEnvironment(
GetAllocator(), 1, graph->GetArtMethod(), 0, nullptr);
- parent2->CopyFrom(ArrayRef<HInstruction* const>(array));
+ parent2->CopyFrom(ArrayRef<HInstruction* const>(&parameter1, 1u));
parent1->SetAndCopyParentChain(GetAllocator(), parent2);
// One use for parent2, and one other use for the new parent of parent1.
ASSERT_EQ(parameter1->GetEnvUses().SizeSlow(), 4u);
// We have copied the parent chain. So we now have two more uses.
- environment->SetAndCopyParentChain(GetAllocator(), parent1);
+ with_environment->GetEnvironment()->SetAndCopyParentChain(GetAllocator(), parent1);
ASSERT_EQ(parameter1->GetEnvUses().SizeSlow(), 6u);
}