blob: 20b750c55b83d39a9de6309466a372a35dcfdc00 [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
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080023#include "common_runtime_test.h"
Ian Rogerse63db272014-07-15 15:36:11 -070024#include "oat_file.h"
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080025
26namespace art {
Ian Rogerse63db272014-07-15 15:36:11 -070027namespace mirror {
28 class ClassLoader;
29} // namespace mirror
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080030
Ian Rogerse63db272014-07-15 15:36:11 -070031class CompilerDriver;
32class CompilerOptions;
33class CumulativeLogger;
34class DexFileToMethodInlinerMap;
35class VerificationResults;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080036
Ian Rogerse63db272014-07-15 15:36:11 -070037template<class T> class Handle;
Dmitry Petrochenkof0972a42014-05-16 17:43:39 +070038
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080039class CommonCompilerTest : public CommonRuntimeTest {
40 public:
Ian Rogerse63db272014-07-15 15:36:11 -070041 CommonCompilerTest();
42 ~CommonCompilerTest();
43
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080044 // Create an OatMethod based on pointers (for unit tests).
Ian Rogerse63db272014-07-15 15:36:11 -070045 OatFile::OatMethod CreateOatMethod(const void* code, const uint8_t* gc_map);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080046
Ian Rogerse63db272014-07-15 15:36:11 -070047 void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080048
Ian Rogerse63db272014-07-15 15:36:11 -070049 static void MakeExecutable(const void* code_start, size_t code_length);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080050
51 void MakeExecutable(mirror::ClassLoader* class_loader, const char* class_name)
Ian Rogerse63db272014-07-15 15:36:11 -070052 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080053
54 protected:
Ian Rogerse63db272014-07-15 15:36:11 -070055 virtual void SetUp();
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080056
Ian Rogerse63db272014-07-15 15:36:11 -070057 virtual void SetUpRuntimeOptions(RuntimeOptions *options);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080058
Ian Rogerse63db272014-07-15 15:36:11 -070059 virtual void TearDown();
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080060
61 void CompileClass(mirror::ClassLoader* class_loader, const char* class_name)
Ian Rogerse63db272014-07-15 15:36:11 -070062 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080063
Ian Rogerse63db272014-07-15 15:36:11 -070064 void CompileMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080065
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070066 void CompileDirectMethod(Handle<mirror::ClassLoader> class_loader, const char* class_name,
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080067 const char* method_name, const char* signature)
Ian Rogerse63db272014-07-15 15:36:11 -070068 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080069
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070070 void CompileVirtualMethod(Handle<mirror::ClassLoader> class_loader, const char* class_name,
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080071 const char* method_name, const char* signature)
Ian Rogerse63db272014-07-15 15:36:11 -070072 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080073
Ian Rogerse63db272014-07-15 15:36:11 -070074 void ReserveImageSpace();
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080075
Ian Rogerse63db272014-07-15 15:36:11 -070076 void UnreserveImageSpace();
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080077
Ian Rogers700a4022014-05-19 16:49:03 -070078 std::unique_ptr<CompilerOptions> compiler_options_;
79 std::unique_ptr<VerificationResults> verification_results_;
80 std::unique_ptr<DexFileToMethodInlinerMap> method_inliner_map_;
Ian Rogerse63db272014-07-15 15:36:11 -070081 std::unique_ptr<CompilerCallbacks> callbacks_;
Ian Rogers700a4022014-05-19 16:49:03 -070082 std::unique_ptr<CompilerDriver> compiler_driver_;
83 std::unique_ptr<CumulativeLogger> timer_;
Ian Rogers6f3dbba2014-10-14 17:41:57 -070084 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_;
85
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080086
87 private:
Ian Rogers700a4022014-05-19 16:49:03 -070088 std::unique_ptr<MemMap> image_reservation_;
Vladimir Marko8a630572014-04-09 18:45:35 +010089
90 // Chunks must not move their storage after being created - use the node-based std::list.
Ian Rogers700a4022014-05-19 16:49:03 -070091 std::list<std::vector<uint8_t>> header_code_and_maps_chunks_;
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -080092};
93
94} // namespace art
95
96#endif // ART_COMPILER_COMMON_COMPILER_TEST_H_