blob: 4f4e49a72002b57902ef1bba594f3089efc05431 [file] [log] [blame]
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_COMMON_COMPILER_TEST_H_
18#define ART_COMPILER_COMMON_COMPILER_TEST_H_
19
Ian Rogerse63db272014-07-15 15:36:11 -070020#include <list>
21#include <vector>
22
Vladimir Marko2afaff72018-11-30 17:01:50 +000023#include <jni.h>
24
Vladimir Markoa0431112018-06-25 09:32:54 +010025#include "arch/instruction_set.h"
26#include "arch/instruction_set_features.h"
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080027#include "common_runtime_test.h"
Roland Levillainbbcc01a2015-06-30 14:16:48 +010028#include "compiler.h"
Ian Rogerse63db272014-07-15 15:36:11 -070029#include "oat_file.h"
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080030
31namespace art {
Ian Rogerse63db272014-07-15 15:36:11 -070032namespace mirror {
Igor Murashkin2ffb7032017-11-08 13:35:21 -080033class ClassLoader;
Ian Rogerse63db272014-07-15 15:36:11 -070034} // namespace mirror
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080035
Vladimir Marko815d5e52019-03-04 10:18:31 +000036class CompiledMethod;
Ian Rogerse63db272014-07-15 15:36:11 -070037class CompilerOptions;
38class CumulativeLogger;
Vladimir Marko213ee2d2018-06-22 11:56:34 +010039class DexFile;
Vladimir Marko2afaff72018-11-30 17:01:50 +000040class TimingLogger;
Ian Rogerse63db272014-07-15 15:36:11 -070041class VerificationResults;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080042
Ian Rogerse63db272014-07-15 15:36:11 -070043template<class T> class Handle;
Dmitry Petrochenkof0972a42014-05-16 17:43:39 +070044
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080045class CommonCompilerTest : public CommonRuntimeTest {
46 public:
Ian Rogerse63db272014-07-15 15:36:11 -070047 CommonCompilerTest();
48 ~CommonCompilerTest();
49
Vladimir Marko815d5e52019-03-04 10:18:31 +000050 void MakeExecutable(ArtMethod* method, const CompiledMethod* compiled_method)
51 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080052
Ian Rogerse63db272014-07-15 15:36:11 -070053 static void MakeExecutable(const void* code_start, size_t code_length);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080054
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080055 protected:
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010056 void SetUp() override;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080057
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010058 void SetUpRuntimeOptions(RuntimeOptions* options) override;
Roland Levillainbbcc01a2015-06-30 14:16:48 +010059
60 Compiler::Kind GetCompilerKind() const;
61 void SetCompilerKind(Compiler::Kind compiler_kind);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080062
Mathieu Chartierd0af56c2017-02-17 12:56:25 -080063 virtual CompilerFilter::Filter GetCompilerFilter() const {
64 return CompilerFilter::kDefaultCompilerFilter;
65 }
66
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010067 void TearDown() override;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080068
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070069 void CompileMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080070
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070071 void CompileDirectMethod(Handle<mirror::ClassLoader> class_loader, const char* class_name,
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080072 const char* method_name, const char* signature)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070073 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080074
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070075 void CompileVirtualMethod(Handle<mirror::ClassLoader> class_loader, const char* class_name,
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080076 const char* method_name, const char* signature)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070077 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080078
Vladimir Markoa0431112018-06-25 09:32:54 +010079 void ApplyInstructionSet();
80 void OverrideInstructionSetFeatures(InstructionSet instruction_set, const std::string& variant);
81
Vladimir Markoa0431112018-06-25 09:32:54 +010082 void ClearBootImageOption();
83
Nicolas Geoffray409e8092015-10-01 10:32:19 +010084 Compiler::Kind compiler_kind_ = Compiler::kOptimizing;
Vladimir Markoa0431112018-06-25 09:32:54 +010085
86 InstructionSet instruction_set_ =
87 (kRuntimeISA == InstructionSet::kArm) ? InstructionSet::kThumb2 : kRuntimeISA;
88 // Take the default set of instruction features from the build.
89 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_
90 = InstructionSetFeatures::FromCppDefines();
91
Ian Rogers700a4022014-05-19 16:49:03 -070092 std::unique_ptr<CompilerOptions> compiler_options_;
93 std::unique_ptr<VerificationResults> verification_results_;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080094
95 private:
Vladimir Marko8a630572014-04-09 18:45:35 +010096 // Chunks must not move their storage after being created - use the node-based std::list.
Ian Rogers700a4022014-05-19 16:49:03 -070097 std::list<std::vector<uint8_t>> header_code_and_maps_chunks_;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080098};
99
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800100} // namespace art
101
102#endif // ART_COMPILER_COMMON_COMPILER_TEST_H_