diff options
author | 2024-08-26 12:07:52 +0000 | |
---|---|---|
committer | 2024-08-27 15:22:50 +0000 | |
commit | 94dab79b1cb768088c254349cdf8a14419e69ed6 (patch) | |
tree | 08435eb4305c42ac16dc39579f0d2ebb07d449d1 /compiler/optimizing/nodes_test.cc | |
parent | 581f40f6612a2a2d31e9f91ffe50b7c362490af2 (diff) |
ART: Clean up environment construction in gtests.
Create required instruction environments in helper functions
that create instructions.
Test: m test-art-host-gtest
Change-Id: Iacdd3c3717d95bc3e7fc3c1b676bc8eb70f2e6bc
Diffstat (limited to 'compiler/optimizing/nodes_test.cc')
-rw-r--r-- | compiler/optimizing/nodes_test.cc | 23 |
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>(¶meter1, 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>(¶meter1, 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); } |