1 /*
2  * Copyright (C) 2019 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_DEX2OAT_COMMON_COMPILER_DRIVER_TEST_H_
18 #define ART_DEX2OAT_COMMON_COMPILER_DRIVER_TEST_H_
19 
20 #include <vector>
21 
22 #include <jni.h>
23 
24 #include "common_compiler_test.h"
25 #include "base/hash_set.h"
26 #include "base/mem_map.h"
27 
28 namespace art {
29 
30 class CompilerDriver;
31 class DexFile;
32 class ProfileCompilationInfo;
33 class TimingLogger;
34 
35 class CommonCompilerDriverTest : public CommonCompilerTest {
36  public:
37   CommonCompilerDriverTest();
38   ~CommonCompilerDriverTest();
39 
40   void CompileAll(jobject class_loader,
41                   const std::vector<const DexFile*>& dex_files,
42                   TimingLogger* timings) REQUIRES(!Locks::mutator_lock_);
43 
44   void SetDexFilesForOatFile(const std::vector<const DexFile*>& dex_files);
45 
46   void ReserveImageSpace();
47 
48   void UnreserveImageSpace();
49 
50   void CreateCompilerDriver();
51 
52  protected:
53   void SetUpRuntimeOptions(RuntimeOptions* options) override;
54 
55   void SetUp() override;
56   void TearDown() override;
57 
58   // Get the set of image classes given to the compiler-driver in SetUp.
59   virtual std::unique_ptr<HashSet<std::string>> GetImageClasses();
60 
61   virtual ProfileCompilationInfo* GetProfileCompilationInfo();
62 
63   size_t number_of_threads_ = 2u;
64 
65   std::unique_ptr<CompilerDriver> compiler_driver_;
66 
67  private:
68   MemMap image_reservation_;
69   void* inaccessible_page_;
70 };
71 
72 }  // namespace art
73 
74 #endif  // ART_DEX2OAT_COMMON_COMPILER_DRIVER_TEST_H_
75