From 7940e44f4517de5e2634a7e07d58d0fb26160513 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Fri, 12 Jul 2013 13:46:57 -0700 Subject: Create separate Android.mk for main build targets The runtime, compiler, dex2oat, and oatdump now are in seperate trees to prevent dependency creep. They can now be individually built without rebuilding the rest of the art projects. dalvikvm and jdwpspy were already this way. Builds in the art directory should behave as before, building everything including tests. Change-Id: Ic6b1151e5ed0f823c3dd301afd2b13eb2d8feb81 --- compiler/llvm/compiler_llvm.cc | 239 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 compiler/llvm/compiler_llvm.cc (limited to 'compiler/llvm/compiler_llvm.cc') diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc new file mode 100644 index 0000000000..afca223192 --- /dev/null +++ b/compiler/llvm/compiler_llvm.cc @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "compiler_llvm.h" + +#include "backend_options.h" +#include "base/stl_util.h" +#include "class_linker.h" +#include "compiled_method.h" +#include "driver/compiler_driver.h" +#include "driver/dex_compilation_unit.h" +#include "globals.h" +#include "ir_builder.h" +#include "jni/portable/jni_compiler.h" +#include "llvm_compilation_unit.h" +#include "oat_file.h" +#include "utils_llvm.h" +#include "verifier/method_verifier.h" + +#include +#include +#include +#include + +namespace art { +void CompileOneMethod(CompilerDriver& driver, + const CompilerBackend compilerBackend, + const DexFile::CodeItem* code_item, + uint32_t access_flags, InvokeType invoke_type, + uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, + const DexFile& dex_file, + llvm::LlvmCompilationUnit* llvm_info); +} + +namespace llvm { + extern bool TimePassesIsEnabled; +} + +namespace { + +pthread_once_t llvm_initialized = PTHREAD_ONCE_INIT; + +void InitializeLLVM() { + // Initialize LLVM internal data structure for multithreading + llvm::llvm_start_multithreaded(); + + // NOTE: Uncomment following line to show the time consumption of LLVM passes + //llvm::TimePassesIsEnabled = true; + + // Initialize LLVM target-specific options. + art::llvm::InitialBackendOptions(); + + // Initialize LLVM target, MC subsystem, asm printer, and asm parser. + if (art::kIsTargetBuild) { + // Don't initialize all targets on device. Just initialize the device's native target + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); + llvm::InitializeNativeTargetAsmParser(); + } else { + llvm::InitializeAllTargets(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmPrinters(); + llvm::InitializeAllAsmParsers(); + } + + // Initialize LLVM optimization passes + llvm::PassRegistry ®istry = *llvm::PassRegistry::getPassRegistry(); + + llvm::initializeCore(registry); + llvm::initializeScalarOpts(registry); + llvm::initializeIPO(registry); + llvm::initializeAnalysis(registry); + llvm::initializeIPA(registry); + llvm::initializeTransformUtils(registry); + llvm::initializeInstCombine(registry); + llvm::initializeInstrumentation(registry); + llvm::initializeTarget(registry); +} + +// The Guard to Shutdown LLVM +// llvm::llvm_shutdown_obj llvm_guard; +// TODO: We are commenting out this line because this will cause SEGV from +// time to time. +// Two reasons: (1) the order of the destruction of static objects, or +// (2) dlopen/dlclose side-effect on static objects. + +} // anonymous namespace + + +namespace art { +namespace llvm { + + +::llvm::Module* makeLLVMModuleContents(::llvm::Module* module); + + +CompilerLLVM::CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set) + : compiler_driver_(driver), insn_set_(insn_set), + next_cunit_id_lock_("compilation unit id lock"), next_cunit_id_(1) { + + // Initialize LLVM libraries + pthread_once(&llvm_initialized, InitializeLLVM); +} + + +CompilerLLVM::~CompilerLLVM() { +} + + +LlvmCompilationUnit* CompilerLLVM::AllocateCompilationUnit() { + MutexLock GUARD(Thread::Current(), next_cunit_id_lock_); + LlvmCompilationUnit* cunit = new LlvmCompilationUnit(this, next_cunit_id_++); + if (!bitcode_filename_.empty()) { + cunit->SetBitcodeFileName(StringPrintf("%s-%zu", + bitcode_filename_.c_str(), + cunit->GetCompilationUnitId())); + } + return cunit; +} + + +CompiledMethod* CompilerLLVM:: +CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_type) { + UniquePtr cunit(AllocateCompilationUnit()); + + cunit->SetDexCompilationUnit(dex_compilation_unit); + cunit->SetCompilerDriver(compiler_driver_); + // TODO: consolidate ArtCompileMethods + CompileOneMethod(*compiler_driver_, + kPortable, + dex_compilation_unit->GetCodeItem(), + dex_compilation_unit->GetAccessFlags(), + invoke_type, + dex_compilation_unit->GetClassDefIndex(), + dex_compilation_unit->GetDexMethodIndex(), + dex_compilation_unit->GetClassLoader(), + *dex_compilation_unit->GetDexFile(), + cunit.get()); + + cunit->Materialize(); + + MethodReference mref(dex_compilation_unit->GetDexFile(), + dex_compilation_unit->GetDexMethodIndex()); + return new CompiledMethod(compiler_driver_->GetInstructionSet(), + cunit->GetElfObject(), + *verifier::MethodVerifier::GetDexGcMap(mref), + cunit->GetDexCompilationUnit()->GetSymbol()); +} + + +CompiledMethod* CompilerLLVM:: +CompileNativeMethod(DexCompilationUnit* dex_compilation_unit) { + UniquePtr cunit(AllocateCompilationUnit()); + + UniquePtr jni_compiler( + new JniCompiler(cunit.get(), *compiler_driver_, dex_compilation_unit)); + + return jni_compiler->Compile(); +} + + +} // namespace llvm +} // namespace art + +inline static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) { + void *compiler_context = driver.GetCompilerContext(); + CHECK(compiler_context != NULL); + return reinterpret_cast(compiler_context); +} + +inline static const art::llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) { + void *compiler_context = driver.GetCompilerContext(); + CHECK(compiler_context != NULL); + return reinterpret_cast(compiler_context); +} + +extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) { + CHECK(driver.GetCompilerContext() == NULL); + + art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(&driver, + driver.GetInstructionSet()); + + driver.SetCompilerContext(compiler_llvm); +} + +extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver) { + delete ContextOf(driver); + driver.SetCompilerContext(NULL); +} +extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, + const art::DexFile::CodeItem* code_item, + uint32_t access_flags, + art::InvokeType invoke_type, + uint32_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const art::DexFile& dex_file) { + UNUSED(class_def_idx); // TODO: this is used with Compiler::RequiresConstructorBarrier. + art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); + + art::DexCompilationUnit dex_compilation_unit( + NULL, class_loader, class_linker, dex_file, code_item, + class_def_idx, method_idx, access_flags); + art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver); + art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type); + return result; +} + +extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver, + uint32_t access_flags, uint32_t method_idx, + const art::DexFile& dex_file) { + art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); + + art::DexCompilationUnit dex_compilation_unit( + NULL, NULL, class_linker, dex_file, NULL, + 0, method_idx, access_flags); + + art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver); + art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&dex_compilation_unit); + return result; +} + +extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, + std::string const& filename) { + ContextOf(driver)->SetBitcodeFileName(filename); +} -- cgit v1.2.3-59-g8ed1b From 56d947fbc9bc2992e2f93112fafb73e50d2aaa7a Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Mon, 15 Jul 2013 13:14:23 -0700 Subject: Add verification of boot.oat generated on device Change-Id: I069586205a9a92fc7375ccf5cdde136bbbcfc800 --- compiler/driver/compiler_driver.cc | 1 - compiler/driver/compiler_driver.h | 2 +- compiler/elf_writer.cc | 1 - compiler/llvm/compiler_llvm.cc | 1 - runtime/class_linker.cc | 55 ++++------- runtime/class_linker.h | 2 +- runtime/gc/heap.cc | 133 ++------------------------ runtime/gc/heap.h | 6 -- runtime/gc/space/image_space.cc | 188 +++++++++++++++++++++++++++++++++++-- runtime/gc/space/image_space.h | 39 +++++++- runtime/oat_file.h | 9 +- 11 files changed, 254 insertions(+), 183 deletions(-) (limited to 'compiler/llvm/compiler_llvm.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index c99d103c17..9e71dff464 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -26,7 +26,6 @@ #include "dex_compilation_unit.h" #include "dex_file-inl.h" #include "jni_internal.h" -#include "oat_file.h" #include "object_utils.h" #include "runtime.h" #include "gc/accounting/card_table-inl.h" diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index d37f494ef1..4d7f0cf7b6 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -29,7 +29,7 @@ #include "instruction_set.h" #include "invoke_type.h" #include "method_reference.h" -#include "oat_file.h" +#include "os.h" #include "runtime.h" #include "safe_map.h" #include "thread_pool.h" diff --git a/compiler/elf_writer.cc b/compiler/elf_writer.cc index 0823a53f87..70d17de102 100644 --- a/compiler/elf_writer.cc +++ b/compiler/elf_writer.cc @@ -27,7 +27,6 @@ #include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "oat.h" -#include "oat_file.h" #include "scoped_thread_state_change.h" namespace art { diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc index afca223192..4475b25043 100644 --- a/compiler/llvm/compiler_llvm.cc +++ b/compiler/llvm/compiler_llvm.cc @@ -26,7 +26,6 @@ #include "ir_builder.h" #include "jni/portable/jni_compiler.h" #include "llvm_compilation_unit.h" -#include "oat_file.h" #include "utils_llvm.h" #include "verifier/method_verifier.h" diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index e35b95c1e9..fbceb597f0 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -680,35 +680,12 @@ void ClassLinker::RegisterOatFileLocked(const OatFile& oat_file) { oat_files_.push_back(&oat_file); } -OatFile* ClassLinker::OpenOat(const gc::space::ImageSpace* space) { +OatFile& ClassLinker::GetImageOatFile(gc::space::ImageSpace* space) { + VLOG(startup) << "ClassLinker::GetImageOatFile entering"; + OatFile& oat_file = space->ReleaseOatFile(); WriterMutexLock mu(Thread::Current(), dex_lock_); - const Runtime* runtime = Runtime::Current(); - const ImageHeader& image_header = space->GetImageHeader(); - // Grab location but don't use Object::AsString as we haven't yet initialized the roots to - // check the down cast - mirror::String* oat_location = - down_cast(image_header.GetImageRoot(ImageHeader::kOatLocation)); - std::string oat_filename; - oat_filename += runtime->GetHostPrefix(); - oat_filename += oat_location->ToModifiedUtf8(); - runtime->GetHeap()->UnReserveOatFileAddressRange(); - OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatDataBegin(), - !Runtime::Current()->IsCompiler()); - VLOG(startup) << "ClassLinker::OpenOat entering oat_filename=" << oat_filename; - if (oat_file == NULL) { - LOG(ERROR) << "Failed to open oat file " << oat_filename << " referenced from image."; - return NULL; - } - uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); - uint32_t image_oat_checksum = image_header.GetOatChecksum(); - if (oat_checksum != image_oat_checksum) { - LOG(ERROR) << "Failed to match oat file checksum " << std::hex << oat_checksum - << " to expected oat checksum " << std::hex << image_oat_checksum - << " in image"; - return NULL; - } - RegisterOatFileLocked(*oat_file); - VLOG(startup) << "ClassLinker::OpenOat exiting"; + RegisterOatFileLocked(oat_file); + VLOG(startup) << "ClassLinker::GetImageOatFile exiting"; return oat_file; } @@ -952,13 +929,13 @@ void ClassLinker::InitFromImage() { gc::Heap* heap = Runtime::Current()->GetHeap(); gc::space::ImageSpace* space = heap->GetImageSpace(); - OatFile* oat_file = OpenOat(space); - CHECK(oat_file != NULL) << "Failed to open oat file for image"; - CHECK_EQ(oat_file->GetOatHeader().GetImageFileLocationOatChecksum(), 0U); - CHECK_EQ(oat_file->GetOatHeader().GetImageFileLocationOatDataBegin(), 0U); - CHECK(oat_file->GetOatHeader().GetImageFileLocation().empty()); - portable_resolution_trampoline_ = oat_file->GetOatHeader().GetPortableResolutionTrampoline(); - quick_resolution_trampoline_ = oat_file->GetOatHeader().GetQuickResolutionTrampoline(); + CHECK(space != NULL); + OatFile& oat_file = GetImageOatFile(space); + CHECK_EQ(oat_file.GetOatHeader().GetImageFileLocationOatChecksum(), 0U); + CHECK_EQ(oat_file.GetOatHeader().GetImageFileLocationOatDataBegin(), 0U); + CHECK(oat_file.GetOatHeader().GetImageFileLocation().empty()); + portable_resolution_trampoline_ = oat_file.GetOatHeader().GetPortableResolutionTrampoline(); + quick_resolution_trampoline_ = oat_file.GetOatHeader().GetQuickResolutionTrampoline(); mirror::Object* dex_caches_object = space->GetImageHeader().GetImageRoot(ImageHeader::kDexCaches); mirror::ObjectArray* dex_caches = dex_caches_object->AsObjectArray(); @@ -971,18 +948,18 @@ void ClassLinker::InitFromImage() { // as being Strings or not mirror::String::SetClass(GetClassRoot(kJavaLangString)); - CHECK_EQ(oat_file->GetOatHeader().GetDexFileCount(), + CHECK_EQ(oat_file.GetOatHeader().GetDexFileCount(), static_cast(dex_caches->GetLength())); Thread* self = Thread::Current(); for (int i = 0; i < dex_caches->GetLength(); i++) { SirtRef dex_cache(self, dex_caches->Get(i)); const std::string& dex_file_location(dex_cache->GetLocation()->ToModifiedUtf8()); - const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file_location); - CHECK(oat_dex_file != NULL) << oat_file->GetLocation() << " " << dex_file_location; + const OatFile::OatDexFile* oat_dex_file = oat_file.GetOatDexFile(dex_file_location); + CHECK(oat_dex_file != NULL) << oat_file.GetLocation() << " " << dex_file_location; const DexFile* dex_file = oat_dex_file->OpenDexFile(); if (dex_file == NULL) { LOG(FATAL) << "Failed to open dex file " << dex_file_location - << " from within oat file " << oat_file->GetLocation(); + << " from within oat file " << oat_file.GetLocation(); } CHECK_EQ(dex_file->GetLocationChecksum(), oat_dex_file->GetDexFileLocationChecksum()); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index df336724fa..df1ecc6207 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -359,7 +359,7 @@ class ClassLinker { // Initialize class linker from one or more images. void InitFromImage() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - OatFile* OpenOat(const gc::space::ImageSpace* space) + OatFile& GetImageOatFile(gc::space::ImageSpace* space) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void InitFromImageCallback(mirror::Object* obj, void* arg) diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index a68cc02435..53b8cd9550 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -18,8 +18,6 @@ #define ATRACE_TAG ATRACE_TAG_DALVIK #include -#include -#include #include #include @@ -66,96 +64,6 @@ static const bool kDumpGcPerformanceOnShutdown = false; static const size_t kMinConcurrentRemainingBytes = 128 * KB; const double Heap::kDefaultTargetUtilization = 0.5; -static bool GenerateImage(const std::string& image_file_name) { - const std::string boot_class_path_string(Runtime::Current()->GetBootClassPathString()); - std::vector boot_class_path; - Split(boot_class_path_string, ':', boot_class_path); - if (boot_class_path.empty()) { - LOG(FATAL) << "Failed to generate image because no boot class path specified"; - } - - std::vector arg_vector; - - std::string dex2oat_string(GetAndroidRoot()); - dex2oat_string += (kIsDebugBuild ? "/bin/dex2oatd" : "/bin/dex2oat"); - const char* dex2oat = dex2oat_string.c_str(); - arg_vector.push_back(strdup(dex2oat)); - - std::string image_option_string("--image="); - image_option_string += image_file_name; - const char* image_option = image_option_string.c_str(); - arg_vector.push_back(strdup(image_option)); - - arg_vector.push_back(strdup("--runtime-arg")); - arg_vector.push_back(strdup("-Xms64m")); - - arg_vector.push_back(strdup("--runtime-arg")); - arg_vector.push_back(strdup("-Xmx64m")); - - for (size_t i = 0; i < boot_class_path.size(); i++) { - std::string dex_file_option_string("--dex-file="); - dex_file_option_string += boot_class_path[i]; - const char* dex_file_option = dex_file_option_string.c_str(); - arg_vector.push_back(strdup(dex_file_option)); - } - - std::string oat_file_option_string("--oat-file="); - oat_file_option_string += image_file_name; - oat_file_option_string.erase(oat_file_option_string.size() - 3); - oat_file_option_string += "oat"; - const char* oat_file_option = oat_file_option_string.c_str(); - arg_vector.push_back(strdup(oat_file_option)); - - std::string base_option_string(StringPrintf("--base=0x%x", ART_BASE_ADDRESS)); - arg_vector.push_back(strdup(base_option_string.c_str())); - - if (kIsTargetBuild) { - arg_vector.push_back(strdup("--image-classes-zip=/system/framework/framework.jar")); - arg_vector.push_back(strdup("--image-classes=preloaded-classes")); - } else { - arg_vector.push_back(strdup("--host")); - } - - std::string command_line(Join(arg_vector, ' ')); - LOG(INFO) << command_line; - - arg_vector.push_back(NULL); - char** argv = &arg_vector[0]; - - // fork and exec dex2oat - pid_t pid = fork(); - if (pid == 0) { - // no allocation allowed between fork and exec - - // change process groups, so we don't get reaped by ProcessManager - setpgid(0, 0); - - execv(dex2oat, argv); - - PLOG(FATAL) << "execv(" << dex2oat << ") failed"; - return false; - } else { - STLDeleteElements(&arg_vector); - - // wait for dex2oat to finish - int status; - pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); - if (got_pid != pid) { - PLOG(ERROR) << "waitpid failed: wanted " << pid << ", got " << got_pid; - return false; - } - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - LOG(ERROR) << dex2oat << " failed: " << command_line; - return false; - } - } - return true; -} - -void Heap::UnReserveOatFileAddressRange() { - oat_file_map_.reset(NULL); -} - Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max_free, double target_utilization, size_t capacity, const std::string& original_image_file_name, bool concurrent_gc) @@ -206,45 +114,20 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max mark_bitmap_.reset(new accounting::HeapBitmap(this)); // Requested begin for the alloc space, to follow the mapped image and oat files - byte* requested_begin = NULL; + byte* requested_alloc_space_begin = NULL; std::string image_file_name(original_image_file_name); if (!image_file_name.empty()) { - space::ImageSpace* image_space = NULL; - - if (OS::FileExists(image_file_name.c_str())) { - // If the /system file exists, it should be up-to-date, don't try to generate - image_space = space::ImageSpace::Create(image_file_name); - } else { - // If the /system file didn't exist, we need to use one from the dalvik-cache. - // If the cache file exists, try to open, but if it fails, regenerate. - // If it does not exist, generate. - image_file_name = GetDalvikCacheFilenameOrDie(image_file_name); - if (OS::FileExists(image_file_name.c_str())) { - image_space = space::ImageSpace::Create(image_file_name); - } - if (image_space == NULL) { - CHECK(GenerateImage(image_file_name)) << "Failed to generate image: " << image_file_name; - image_space = space::ImageSpace::Create(image_file_name); - } - } - - CHECK(image_space != NULL) << "Failed to create space from " << image_file_name; + space::ImageSpace* image_space = space::ImageSpace::Create(image_file_name); + CHECK(image_space != NULL) << "Failed to create space for " << image_file_name; AddContinuousSpace(image_space); // Oat files referenced by image files immediately follow them in memory, ensure alloc space // isn't going to get in the middle byte* oat_file_end_addr = image_space->GetImageHeader().GetOatFileEnd(); CHECK_GT(oat_file_end_addr, image_space->End()); - - // Reserve address range from image_space->End() to image_space->GetImageHeader().GetOatEnd() - uintptr_t reserve_begin = RoundUp(reinterpret_cast(image_space->End()), kPageSize); - uintptr_t reserve_end = RoundUp(reinterpret_cast(oat_file_end_addr), kPageSize); - oat_file_map_.reset(MemMap::MapAnonymous("oat file reserve", - reinterpret_cast(reserve_begin), - reserve_end - reserve_begin, PROT_NONE)); - - if (oat_file_end_addr > requested_begin) { - requested_begin = reinterpret_cast(RoundUp(reinterpret_cast(oat_file_end_addr), - kPageSize)); + if (oat_file_end_addr > requested_alloc_space_begin) { + requested_alloc_space_begin = + reinterpret_cast(RoundUp(reinterpret_cast(oat_file_end_addr), + kPageSize)); } } @@ -261,7 +144,7 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max alloc_space_ = space::DlMallocSpace::Create("alloc space", initial_size, growth_limit, capacity, - requested_begin); + requested_alloc_space_begin); CHECK(alloc_space_ != NULL) << "Failed to create alloc space"; alloc_space_->SetFootprintLimit(alloc_space_->Capacity()); AddContinuousSpace(alloc_space_); diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index 790ab0216d..e6c92211d4 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -373,9 +373,6 @@ class Heap { void DumpSpaces(); - // UnReserve the address range where the oat file will be placed. - void UnReserveOatFileAddressRange(); - // GC performance measuring void DumpGcPerformanceInfo(std::ostream& os); @@ -599,9 +596,6 @@ class Heap { std::vector mark_sweep_collectors_; - // A map that we use to temporarily reserve address range for the oat file. - UniquePtr oat_file_map_; - friend class collector::MarkSweep; friend class VerifyReferenceCardVisitor; friend class VerifyReferenceVisitor; diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 46c39378d7..c279ecf1ff 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -16,11 +16,16 @@ #include "image_space.h" +#include +#include + +#include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "gc/accounting/space_bitmap-inl.h" #include "mirror/abstract_method.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" +#include "oat_file.h" #include "os.h" #include "runtime.h" #include "space-inl.h" @@ -41,13 +46,118 @@ ImageSpace::ImageSpace(const std::string& name, MemMap* mem_map) DCHECK(live_bitmap_.get() != NULL) << "could not create imagespace live bitmap #" << bitmap_index; } -ImageSpace* ImageSpace::Create(const std::string& image_file_name) { +static bool GenerateImage(const std::string& image_file_name) { + const std::string boot_class_path_string(Runtime::Current()->GetBootClassPathString()); + std::vector boot_class_path; + Split(boot_class_path_string, ':', boot_class_path); + if (boot_class_path.empty()) { + LOG(FATAL) << "Failed to generate image because no boot class path specified"; + } + + std::vector arg_vector; + + std::string dex2oat_string(GetAndroidRoot()); + dex2oat_string += (kIsDebugBuild ? "/bin/dex2oatd" : "/bin/dex2oat"); + const char* dex2oat = dex2oat_string.c_str(); + arg_vector.push_back(strdup(dex2oat)); + + std::string image_option_string("--image="); + image_option_string += image_file_name; + const char* image_option = image_option_string.c_str(); + arg_vector.push_back(strdup(image_option)); + + arg_vector.push_back(strdup("--runtime-arg")); + arg_vector.push_back(strdup("-Xms64m")); + + arg_vector.push_back(strdup("--runtime-arg")); + arg_vector.push_back(strdup("-Xmx64m")); + + for (size_t i = 0; i < boot_class_path.size(); i++) { + std::string dex_file_option_string("--dex-file="); + dex_file_option_string += boot_class_path[i]; + const char* dex_file_option = dex_file_option_string.c_str(); + arg_vector.push_back(strdup(dex_file_option)); + } + + std::string oat_file_option_string("--oat-file="); + oat_file_option_string += image_file_name; + oat_file_option_string.erase(oat_file_option_string.size() - 3); + oat_file_option_string += "oat"; + const char* oat_file_option = oat_file_option_string.c_str(); + arg_vector.push_back(strdup(oat_file_option)); + + std::string base_option_string(StringPrintf("--base=0x%x", ART_BASE_ADDRESS)); + arg_vector.push_back(strdup(base_option_string.c_str())); + + if (kIsTargetBuild) { + arg_vector.push_back(strdup("--image-classes-zip=/system/framework/framework.jar")); + arg_vector.push_back(strdup("--image-classes=preloaded-classes")); + } else { + arg_vector.push_back(strdup("--host")); + } + + std::string command_line(Join(arg_vector, ' ')); + LOG(INFO) << "GenerateImage: " << command_line; + + arg_vector.push_back(NULL); + char** argv = &arg_vector[0]; + + // fork and exec dex2oat + pid_t pid = fork(); + if (pid == 0) { + // no allocation allowed between fork and exec + + // change process groups, so we don't get reaped by ProcessManager + setpgid(0, 0); + + execv(dex2oat, argv); + + PLOG(FATAL) << "execv(" << dex2oat << ") failed"; + return false; + } else { + STLDeleteElements(&arg_vector); + + // wait for dex2oat to finish + int status; + pid_t got_pid = TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)); + if (got_pid != pid) { + PLOG(ERROR) << "waitpid failed: wanted " << pid << ", got " << got_pid; + return false; + } + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + LOG(ERROR) << dex2oat << " failed: " << command_line; + return false; + } + } + return true; +} + +ImageSpace* ImageSpace::Create(const std::string& original_image_file_name) { + if (OS::FileExists(original_image_file_name.c_str())) { + // If the /system file exists, it should be up-to-date, don't try to generate + return space::ImageSpace::Init(original_image_file_name, false); + } + // If the /system file didn't exist, we need to use one from the dalvik-cache. + // If the cache file exists, try to open, but if it fails, regenerate. + // If it does not exist, generate. + std::string image_file_name(GetDalvikCacheFilenameOrDie(original_image_file_name)); + if (OS::FileExists(image_file_name.c_str())) { + space::ImageSpace* image_space = space::ImageSpace::Init(image_file_name, true); + if (image_space != NULL) { + return image_space; + } + } + CHECK(GenerateImage(image_file_name)) << "Failed to generate image: " << image_file_name; + return space::ImageSpace::Init(image_file_name, true); +} + +ImageSpace* ImageSpace::Init(const std::string& image_file_name, bool validate_oat_file) { CHECK(!image_file_name.empty()); uint64_t start_time = 0; if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { start_time = NanoTime(); - LOG(INFO) << "Space::CreateImageSpace entering" << " image_file_name=" << image_file_name; + LOG(INFO) << "ImageSpace::Init entering image_file_name=" << image_file_name; } UniquePtr file(OS::OpenFile(image_file_name.c_str(), false)); @@ -86,12 +196,78 @@ ImageSpace* ImageSpace::Create(const std::string& image_file_name) { callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsAndArgs); - ImageSpace* space = new ImageSpace(image_file_name, map.release()); + UniquePtr space(new ImageSpace(image_file_name, map.release())); + + space->oat_file_.reset(space->OpenOatFile()); + if (space->oat_file_.get() == NULL) { + LOG(ERROR) << "Failed to open oat file for image: " << image_file_name; + return NULL; + } + + if (validate_oat_file && !space->ValidateOatFile()) { + LOG(WARNING) << "Failed to validate oat file for image: " << image_file_name; + return NULL; + } + if (VLOG_IS_ON(heap) || VLOG_IS_ON(startup)) { - LOG(INFO) << "Space::CreateImageSpace exiting (" << PrettyDuration(NanoTime() - start_time) - << ") " << *space; + LOG(INFO) << "ImageSpace::Init exiting (" << PrettyDuration(NanoTime() - start_time) + << ") " << *space.get(); } - return space; + return space.release(); +} + +OatFile* ImageSpace::OpenOatFile() const { + const Runtime* runtime = Runtime::Current(); + const ImageHeader& image_header = GetImageHeader(); + // Grab location but don't use Object::AsString as we haven't yet initialized the roots to + // check the down cast + mirror::String* oat_location = + down_cast(image_header.GetImageRoot(ImageHeader::kOatLocation)); + std::string oat_filename; + oat_filename += runtime->GetHostPrefix(); + oat_filename += oat_location->ToModifiedUtf8(); + OatFile* oat_file = OatFile::Open(oat_filename, oat_filename, image_header.GetOatDataBegin(), + !Runtime::Current()->IsCompiler()); + if (oat_file == NULL) { + LOG(ERROR) << "Failed to open oat file " << oat_filename << " referenced from image."; + return NULL; + } + uint32_t oat_checksum = oat_file->GetOatHeader().GetChecksum(); + uint32_t image_oat_checksum = image_header.GetOatChecksum(); + if (oat_checksum != image_oat_checksum) { + LOG(ERROR) << "Failed to match oat file checksum " << std::hex << oat_checksum + << " to expected oat checksum " << std::hex << image_oat_checksum + << " in image"; + return NULL; + } + return oat_file; +} + +bool ImageSpace::ValidateOatFile() const { + CHECK(oat_file_.get() != NULL); + std::vector oat_dex_files = oat_file_->GetOatDexFiles(); + for (size_t i = 0; i < oat_dex_files.size(); i++) { + const OatFile::OatDexFile* oat_dex_file = oat_dex_files[i]; + const std::string& dex_file_location = oat_dex_file->GetDexFileLocation(); + uint32_t dex_file_location_checksum; + if (!DexFile::GetChecksum(dex_file_location.c_str(), dex_file_location_checksum)) { + LOG(WARNING) << "ValidateOatFile could not find checksum for " << dex_file_location; + return false; + } + if (dex_file_location_checksum != oat_dex_file->GetDexFileLocationChecksum()) { + LOG(WARNING) << "ValidateOatFile found checksum mismatch between oat file " + << oat_file_->GetLocation() << " and dex file " << dex_file_location + << " (" << oat_dex_file->GetDexFileLocationChecksum() << " != " + << dex_file_location_checksum << ")"; + return false; + } + } + return true; +} + +OatFile& ImageSpace::ReleaseOatFile() { + CHECK(oat_file_.get() != NULL); + return *oat_file_.release(); } void ImageSpace::RecordImageAllocations(accounting::SpaceBitmap* live_bitmap) const { diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h index afec5b7305..833fb8d73a 100644 --- a/runtime/gc/space/image_space.h +++ b/runtime/gc/space/image_space.h @@ -20,6 +20,9 @@ #include "space.h" namespace art { + +class OatFile; + namespace gc { namespace space { @@ -34,10 +37,22 @@ class ImageSpace : public MemMapSpace { return kSpaceTypeImageSpace; } - // create a Space from an image file. cannot be used for future allocation or collected. + // Create a Space from an image file. Cannot be used for future + // allocation or collected. + // + // Create also opens the OatFile associated with the image file so + // that it be contiguously allocated with the image before the + // creation of the alloc space. The ReleaseOatFile will later be + // used to transfer ownership of the OatFile to the ClassLinker when + // it is initialized. static ImageSpace* Create(const std::string& image) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // Releases the OatFile from the ImageSpace so it can be transfer to + // the caller, presumably the ClassLinker. + OatFile& ReleaseOatFile() + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const ImageHeader& GetImageHeader() const { return *reinterpret_cast(Begin()); } @@ -63,6 +78,23 @@ class ImageSpace : public MemMapSpace { void Dump(std::ostream& os) const; private: + + // Tries to initialize an ImageSpace from the given image path, + // returning NULL on error. + // + // If validate_oat_file is false (for /system), do not verify that + // image's OatFile is up-to-date relative to its DexFile + // inputs. Otherwise (for /data), validate the inputs and generate + // the OatFile in /data/dalvik-cache if necessary. + static ImageSpace* Init(const std::string& image, bool validate_oat_file) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + OatFile* OpenOatFile() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool ValidateOatFile() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + friend class Space; static size_t bitmap_index_; @@ -71,6 +103,11 @@ class ImageSpace : public MemMapSpace { ImageSpace(const std::string& name, MemMap* mem_map); + // The OatFile associated with the image during early startup to + // reserve space contiguous to the image. It is later released to + // the ClassLinker during it's initialization. + UniquePtr oat_file_; + DISALLOW_COPY_AND_ASSIGN(ImageSpace); }; diff --git a/runtime/oat_file.h b/runtime/oat_file.h index e3fd0025f0..ecc8d0c965 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -166,18 +166,25 @@ class OatFile { class OatDexFile { public: + // Opens the DexFile referred to by this OatDexFile from within the containing OatFile. const DexFile* OpenDexFile() const; - const OatClass* GetOatClass(uint32_t class_def_index) const; + + // Returns the size of the DexFile refered to by this OatDexFile. size_t FileSize() const; + // Returns original path of DexFile that was the source of this OatDexFile. const std::string& GetDexFileLocation() const { return dex_file_location_; } + // Returns checksum of original DexFile that was the source of this OatDexFile; uint32_t GetDexFileLocationChecksum() const { return dex_file_location_checksum_; } + // Returns the OatClass for the class specified by the given DexFile class_def_index. + const OatClass* GetOatClass(uint32_t class_def_index) const; + ~OatDexFile(); private: -- cgit v1.2.3-59-g8ed1b From 7934ac288acfb2552bb0b06ec1f61e5820d924a4 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Fri, 26 Jul 2013 10:54:15 -0700 Subject: Fix cpplint whitespace/comments issues Change-Id: Iae286862c85fb8fd8901eae1204cd6d271d69496 --- build/Android.cpplint.mk | 2 +- compiler/dex/arena_allocator.h | 2 +- compiler/dex/compiler_enums.h | 20 +- compiler/dex/dataflow_iterator.h | 2 +- compiler/dex/dex_to_dex_compiler.cc | 4 +- compiler/dex/frontend.cc | 56 +- compiler/dex/frontend.h | 2 +- compiler/dex/local_value_numbering.h | 2 +- compiler/dex/mir_graph.cc | 12 +- compiler/dex/mir_graph.h | 6 +- compiler/dex/mir_optimization.cc | 2 +- compiler/dex/portable/mir_to_gbc.cc | 6 +- compiler/dex/quick/arm/arm_lir.h | 28 +- compiler/dex/quick/arm/call_arm.cc | 6 +- compiler/dex/quick/arm/fp_arm.cc | 2 +- compiler/dex/quick/arm/int_arm.cc | 16 +- compiler/dex/quick/arm/target_arm.cc | 2 +- compiler/dex/quick/arm/utility_arm.cc | 6 +- compiler/dex/quick/codegen_util.cc | 2 +- compiler/dex/quick/gen_common.cc | 10 +- compiler/dex/quick/gen_invoke.cc | 14 +- compiler/dex/quick/mips/call_mips.cc | 2 +- compiler/dex/quick/mips/fp_mips.cc | 4 +- compiler/dex/quick/mips/int_mips.cc | 6 +- compiler/dex/quick/mips/mips_lir.h | 58 +- compiler/dex/quick/mips/target_mips.cc | 4 +- compiler/dex/quick/mips/utility_mips.cc | 2 +- compiler/dex/quick/mir_to_lir.h | 4 +- compiler/dex/quick/ralloc_util.cc | 10 +- compiler/dex/quick/x86/assemble_x86.cc | 4 +- compiler/dex/quick/x86/call_x86.cc | 2 +- compiler/dex/quick/x86/fp_x86.cc | 2 +- compiler/dex/quick/x86/target_x86.cc | 4 +- compiler/dex/quick/x86/utility_x86.cc | 10 +- compiler/dex/quick/x86/x86_lir.h | 36 +- compiler/dex/ssa_transformation.cc | 8 +- compiler/dex/vreg_analysis.cc | 2 +- compiler/driver/compiler_driver.cc | 808 ++++++++++----------- compiler/driver/dex_compilation_unit.cc | 2 +- compiler/driver/dex_compilation_unit.h | 2 +- compiler/elf_fixup.cc | 32 +- compiler/elf_writer_mclinker.h | 2 +- compiler/elf_writer_quick.cc | 4 +- compiler/image_writer.cc | 6 +- compiler/jni/portable/jni_compiler.cc | 14 +- compiler/llvm/backend_types.h | 4 +- compiler/llvm/compiler_llvm.cc | 8 +- compiler/llvm/compiler_llvm.h | 4 +- compiler/llvm/gbc_expander.cc | 46 +- compiler/llvm/generated/art_module.cc | 132 ++-- compiler/llvm/intrinsic_helper.cc | 4 +- compiler/llvm/intrinsic_helper.h | 4 +- compiler/llvm/ir_builder.cc | 4 +- compiler/llvm/ir_builder.h | 4 +- compiler/llvm/llvm_compilation_unit.cc | 12 +- compiler/llvm/llvm_compilation_unit.h | 6 +- compiler/llvm/md_builder.cc | 4 +- compiler/llvm/md_builder.h | 4 +- compiler/llvm/runtime_support_builder.cc | 4 +- compiler/llvm/runtime_support_builder.h | 4 +- compiler/llvm/runtime_support_builder_arm.cc | 6 +- compiler/llvm/runtime_support_builder_arm.h | 4 +- compiler/llvm/runtime_support_builder_thumb2.cc | 6 +- compiler/llvm/runtime_support_builder_thumb2.h | 4 +- compiler/llvm/runtime_support_builder_x86.cc | 4 +- compiler/llvm/runtime_support_builder_x86.h | 4 +- compiler/llvm/runtime_support_llvm_func.h | 6 +- compiler/sea_ir/code_gen.cc | 4 +- compiler/sea_ir/code_gen.h | 8 +- compiler/sea_ir/frontend.cc | 4 +- compiler/sea_ir/instruction_nodes.h | 6 +- compiler/sea_ir/instruction_tools.cc | 2 +- compiler/sea_ir/instruction_tools.h | 2 +- compiler/sea_ir/sea.cc | 28 +- compiler/sea_ir/sea.h | 4 +- compiler/sea_ir/sea_node.h | 2 +- compiler/sea_ir/visitor.h | 4 +- compiler/stubs/portable/stubs.cc | 14 +- compiler/stubs/quick/stubs.cc | 12 +- compiler/utils/scoped_hashtable.h | 2 +- compiler/utils/scoped_hashtable_test.cc | 2 +- dalvikvm/dalvikvm.cc | 2 +- dex2oat/dex2oat.cc | 6 +- jdwpspy/Net.cpp | 2 +- oatdump/oatdump.cc | 2 +- runtime/base/histogram_test.cc | 28 +- runtime/base/logging.cc | 2 +- runtime/base/logging.h | 4 +- runtime/base/macros.h | 2 +- runtime/base/mutex-inl.h | 2 +- runtime/base/mutex.cc | 10 +- runtime/base/unix_file/mapped_file_test.cc | 2 +- runtime/check_jni.cc | 56 +- runtime/class_linker.cc | 6 +- runtime/class_linker.h | 4 +- runtime/common_test.h | 8 +- runtime/compiled_method.cc | 2 +- runtime/debugger.cc | 44 +- runtime/debugger.h | 2 +- runtime/dex_file.cc | 2 +- runtime/dex_file.h | 2 +- runtime/dex_file_verifier.cc | 2 +- runtime/dex_instruction-inl.h | 8 +- runtime/dex_instruction.cc | 8 +- runtime/dex_instruction.h | 4 +- runtime/dex_instruction_list.h | 2 +- runtime/disassembler_arm.cc | 52 +- runtime/disassembler_mips.cc | 42 +- runtime/disassembler_x86.cc | 2 +- runtime/exception_test.cc | 2 +- runtime/gc/accounting/card_table.cc | 2 +- runtime/gc/accounting/space_bitmap-inl.h | 2 +- runtime/gc/collector/mark_sweep.cc | 4 +- runtime/gc/collector/mark_sweep.h | 2 +- runtime/gc/heap.cc | 2 +- runtime/gc/space/dlmalloc_space.cc | 4 +- runtime/gc/space/space.h | 2 +- runtime/hprof/hprof.cc | 18 +- runtime/indirect_reference_table.cc | 2 +- runtime/indirect_reference_table.h | 8 +- runtime/instrumentation.cc | 14 +- runtime/intern_table.cc | 8 +- runtime/intern_table_test.cc | 2 +- runtime/interpreter/interpreter.cc | 6 +- runtime/invoke_type.h | 10 +- runtime/jdwp/jdwp.h | 8 +- runtime/jdwp/jdwp_constants.h | 8 +- runtime/jdwp/jdwp_event.cc | 6 +- runtime/jdwp/jdwp_handler.cc | 6 +- runtime/jdwp/jdwp_priv.h | 4 +- runtime/jdwp/jdwp_request.cc | 2 +- runtime/jdwp/object_registry.cc | 6 +- runtime/jni_internal.cc | 26 +- runtime/jvalue.h | 4 +- runtime/locks.h | 2 +- runtime/log_severity.h | 2 +- runtime/mem_map.cc | 6 +- runtime/mirror/dex_cache.h | 2 +- runtime/mirror/field.cc | 2 +- runtime/mirror/throwable.h | 2 +- runtime/monitor.cc | 6 +- runtime/native/dalvik_system_VMDebug.cc | 4 +- runtime/native/dalvik_system_Zygote.cc | 2 +- runtime/native/java_lang_Thread.cc | 2 +- runtime/oat/runtime/arm/context_arm.cc | 2 +- runtime/oat/runtime/mips/context_mips.cc | 2 +- runtime/oat/runtime/support_interpreter.cc | 2 +- runtime/oat/runtime/support_jni.cc | 2 +- runtime/oat/runtime/support_stubs.cc | 4 +- .../oat/runtime/x86/oat_support_entrypoints_x86.cc | 12 +- runtime/oat_test.cc | 2 +- runtime/reference_table.cc | 2 +- runtime/reference_table.h | 2 +- runtime/reflection.cc | 2 +- runtime/runtime.cc | 32 +- runtime/runtime_linux.cc | 2 +- runtime/runtime_support.cc | 8 +- runtime/runtime_support_llvm_func_list.h | 2 +- runtime/safe_map.h | 2 +- runtime/scoped_thread_state_change.h | 2 +- runtime/signal_catcher.cc | 2 +- runtime/stack.cc | 8 +- runtime/stack.h | 6 +- runtime/thread.cc | 20 +- runtime/thread.h | 6 +- runtime/thread_linux.cc | 2 +- runtime/thread_list.cc | 6 +- runtime/thread_list.h | 4 +- runtime/thread_state.h | 40 +- runtime/trace.cc | 14 +- runtime/utils.cc | 34 +- runtime/verifier/dex_gc_map.h | 6 +- runtime/verifier/method_verifier.cc | 16 +- runtime/verifier/method_verifier.h | 22 +- runtime/verifier/reg_type_cache.cc | 2 +- runtime/verifier/reg_type_test.cc | 2 +- runtime/zip_archive.cc | 2 +- test/ReferenceMap/stack_walk_refmap_jni.cc | 44 +- test/StackWalk/stack_walk_jni.cc | 2 +- 179 files changed, 1208 insertions(+), 1208 deletions(-) (limited to 'compiler/llvm/compiler_llvm.cc') diff --git a/build/Android.cpplint.mk b/build/Android.cpplint.mk index eabaf31cca..adb87cb4e9 100644 --- a/build/Android.cpplint.mk +++ b/build/Android.cpplint.mk @@ -15,7 +15,7 @@ # ART_CPPLINT := art/tools/cpplint.py -ART_CPPLINT_FILTER := --filter=-whitespace/comments,-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references,-runtime/sizeof,-runtime/threadsafe_fn,-runtime/printf +ART_CPPLINT_FILTER := --filter=-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references,-runtime/sizeof,-runtime/threadsafe_fn,-runtime/printf ART_CPPLINT_SRC := $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION) | grep -v art/compiler/llvm/generated/) # "mm cpplint-art" to verify we aren't regressing diff --git a/compiler/dex/arena_allocator.h b/compiler/dex/arena_allocator.h index 3bd733e753..e8e2c027d0 100644 --- a/compiler/dex/arena_allocator.h +++ b/compiler/dex/arena_allocator.h @@ -86,7 +86,7 @@ struct MemStats { explicit MemStats(const ArenaAllocator &arena) : arena_(arena) {} private: const ArenaAllocator &arena_; -}; // MemStats +}; // MemStats } // namespace art diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h index 88240e8c40..97a682f2aa 100644 --- a/compiler/dex/compiler_enums.h +++ b/compiler/dex/compiler_enums.h @@ -48,7 +48,7 @@ enum SpecialTargetRegister { }; enum RegLocationType { - kLocDalvikFrame = 0, // Normal Dalvik register + kLocDalvikFrame = 0, // Normal Dalvik register kLocPhysReg, kLocCompilerTemp, kLocInvalid @@ -249,20 +249,20 @@ enum X86ConditionCode { kX86CondC = kX86CondB, // carry kX86CondNb = 0x3, // not-below - kX86CondAe = kX86CondNb, // above-equal - kX86CondNc = kX86CondNb, // not-carry + kX86CondAe = kX86CondNb, // above-equal + kX86CondNc = kX86CondNb, // not-carry kX86CondZ = 0x4, // zero kX86CondEq = kX86CondZ, // equal kX86CondNz = 0x5, // not-zero - kX86CondNe = kX86CondNz, // not-equal + kX86CondNe = kX86CondNz, // not-equal kX86CondBe = 0x6, // below-equal - kX86CondNa = kX86CondBe, // not-above + kX86CondNa = kX86CondBe, // not-above kX86CondNbe = 0x7, // not-below-equal - kX86CondA = kX86CondNbe,// above + kX86CondA = kX86CondNbe, // above kX86CondS = 0x8, // sign kX86CondNs = 0x9, // not-sign @@ -277,13 +277,13 @@ enum X86ConditionCode { kX86CondNge = kX86CondL, // not-greater-equal kX86CondNl = 0xd, // not-less-than - kX86CondGe = kX86CondNl, // not-greater-equal + kX86CondGe = kX86CondNl, // not-greater-equal kX86CondLe = 0xe, // less-than-equal - kX86CondNg = kX86CondLe, // not-greater + kX86CondNg = kX86CondLe, // not-greater kX86CondNle = 0xf, // not-less-than - kX86CondG = kX86CondNle,// greater + kX86CondG = kX86CondNle, // greater }; std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind); @@ -349,7 +349,7 @@ enum OpFeatureFlags { kIsIT, kMemLoad, kMemStore, - kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes. + kPCRelFixup, // x86 FIXME: add NEEDS_FIXUP to instruction attributes. kRegDef0, kRegDef1, kRegDefA, diff --git a/compiler/dex/dataflow_iterator.h b/compiler/dex/dataflow_iterator.h index 847a614727..da44ffd99c 100644 --- a/compiler/dex/dataflow_iterator.h +++ b/compiler/dex/dataflow_iterator.h @@ -80,7 +80,7 @@ namespace art { GrowableArray* block_id_list_; int idx_; bool changed_; - }; // DataflowIterator + }; // DataflowIterator class ReachableNodesIterator : public DataflowIterator { public: diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 28c325726e..3c491ce20f 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -240,12 +240,12 @@ Instruction* DexCompiler::CompileCheckCast(Instruction* inst, uint32_t dex_pc) { // We are modifying 4 consecutive bytes. ScopedDexWriteAccess sdwa(GetModifiableDexFile(), inst, 4u); inst->SetOpcode(Instruction::NOP); - inst->SetVRegA_10x(0u); // keep compliant with verifier. + inst->SetVRegA_10x(0u); // keep compliant with verifier. // Get to next instruction which is the second half of check-cast and replace // it by a NOP. inst = const_cast(inst->Next()); inst->SetOpcode(Instruction::NOP); - inst->SetVRegA_10x(0u); // keep compliant with verifier. + inst->SetVRegA_10x(0u); // keep compliant with verifier. return inst; } diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index 113a80a96c..9cc4d18d37 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -72,37 +72,37 @@ extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& compiler) { } /* Default optimizer/debug setting for the compiler. */ -static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations +static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations (1 << kLoadStoreElimination) | - //(1 << kLoadHoisting) | - //(1 << kSuppressLoads) | - //(1 << kNullCheckElimination) | - //(1 << kPromoteRegs) | - //(1 << kTrackLiveTemps) | - //(1 << kSafeOptimizations) | - //(1 << kBBOpt) | - //(1 << kMatch) | - //(1 << kPromoteCompilerTemps) | + // (1 << kLoadHoisting) | + // (1 << kSuppressLoads) | + // (1 << kNullCheckElimination) | + // (1 << kPromoteRegs) | + // (1 << kTrackLiveTemps) | + // (1 << kSafeOptimizations) | + // (1 << kBBOpt) | + // (1 << kMatch) | + // (1 << kPromoteCompilerTemps) | 0; static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes - //(1 << kDebugDisplayMissingTargets) | - //(1 << kDebugVerbose) | - //(1 << kDebugDumpCFG) | - //(1 << kDebugSlowFieldPath) | - //(1 << kDebugSlowInvokePath) | - //(1 << kDebugSlowStringPath) | - //(1 << kDebugSlowestFieldPath) | - //(1 << kDebugSlowestStringPath) | - //(1 << kDebugExerciseResolveMethod) | - //(1 << kDebugVerifyDataflow) | - //(1 << kDebugShowMemoryUsage) | - //(1 << kDebugShowNops) | - //(1 << kDebugCountOpcodes) | - //(1 << kDebugDumpCheckStats) | - //(1 << kDebugDumpBitcodeFile) | - //(1 << kDebugVerifyBitcode) | - //(1 << kDebugShowSummaryMemoryUsage) | + // (1 << kDebugDisplayMissingTargets) | + // (1 << kDebugVerbose) | + // (1 << kDebugDumpCFG) | + // (1 << kDebugSlowFieldPath) | + // (1 << kDebugSlowInvokePath) | + // (1 << kDebugSlowStringPath) | + // (1 << kDebugSlowestFieldPath) | + // (1 << kDebugSlowestStringPath) | + // (1 << kDebugExerciseResolveMethod) | + // (1 << kDebugVerifyDataflow) | + // (1 << kDebugShowMemoryUsage) | + // (1 << kDebugShowNops) | + // (1 << kDebugCountOpcodes) | + // (1 << kDebugDumpCheckStats) | + // (1 << kDebugDumpBitcodeFile) | + // (1 << kDebugVerifyBitcode) | + // (1 << kDebugShowSummaryMemoryUsage) | 0; static CompiledMethod* CompileMethod(CompilerDriver& compiler, @@ -277,7 +277,7 @@ CompiledMethod* CompileOneMethod(CompilerDriver& compiler, #if defined(ART_USE_PORTABLE_COMPILER) , llvm_compilation_unit #endif - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) } } // namespace art diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h index a86338950c..5c68ab4244 100644 --- a/compiler/dex/frontend.h +++ b/compiler/dex/frontend.h @@ -102,7 +102,7 @@ class LLVMInfo { private: UniquePtr< ::llvm::LLVMContext> llvm_context_; - ::llvm::Module* llvm_module_; // Managed by context_. + ::llvm::Module* llvm_module_; // Managed by context_. UniquePtr intrinsic_helper_; UniquePtr ir_builder_; }; diff --git a/compiler/dex/local_value_numbering.h b/compiler/dex/local_value_numbering.h index e3fd7ad2da..33ca8f1ad8 100644 --- a/compiler/dex/local_value_numbering.h +++ b/compiler/dex/local_value_numbering.h @@ -137,6 +137,6 @@ class LocalValueNumbering { std::set null_checked_; }; -} // namespace art +} // namespace art #endif // ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc index 264604c355..6b010ed9b3 100644 --- a/compiler/dex/mir_graph.cc +++ b/compiler/dex/mir_graph.cc @@ -972,23 +972,23 @@ char* MIRGraph::GetDalvikDisassembly(const MIR* mir) { } } switch (dalvik_format) { - case Instruction::k11n: // Add one immediate from vB + case Instruction::k11n: // Add one immediate from vB case Instruction::k21s: case Instruction::k31i: case Instruction::k21h: str.append(StringPrintf(", #%d", insn.vB)); break; - case Instruction::k51l: // Add one wide immediate + case Instruction::k51l: // Add one wide immediate str.append(StringPrintf(", #%lld", insn.vB_wide)); break; - case Instruction::k21c: // One register, one string/type/method index + case Instruction::k21c: // One register, one string/type/method index case Instruction::k31c: str.append(StringPrintf(", index #%d", insn.vB)); break; - case Instruction::k22c: // Two registers, one string/type/method index + case Instruction::k22c: // Two registers, one string/type/method index str.append(StringPrintf(", index #%d", insn.vC)); break; - case Instruction::k22s: // Add one immediate from vC + case Instruction::k22s: // Add one immediate from vC case Instruction::k22b: str.append(StringPrintf(", #%d", insn.vC)); break; @@ -1154,4 +1154,4 @@ BasicBlock* MIRGraph::NewMemBB(BBType block_type, int block_id) { return bb; } -} // namespace art +} // namespace art diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index 342d2a296a..e9ec949f23 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -273,7 +273,7 @@ struct RegLocation { unsigned fp:1; // Floating point? unsigned core:1; // Non-floating point? unsigned ref:1; // Something GC cares about. - unsigned high_word:1; // High word of pair? + unsigned high_word:1; // High word of pair? unsigned home:1; // Does this represent the home location? uint8_t low_reg; // First physical register. uint8_t high_reg; // 2nd physical register (if wide). @@ -650,7 +650,7 @@ class MIRGraph { BasicBlock* cur_block_; int num_blocks_; const DexFile::CodeItem* current_code_item_; - SafeMap block_map_; // FindBlock lookup cache. + SafeMap block_map_; // FindBlock lookup cache. std::vector m_units_; // List of methods included in this graph typedef std::pair MIRLocation; // Insert point, (m_unit_ index, offset) std::vector method_stack_; // Include stack @@ -659,7 +659,7 @@ class MIRGraph { int def_count_; // Used to estimate size of ssa name storage. int* opcode_count_; // Dex opcode coverage stats. int num_ssa_regs_; // Number of names following SSA transformation. - std::vector extended_basic_blocks_; // Heads of block "traces". + std::vector extended_basic_blocks_; // Heads of block "traces". int method_sreg_; unsigned int attributes_; Checkstats* checkstats_; diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index d79b26e4b9..a6314f4cab 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -845,7 +845,7 @@ bool MIRGraph::BuildExtendedBBList(struct BasicBlock* bb) { bb = NextDominatedBlock(bb); } } - return false; // Not iterative - return value will be ignored + return false; // Not iterative - return value will be ignored } diff --git a/compiler/dex/portable/mir_to_gbc.cc b/compiler/dex/portable/mir_to_gbc.cc index 6fc01bdff2..7831cf6f7a 100644 --- a/compiler/dex/portable/mir_to_gbc.cc +++ b/compiler/dex/portable/mir_to_gbc.cc @@ -1648,7 +1648,7 @@ bool MirConverter::BlockBitcodeConversion(BasicBlock* bb) { if (bb->block_type == kEntryBlock) { SetMethodInfo(); - { // Allocate shadowframe. + { // Allocate shadowframe. art::llvm::IntrinsicHelper::IntrinsicId id = art::llvm::IntrinsicHelper::AllocaShadowFrame; ::llvm::Function* func = intrinsic_helper_->GetIntrinsicFunction(id); @@ -1656,7 +1656,7 @@ bool MirConverter::BlockBitcodeConversion(BasicBlock* bb) { irb_->CreateCall(func, entries); } - { // Store arguments to vregs. + { // Store arguments to vregs. uint16_t arg_reg = cu_->num_regs; ::llvm::Function::arg_iterator arg_iter(func_->arg_begin()); @@ -1666,7 +1666,7 @@ bool MirConverter::BlockBitcodeConversion(BasicBlock* bb) { uint32_t shorty_size = strlen(shorty); CHECK_GE(shorty_size, 1u); - ++arg_iter; // skip method object + ++arg_iter; // skip method object if ((cu_->access_flags & kAccStatic) == 0) { SetVregOnValue(arg_iter, arg_reg); diff --git a/compiler/dex/quick/arm/arm_lir.h b/compiler/dex/quick/arm/arm_lir.h index 93fee05e4e..2f54190ae7 100644 --- a/compiler/dex/quick/arm/arm_lir.h +++ b/compiler/dex/quick/arm/arm_lir.h @@ -239,7 +239,7 @@ enum ArmShiftEncodings { */ enum ArmOpcode { kArmFirst = 0, - kArm16BitData = kArmFirst, // DATA [0] rd[15..0]. + kArm16BitData = kArmFirst, // DATA [0] rd[15..0]. kThumbAdcRR, // adc [0100000101] rm[5..3] rd[2..0]. kThumbAddRRI3, // add(1) [0001110] imm_3[8..6] rn[5..3] rd[2..0]*/ kThumbAddRI8, // add(2) [00110] rd[10..8] imm_8[7..0]. @@ -332,12 +332,12 @@ enum ArmOpcode { kThumb2VcvtDF, // vcvt.F32.F64 vd, vm [1110111010110111] vd[15..12] [10111100] vm[3..0]. kThumb2Vsqrts, // vsqrt.f32 vd, vm [1110111010110001] vd[15..12] [10101100] vm[3..0]. kThumb2Vsqrtd, // vsqrt.f64 vd, vm [1110111010110001] vd[15..12] [10111100] vm[3..0]. - kThumb2MovImmShift,// mov(T2) rd, # [11110] i [00001001111] imm3 rd[11..8] imm8. + kThumb2MovImmShift, // mov(T2) rd, # [11110] i [00001001111] imm3 rd[11..8] imm8. kThumb2MovImm16, // mov(T3) rd, # [11110] i [0010100] imm4 [0] imm3 rd[11..8] imm8. kThumb2StrRRI12, // str(Imm,T3) rd,[rn,#imm12] [111110001100] rn[19..16] rt[15..12] imm12[11..0]. kThumb2LdrRRI12, // str(Imm,T3) rd,[rn,#imm12] [111110001100] rn[19..16] rt[15..12] imm12[11..0]. - kThumb2StrRRI8Predec, // str(Imm,T4) rd,[rn,#-imm8] [111110000100] rn[19..16] rt[15..12] [1100] imm[7..0]*/ - kThumb2LdrRRI8Predec, // ldr(Imm,T4) rd,[rn,#-imm8] [111110000101] rn[19..16] rt[15..12] [1100] imm[7..0]*/ + kThumb2StrRRI8Predec, // str(Imm,T4) rd,[rn,#-imm8] [111110000100] rn[19..16] rt[15..12] [1100] imm[7..0]*/ + kThumb2LdrRRI8Predec, // ldr(Imm,T4) rd,[rn,#-imm8] [111110000101] rn[19..16] rt[15..12] [1100] imm[7..0]*/ kThumb2Cbnz, // cbnz rd,