summaryrefslogtreecommitdiff
path: root/compiler/common_compiler_test.h
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2020-11-18 12:23:48 -0800
committerTreehugger Robot <treehugger-gerrit@google.com>2020-12-10 18:09:40 +0000
commit3ac2f5a25e9cae22ec8f5ae5e28de93f34d6485a (patch)
tree70b8e5628d1d98490229ae98b370cf3407cfcc04 /compiler/common_compiler_test.h
parent0b8b5a731f37491e1b135f577b16a5376bf4b753 (diff)
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
Diffstat (limited to 'compiler/common_compiler_test.h')
-rw-r--r--compiler/common_compiler_test.h47
1 files changed, 41 insertions, 6 deletions
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 T> class Handle;
-class CommonCompilerTest : public CommonRuntimeTest {
+class CommonCompilerTestImpl {
public:
static std::unique_ptr<CompilerOptions> 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<CompilerOptions> compiler_options_;
std::unique_ptr<VerificationResults> 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<std::vector<uint8_t>> header_code_and_maps_chunks_;
};
+template <typename RuntimeBase>
+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<CommonRuntimeTest> {};
+
+template <typename Param>
+class CommonCompilerTestWithParam
+ : public CommonCompilerTestBase<CommonRuntimeTestWithParam<Param>> {};
+
} // namespace art
#endif // ART_COMPILER_COMMON_COMPILER_TEST_H_