From 3ac2f5a25e9cae22ec8f5ae5e28de93f34d6485a Mon Sep 17 00:00:00 2001 From: Alex Light Date: Wed, 18 Nov 2020 12:23:48 -0800 Subject: Make RTP::Visit robust against input order ReferenceTypePropogation::Visit(ArrayRef) relied on the input having a particular order with known values at the front then topological. This could cause issues if the list was not properly sorted, causing the RTP to silently fail. This makes RTP robust against the ordering of inputs for this function. Test: ./test.py --host Bug: 67037140 Change-Id: I03c522ea745f271ce438c82f7c6f3ab476c8249a --- compiler/common_compiler_test.h | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'compiler/common_compiler_test.h') diff --git a/compiler/common_compiler_test.h b/compiler/common_compiler_test.h index 703e5f8523..8317d7f48a 100644 --- a/compiler/common_compiler_test.h +++ b/compiler/common_compiler_test.h @@ -42,13 +42,13 @@ class VerificationResults; template class Handle; -class CommonCompilerTest : public CommonRuntimeTest { +class CommonCompilerTestImpl { public: static std::unique_ptr CreateCompilerOptions(InstructionSet instruction_set, const std::string& variant); - CommonCompilerTest(); - ~CommonCompilerTest(); + CommonCompilerTestImpl(); + virtual ~CommonCompilerTestImpl(); void MakeExecutable(ArtMethod* method, const CompiledMethod* compiled_method) REQUIRES_SHARED(Locks::mutator_lock_); @@ -56,9 +56,9 @@ class CommonCompilerTest : public CommonRuntimeTest { static void MakeExecutable(const void* code_start, size_t code_length); protected: - void SetUp() override; + void SetUp(); - void SetUpRuntimeOptions(RuntimeOptions* options) override; + void SetUpRuntimeOptionsImpl(); Compiler::Kind GetCompilerKind() const; void SetCompilerKind(Compiler::Kind compiler_kind); @@ -67,7 +67,7 @@ class CommonCompilerTest : public CommonRuntimeTest { return CompilerFilter::kDefaultCompilerFilter; } - void TearDown() override; + void TearDown(); void CompileMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); @@ -95,11 +95,46 @@ class CommonCompilerTest : public CommonRuntimeTest { std::unique_ptr compiler_options_; std::unique_ptr verification_results_; + protected: + virtual ClassLinker* GetClassLinker() = 0; + virtual Runtime* GetRuntime() = 0; + private: // Chunks must not move their storage after being created - use the node-based std::list. std::list> header_code_and_maps_chunks_; }; +template +class CommonCompilerTestBase : public CommonCompilerTestImpl, public RuntimeBase { + public: + void SetUp() override { + RuntimeBase::SetUp(); + CommonCompilerTestImpl::SetUp(); + } + void SetUpRuntimeOptions(RuntimeOptions* options) override { + RuntimeBase::SetUpRuntimeOptions(options); + CommonCompilerTestImpl::SetUpRuntimeOptionsImpl(); + } + void TearDown() override { + CommonCompilerTestImpl::TearDown(); + RuntimeBase::TearDown(); + } + + protected: + ClassLinker* GetClassLinker() override { + return RuntimeBase::class_linker_; + } + Runtime* GetRuntime() override { + return RuntimeBase::runtime_.get(); + } +}; + +class CommonCompilerTest : public CommonCompilerTestBase {}; + +template +class CommonCompilerTestWithParam + : public CommonCompilerTestBase> {}; + } // namespace art #endif // ART_COMPILER_COMMON_COMPILER_TEST_H_ -- cgit v1.2.3-59-g8ed1b