blob: e8e1d408efd50c867ef23abd5c1fa889bdc60f2e [file] [log] [blame]
Ian Rogerse63db272014-07-15 15:36:11 -07001/*
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#include "common_compiler_test.h"
18
Andreas Gampeb68ed2c2018-06-20 10:39:31 -070019#include <type_traits>
20
Ian Rogersd582fa42014-11-05 23:46:43 -080021#include "arch/instruction_set_features.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070022#include "art_field-inl.h"
Andreas Gampec6ea7d02017-02-01 16:46:28 -080023#include "art_method-inl.h"
Andreas Gampe8228cdf2017-05-30 15:03:54 -070024#include "base/callee_save_type.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070025#include "base/enums.h"
David Sehrc431b9d2018-03-02 12:01:51 -080026#include "base/utils.h"
Ian Rogerse63db272014-07-15 15:36:11 -070027#include "class_linker.h"
Vladimir Markod8dbc8d2017-09-20 13:37:47 +010028#include "compiled_method-inl.h"
David Sehrb2ec9f52018-02-21 13:20:31 -080029#include "dex/descriptors_names.h"
Ian Rogerse63db272014-07-15 15:36:11 -070030#include "dex/quick_compiler_callbacks.h"
Mathieu Chartier5bdab122015-01-26 18:30:19 -080031#include "dex/verification_results.h"
Ian Rogerse63db272014-07-15 15:36:11 -070032#include "driver/compiler_driver.h"
Vladimir Marko20f85592015-03-19 10:07:02 +000033#include "driver/compiler_options.h"
Vladimir Markodc4bcce2018-06-21 16:15:42 +010034#include "jni/java_vm_ext.h"
Ian Rogerse63db272014-07-15 15:36:11 -070035#include "interpreter/interpreter.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070036#include "mirror/class-inl.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070037#include "mirror/class_loader.h"
Ian Rogerse63db272014-07-15 15:36:11 -070038#include "mirror/dex_cache.h"
39#include "mirror/object-inl.h"
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +010040#include "oat_quick_method_header.h"
Mathieu Chartier0795f232016-09-27 18:43:30 -070041#include "scoped_thread_state_change-inl.h"
Andreas Gampeb486a982017-06-01 13:45:54 -070042#include "thread-current-inl.h"
Vladimir Marko213ee2d2018-06-22 11:56:34 +010043#include "utils/atomic_dex_ref_map-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070044
45namespace art {
46
Ian Rogerse63db272014-07-15 15:36:11 -070047CommonCompilerTest::CommonCompilerTest() {}
48CommonCompilerTest::~CommonCompilerTest() {}
49
Mathieu Chartiere401d142015-04-22 13:56:20 -070050void CommonCompilerTest::MakeExecutable(ArtMethod* method) {
Ian Rogerse63db272014-07-15 15:36:11 -070051 CHECK(method != nullptr);
52
53 const CompiledMethod* compiled_method = nullptr;
54 if (!method->IsAbstract()) {
55 mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache();
56 const DexFile& dex_file = *dex_cache->GetDexFile();
57 compiled_method =
58 compiler_driver_->GetCompiledMethod(MethodReference(&dex_file,
59 method->GetDexMethodIndex()));
60 }
Calin Juravlee0ac1152017-02-13 19:03:47 -080061 // If the code size is 0 it means the method was skipped due to profile guided compilation.
62 if (compiled_method != nullptr && compiled_method->GetQuickCode().size() != 0u) {
Vladimir Marko35831e82015-09-11 11:59:18 +010063 ArrayRef<const uint8_t> code = compiled_method->GetQuickCode();
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070064 const uint32_t code_size = code.size();
Vladimir Marko35831e82015-09-11 11:59:18 +010065 ArrayRef<const uint8_t> vmap_table = compiled_method->GetVmapTable();
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070066 const uint32_t vmap_table_offset = vmap_table.empty() ? 0u
Vladimir Marko35831e82015-09-11 11:59:18 +010067 : sizeof(OatQuickMethodHeader) + vmap_table.size();
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070068 // The method info is directly before the vmap table.
69 ArrayRef<const uint8_t> method_info = compiled_method->GetMethodInfo();
70 const uint32_t method_info_offset = method_info.empty() ? 0u
71 : vmap_table_offset + method_info.size();
72
Vladimir Marko9d07e3d2016-03-31 12:02:28 +010073 OatQuickMethodHeader method_header(vmap_table_offset,
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070074 method_info_offset,
Elliott Hughes956af0f2014-12-11 14:34:28 -080075 compiled_method->GetFrameSizeInBytes(),
76 compiled_method->GetCoreSpillMask(),
Vladimir Marko9d07e3d2016-03-31 12:02:28 +010077 compiled_method->GetFpSpillMask(),
78 code_size);
Ian Rogerse63db272014-07-15 15:36:11 -070079
Elliott Hughes956af0f2014-12-11 14:34:28 -080080 header_code_and_maps_chunks_.push_back(std::vector<uint8_t>());
81 std::vector<uint8_t>* chunk = &header_code_and_maps_chunks_.back();
Vladimir Marko562ff442015-10-27 18:51:20 +000082 const size_t max_padding = GetInstructionSetAlignment(compiled_method->GetInstructionSet());
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070083 const size_t size = method_info.size() + vmap_table.size() + sizeof(method_header) + code_size;
Vladimir Marko562ff442015-10-27 18:51:20 +000084 chunk->reserve(size + max_padding);
Elliott Hughes956af0f2014-12-11 14:34:28 -080085 chunk->resize(sizeof(method_header));
Andreas Gampeb68ed2c2018-06-20 10:39:31 -070086 static_assert(std::is_trivially_copyable<OatQuickMethodHeader>::value, "Cannot use memcpy");
Elliott Hughes956af0f2014-12-11 14:34:28 -080087 memcpy(&(*chunk)[0], &method_header, sizeof(method_header));
Vladimir Marko35831e82015-09-11 11:59:18 +010088 chunk->insert(chunk->begin(), vmap_table.begin(), vmap_table.end());
Mathieu Chartiercbcedbf2017-03-12 22:24:50 -070089 chunk->insert(chunk->begin(), method_info.begin(), method_info.end());
Vladimir Marko35831e82015-09-11 11:59:18 +010090 chunk->insert(chunk->end(), code.begin(), code.end());
Vladimir Marko562ff442015-10-27 18:51:20 +000091 CHECK_EQ(chunk->size(), size);
92 const void* unaligned_code_ptr = chunk->data() + (size - code_size);
93 size_t offset = dchecked_integral_cast<size_t>(reinterpret_cast<uintptr_t>(unaligned_code_ptr));
94 size_t padding = compiled_method->AlignCode(offset) - offset;
95 // Make sure no resizing takes place.
96 CHECK_GE(chunk->capacity(), chunk->size() + padding);
97 chunk->insert(chunk->begin(), padding, 0);
98 const void* code_ptr = reinterpret_cast<const uint8_t*>(unaligned_code_ptr) + padding;
99 CHECK_EQ(code_ptr, static_cast<const void*>(chunk->data() + (chunk->size() - code_size)));
Vladimir Marko35831e82015-09-11 11:59:18 +0100100 MakeExecutable(code_ptr, code.size());
Ian Rogerse63db272014-07-15 15:36:11 -0700101 const void* method_code = CompiledMethod::CodePointer(code_ptr,
102 compiled_method->GetInstructionSet());
David Sehr709b0702016-10-13 09:12:37 -0700103 LOG(INFO) << "MakeExecutable " << method->PrettyMethod() << " code=" << method_code;
Vladimir Markofbfc3942017-07-27 16:51:35 +0100104 method->SetEntryPointFromQuickCompiledCode(method_code);
Ian Rogerse63db272014-07-15 15:36:11 -0700105 } else {
106 // No code? You must mean to go into the interpreter.
107 // Or the generic JNI...
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700108 class_linker_->SetEntryPointsToInterpreter(method);
Ian Rogerse63db272014-07-15 15:36:11 -0700109 }
110}
111
112void CommonCompilerTest::MakeExecutable(const void* code_start, size_t code_length) {
113 CHECK(code_start != nullptr);
114 CHECK_NE(code_length, 0U);
115 uintptr_t data = reinterpret_cast<uintptr_t>(code_start);
116 uintptr_t base = RoundDown(data, kPageSize);
117 uintptr_t limit = RoundUp(data + code_length, kPageSize);
118 uintptr_t len = limit - base;
119 int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC);
120 CHECK_EQ(result, 0);
121
Roland Levillain32430262016-02-01 15:23:20 +0000122 FlushInstructionCache(reinterpret_cast<char*>(base), reinterpret_cast<char*>(base + len));
Ian Rogerse63db272014-07-15 15:36:11 -0700123}
124
Mathieu Chartier0795f232016-09-27 18:43:30 -0700125void CommonCompilerTest::MakeExecutable(ObjPtr<mirror::ClassLoader> class_loader,
126 const char* class_name) {
Ian Rogerse63db272014-07-15 15:36:11 -0700127 std::string class_descriptor(DotToDescriptor(class_name));
128 Thread* self = Thread::Current();
129 StackHandleScope<1> hs(self);
130 Handle<mirror::ClassLoader> loader(hs.NewHandle(class_loader));
Vladimir Markoe9987b02018-05-22 16:26:43 +0100131 ObjPtr<mirror::Class> klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader);
Ian Rogerse63db272014-07-15 15:36:11 -0700132 CHECK(klass != nullptr) << "Class not found " << class_name;
Andreas Gampe542451c2016-07-26 09:02:02 -0700133 PointerSize pointer_size = class_linker_->GetImagePointerSize();
Alex Lighte64300b2015-12-15 15:02:47 -0800134 for (auto& m : klass->GetMethods(pointer_size)) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700135 MakeExecutable(&m);
Ian Rogerse63db272014-07-15 15:36:11 -0700136 }
137}
138
Vladimir Markodc4bcce2018-06-21 16:15:42 +0100139// Get the set of image classes given to the compiler options in SetUp.
Vladimir Marko54159c62018-06-20 14:30:08 +0100140std::unique_ptr<HashSet<std::string>> CommonCompilerTest::GetImageClasses() {
Andreas Gampe70bef0d2015-04-15 02:37:28 -0700141 // Empty set: by default no classes are retained in the image.
Vladimir Marko54159c62018-06-20 14:30:08 +0100142 return std::make_unique<HashSet<std::string>>();
Andreas Gampe70bef0d2015-04-15 02:37:28 -0700143}
144
Calin Juravle877fd962016-01-05 14:29:29 +0000145// Get ProfileCompilationInfo that should be passed to the driver.
146ProfileCompilationInfo* CommonCompilerTest::GetProfileCompilationInfo() {
147 // Null, profile information will not be taken into account.
148 return nullptr;
149}
150
Ian Rogerse63db272014-07-15 15:36:11 -0700151void CommonCompilerTest::SetUp() {
152 CommonRuntimeTest::SetUp();
153 {
154 ScopedObjectAccess soa(Thread::Current());
155
Vladimir Markoa0431112018-06-25 09:32:54 +0100156 runtime_->SetInstructionSet(instruction_set_);
Andreas Gampe8228cdf2017-05-30 15:03:54 -0700157 for (uint32_t i = 0; i < static_cast<uint32_t>(CalleeSaveType::kLastCalleeSaveType); ++i) {
158 CalleeSaveType type = CalleeSaveType(i);
Ian Rogerse63db272014-07-15 15:36:11 -0700159 if (!runtime_->HasCalleeSaveMethod(type)) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700160 runtime_->SetCalleeSaveMethod(runtime_->CreateCalleeSaveMethod(), type);
Ian Rogerse63db272014-07-15 15:36:11 -0700161 }
162 }
163
Vladimir Markoa0431112018-06-25 09:32:54 +0100164 CreateCompilerDriver();
Ian Rogerse63db272014-07-15 15:36:11 -0700165 }
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800166}
167
Vladimir Markoa0431112018-06-25 09:32:54 +0100168void CommonCompilerTest::ApplyInstructionSet() {
169 // Copy local instruction_set_ and instruction_set_features_ to *compiler_options_;
170 CHECK(instruction_set_features_ != nullptr);
171 if (instruction_set_ == InstructionSet::kThumb2) {
172 CHECK_EQ(InstructionSet::kArm, instruction_set_features_->GetInstructionSet());
173 } else {
174 CHECK_EQ(instruction_set_, instruction_set_features_->GetInstructionSet());
175 }
176 compiler_options_->instruction_set_ = instruction_set_;
177 compiler_options_->instruction_set_features_ =
178 InstructionSetFeatures::FromBitmap(instruction_set_, instruction_set_features_->AsBitmap());
179 CHECK(compiler_options_->instruction_set_features_->Equals(instruction_set_features_.get()));
180}
181
182void CommonCompilerTest::OverrideInstructionSetFeatures(InstructionSet instruction_set,
183 const std::string& variant) {
184 instruction_set_ = instruction_set;
185 std::string error_msg;
186 instruction_set_features_ =
187 InstructionSetFeatures::FromVariant(instruction_set, variant, &error_msg);
188 CHECK(instruction_set_features_ != nullptr) << error_msg;
189
190 if (compiler_options_ != nullptr) {
191 ApplyInstructionSet();
192 }
193}
194
195void CommonCompilerTest::CreateCompilerDriver() {
196 ApplyInstructionSet();
197
Vladimir Markoaad75c62016-10-03 08:46:48 +0000198 compiler_options_->boot_image_ = true;
Vladimir Markobb089b62018-06-28 17:30:16 +0100199 compiler_options_->compile_pic_ = false; // Non-PIC boot image is a test configuration.
Mathieu Chartierd0af56c2017-02-17 12:56:25 -0800200 compiler_options_->SetCompilerFilter(GetCompilerFilter());
Vladimir Markodc4bcce2018-06-21 16:15:42 +0100201 compiler_options_->image_classes_.swap(*GetImageClasses());
Mathieu Chartierceb07b32015-12-10 09:33:21 -0800202 compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
203 verification_results_.get(),
Vladimir Markoa0431112018-06-25 09:32:54 +0100204 compiler_kind_,
Vladimir Markodc4bcce2018-06-21 16:15:42 +0100205 &compiler_options_->image_classes_,
Vladimir Markoa0431112018-06-25 09:32:54 +0100206 number_of_threads_,
Vladimir Marko944da602016-02-19 12:27:55 +0000207 /* swap_fd */ -1,
Calin Juravle877fd962016-01-05 14:29:29 +0000208 GetProfileCompilationInfo()));
Ian Rogerse63db272014-07-15 15:36:11 -0700209}
210
211void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) {
212 CommonRuntimeTest::SetUpRuntimeOptions(options);
213
214 compiler_options_.reset(new CompilerOptions);
215 verification_results_.reset(new VerificationResults(compiler_options_.get()));
Mathieu Chartiere01b6f62017-07-19 16:55:04 -0700216 QuickCompilerCallbacks* callbacks =
217 new QuickCompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp);
218 callbacks->SetVerificationResults(verification_results_.get());
219 callbacks_.reset(callbacks);
Ian Rogerse63db272014-07-15 15:36:11 -0700220}
221
Roland Levillainbbcc01a2015-06-30 14:16:48 +0100222Compiler::Kind CommonCompilerTest::GetCompilerKind() const {
223 return compiler_kind_;
224}
225
226void CommonCompilerTest::SetCompilerKind(Compiler::Kind compiler_kind) {
227 compiler_kind_ = compiler_kind;
228}
229
Ian Rogerse63db272014-07-15 15:36:11 -0700230void CommonCompilerTest::TearDown() {
Ian Rogerse63db272014-07-15 15:36:11 -0700231 compiler_driver_.reset();
232 callbacks_.reset();
Ian Rogerse63db272014-07-15 15:36:11 -0700233 verification_results_.reset();
234 compiler_options_.reset();
Mathieu Chartier496577f2016-09-20 15:33:31 -0700235 image_reservation_.reset();
Ian Rogerse63db272014-07-15 15:36:11 -0700236
237 CommonRuntimeTest::TearDown();
238}
239
240void CommonCompilerTest::CompileClass(mirror::ClassLoader* class_loader, const char* class_name) {
241 std::string class_descriptor(DotToDescriptor(class_name));
242 Thread* self = Thread::Current();
243 StackHandleScope<1> hs(self);
244 Handle<mirror::ClassLoader> loader(hs.NewHandle(class_loader));
Vladimir Markoe9987b02018-05-22 16:26:43 +0100245 ObjPtr<mirror::Class> klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader);
Ian Rogerse63db272014-07-15 15:36:11 -0700246 CHECK(klass != nullptr) << "Class not found " << class_name;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700247 auto pointer_size = class_linker_->GetImagePointerSize();
Alex Lighte64300b2015-12-15 15:02:47 -0800248 for (auto& m : klass->GetMethods(pointer_size)) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700249 CompileMethod(&m);
Ian Rogerse63db272014-07-15 15:36:11 -0700250 }
251}
252
Mathieu Chartiere401d142015-04-22 13:56:20 -0700253void CommonCompilerTest::CompileMethod(ArtMethod* method) {
Ian Rogerse63db272014-07-15 15:36:11 -0700254 CHECK(method != nullptr);
Vladimir Markodc4bcce2018-06-21 16:15:42 +0100255 TimingLogger timings("CommonCompilerTest::CompileMethod", false, false);
Ian Rogerse63db272014-07-15 15:36:11 -0700256 TimingLogger::ScopedTiming t(__FUNCTION__, &timings);
Vladimir Markodc4bcce2018-06-21 16:15:42 +0100257 {
258 Thread* self = Thread::Current();
259 jobject class_loader = self->GetJniEnv()->GetVm()->AddGlobalRef(self, method->GetClassLoader());
260
261 DCHECK(!Runtime::Current()->IsStarted());
262 const DexFile* dex_file = method->GetDexFile();
263 uint16_t class_def_idx = method->GetClassDefIndex();
264 uint32_t method_idx = method->GetDexMethodIndex();
265 uint32_t access_flags = method->GetAccessFlags();
266 InvokeType invoke_type = method->GetInvokeType();
267 StackHandleScope<2> hs(self);
268 Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
269 Handle<mirror::ClassLoader> h_class_loader = hs.NewHandle(
270 self->DecodeJObject(class_loader)->AsClassLoader());
271 const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset());
272
273 std::vector<const DexFile*> dex_files;
274 dex_files.push_back(dex_file);
275
276 // Go to native so that we don't block GC during compilation.
277 ScopedThreadSuspension sts(self, kNative);
278
279 compiler_driver_->InitializeThreadPools();
280
281 compiler_driver_->PreCompile(class_loader, dex_files, &timings);
282
283 compiler_driver_->CompileOne(self,
284 class_loader,
285 *dex_file,
286 class_def_idx,
287 method_idx,
288 access_flags,
289 invoke_type,
290 code_item,
291 dex_cache,
292 h_class_loader);
293
294 compiler_driver_->FreeThreadPools();
295
296 self->GetJniEnv()->DeleteGlobalRef(class_loader);
297 }
Ian Rogerse63db272014-07-15 15:36:11 -0700298 TimingLogger::ScopedTiming t2("MakeExecutable", &timings);
299 MakeExecutable(method);
300}
301
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700302void CommonCompilerTest::CompileDirectMethod(Handle<mirror::ClassLoader> class_loader,
Ian Rogerse63db272014-07-15 15:36:11 -0700303 const char* class_name, const char* method_name,
304 const char* signature) {
305 std::string class_descriptor(DotToDescriptor(class_name));
306 Thread* self = Thread::Current();
Vladimir Markoe9987b02018-05-22 16:26:43 +0100307 ObjPtr<mirror::Class> klass =
308 class_linker_->FindClass(self, class_descriptor.c_str(), class_loader);
Ian Rogerse63db272014-07-15 15:36:11 -0700309 CHECK(klass != nullptr) << "Class not found " << class_name;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700310 auto pointer_size = class_linker_->GetImagePointerSize();
Vladimir Markoba118822017-06-12 15:41:56 +0100311 ArtMethod* method = klass->FindClassMethod(method_name, signature, pointer_size);
312 CHECK(method != nullptr && method->IsDirect()) << "Direct method not found: "
Ian Rogerse63db272014-07-15 15:36:11 -0700313 << class_name << "." << method_name << signature;
314 CompileMethod(method);
315}
316
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700317void CommonCompilerTest::CompileVirtualMethod(Handle<mirror::ClassLoader> class_loader,
Mathieu Chartierbf99f772014-08-23 16:37:27 -0700318 const char* class_name, const char* method_name,
319 const char* signature) {
Ian Rogerse63db272014-07-15 15:36:11 -0700320 std::string class_descriptor(DotToDescriptor(class_name));
321 Thread* self = Thread::Current();
Vladimir Markoe9987b02018-05-22 16:26:43 +0100322 ObjPtr<mirror::Class> klass =
323 class_linker_->FindClass(self, class_descriptor.c_str(), class_loader);
Ian Rogerse63db272014-07-15 15:36:11 -0700324 CHECK(klass != nullptr) << "Class not found " << class_name;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700325 auto pointer_size = class_linker_->GetImagePointerSize();
Vladimir Markoba118822017-06-12 15:41:56 +0100326 ArtMethod* method = klass->FindClassMethod(method_name, signature, pointer_size);
327 CHECK(method != nullptr && !method->IsDirect()) << "Virtual method not found: "
Ian Rogerse63db272014-07-15 15:36:11 -0700328 << class_name << "." << method_name << signature;
329 CompileMethod(method);
330}
331
332void CommonCompilerTest::ReserveImageSpace() {
333 // Reserve where the image will be loaded up front so that other parts of test set up don't
334 // accidentally end up colliding with the fixed memory address when we need to load the image.
335 std::string error_msg;
Mathieu Chartier6e88ef62014-10-14 15:01:24 -0700336 MemMap::Init();
Ian Rogerse63db272014-07-15 15:36:11 -0700337 image_reservation_.reset(MemMap::MapAnonymous("image reservation",
Ian Rogers13735952014-10-08 12:43:28 -0700338 reinterpret_cast<uint8_t*>(ART_BASE_ADDRESS),
Hiroshi Yamauchi1d6fdaf2016-04-07 11:31:26 -0700339 (size_t)120 * 1024 * 1024, // 120MB
Ian Rogerse63db272014-07-15 15:36:11 -0700340 PROT_NONE,
341 false /* no need for 4gb flag with fixed mmap*/,
Vladimir Marko5c42c292015-02-25 12:02:49 +0000342 false /* not reusing existing reservation */,
Ian Rogerse63db272014-07-15 15:36:11 -0700343 &error_msg));
344 CHECK(image_reservation_.get() != nullptr) << error_msg;
345}
346
347void CommonCompilerTest::UnreserveImageSpace() {
348 image_reservation_.reset();
349}
350
Vladimir Marko213ee2d2018-06-22 11:56:34 +0100351void CommonCompilerTest::SetDexFilesForOatFile(const std::vector<const DexFile*>& dex_files) {
352 compiler_options_->dex_files_for_oat_file_ = dex_files;
353 compiler_driver_->compiled_classes_.AddDexFiles(dex_files);
354 compiler_driver_->dex_to_dex_compiler_.SetDexFiles(dex_files);
355}
356
Vladimir Markoa0431112018-06-25 09:32:54 +0100357void CommonCompilerTest::ClearBootImageOption() {
358 compiler_options_->boot_image_ = false;
359}
360
Ian Rogerse63db272014-07-15 15:36:11 -0700361} // namespace art