Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 19 | #include "arch/instruction_set_features.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 20 | #include "art_field-inl.h" |
| 21 | #include "art_method.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 22 | #include "class_linker.h" |
| 23 | #include "compiled_method.h" |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 24 | #include "dex/pass_manager.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 25 | #include "dex/quick_compiler_callbacks.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 26 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 27 | #include "dex/verification_results.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 28 | #include "driver/compiler_driver.h" |
Vladimir Marko | 20f8559 | 2015-03-19 10:07:02 +0000 | [diff] [blame] | 29 | #include "driver/compiler_options.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 30 | #include "interpreter/interpreter.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 31 | #include "mirror/class_loader.h" |
| 32 | #include "mirror/class-inl.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 33 | #include "mirror/dex_cache.h" |
| 34 | #include "mirror/object-inl.h" |
Nicolas Geoffray | 524e7ea | 2015-10-16 17:13:34 +0100 | [diff] [blame] | 35 | #include "oat_quick_method_header.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 36 | #include "scoped_thread_state_change.h" |
| 37 | #include "thread-inl.h" |
| 38 | #include "utils.h" |
| 39 | |
| 40 | namespace art { |
| 41 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 42 | CommonCompilerTest::CommonCompilerTest() {} |
| 43 | CommonCompilerTest::~CommonCompilerTest() {} |
| 44 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 45 | void CommonCompilerTest::MakeExecutable(ArtMethod* method) { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 46 | CHECK(method != nullptr); |
| 47 | |
| 48 | const CompiledMethod* compiled_method = nullptr; |
| 49 | if (!method->IsAbstract()) { |
| 50 | mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); |
| 51 | const DexFile& dex_file = *dex_cache->GetDexFile(); |
| 52 | compiled_method = |
| 53 | compiler_driver_->GetCompiledMethod(MethodReference(&dex_file, |
| 54 | method->GetDexMethodIndex())); |
| 55 | } |
| 56 | if (compiled_method != nullptr) { |
Andreas Gampe | e21dc3d | 2014-12-08 16:59:43 -0800 | [diff] [blame] | 57 | const SwapVector<uint8_t>* code = compiled_method->GetQuickCode(); |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 58 | uint32_t code_size = code->size(); |
| 59 | CHECK_NE(0u, code_size); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 60 | const SwapVector<uint8_t>* vmap_table = compiled_method->GetVmapTable(); |
| 61 | uint32_t vmap_table_offset = vmap_table->empty() ? 0u |
| 62 | : sizeof(OatQuickMethodHeader) + vmap_table->size(); |
Andreas Gampe | a2d0afc | 2014-12-22 13:43:33 -0800 | [diff] [blame] | 63 | const SwapVector<uint8_t>* mapping_table = compiled_method->GetMappingTable(); |
| 64 | bool mapping_table_used = mapping_table != nullptr && !mapping_table->empty(); |
| 65 | size_t mapping_table_size = mapping_table_used ? mapping_table->size() : 0U; |
| 66 | uint32_t mapping_table_offset = !mapping_table_used ? 0u |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 67 | : sizeof(OatQuickMethodHeader) + vmap_table->size() + mapping_table_size; |
Andreas Gampe | a2d0afc | 2014-12-22 13:43:33 -0800 | [diff] [blame] | 68 | const SwapVector<uint8_t>* gc_map = compiled_method->GetGcMap(); |
| 69 | bool gc_map_used = gc_map != nullptr && !gc_map->empty(); |
| 70 | size_t gc_map_size = gc_map_used ? gc_map->size() : 0U; |
| 71 | uint32_t gc_map_offset = !gc_map_used ? 0u |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 72 | : sizeof(OatQuickMethodHeader) + vmap_table->size() + mapping_table_size + gc_map_size; |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 73 | OatQuickMethodHeader method_header(mapping_table_offset, vmap_table_offset, gc_map_offset, |
| 74 | compiled_method->GetFrameSizeInBytes(), |
| 75 | compiled_method->GetCoreSpillMask(), |
| 76 | compiled_method->GetFpSpillMask(), code_size); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 77 | |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 78 | header_code_and_maps_chunks_.push_back(std::vector<uint8_t>()); |
| 79 | std::vector<uint8_t>* chunk = &header_code_and_maps_chunks_.back(); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 80 | size_t size = sizeof(method_header) + code_size + vmap_table->size() + mapping_table_size + |
Andreas Gampe | a2d0afc | 2014-12-22 13:43:33 -0800 | [diff] [blame] | 81 | gc_map_size; |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 82 | size_t code_offset = compiled_method->AlignCode(size - code_size); |
| 83 | size_t padding = code_offset - (size - code_size); |
| 84 | chunk->reserve(padding + size); |
| 85 | chunk->resize(sizeof(method_header)); |
| 86 | memcpy(&(*chunk)[0], &method_header, sizeof(method_header)); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 87 | chunk->insert(chunk->begin(), vmap_table->begin(), vmap_table->end()); |
Andreas Gampe | a2d0afc | 2014-12-22 13:43:33 -0800 | [diff] [blame] | 88 | if (mapping_table_used) { |
| 89 | chunk->insert(chunk->begin(), mapping_table->begin(), mapping_table->end()); |
| 90 | } |
| 91 | if (gc_map_used) { |
| 92 | chunk->insert(chunk->begin(), gc_map->begin(), gc_map->end()); |
| 93 | } |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 94 | chunk->insert(chunk->begin(), padding, 0); |
| 95 | chunk->insert(chunk->end(), code->begin(), code->end()); |
| 96 | CHECK_EQ(padding + size, chunk->size()); |
| 97 | const void* code_ptr = &(*chunk)[code_offset]; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 98 | MakeExecutable(code_ptr, code->size()); |
| 99 | const void* method_code = CompiledMethod::CodePointer(code_ptr, |
| 100 | compiled_method->GetInstructionSet()); |
| 101 | LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code; |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 102 | class_linker_->SetEntryPointsToCompiledCode(method, method_code); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 103 | } else { |
| 104 | // No code? You must mean to go into the interpreter. |
| 105 | // Or the generic JNI... |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 106 | class_linker_->SetEntryPointsToInterpreter(method); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | |
| 110 | void CommonCompilerTest::MakeExecutable(const void* code_start, size_t code_length) { |
| 111 | CHECK(code_start != nullptr); |
| 112 | CHECK_NE(code_length, 0U); |
| 113 | uintptr_t data = reinterpret_cast<uintptr_t>(code_start); |
| 114 | uintptr_t base = RoundDown(data, kPageSize); |
| 115 | uintptr_t limit = RoundUp(data + code_length, kPageSize); |
| 116 | uintptr_t len = limit - base; |
| 117 | int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC); |
| 118 | CHECK_EQ(result, 0); |
| 119 | |
| 120 | // Flush instruction cache |
| 121 | // Only uses __builtin___clear_cache if GCC >= 4.3.3 |
| 122 | #if GCC_VERSION >= 40303 |
| 123 | __builtin___clear_cache(reinterpret_cast<void*>(base), reinterpret_cast<void*>(base + len)); |
| 124 | #else |
| 125 | // Only warn if not Intel as Intel doesn't have cache flush instructions. |
| 126 | #if !defined(__i386__) && !defined(__x86_64__) |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 127 | UNIMPLEMENTED(WARNING) << "cache flush"; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 128 | #endif |
| 129 | #endif |
| 130 | } |
| 131 | |
| 132 | void CommonCompilerTest::MakeExecutable(mirror::ClassLoader* class_loader, const char* class_name) { |
| 133 | std::string class_descriptor(DotToDescriptor(class_name)); |
| 134 | Thread* self = Thread::Current(); |
| 135 | StackHandleScope<1> hs(self); |
| 136 | Handle<mirror::ClassLoader> loader(hs.NewHandle(class_loader)); |
| 137 | mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader); |
| 138 | CHECK(klass != nullptr) << "Class not found " << class_name; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 139 | size_t pointer_size = class_linker_->GetImagePointerSize(); |
| 140 | for (auto& m : klass->GetDirectMethods(pointer_size)) { |
| 141 | MakeExecutable(&m); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 142 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 143 | for (auto& m : klass->GetVirtualMethods(pointer_size)) { |
| 144 | MakeExecutable(&m); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
Andreas Gampe | 70bef0d | 2015-04-15 02:37:28 -0700 | [diff] [blame] | 148 | // Get the set of image classes given to the compiler-driver in SetUp. Note: the compiler |
| 149 | // driver assumes ownership of the set, so the test should properly release the set. |
| 150 | std::unordered_set<std::string>* CommonCompilerTest::GetImageClasses() { |
| 151 | // Empty set: by default no classes are retained in the image. |
| 152 | return new std::unordered_set<std::string>(); |
| 153 | } |
| 154 | |
| 155 | // Get the set of compiled classes given to the compiler-driver in SetUp. Note: the compiler |
| 156 | // driver assumes ownership of the set, so the test should properly release the set. |
| 157 | std::unordered_set<std::string>* CommonCompilerTest::GetCompiledClasses() { |
| 158 | // Null, no selection of compiled-classes. |
| 159 | return nullptr; |
| 160 | } |
| 161 | |
| 162 | // Get the set of compiled methods given to the compiler-driver in SetUp. Note: the compiler |
| 163 | // driver assumes ownership of the set, so the test should properly release the set. |
| 164 | std::unordered_set<std::string>* CommonCompilerTest::GetCompiledMethods() { |
| 165 | // Null, no selection of compiled-methods. |
| 166 | return nullptr; |
| 167 | } |
| 168 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 169 | void CommonCompilerTest::SetUp() { |
| 170 | CommonRuntimeTest::SetUp(); |
| 171 | { |
| 172 | ScopedObjectAccess soa(Thread::Current()); |
| 173 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 174 | const InstructionSet instruction_set = kRuntimeISA; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 175 | // Take the default set of instruction features from the build. |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 176 | instruction_set_features_.reset(InstructionSetFeatures::FromCppDefines()); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 177 | |
| 178 | runtime_->SetInstructionSet(instruction_set); |
| 179 | for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { |
| 180 | Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i); |
| 181 | if (!runtime_->HasCalleeSaveMethod(type)) { |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 182 | runtime_->SetCalleeSaveMethod(runtime_->CreateCalleeSaveMethod(), type); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 186 | timer_.reset(new CumulativeLogger("Compilation times")); |
| 187 | compiler_driver_.reset(new CompilerDriver(compiler_options_.get(), |
| 188 | verification_results_.get(), |
| 189 | method_inliner_map_.get(), |
Roland Levillain | bbcc01a | 2015-06-30 14:16:48 +0100 | [diff] [blame] | 190 | compiler_kind_, instruction_set, |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 191 | instruction_set_features_.get(), |
Andreas Gampe | 70bef0d | 2015-04-15 02:37:28 -0700 | [diff] [blame] | 192 | true, |
| 193 | GetImageClasses(), |
| 194 | GetCompiledClasses(), |
| 195 | GetCompiledMethods(), |
Calin Juravle | 87000a9 | 2015-08-24 15:34:44 +0100 | [diff] [blame] | 196 | 2, true, true, "", false, timer_.get(), -1, "")); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 197 | } |
| 198 | // We typically don't generate an image in unit tests, disable this optimization by default. |
| 199 | compiler_driver_->SetSupportBootImageFixup(false); |
| 200 | } |
| 201 | |
| 202 | void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) { |
| 203 | CommonRuntimeTest::SetUpRuntimeOptions(options); |
| 204 | |
| 205 | compiler_options_.reset(new CompilerOptions); |
| 206 | verification_results_.reset(new VerificationResults(compiler_options_.get())); |
| 207 | method_inliner_map_.reset(new DexFileToMethodInlinerMap); |
| 208 | callbacks_.reset(new QuickCompilerCallbacks(verification_results_.get(), |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 209 | method_inliner_map_.get(), |
Andreas Gampe | 4585f87 | 2015-03-27 23:45:15 -0700 | [diff] [blame] | 210 | CompilerCallbacks::CallbackMode::kCompileApp)); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Roland Levillain | bbcc01a | 2015-06-30 14:16:48 +0100 | [diff] [blame] | 213 | Compiler::Kind CommonCompilerTest::GetCompilerKind() const { |
| 214 | return compiler_kind_; |
| 215 | } |
| 216 | |
| 217 | void CommonCompilerTest::SetCompilerKind(Compiler::Kind compiler_kind) { |
| 218 | compiler_kind_ = compiler_kind; |
| 219 | } |
| 220 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 221 | void CommonCompilerTest::TearDown() { |
| 222 | timer_.reset(); |
| 223 | compiler_driver_.reset(); |
| 224 | callbacks_.reset(); |
| 225 | method_inliner_map_.reset(); |
| 226 | verification_results_.reset(); |
| 227 | compiler_options_.reset(); |
| 228 | |
| 229 | CommonRuntimeTest::TearDown(); |
| 230 | } |
| 231 | |
| 232 | void CommonCompilerTest::CompileClass(mirror::ClassLoader* class_loader, const char* class_name) { |
| 233 | std::string class_descriptor(DotToDescriptor(class_name)); |
| 234 | Thread* self = Thread::Current(); |
| 235 | StackHandleScope<1> hs(self); |
| 236 | Handle<mirror::ClassLoader> loader(hs.NewHandle(class_loader)); |
| 237 | mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader); |
| 238 | CHECK(klass != nullptr) << "Class not found " << class_name; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 239 | auto pointer_size = class_linker_->GetImagePointerSize(); |
| 240 | for (auto& m : klass->GetDirectMethods(pointer_size)) { |
| 241 | CompileMethod(&m); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 242 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 243 | for (auto& m : klass->GetVirtualMethods(pointer_size)) { |
| 244 | CompileMethod(&m); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 248 | void CommonCompilerTest::CompileMethod(ArtMethod* method) { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 249 | CHECK(method != nullptr); |
| 250 | TimingLogger timings("CommonTest::CompileMethod", false, false); |
| 251 | TimingLogger::ScopedTiming t(__FUNCTION__, &timings); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 252 | compiler_driver_->CompileOne(Thread::Current(), method, &timings); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 253 | TimingLogger::ScopedTiming t2("MakeExecutable", &timings); |
| 254 | MakeExecutable(method); |
| 255 | } |
| 256 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 257 | void CommonCompilerTest::CompileDirectMethod(Handle<mirror::ClassLoader> class_loader, |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 258 | const char* class_name, const char* method_name, |
| 259 | const char* signature) { |
| 260 | std::string class_descriptor(DotToDescriptor(class_name)); |
| 261 | Thread* self = Thread::Current(); |
| 262 | mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), class_loader); |
| 263 | CHECK(klass != nullptr) << "Class not found " << class_name; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 264 | auto pointer_size = class_linker_->GetImagePointerSize(); |
| 265 | ArtMethod* method = klass->FindDirectMethod(method_name, signature, pointer_size); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 266 | CHECK(method != nullptr) << "Direct method not found: " |
| 267 | << class_name << "." << method_name << signature; |
| 268 | CompileMethod(method); |
| 269 | } |
| 270 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 271 | void CommonCompilerTest::CompileVirtualMethod(Handle<mirror::ClassLoader> class_loader, |
Mathieu Chartier | bf99f77 | 2014-08-23 16:37:27 -0700 | [diff] [blame] | 272 | const char* class_name, const char* method_name, |
| 273 | const char* signature) { |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 274 | std::string class_descriptor(DotToDescriptor(class_name)); |
| 275 | Thread* self = Thread::Current(); |
| 276 | mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), class_loader); |
| 277 | CHECK(klass != nullptr) << "Class not found " << class_name; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 278 | auto pointer_size = class_linker_->GetImagePointerSize(); |
| 279 | ArtMethod* method = klass->FindVirtualMethod(method_name, signature, pointer_size); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 280 | CHECK(method != nullptr) << "Virtual method not found: " |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 281 | << class_name << "." << method_name << signature; |
| 282 | CompileMethod(method); |
| 283 | } |
| 284 | |
| 285 | void CommonCompilerTest::ReserveImageSpace() { |
| 286 | // Reserve where the image will be loaded up front so that other parts of test set up don't |
| 287 | // accidentally end up colliding with the fixed memory address when we need to load the image. |
| 288 | std::string error_msg; |
Mathieu Chartier | 6e88ef6 | 2014-10-14 15:01:24 -0700 | [diff] [blame] | 289 | MemMap::Init(); |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 290 | image_reservation_.reset(MemMap::MapAnonymous("image reservation", |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 291 | reinterpret_cast<uint8_t*>(ART_BASE_ADDRESS), |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 292 | (size_t)100 * 1024 * 1024, // 100MB |
| 293 | PROT_NONE, |
| 294 | false /* no need for 4gb flag with fixed mmap*/, |
Vladimir Marko | 5c42c29 | 2015-02-25 12:02:49 +0000 | [diff] [blame] | 295 | false /* not reusing existing reservation */, |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 296 | &error_msg)); |
| 297 | CHECK(image_reservation_.get() != nullptr) << error_msg; |
| 298 | } |
| 299 | |
| 300 | void CommonCompilerTest::UnreserveImageSpace() { |
| 301 | image_reservation_.reset(); |
| 302 | } |
| 303 | |
| 304 | } // namespace art |