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/driver/compiler_driver.h | 413 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 413 insertions(+) create mode 100644 compiler/driver/compiler_driver.h (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h new file mode 100644 index 0000000000..d37f494ef1 --- /dev/null +++ b/compiler/driver/compiler_driver.h @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#define ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ + +#include +#include +#include + +#include "base/mutex.h" +#include "class_reference.h" +#include "compiled_class.h" +#include "compiled_method.h" +#include "dex_file.h" +#include "instruction_set.h" +#include "invoke_type.h" +#include "method_reference.h" +#include "oat_file.h" +#include "runtime.h" +#include "safe_map.h" +#include "thread_pool.h" + +namespace art { + +class AOTCompilationStats; +class ParallelCompilationManager; +class DexCompilationUnit; +class TimingLogger; + +enum CompilerBackend { + kQuick, + kPortable, + kNoBackend +}; + +// Thread-local storage compiler worker threads +class CompilerTls { + public: + CompilerTls() : llvm_info_(NULL) {} + ~CompilerTls() {} + + void* GetLLVMInfo() { return llvm_info_; } + + void SetLLVMInfo(void* llvm_info) { llvm_info_ = llvm_info; } + + private: + void* llvm_info_; +}; + +class CompilerDriver { + public: + typedef std::set DescriptorSet; + + // Create a compiler targeting the requested "instruction_set". + // "image" should be true if image specific optimizations should be + // enabled. "image_classes" lets the compiler know what classes it + // can assume will be in the image, with NULL implying all available + // classes. + explicit CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, + bool image, DescriptorSet* image_classes, + size_t thread_count, bool support_debugging, + bool dump_stats, bool dump_timings); + + ~CompilerDriver(); + + void CompileAll(jobject class_loader, const std::vector& dex_files) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Compile a single Method + void CompileOne(const mirror::AbstractMethod* method) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool IsDebuggingSupported() { + return support_debugging_; + } + + InstructionSet GetInstructionSet() const { + return instruction_set_; + } + + CompilerBackend GetCompilerBackend() const { + return compiler_backend_; + } + + bool IsImage() const { + return image_; + } + + DescriptorSet* GetImageClasses() const { + return image_classes_.get(); + } + + CompilerTls* GetTls(); + + // Generate the trampolines that are invoked by unresolved direct methods. + const std::vector* CreatePortableResolutionTrampoline() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const std::vector* CreateQuickResolutionTrampoline() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const std::vector* CreateInterpreterToInterpreterEntry() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const std::vector* CreateInterpreterToQuickEntry() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + CompiledClass* GetCompiledClass(ClassReference ref) const + LOCKS_EXCLUDED(compiled_classes_lock_); + + CompiledMethod* GetCompiledMethod(MethodReference ref) const + LOCKS_EXCLUDED(compiled_methods_lock_); + + void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index); + bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index); + + // Callbacks from compiler to see what runtime checks must be generated. + + bool CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + bool CanAssumeStringIsPresentInDexCache(const DexFile& dex_file, uint32_t string_idx) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Are runtime access checks necessary in the compiled code? + bool CanAccessTypeWithoutChecks(uint32_t referrer_idx, const DexFile& dex_file, + uint32_t type_idx, bool* type_known_final = NULL, + bool* type_known_abstract = NULL, + bool* equals_referrers_class = NULL) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Are runtime access and instantiable checks necessary in the code? + bool CanAccessInstantiableTypeWithoutChecks(uint32_t referrer_idx, const DexFile& dex_file, + uint32_t type_idx) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Can we fast path instance field access? Computes field's offset and volatility. + bool ComputeInstanceFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit, + int& field_offset, bool& is_volatile, bool is_put) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Can we fastpath static field access? Computes field's offset, volatility and whether the + // field is within the referrer (which can avoid checking class initialization). + bool ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit, + int& field_offset, int& ssb_index, + bool& is_referrers_class, bool& is_volatile, bool is_put) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + // Can we fastpath a interface, super class or virtual method call? Computes method's vtable + // index. + bool ComputeInvokeInfo(const DexCompilationUnit* mUnit, const uint32_t dex_pc, + InvokeType& type, MethodReference& target_method, int& vtable_idx, + uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + bool IsSafeCast(const MethodReference& mr, uint32_t dex_pc); + + // Record patch information for later fix up. + void AddCodePatch(const DexFile* dex_file, + uint32_t referrer_method_idx, + InvokeType referrer_invoke_type, + uint32_t target_method_idx, + InvokeType target_invoke_type, + size_t literal_offset) + LOCKS_EXCLUDED(compiled_methods_lock_); + void AddMethodPatch(const DexFile* dex_file, + uint32_t referrer_method_idx, + InvokeType referrer_invoke_type, + uint32_t target_method_idx, + InvokeType target_invoke_type, + size_t literal_offset) + LOCKS_EXCLUDED(compiled_methods_lock_); + + void SetBitcodeFileName(std::string const& filename); + + bool GetSupportBootImageFixup() const { + return support_boot_image_fixup_; + } + + void SetSupportBootImageFixup(bool support_boot_image_fixup) { + support_boot_image_fixup_ = support_boot_image_fixup; + } + + + bool WriteElf(const std::string& android_root, + bool is_host, + const std::vector& dex_files, + std::vector& oat_contents, + File* file); + + // TODO: move to a common home for llvm helpers once quick/portable are merged + static void InstructionSetToLLVMTarget(InstructionSet instruction_set, + std::string& target_triple, + std::string& target_cpu, + std::string& target_attr); + + void SetCompilerContext(void* compiler_context) { + compiler_context_ = compiler_context; + } + + void* GetCompilerContext() const { + return compiler_context_; + } + + size_t GetThreadCount() const { + return thread_count_; + } + + class PatchInformation { + public: + const DexFile& GetDexFile() const { + return *dex_file_; + } + uint32_t GetReferrerMethodIdx() const { + return referrer_method_idx_; + } + InvokeType GetReferrerInvokeType() const { + return referrer_invoke_type_; + } + uint32_t GetTargetMethodIdx() const { + return target_method_idx_; + } + InvokeType GetTargetInvokeType() const { + return target_invoke_type_; + } + size_t GetLiteralOffset() const {; + return literal_offset_; + } + + private: + PatchInformation(const DexFile* dex_file, + uint32_t referrer_method_idx, + InvokeType referrer_invoke_type, + uint32_t target_method_idx, + InvokeType target_invoke_type, + size_t literal_offset) + : dex_file_(dex_file), + referrer_method_idx_(referrer_method_idx), + referrer_invoke_type_(referrer_invoke_type), + target_method_idx_(target_method_idx), + target_invoke_type_(target_invoke_type), + literal_offset_(literal_offset) { + CHECK(dex_file_ != NULL); + } + + const DexFile* dex_file_; + uint32_t referrer_method_idx_; + InvokeType referrer_invoke_type_; + uint32_t target_method_idx_; + InvokeType target_invoke_type_; + size_t literal_offset_; + + friend class CompilerDriver; + DISALLOW_COPY_AND_ASSIGN(PatchInformation); + }; + + const std::vector& GetCodeToPatch() const { + return code_to_patch_; + } + const std::vector& GetMethodsToPatch() const { + return methods_to_patch_; + } + + // Checks if class specified by type_idx is one of the image_classes_ + bool IsImageClass(const char* descriptor) const; + + void RecordClassStatus(ClassReference ref, CompiledClass* compiled_class); + + private: + // Compute constant code and method pointers when possible + void GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, + mirror::Class* referrer_class, + mirror::AbstractMethod* method, + uintptr_t& direct_code, uintptr_t& direct_method, + bool update_stats) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void PreCompile(jobject class_loader, const std::vector& dex_files, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + void LoadImageClasses(TimingLogger& timings); + + // Attempt to resolve all type, methods, fields, and strings + // referenced from code in the dex file following PathClassLoader + // ordering semantics. + void Resolve(jobject class_loader, const std::vector& dex_files, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + void ResolveDexFile(jobject class_loader, const DexFile& dex_file, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + void Verify(jobject class_loader, const std::vector& dex_files, + ThreadPool& thread_pool, TimingLogger& timings); + void VerifyDexFile(jobject class_loader, const DexFile& dex_file, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + void InitializeClasses(jobject class_loader, const std::vector& dex_files, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + void InitializeClasses(jobject class_loader, const DexFile& dex_file, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_, compiled_classes_lock_); + + void UpdateImageClasses(TimingLogger& timings); + static void FindClinitImageClassesCallback(mirror::Object* object, void* arg) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void Compile(jobject class_loader, const std::vector& dex_files, + ThreadPool& thread_pool, TimingLogger& timings); + void CompileDexFile(jobject class_loader, const DexFile& dex_file, + ThreadPool& thread_pool, TimingLogger& timings) + LOCKS_EXCLUDED(Locks::mutator_lock_); + void CompileMethod(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, + bool allow_dex_to_dex_compilation) + LOCKS_EXCLUDED(compiled_methods_lock_); + + static void CompileClass(const ParallelCompilationManager* context, size_t class_def_index) + LOCKS_EXCLUDED(Locks::mutator_lock_); + + std::vector code_to_patch_; + std::vector methods_to_patch_; + + CompilerBackend compiler_backend_; + + InstructionSet instruction_set_; + + // All class references that require + mutable Mutex freezing_constructor_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + std::set freezing_constructor_classes_ GUARDED_BY(freezing_constructor_lock_); + + typedef SafeMap ClassTable; + // All class references that this compiler has compiled. + mutable Mutex compiled_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + ClassTable compiled_classes_ GUARDED_BY(compiled_classes_lock_); + + typedef SafeMap MethodTable; + // All method references that this compiler has compiled. + mutable Mutex compiled_methods_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + MethodTable compiled_methods_ GUARDED_BY(compiled_methods_lock_); + + const bool image_; + + // If image_ is true, specifies the classes that will be included in + // the image. Note if image_classes_ is NULL, all classes are + // included in the image. + UniquePtr image_classes_; + + size_t thread_count_; + bool support_debugging_; + uint64_t start_ns_; + + UniquePtr stats_; + + bool dump_stats_; + bool dump_timings_; + + typedef void (*CompilerCallbackFn)(CompilerDriver& driver); + typedef MutexLock* (*CompilerMutexLockFn)(CompilerDriver& driver); + + void* compiler_library_; + + typedef CompiledMethod* (*CompilerFn)(CompilerDriver& driver, + const DexFile::CodeItem* code_item, + uint32_t access_flags, InvokeType invoke_type, + uint32_t class_dex_idx, uint32_t method_idx, + jobject class_loader, const DexFile& dex_file); + CompilerFn compiler_; +#ifdef ART_SEA_IR_MODE + CompilerFn sea_ir_compiler_; +#endif + + CompilerFn dex_to_dex_compiler_; + + void* compiler_context_; + + typedef CompiledMethod* (*JniCompilerFn)(CompilerDriver& driver, + uint32_t access_flags, uint32_t method_idx, + const DexFile& dex_file); + JniCompilerFn jni_compiler_; + + pthread_key_t tls_key_; + + typedef void (*CompilerEnableAutoElfLoadingFn)(CompilerDriver& driver); + CompilerEnableAutoElfLoadingFn compiler_enable_auto_elf_loading_; + + typedef const void* (*CompilerGetMethodCodeAddrFn) + (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::AbstractMethod* method); + CompilerGetMethodCodeAddrFn compiler_get_method_code_addr_; + + bool support_boot_image_fixup_; + + DISALLOW_COPY_AND_ASSIGN(CompilerDriver); +}; + +} // namespace art + +#endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ -- 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/driver/compiler_driver.h') 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 fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Wed, 17 Jul 2013 14:40:12 -0700 Subject: Fix multiple inclusion guards to match new pathnames Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43 --- Android.mk | 20 +++++++++++++++----- compiler/dex/arena_allocator.h | 6 +++--- compiler/dex/arena_bit_vector.h | 6 +++--- compiler/dex/backend.h | 6 +++--- compiler/dex/compiler_enums.h | 6 +++--- compiler/dex/compiler_internals.h | 6 +++--- compiler/dex/compiler_ir.h | 6 +++--- compiler/dex/dataflow_iterator-inl.h | 6 +++--- compiler/dex/dataflow_iterator.h | 6 +++--- compiler/dex/frontend.h | 6 +++--- compiler/dex/growable_array.h | 6 +++--- compiler/dex/local_value_numbering.h | 6 +++--- compiler/dex/mir_graph.h | 6 +++--- compiler/dex/portable/mir_to_gbc.h | 6 +++--- compiler/dex/quick/arm/arm_lir.h | 6 +++--- compiler/dex/quick/arm/codegen_arm.h | 6 +++--- compiler/dex/quick/mips/codegen_mips.h | 6 +++--- compiler/dex/quick/mips/mips_lir.h | 6 +++--- compiler/dex/quick/mir_to_lir-inl.h | 6 +++--- compiler/dex/quick/mir_to_lir.h | 6 +++--- compiler/dex/quick/x86/codegen_x86.h | 6 +++--- compiler/dex/quick/x86/x86_lir.h | 6 +++--- compiler/driver/compiler_driver.h | 6 +++--- compiler/driver/dex_compilation_unit.h | 6 +++--- compiler/elf_fixup.h | 6 +++--- compiler/elf_stripper.h | 6 +++--- compiler/elf_writer.h | 6 +++--- compiler/elf_writer_mclinker.h | 6 +++--- compiler/elf_writer_quick.h | 6 +++--- compiler/image_writer.h | 6 +++--- compiler/jni/portable/jni_compiler.h | 6 +++--- compiler/jni/quick/arm/calling_convention_arm.h | 6 +++--- compiler/jni/quick/calling_convention.h | 6 +++--- compiler/jni/quick/mips/calling_convention_mips.h | 6 +++--- compiler/jni/quick/x86/calling_convention_x86.h | 6 +++--- compiler/llvm/backend_options.h | 6 +++--- compiler/llvm/backend_types.h | 6 +++--- compiler/llvm/compiler_llvm.h | 6 +++--- compiler/llvm/intrinsic_helper.h | 6 +++--- compiler/llvm/ir_builder.h | 6 +++--- compiler/llvm/llvm_compilation_unit.h | 6 +++--- compiler/llvm/md_builder.h | 6 +++--- compiler/llvm/runtime_support_builder.h | 6 +++--- compiler/llvm/runtime_support_builder_arm.h | 6 +++--- compiler/llvm/runtime_support_builder_thumb2.h | 6 +++--- compiler/llvm/runtime_support_builder_x86.h | 6 +++--- compiler/llvm/runtime_support_llvm_func.h | 6 +++--- compiler/llvm/utils_llvm.h | 6 +++--- compiler/oat_writer.h | 6 +++--- compiler/sea_ir/instruction_tools.h | 6 +++--- compiler/sea_ir/sea.h | 6 +++--- compiler/stubs/stubs.h | 6 +++--- jdwpspy/Common.h | 6 +++--- runtime/asm_support.h | 6 +++--- runtime/atomic.h | 6 +++--- runtime/atomic_integer.h | 6 +++--- runtime/barrier.h | 6 +++--- runtime/base/casts.h | 6 +++--- runtime/base/histogram-inl.h | 6 +++--- runtime/base/histogram.h | 6 +++--- runtime/base/logging.h | 6 +++--- runtime/base/macros.h | 6 +++--- runtime/base/mutex-inl.h | 6 +++--- runtime/base/mutex.h | 6 +++--- runtime/base/stl_util.h | 6 +++--- runtime/base/stringpiece.h | 6 +++--- runtime/base/stringprintf.h | 6 +++--- runtime/base/timing_logger.h | 6 +++--- runtime/base/unix_file/fd_file.h | 6 +++--- runtime/base/unix_file/mapped_file.h | 6 +++--- runtime/base/unix_file/null_file.h | 6 +++--- runtime/base/unix_file/random_access_file.h | 6 +++--- runtime/base/unix_file/random_access_file_test.h | 6 +++--- runtime/base/unix_file/random_access_file_utils.h | 6 +++--- runtime/base/unix_file/string_file.h | 6 +++--- runtime/class_linker-inl.h | 6 +++--- runtime/class_linker.h | 6 +++--- runtime/class_reference.h | 6 +++--- runtime/closure.h | 6 +++--- runtime/common_test.h | 5 +++++ runtime/common_throws.h | 6 +++--- runtime/compiled_class.h | 6 +++--- runtime/compiled_method.h | 6 +++--- runtime/constants_arm.h | 6 +++--- runtime/constants_mips.h | 6 +++--- runtime/constants_x86.h | 6 +++--- runtime/debugger.h | 6 +++--- runtime/dex_file-inl.h | 6 +++--- runtime/dex_file.h | 6 +++--- runtime/dex_file_verifier.h | 6 +++--- runtime/dex_instruction-inl.h | 6 +++--- runtime/dex_instruction.h | 6 +++--- runtime/dex_instruction_list.h | 6 ++++++ runtime/dex_instruction_visitor.h | 6 +++--- runtime/dex_method_iterator.h | 6 +++--- runtime/disassembler.h | 6 +++--- runtime/disassembler_arm.h | 6 +++--- runtime/disassembler_mips.h | 6 +++--- runtime/disassembler_x86.h | 6 +++--- runtime/elf_file.h | 6 +++--- runtime/file_output_stream.h | 6 +++--- runtime/gc/accounting/atomic_stack.h | 6 +++--- runtime/gc/accounting/card_table-inl.h | 6 +++--- runtime/gc/accounting/card_table.h | 6 +++--- runtime/gc/accounting/heap_bitmap-inl.h | 6 +++--- runtime/gc/accounting/heap_bitmap.h | 6 +++--- runtime/gc/accounting/mod_union_table-inl.h | 6 +++--- runtime/gc/accounting/mod_union_table.h | 6 +++--- runtime/gc/accounting/space_bitmap-inl.h | 6 +++--- runtime/gc/accounting/space_bitmap.h | 6 +++--- runtime/gc/allocator/dlmalloc.h | 6 +++--- runtime/gc/collector/garbage_collector.h | 6 +++--- runtime/gc/collector/gc_type.h | 6 +++--- runtime/gc/collector/mark_sweep-inl.h | 6 +++--- runtime/gc/collector/mark_sweep.h | 6 +++--- runtime/gc/collector/partial_mark_sweep.h | 6 +++--- runtime/gc/collector/sticky_mark_sweep.h | 6 +++--- runtime/gc/heap.h | 6 +++--- runtime/gc/space/dlmalloc_space.h | 6 +++--- runtime/gc/space/image_space.h | 6 +++--- runtime/gc/space/large_object_space.h | 6 +++--- runtime/gc/space/space-inl.h | 6 +++--- runtime/gc/space/space.h | 6 +++--- runtime/gc_map.h | 6 +++--- runtime/globals.h | 6 +++--- runtime/hprof/hprof.h | 6 +++--- runtime/image.h | 6 +++--- runtime/indenter.h | 6 +++--- runtime/indirect_reference_table.h | 6 +++--- runtime/instruction_set.h | 6 +++--- runtime/instrumentation.h | 6 +++--- runtime/intern_table.h | 6 +++--- runtime/interpreter/interpreter.h | 6 +++--- runtime/invoke_arg_array_builder.h | 6 +++--- runtime/invoke_type.h | 6 +++--- runtime/jdwp/jdwp.h | 6 +++--- runtime/jdwp/jdwp_bits.h | 6 +++--- runtime/jdwp/jdwp_constants.h | 6 +++--- runtime/jdwp/jdwp_event.h | 6 +++--- runtime/jdwp/jdwp_expand_buf.h | 6 +++--- runtime/jdwp/jdwp_priv.h | 6 +++--- runtime/jdwp/object_registry.h | 5 +++++ runtime/jni_internal.h | 6 +++--- runtime/jobject_comparator.h | 6 +++--- runtime/jvalue.h | 6 +++--- runtime/leb128.h | 6 +++--- runtime/locks.h | 6 +++--- runtime/log_severity.h | 6 +++--- runtime/mem_map.h | 6 +++--- runtime/memory_region.h | 6 +++--- runtime/method_reference.h | 6 +++--- runtime/mirror/abstract_method-inl.h | 6 +++--- runtime/mirror/abstract_method.h | 6 +++--- runtime/mirror/array-inl.h | 6 +++--- runtime/mirror/array.h | 6 +++--- runtime/mirror/class-inl.h | 6 +++--- runtime/mirror/class.h | 6 +++--- runtime/mirror/class_loader.h | 6 +++--- runtime/mirror/dex_cache-inl.h | 6 +++--- runtime/mirror/dex_cache.h | 6 +++--- runtime/mirror/field-inl.h | 6 +++--- runtime/mirror/field.h | 6 +++--- runtime/mirror/iftable-inl.h | 6 +++--- runtime/mirror/iftable.h | 6 +++--- runtime/mirror/object-inl.h | 6 +++--- runtime/mirror/object.h | 6 +++--- runtime/mirror/object_array-inl.h | 6 +++--- runtime/mirror/object_array.h | 6 +++--- runtime/mirror/proxy.h | 6 +++--- runtime/mirror/stack_trace_element.h | 6 +++--- runtime/mirror/string.h | 6 +++--- runtime/mirror/throwable.h | 6 +++--- runtime/modifiers.h | 6 +++--- runtime/monitor.h | 6 +++--- runtime/nth_caller_visitor.h | 6 +++--- runtime/oat.h | 6 +++--- runtime/oat/runtime/argument_visitor.h | 6 +++--- runtime/oat/runtime/arm/context_arm.h | 6 +++--- runtime/oat/runtime/callee_save_frame.h | 6 +++--- runtime/oat/runtime/context.h | 6 +++--- runtime/oat/runtime/mips/context_mips.h | 6 +++--- runtime/oat/runtime/oat_support_entrypoints.h | 6 +++--- runtime/oat/runtime/x86/context_x86.h | 6 +++--- runtime/oat/utils/arm/assembler_arm.h | 6 +++--- runtime/oat/utils/arm/managed_register_arm.h | 6 +++--- runtime/oat/utils/assembler.h | 6 +++--- runtime/oat/utils/managed_register.h | 6 +++--- runtime/oat/utils/mips/assembler_mips.h | 6 +++--- runtime/oat/utils/mips/managed_register_mips.h | 6 +++--- runtime/oat/utils/x86/assembler_x86.h | 6 +++--- runtime/oat/utils/x86/managed_register_x86.h | 6 +++--- runtime/oat_file.h | 6 +++--- runtime/object_utils.h | 6 +++--- runtime/offsets.h | 6 +++--- runtime/os.h | 6 +++--- runtime/output_stream.h | 6 +++--- runtime/primitive.h | 6 +++--- runtime/reference_table.h | 6 +++--- runtime/reflection.h | 6 +++--- runtime/root_visitor.h | 6 +++--- runtime/runtime.h | 6 +++--- runtime/runtime_stats.h | 6 +++--- runtime/runtime_support.h | 6 +++--- runtime/runtime_support_llvm.h | 6 +++--- runtime/runtime_support_llvm_func_list.h | 6 ++++++ runtime/safe_map.h | 6 +++--- runtime/scoped_thread_state_change.h | 6 +++--- runtime/signal_catcher.h | 6 +++--- runtime/signal_set.h | 6 +++--- runtime/sirt_ref.h | 6 +++--- runtime/stack.h | 6 +++--- runtime/stack_indirect_reference_table.h | 6 +++--- runtime/strutil.h | 6 +++--- runtime/thread-inl.h | 6 +++--- runtime/thread.h | 6 +++--- runtime/thread_list.h | 6 +++--- runtime/thread_pool.h | 6 +++--- runtime/thread_state.h | 6 +++--- runtime/throw_location.h | 6 +++--- runtime/trace.h | 6 +++--- runtime/utf.h | 6 +++--- runtime/utils.h | 6 +++--- runtime/vector_output_stream.h | 6 +++--- runtime/verifier/dex_gc_map.h | 6 +++--- runtime/verifier/instruction_flags.h | 6 +++--- runtime/verifier/method_verifier.h | 6 +++--- runtime/verifier/reg_type.h | 6 +++--- runtime/verifier/reg_type_cache-inl.h | 6 +++--- runtime/verifier/reg_type_cache.h | 6 +++--- runtime/verifier/register_line-inl.h | 6 +++--- runtime/verifier/register_line.h | 6 +++--- runtime/well_known_classes.h | 6 +++--- runtime/zip_archive.h | 6 +++--- tools/cpplint.py | 7 +++++-- 234 files changed, 726 insertions(+), 691 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/Android.mk b/Android.mk index 4ffa9ac0ab..5a28723e8e 100644 --- a/Android.mk +++ b/Android.mk @@ -78,8 +78,11 @@ clean-oat-target: adb shell rm system/app/*.odex adb shell rm data/run-test/test-*/dalvik-cache/*@classes.dex +######################################################################## +# darwin build + # we aren't building most of art on darwin right now, but we do need to build new dalvikvm -ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-x86) +ifeq ($(HOST_OS),darwin) art_dont_bother := true include $(art_path)/dalvikvm/Android.mk endif @@ -325,14 +328,21 @@ dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(TARGET_BOOT_IMG_OUT) $ endif ######################################################################## -# cpplint target +# cpplint targets to style check art source files -# "mm cpplint-art" to style check art source files +# "mm cpplint-art" to verify we aren't regressing .PHONY: cpplint-art cpplint-art: ./art/tools/cpplint.py \ - --filter=-whitespace/comments,-whitespace/line_length,-build/include,-build/header_guard,-readability/function,-readability/streams,-readability/todo,-runtime/references \ - $(ANDROID_BUILD_TOP)/art/src/*.h $(ANDROID_BUILD_TOP)/art/src/*.cc + --filter=-,+build/header_guard, \ + $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION)) + +# "mm cpplint-art-aspirational" to see warnings we would like to fix +.PHONY: cpplint-art-aspirational +cpplint-art-aspirational: + ./art/tools/cpplint.py \ + --filter=-whitespace/comments,-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references \ + $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION)) ######################################################################## # targets to switch back and forth from libdvm to libart diff --git a/compiler/dex/arena_allocator.h b/compiler/dex/arena_allocator.h index 78d4614f90..23d6b9f06b 100644 --- a/compiler/dex/arena_allocator.h +++ b/compiler/dex/arena_allocator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ +#ifndef ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ +#define ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ #include #include @@ -93,4 +93,4 @@ struct MemStats { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ +#endif // ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ diff --git a/compiler/dex/arena_bit_vector.h b/compiler/dex/arena_bit_vector.h index a950e82498..0b7bbc5f16 100644 --- a/compiler/dex/arena_bit_vector.h +++ b/compiler/dex/arena_bit_vector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ +#ifndef ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ +#define ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ #include #include @@ -124,4 +124,4 @@ class ArenaBitVector { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ +#endif // ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ diff --git a/compiler/dex/backend.h b/compiler/dex/backend.h index 45a1531b85..6f5ba388e1 100644 --- a/compiler/dex/backend.h +++ b/compiler/dex/backend.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_BACKEND_H_ -#define ART_SRC_COMPILER_DEX_BACKEND_H_ +#ifndef ART_COMPILER_DEX_BACKEND_H_ +#define ART_COMPILER_DEX_BACKEND_H_ #include "compiled_method.h" #include "arena_allocator.h" @@ -37,4 +37,4 @@ class Backend { } // namespace art -#endif // ART_SRC_COMPILER_DEX_BACKEND_H_ +#endif // ART_COMPILER_DEX_BACKEND_H_ diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h index bc456b2e70..88240e8c40 100644 --- a/compiler/dex/compiler_enums.h +++ b/compiler/dex/compiler_enums.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ -#define ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ +#ifndef ART_COMPILER_DEX_COMPILER_ENUMS_H_ +#define ART_COMPILER_DEX_COMPILER_ENUMS_H_ #include "dex_instruction.h" @@ -414,4 +414,4 @@ std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ +#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_ diff --git a/compiler/dex/compiler_internals.h b/compiler/dex/compiler_internals.h index a3fa25e842..9dd0272e50 100644 --- a/compiler/dex/compiler_internals.h +++ b/compiler/dex/compiler_internals.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ +#ifndef ART_COMPILER_DEX_COMPILER_INTERNALS_H_ +#define ART_COMPILER_DEX_COMPILER_INTERNALS_H_ #include #include @@ -33,4 +33,4 @@ #include "thread.h" #include "utils.h" -#endif // ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ +#endif // ART_COMPILER_DEX_COMPILER_INTERNALS_H_ diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h index c6f99f3a88..a9b5bf68fc 100644 --- a/compiler/dex/compiler_ir.h +++ b/compiler/dex/compiler_ir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_IR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_IR_H_ +#ifndef ART_COMPILER_DEX_COMPILER_IR_H_ +#define ART_COMPILER_DEX_COMPILER_IR_H_ #include #include @@ -112,4 +112,4 @@ struct CompilationUnit { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_IR_H_ +#endif // ART_COMPILER_DEX_COMPILER_IR_H_ diff --git a/compiler/dex/dataflow_iterator-inl.h b/compiler/dex/dataflow_iterator-inl.h index b20004decc..06cc505a9a 100644 --- a/compiler/dex/dataflow_iterator-inl.h +++ b/compiler/dex/dataflow_iterator-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ -#define ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#ifndef ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#define ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ #include "dataflow_iterator.h" @@ -65,4 +65,4 @@ inline BasicBlock* AllNodesIterator::NextBody(bool had_change) { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#endif // ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ diff --git a/compiler/dex/dataflow_iterator.h b/compiler/dex/dataflow_iterator.h index 12cbf9cadf..4c112f9678 100644 --- a/compiler/dex/dataflow_iterator.h +++ b/compiler/dex/dataflow_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ -#define ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#ifndef ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#define ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ #include "compiler_ir.h" #include "mir_graph.h" @@ -155,4 +155,4 @@ namespace art { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#endif // ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h index 69d7f7728c..a86338950c 100644 --- a/compiler/dex/frontend.h +++ b/compiler/dex/frontend.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_H_ +#ifndef ART_COMPILER_DEX_FRONTEND_H_ +#define ART_COMPILER_DEX_FRONTEND_H_ #include "dex_file.h" #include "dex_instruction.h" @@ -123,4 +123,4 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, -#endif // ART_SRC_COMPILER_DEX_COMPILER_H_ +#endif // ART_COMPILER_DEX_FRONTEND_H_ diff --git a/compiler/dex/growable_array.h b/compiler/dex/growable_array.h index c4684a71f6..6ab0f1630a 100644 --- a/compiler/dex/growable_array.h +++ b/compiler/dex/growable_array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ -#define ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ +#ifndef ART_COMPILER_DEX_GROWABLE_ARRAY_H_ +#define ART_COMPILER_DEX_GROWABLE_ARRAY_H_ #include #include @@ -168,4 +168,4 @@ class GrowableArray { } // namespace art -#endif // ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ +#endif // ART_COMPILER_DEX_GROWABLE_ARRAY_H_ diff --git a/compiler/dex/local_value_numbering.h b/compiler/dex/local_value_numbering.h index beb4cea733..f2b2291e56 100644 --- a/compiler/dex/local_value_numbering.h +++ b/compiler/dex/local_value_numbering.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ -#define ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#ifndef ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#define ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ #include "compiler_internals.h" @@ -140,4 +140,4 @@ class LocalValueNumbering { } // namespace art -#endif // ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#endif // ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index 2b1c21fd70..a40fa97ad5 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_MIRGRAPH_H_ -#define ART_SRC_COMPILER_DEX_MIRGRAPH_H_ +#ifndef ART_COMPILER_DEX_MIR_GRAPH_H_ +#define ART_COMPILER_DEX_MIR_GRAPH_H_ #include "dex_file.h" #include "dex_instruction.h" @@ -667,4 +667,4 @@ class MIRGraph { } // namespace art -#endif // ART_SRC_COMPILER_DEX_MIRGRAPH_H_ +#endif // ART_COMPILER_DEX_MIR_GRAPH_H_ diff --git a/compiler/dex/portable/mir_to_gbc.h b/compiler/dex/portable/mir_to_gbc.h index 8aa0271761..278631466f 100644 --- a/compiler/dex/portable/mir_to_gbc.h +++ b/compiler/dex/portable/mir_to_gbc.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ -#define ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ +#ifndef ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ +#define ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ #include "invoke_type.h" #include "compiled_method.h" @@ -192,4 +192,4 @@ class MirConverter : public Backend { } // namespace art -#endif // ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ +#endif // ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ diff --git a/compiler/dex/quick/arm/arm_lir.h b/compiler/dex/quick/arm/arm_lir.h index 9dd7dafcd6..fca17a1640 100644 --- a/compiler/dex/quick/arm/arm_lir.h +++ b/compiler/dex/quick/arm/arm_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ +#define ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ #include "dex/compiler_internals.h" @@ -496,4 +496,4 @@ struct ArmEncodingMap { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ +#endif // ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ diff --git a/compiler/dex/quick/arm/codegen_arm.h b/compiler/dex/quick/arm/codegen_arm.h index a9199dfa7c..1599941ef6 100644 --- a/compiler/dex/quick/arm/codegen_arm.h +++ b/compiler/dex/quick/arm/codegen_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ -#define ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ +#ifndef ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ +#define ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ #include "dex/compiler_internals.h" @@ -192,4 +192,4 @@ class ArmMir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ +#endif // ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ diff --git a/compiler/dex/quick/mips/codegen_mips.h b/compiler/dex/quick/mips/codegen_mips.h index 9723b899a9..376ad7f10e 100644 --- a/compiler/dex/quick/mips/codegen_mips.h +++ b/compiler/dex/quick/mips/codegen_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ -#define ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ +#define ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ #include "dex/compiler_internals.h" #include "mips_lir.h" @@ -180,4 +180,4 @@ class MipsMir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ +#endif // ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ diff --git a/compiler/dex/quick/mips/mips_lir.h b/compiler/dex/quick/mips/mips_lir.h index ceab9ab1e5..8a99e93f09 100644 --- a/compiler/dex/quick/mips/mips_lir.h +++ b/compiler/dex/quick/mips/mips_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ +#define ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ #include "dex/compiler_internals.h" @@ -429,4 +429,4 @@ extern MipsEncodingMap EncodingMap[kMipsLast]; } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ +#endif // ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ diff --git a/compiler/dex/quick/mir_to_lir-inl.h b/compiler/dex/quick/mir_to_lir-inl.h index 4eef264a0f..d9aef5d968 100644 --- a/compiler/dex/quick/mir_to_lir-inl.h +++ b/compiler/dex/quick/mir_to_lir-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#define ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ #include "mir_to_lir.h" @@ -198,4 +198,4 @@ inline void Mir2Lir::SetupResourceMasks(LIR* lir) { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#endif // ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index 47514f769f..bec86c181e 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#define ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ #include "invoke_type.h" #include "compiled_method.h" @@ -776,4 +776,4 @@ class Mir2Lir : public Backend { } // namespace art -#endif //ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#endif // ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ diff --git a/compiler/dex/quick/x86/codegen_x86.h b/compiler/dex/quick/x86/codegen_x86.h index 3e30141594..4fa9dfb4d9 100644 --- a/compiler/dex/quick/x86/codegen_x86.h +++ b/compiler/dex/quick/x86/codegen_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ -#define ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ +#ifndef ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ +#define ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ #include "dex/compiler_internals.h" #include "x86_lir.h" @@ -202,4 +202,4 @@ class X86Mir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ +#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ diff --git a/compiler/dex/quick/x86/x86_lir.h b/compiler/dex/quick/x86/x86_lir.h index 600bd03026..a39231b75a 100644 --- a/compiler/dex/quick/x86/x86_lir.h +++ b/compiler/dex/quick/x86/x86_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ +#define ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ #include "dex/compiler_internals.h" @@ -439,4 +439,4 @@ extern X86ConditionCode X86ConditionEncoding(ConditionCode cond); } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ +#endif // ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 4d7f0cf7b6..80cc89b95f 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ -#define ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#ifndef ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#define ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ #include #include @@ -410,4 +410,4 @@ class CompilerDriver { } // namespace art -#endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#endif // ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h index 3c6129d642..53efd12ba7 100644 --- a/compiler/driver/dex_compilation_unit.h +++ b/compiler/driver/dex_compilation_unit.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ -#define ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ +#ifndef ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ +#define ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ #include @@ -113,4 +113,4 @@ class DexCompilationUnit { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ +#endif // ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ diff --git a/compiler/elf_fixup.h b/compiler/elf_fixup.h index 79c45c1874..1abf06b1c5 100644 --- a/compiler/elf_fixup.h +++ b/compiler/elf_fixup.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_FIXUP_H_ -#define ART_SRC_ELF_FIXUP_H_ +#ifndef ART_COMPILER_ELF_FIXUP_H_ +#define ART_COMPILER_ELF_FIXUP_H_ #include @@ -53,4 +53,4 @@ class ElfFixup { } // namespace art -#endif // ART_SRC_ELF_FIXUP_H_ +#endif // ART_COMPILER_ELF_FIXUP_H_ diff --git a/compiler/elf_stripper.h b/compiler/elf_stripper.h index b202e6e1f0..6015b30cb2 100644 --- a/compiler/elf_stripper.h +++ b/compiler/elf_stripper.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_STRIPPER_H_ -#define ART_SRC_ELF_STRIPPER_H_ +#ifndef ART_COMPILER_ELF_STRIPPER_H_ +#define ART_COMPILER_ELF_STRIPPER_H_ #include "base/macros.h" #include "os.h" @@ -34,4 +34,4 @@ class ElfStripper { } // namespace art -#endif // ART_SRC_ELF_STRIPPER_H_ +#endif // ART_COMPILER_ELF_STRIPPER_H_ diff --git a/compiler/elf_writer.h b/compiler/elf_writer.h index 7392e67d7f..ab436e4fb3 100644 --- a/compiler/elf_writer.h +++ b/compiler/elf_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_H_ -#define ART_SRC_ELF_WRITER_H_ +#ifndef ART_COMPILER_ELF_WRITER_H_ +#define ART_COMPILER_ELF_WRITER_H_ #include @@ -62,4 +62,4 @@ class ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_H_ +#endif // ART_COMPILER_ELF_WRITER_H_ diff --git a/compiler/elf_writer_mclinker.h b/compiler/elf_writer_mclinker.h index 21f23e113d..468fa9a84f 100644 --- a/compiler/elf_writer_mclinker.h +++ b/compiler/elf_writer_mclinker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_MCLINKER_H_ -#define ART_SRC_ELF_WRITER_MCLINKER_H_ +#ifndef ART_COMPILER_ELF_WRITER_MCLINKER_H_ +#define ART_COMPILER_ELF_WRITER_MCLINKER_H_ #include "elf_writer.h" @@ -96,4 +96,4 @@ class ElfWriterMclinker : public ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_MCLINKER_H_ +#endif // ART_COMPILER_ELF_WRITER_MCLINKER_H_ diff --git a/compiler/elf_writer_quick.h b/compiler/elf_writer_quick.h index a1a386b3d7..a15c239de9 100644 --- a/compiler/elf_writer_quick.h +++ b/compiler/elf_writer_quick.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_MCLINKER_H_ -#define ART_SRC_ELF_WRITER_MCLINKER_H_ +#ifndef ART_COMPILER_ELF_WRITER_QUICK_H_ +#define ART_COMPILER_ELF_WRITER_QUICK_H_ #include "elf_writer.h" @@ -48,4 +48,4 @@ class ElfWriterQuick : public ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_MCLINKER_H_ +#endif // ART_COMPILER_ELF_WRITER_QUICK_H_ diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 9b0d671604..e43ec6338f 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_IMAGE_WRITER_H_ -#define ART_SRC_IMAGE_WRITER_H_ +#ifndef ART_COMPILER_IMAGE_WRITER_H_ +#define ART_COMPILER_IMAGE_WRITER_H_ #include @@ -207,4 +207,4 @@ class ImageWriter { } // namespace art -#endif // ART_SRC_IMAGE_WRITER_H_ +#endif // ART_COMPILER_IMAGE_WRITER_H_ diff --git a/compiler/jni/portable/jni_compiler.h b/compiler/jni/portable/jni_compiler.h index a04277c9e6..9bdf35ef10 100644 --- a/compiler/jni/portable/jni_compiler.h +++ b/compiler/jni/portable/jni_compiler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ -#define ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#ifndef ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#define ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ #include @@ -84,4 +84,4 @@ class JniCompiler { } // namespace art -#endif // ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#endif // ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ diff --git a/compiler/jni/quick/arm/calling_convention_arm.h b/compiler/jni/quick/arm/calling_convention_arm.h index 3787d45c6f..f188700746 100644 --- a/compiler/jni/quick/arm/calling_convention_arm.h +++ b/compiler/jni/quick/arm/calling_convention_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ -#define ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ +#ifndef ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ +#define ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ #include "jni/quick/calling_convention.h" @@ -85,4 +85,4 @@ class ArmJniCallingConvention : public JniCallingConvention { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ +#endif // ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ diff --git a/compiler/jni/quick/calling_convention.h b/compiler/jni/quick/calling_convention.h index 121d1f80ae..d492b42237 100644 --- a/compiler/jni/quick/calling_convention.h +++ b/compiler/jni/quick/calling_convention.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ -#define ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ +#ifndef ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ +#define ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ #include #include "oat/utils/managed_register.h" @@ -286,4 +286,4 @@ class JniCallingConvention : public CallingConvention { } // namespace art -#endif // ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ +#endif // ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ diff --git a/compiler/jni/quick/mips/calling_convention_mips.h b/compiler/jni/quick/mips/calling_convention_mips.h index 90681362bc..8412898dd8 100644 --- a/compiler/jni/quick/mips/calling_convention_mips.h +++ b/compiler/jni/quick/mips/calling_convention_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ -#define ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ +#ifndef ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ +#define ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ #include "jni/quick/calling_convention.h" @@ -83,4 +83,4 @@ class MipsJniCallingConvention : public JniCallingConvention { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ +#endif // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ diff --git a/compiler/jni/quick/x86/calling_convention_x86.h b/compiler/jni/quick/x86/calling_convention_x86.h index ea8a26e7d5..082c1c8eb1 100644 --- a/compiler/jni/quick/x86/calling_convention_x86.h +++ b/compiler/jni/quick/x86/calling_convention_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ -#define ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ +#ifndef ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ +#define ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ #include "jni/quick/calling_convention.h" @@ -80,4 +80,4 @@ class X86JniCallingConvention : public JniCallingConvention { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ +#endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ diff --git a/compiler/llvm/backend_options.h b/compiler/llvm/backend_options.h index 924a34639c..2a08bda2f1 100644 --- a/compiler/llvm/backend_options.h +++ b/compiler/llvm/backend_options.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ -#define ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#ifndef ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#define ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ #include @@ -47,4 +47,4 @@ inline void InitialBackendOptions() { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#endif // ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ diff --git a/compiler/llvm/backend_types.h b/compiler/llvm/backend_types.h index c89504a859..095040e5eb 100644 --- a/compiler/llvm/backend_types.h +++ b/compiler/llvm/backend_types.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ -#define ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ +#ifndef ART_COMPILER_LLVM_BACKEND_TYPES_H_ +#define ART_COMPILER_LLVM_BACKEND_TYPES_H_ #include "base/logging.h" @@ -101,4 +101,4 @@ inline JType GetJTypeFromShorty(char shorty_jty) { } // namespace art -#endif // ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ +#endif // ART_COMPILER_LLVM_BACKEND_TYPES_H_ diff --git a/compiler/llvm/compiler_llvm.h b/compiler/llvm/compiler_llvm.h index b70ddc5e20..77841d8564 100644 --- a/compiler/llvm/compiler_llvm.h +++ b/compiler/llvm/compiler_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ -#define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ +#ifndef ART_COMPILER_LLVM_COMPILER_LLVM_H_ +#define ART_COMPILER_LLVM_COMPILER_LLVM_H_ #include "base/macros.h" #include "dex_file.h" @@ -100,4 +100,4 @@ class CompilerLLVM { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ +#endif // ART_COMPILER_LLVM_COMPILER_LLVM_H_ diff --git a/compiler/llvm/intrinsic_helper.h b/compiler/llvm/intrinsic_helper.h index 49b8a95230..bb123fd575 100644 --- a/compiler/llvm/intrinsic_helper.h +++ b/compiler/llvm/intrinsic_helper.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ -#define ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ +#ifndef ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ +#define ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ #include "base/logging.h" @@ -154,4 +154,4 @@ class IntrinsicHelper { } // namespace llvm } // namespace art -#endif // ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ +#endif // ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ diff --git a/compiler/llvm/ir_builder.h b/compiler/llvm/ir_builder.h index 734b22f791..65da005e9b 100644 --- a/compiler/llvm/ir_builder.h +++ b/compiler/llvm/ir_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_IR_BUILDER_H_ +#define ART_COMPILER_LLVM_IR_BUILDER_H_ #include "backend_types.h" #include "dex/compiler_enums.h" @@ -487,4 +487,4 @@ class IRBuilder : public LLVMIRBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ +#endif // ART_COMPILER_LLVM_IR_BUILDER_H_ diff --git a/compiler/llvm/llvm_compilation_unit.h b/compiler/llvm/llvm_compilation_unit.h index a4f0adbab8..9de132379b 100644 --- a/compiler/llvm/llvm_compilation_unit.h +++ b/compiler/llvm/llvm_compilation_unit.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ -#define ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#ifndef ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#define ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ #include "base/logging.h" #include "base/mutex.h" @@ -135,4 +135,4 @@ class LlvmCompilationUnit { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#endif // ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ diff --git a/compiler/llvm/md_builder.h b/compiler/llvm/md_builder.h index 79a7caa04c..cc169a3219 100644 --- a/compiler/llvm/md_builder.h +++ b/compiler/llvm/md_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_MD_BUILDER_H_ +#define ART_COMPILER_LLVM_MD_BUILDER_H_ #include "backend_types.h" @@ -68,4 +68,4 @@ class MDBuilder : public LLVMMDBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ +#endif // ART_COMPILER_LLVM_MD_BUILDER_H_ diff --git a/compiler/llvm/runtime_support_builder.h b/compiler/llvm/runtime_support_builder.h index 267b406232..c3c0856bd0 100644 --- a/compiler/llvm/runtime_support_builder.h +++ b/compiler/llvm/runtime_support_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ #include "backend_types.h" #include "base/logging.h" @@ -95,4 +95,4 @@ class RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ diff --git a/compiler/llvm/runtime_support_builder_arm.h b/compiler/llvm/runtime_support_builder_arm.h index 3c5972fc33..6aa23b2306 100644 --- a/compiler/llvm/runtime_support_builder_arm.h +++ b/compiler/llvm/runtime_support_builder_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ #include "runtime_support_builder.h" @@ -43,4 +43,4 @@ class RuntimeSupportBuilderARM : public RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ diff --git a/compiler/llvm/runtime_support_builder_thumb2.h b/compiler/llvm/runtime_support_builder_thumb2.h index 4762a269f9..941bd6b2bb 100644 --- a/compiler/llvm/runtime_support_builder_thumb2.h +++ b/compiler/llvm/runtime_support_builder_thumb2.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ #include "runtime_support_builder_arm.h" @@ -34,4 +34,4 @@ class RuntimeSupportBuilderThumb2 : public RuntimeSupportBuilderARM { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ diff --git a/compiler/llvm/runtime_support_builder_x86.h b/compiler/llvm/runtime_support_builder_x86.h index e5fdbc2e26..831d022ce5 100644 --- a/compiler/llvm/runtime_support_builder_x86.h +++ b/compiler/llvm/runtime_support_builder_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ #include "runtime_support_builder.h" @@ -39,4 +39,4 @@ class RuntimeSupportBuilderX86 : public RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ diff --git a/compiler/llvm/runtime_support_llvm_func.h b/compiler/llvm/runtime_support_llvm_func.h index ac6f3b869f..c0e76addc6 100644 --- a/compiler/llvm/runtime_support_llvm_func.h +++ b/compiler/llvm/runtime_support_llvm_func.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ namespace art { namespace llvm { @@ -35,4 +35,4 @@ namespace runtime_support { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ diff --git a/compiler/llvm/utils_llvm.h b/compiler/llvm/utils_llvm.h index 2e273f4fe9..a606b91958 100644 --- a/compiler/llvm/utils_llvm.h +++ b/compiler/llvm/utils_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTILS_LLVM_H_ -#define ART_SRC_UTILS_LLVM_H_ +#ifndef ART_COMPILER_LLVM_UTILS_LLVM_H_ +#define ART_COMPILER_LLVM_UTILS_LLVM_H_ #include @@ -29,4 +29,4 @@ namespace art { } // namespace art -#endif // ART_SRC_UTILS_LLVM_H_ +#endif // ART_COMPILER_LLVM_UTILS_LLVM_H_ diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index 1f97bf853c..ea7156ea49 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_WRITER_H_ -#define ART_SRC_OAT_WRITER_H_ +#ifndef ART_COMPILER_OAT_WRITER_H_ +#define ART_COMPILER_OAT_WRITER_H_ #include @@ -224,4 +224,4 @@ class OatWriter { } // namespace art -#endif // ART_SRC_OAT_WRITER_H_ +#endif // ART_COMPILER_OAT_WRITER_H_ diff --git a/compiler/sea_ir/instruction_tools.h b/compiler/sea_ir/instruction_tools.h index f68cdd0784..b0bbc272c8 100644 --- a/compiler/sea_ir/instruction_tools.h +++ b/compiler/sea_ir/instruction_tools.h @@ -17,8 +17,8 @@ #include "dex_instruction.h" -#ifndef INSTRUCTION_TOOLS_H_ -#define INSTRUCTION_TOOLS_H_ +#ifndef ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ +#define ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ // Note: This file has content cannibalized for SEA_IR from the MIR implementation, // to avoid having a dependence on MIR. @@ -121,4 +121,4 @@ class InstructionTools { static const int instruction_attributes_[]; }; } // end namespace sea_ir -#endif // INSTRUCTION_TOOLS_H_ +#endif // ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ diff --git a/compiler/sea_ir/sea.h b/compiler/sea_ir/sea.h index f2c71469e5..ce4624d438 100644 --- a/compiler/sea_ir/sea.h +++ b/compiler/sea_ir/sea.h @@ -15,8 +15,8 @@ */ -#ifndef SEA_IR_H_ -#define SEA_IR_H_ +#ifndef ART_COMPILER_SEA_IR_SEA_H_ +#define ART_COMPILER_SEA_IR_SEA_H_ #include #include @@ -159,4 +159,4 @@ class SeaGraph { } // end namespace sea_ir -#endif +#endif // ART_COMPILER_SEA_IR_SEA_H_ diff --git a/compiler/stubs/stubs.h b/compiler/stubs/stubs.h index ebe761df35..d85eae8e1e 100644 --- a/compiler/stubs/stubs.h +++ b/compiler/stubs/stubs.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_STUBS_STUBS_H_ -#define ART_SRC_COMPILER_STUBS_STUBS_H_ +#ifndef ART_COMPILER_STUBS_STUBS_H_ +#define ART_COMPILER_STUBS_STUBS_H_ #include "runtime.h" @@ -56,4 +56,4 @@ const std::vector* CreateInterpreterToQuickEntry() } // namespace art -#endif // ART_SRC_COMPILER_STUBS_STUBS_H_ +#endif // ART_COMPILER_STUBS_STUBS_H_ diff --git a/jdwpspy/Common.h b/jdwpspy/Common.h index 0bd305643a..33f1a670ea 100644 --- a/jdwpspy/Common.h +++ b/jdwpspy/Common.h @@ -3,8 +3,8 @@ * * jdwpspy common stuff. */ -#ifndef _JDWPSPY_COMMON -#define _JDWPSPY_COMMON +#ifndef ART_JDWPSPY_COMMON_H_ +#define ART_JDWPSPY_COMMON_H_ #include #include @@ -99,4 +99,4 @@ void printHexDump2(const void* vaddr, size_t length, const char* prefix); void printHexDumpEx(FILE* fp, const void* vaddr, size_t length, HexDumpMode mode, const char* prefix); -#endif /*_JDWPSPY_COMMON*/ +#endif // ART_JDWPSPY_COMMON_H_ diff --git a/runtime/asm_support.h b/runtime/asm_support.h index 8ea4adfcf2..7b20c7aee0 100644 --- a/runtime/asm_support.h +++ b/runtime/asm_support.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ASM_SUPPORT_H_ -#define ART_SRC_ASM_SUPPORT_H_ +#ifndef ART_RUNTIME_ASM_SUPPORT_H_ +#define ART_RUNTIME_ASM_SUPPORT_H_ // Value loaded into rSUSPEND for quick. When this value is counted down to zero we do a suspend // check. @@ -55,4 +55,4 @@ #define THREAD_EXCEPTION_OFFSET 12 #endif -#endif // ART_SRC_ASM_SUPPORT_H_ +#endif // ART_RUNTIME_ASM_SUPPORT_H_ diff --git a/runtime/atomic.h b/runtime/atomic.h index d340dc5474..cb6f86b921 100644 --- a/runtime/atomic.h +++ b/runtime/atomic.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ATOMIC_H_ -#define ART_SRC_ATOMIC_H_ +#ifndef ART_RUNTIME_ATOMIC_H_ +#define ART_RUNTIME_ATOMIC_H_ #include @@ -54,4 +54,4 @@ class QuasiAtomic { } // namespace art -#endif // ART_SRC_ATOMIC_H_ +#endif // ART_RUNTIME_ATOMIC_H_ diff --git a/runtime/atomic_integer.h b/runtime/atomic_integer.h index c4a8de9817..57836d6e26 100644 --- a/runtime/atomic_integer.h +++ b/runtime/atomic_integer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ATOMIC_INTEGER_H_ -#define ART_SRC_ATOMIC_INTEGER_H_ +#ifndef ART_RUNTIME_ATOMIC_INTEGER_H_ +#define ART_RUNTIME_ATOMIC_INTEGER_H_ #include "cutils/atomic.h" #include "cutils/atomic-inline.h" @@ -76,4 +76,4 @@ class AtomicInteger { } -#endif // ART_SRC_ATOMIC_INTEGER_H_ +#endif // ART_RUNTIME_ATOMIC_INTEGER_H_ diff --git a/runtime/barrier.h b/runtime/barrier.h index 2b0429a7c2..e0ad239eab 100644 --- a/runtime/barrier.h +++ b/runtime/barrier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BARRIER_H_ -#define ART_SRC_BARRIER_H_ +#ifndef ART_RUNTIME_BARRIER_H_ +#define ART_RUNTIME_BARRIER_H_ #include "base/mutex.h" #include "locks.h" @@ -52,4 +52,4 @@ class Barrier { }; } // namespace art -#endif // ART_SRC_GC_BARRIER_H_ +#endif // ART_RUNTIME_BARRIER_H_ diff --git a/runtime/base/casts.h b/runtime/base/casts.h index 34c05af4e3..be94c2eb78 100644 --- a/runtime/base/casts.h +++ b/runtime/base/casts.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_CASTS_H_ -#define ART_SRC_BASE_CASTS_H_ +#ifndef ART_RUNTIME_BASE_CASTS_H_ +#define ART_RUNTIME_BASE_CASTS_H_ #include #include @@ -90,4 +90,4 @@ inline Dest bit_cast(const Source& source) { } // namespace art -#endif // ART_SRC_BASE_CASTS_H_ +#endif // ART_RUNTIME_BASE_CASTS_H_ diff --git a/runtime/base/histogram-inl.h b/runtime/base/histogram-inl.h index 9514209c11..bbca60308a 100644 --- a/runtime/base/histogram-inl.h +++ b/runtime/base/histogram-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef SRC_BASE_HISTOGRAM_INL_H_ -#define SRC_BASE_HISTOGRAM_INL_H_ +#ifndef ART_RUNTIME_BASE_HISTOGRAM_INL_H_ +#define ART_RUNTIME_BASE_HISTOGRAM_INL_H_ #include "histogram.h" @@ -251,5 +251,5 @@ inline double Histogram::Percentile(double per) const { } } // namespace art -#endif // SRC_BASE_HISTOGRAM_INL_H_ +#endif // ART_RUNTIME_BASE_HISTOGRAM_INL_H_ diff --git a/runtime/base/histogram.h b/runtime/base/histogram.h index 6878e71ccc..8724d2c582 100644 --- a/runtime/base/histogram.h +++ b/runtime/base/histogram.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ART_SRC_BASE_HISTOGRAM_H_ -#define ART_SRC_BASE_HISTOGRAM_H_ +#ifndef ART_RUNTIME_BASE_HISTOGRAM_H_ +#define ART_RUNTIME_BASE_HISTOGRAM_H_ #include #include @@ -117,4 +117,4 @@ template class Histogram { }; } -#endif // ART_SRC_BASE_HISTOGRAM_H_ +#endif // ART_RUNTIME_BASE_HISTOGRAM_H_ diff --git a/runtime/base/logging.h b/runtime/base/logging.h index 8d89e4d0cb..f02a39a1f9 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_LOGGING_H_ -#define ART_SRC_BASE_LOGGING_H_ +#ifndef ART_RUNTIME_BASE_LOGGING_H_ +#define ART_RUNTIME_BASE_LOGGING_H_ #include #include @@ -334,4 +334,4 @@ extern const char* ProgramInvocationShortName(); } // namespace art -#endif // ART_SRC_BASE_LOGGING_H_ +#endif // ART_RUNTIME_BASE_LOGGING_H_ diff --git a/runtime/base/macros.h b/runtime/base/macros.h index 847105d20c..4a196f28e7 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MACROS_H_ -#define ART_SRC_BASE_MACROS_H_ +#ifndef ART_RUNTIME_BASE_MACROS_H_ +#define ART_RUNTIME_BASE_MACROS_H_ #include // for size_t @@ -198,4 +198,4 @@ template void UNUSED(const T&) {} #endif // defined(__SUPPORT_TS_ANNOTATION__) -#endif // ART_SRC_BASE_MACROS_H_ +#endif // ART_RUNTIME_BASE_MACROS_H_ diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index f911054b86..07157da7aa 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MUTEX_INL_H_ -#define ART_SRC_BASE_MUTEX_INL_H_ +#ifndef ART_RUNTIME_BASE_MUTEX_INL_H_ +#define ART_RUNTIME_BASE_MUTEX_INL_H_ #include "mutex.h" @@ -184,4 +184,4 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) { } // namespace art -#endif // ART_SRC_BASE_MUTEX_INL_H_ +#endif // ART_RUNTIME_BASE_MUTEX_INL_H_ diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index b62755917c..dea52a6615 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MUTEX_H_ -#define ART_SRC_BASE_MUTEX_H_ +#ifndef ART_RUNTIME_BASE_MUTEX_H_ +#define ART_RUNTIME_BASE_MUTEX_H_ #include #include @@ -398,4 +398,4 @@ class SCOPED_LOCKABLE WriterMutexLock { } // namespace art -#endif // ART_SRC_BASE_MUTEX_H_ +#endif // ART_RUNTIME_BASE_MUTEX_H_ diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h index eb8be42df3..ff9f40cbf8 100644 --- a/runtime/base/stl_util.h +++ b/runtime/base/stl_util.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_STL_UTIL_H_ -#define ART_SRC_BASE_STL_UTIL_H_ +#ifndef ART_RUNTIME_BASE_STL_UTIL_H_ +#define ART_RUNTIME_BASE_STL_UTIL_H_ #include #include @@ -94,4 +94,4 @@ std::string ToString(const T& v) { } // namespace art -#endif // ART_SRC_BASE_STL_UTIL_H_ +#endif // ART_RUNTIME_BASE_STL_UTIL_H_ diff --git a/runtime/base/stringpiece.h b/runtime/base/stringpiece.h index 3664218860..62088cc183 100644 --- a/runtime/base/stringpiece.h +++ b/runtime/base/stringpiece.h @@ -25,8 +25,8 @@ // Systematic usage of StringPiece is encouraged as it will reduce unnecessary // conversions from "const char*" to "string" and back again. -#ifndef ART_SRC_BASE_STRINGPIECE_H_ -#define ART_SRC_BASE_STRINGPIECE_H_ +#ifndef ART_RUNTIME_BASE_STRINGPIECE_H_ +#define ART_RUNTIME_BASE_STRINGPIECE_H_ #include #include @@ -223,4 +223,4 @@ struct StringPieceHash { } // namespace art -#endif // ART_SRC_BASE_STRINGPIECE_H_ +#endif // ART_RUNTIME_BASE_STRINGPIECE_H_ diff --git a/runtime/base/stringprintf.h b/runtime/base/stringprintf.h index d707cc02d6..4767a750c3 100644 --- a/runtime/base/stringprintf.h +++ b/runtime/base/stringprintf.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_STRINGPRINTF_H_ -#define ART_SRC_BASE_STRINGPRINTF_H_ +#ifndef ART_RUNTIME_BASE_STRINGPRINTF_H_ +#define ART_RUNTIME_BASE_STRINGPRINTF_H_ #include #include @@ -35,4 +35,4 @@ void StringAppendV(std::string* dst, const char* format, va_list ap); } // namespace art -#endif // ART_SRC_BASE_STRINGPRINTF_H_ +#endif // ART_RUNTIME_BASE_STRINGPRINTF_H_ diff --git a/runtime/base/timing_logger.h b/runtime/base/timing_logger.h index 65732b170d..816cbeadec 100644 --- a/runtime/base/timing_logger.h +++ b/runtime/base/timing_logger.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_TIMING_LOGGER_H_ -#define ART_SRC_TIMING_LOGGER_H_ +#ifndef ART_RUNTIME_BASE_TIMING_LOGGER_H_ +#define ART_RUNTIME_BASE_TIMING_LOGGER_H_ #include "base/histogram.h" #include "base/macros.h" @@ -139,4 +139,4 @@ class NewTimingLogger { } // namespace base } // namespace art -#endif // ART_SRC_TIMING_LOGGER_H_ +#endif // ART_RUNTIME_BASE_TIMING_LOGGER_H_ diff --git a/runtime/base/unix_file/fd_file.h b/runtime/base/unix_file/fd_file.h index 2b339613ba..79a0db9eda 100644 --- a/runtime/base/unix_file/fd_file.h +++ b/runtime/base/unix_file/fd_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_FD_FILE_H_ -#define BASE_UNIX_FILE_FD_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ #include #include @@ -72,4 +72,4 @@ class FdFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_FD_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ diff --git a/runtime/base/unix_file/mapped_file.h b/runtime/base/unix_file/mapped_file.h index 161100b0d5..28cc5514f7 100644 --- a/runtime/base/unix_file/mapped_file.h +++ b/runtime/base/unix_file/mapped_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_MAPPED_FILE_H_ -#define BASE_UNIX_FILE_MAPPED_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ #include #include @@ -94,4 +94,4 @@ class MappedFile : public FdFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_MAPPED_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ diff --git a/runtime/base/unix_file/null_file.h b/runtime/base/unix_file/null_file.h index e716603687..33947311f0 100644 --- a/runtime/base/unix_file/null_file.h +++ b/runtime/base/unix_file/null_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_NULL_FILE_H_ -#define BASE_UNIX_FILE_NULL_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ #include "base/unix_file/random_access_file.h" #include "base/macros.h" @@ -47,4 +47,4 @@ class NullFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_NULL_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ diff --git a/runtime/base/unix_file/random_access_file.h b/runtime/base/unix_file/random_access_file.h index 22da37f03e..31a6dbe1fc 100644 --- a/runtime/base/unix_file/random_access_file.h +++ b/runtime/base/unix_file/random_access_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ #include @@ -65,4 +65,4 @@ class RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ diff --git a/runtime/base/unix_file/random_access_file_test.h b/runtime/base/unix_file/random_access_file_test.h index 3baaeae8ac..9d8550d6f6 100644 --- a/runtime/base/unix_file/random_access_file_test.h +++ b/runtime/base/unix_file/random_access_file_test.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ #include @@ -169,4 +169,4 @@ class RandomAccessFileTest : public testing::Test { } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ diff --git a/runtime/base/unix_file/random_access_file_utils.h b/runtime/base/unix_file/random_access_file_utils.h index 0535ead8c5..30c81c09aa 100644 --- a/runtime/base/unix_file/random_access_file_utils.h +++ b/runtime/base/unix_file/random_access_file_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ namespace unix_file { @@ -27,4 +27,4 @@ bool CopyFile(const RandomAccessFile& src, RandomAccessFile* dst); } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ diff --git a/runtime/base/unix_file/string_file.h b/runtime/base/unix_file/string_file.h index 8944373344..26904f89a6 100644 --- a/runtime/base/unix_file/string_file.h +++ b/runtime/base/unix_file/string_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_STRING_FILE_H_ -#define BASE_UNIX_FILE_STRING_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ #include @@ -56,4 +56,4 @@ class StringFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_STRING_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 6cf49912a2..4d01b66f0a 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LINKER_INL_H_ -#define ART_SRC_CLASS_LINKER_INL_H_ +#ifndef ART_RUNTIME_CLASS_LINKER_INL_H_ +#define ART_RUNTIME_CLASS_LINKER_INL_H_ #include "class_linker.h" @@ -143,4 +143,4 @@ inline mirror::Class* ClassLinker::GetClassRoot(ClassRoot class_root) } // namespace art -#endif // ART_SRC_CLASS_LINKER_INL_H_ +#endif // ART_RUNTIME_CLASS_LINKER_INL_H_ diff --git a/runtime/class_linker.h b/runtime/class_linker.h index df1ecc6207..3993cb214b 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LINKER_H_ -#define ART_SRC_CLASS_LINKER_H_ +#ifndef ART_RUNTIME_CLASS_LINKER_H_ +#define ART_RUNTIME_CLASS_LINKER_H_ #include #include @@ -627,4 +627,4 @@ class ClassLinker { } // namespace art -#endif // ART_SRC_CLASS_LINKER_H_ +#endif // ART_RUNTIME_CLASS_LINKER_H_ diff --git a/runtime/class_reference.h b/runtime/class_reference.h index c3be720ea5..77c296facd 100644 --- a/runtime/class_reference.h +++ b/runtime/class_reference.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_REFERENCE_H_ -#define ART_SRC_CLASS_REFERENCE_H_ +#ifndef ART_RUNTIME_CLASS_REFERENCE_H_ +#define ART_RUNTIME_CLASS_REFERENCE_H_ #include @@ -38,4 +38,4 @@ inline bool operator<(const ClassReference& lhs, const ClassReference& rhs) { } // namespace art -#endif // ART_SRC_CLASS_REFERENCE_H_ +#endif // ART_RUNTIME_CLASS_REFERENCE_H_ diff --git a/runtime/closure.h b/runtime/closure.h index 17f2b84d82..9bea28fa58 100644 --- a/runtime/closure.h +++ b/runtime/closure.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLOSURE_H_ -#define ART_SRC_CLOSURE_H_ +#ifndef ART_RUNTIME_CLOSURE_H_ +#define ART_RUNTIME_CLOSURE_H_ namespace art { @@ -29,4 +29,4 @@ class Closure { } // namespace art -#endif // ART_SRC_CLOSURE_H_ +#endif // ART_RUNTIME_CLOSURE_H_ diff --git a/runtime/common_test.h b/runtime/common_test.h index f03b1f9cdb..73c47b5a8c 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_COMMON_TEST_H_ +#define ART_RUNTIME_COMMON_TEST_H_ + #include #include #include @@ -586,3 +589,5 @@ std::ostream& operator<<(std::ostream& os, const std::vector& rhs) { } } // namespace std + +#endif // ART_RUNTIME_COMMON_TEST_H_ diff --git a/runtime/common_throws.h b/runtime/common_throws.h index 4bf12c0d01..b7f2754df1 100644 --- a/runtime/common_throws.h +++ b/runtime/common_throws.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMMON_THROWS__H_ -#define ART_SRC_COMMON_THROWS_H_ +#ifndef ART_RUNTIME_COMMON_THROWS_H_ +#define ART_RUNTIME_COMMON_THROWS_H_ #include "base/mutex.h" #include "invoke_type.h" @@ -183,4 +183,4 @@ void ThrowVerifyError(const mirror::Class* referrer, const char* fmt, ...) } // namespace art -#endif // ART_SRC_COMMON_THROWS_H_ +#endif // ART_RUNTIME_COMMON_THROWS_H_ diff --git a/runtime/compiled_class.h b/runtime/compiled_class.h index f050ee6a7e..c53d500502 100644 --- a/runtime/compiled_class.h +++ b/runtime/compiled_class.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILED_CLASS_H_ -#define ART_SRC_COMPILED_CLASS_H_ +#ifndef ART_RUNTIME_COMPILED_CLASS_H_ +#define ART_RUNTIME_COMPILED_CLASS_H_ #include "mirror/class.h" @@ -34,4 +34,4 @@ class CompiledClass { } // namespace art -#endif // ART_SRC_COMPILED_CLASS_H_ +#endif // ART_RUNTIME_COMPILED_CLASS_H_ diff --git a/runtime/compiled_method.h b/runtime/compiled_method.h index fb0172cc19..800dde2208 100644 --- a/runtime/compiled_method.h +++ b/runtime/compiled_method.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILED_METHOD_H_ -#define ART_SRC_COMPILED_METHOD_H_ +#ifndef ART_RUNTIME_COMPILED_METHOD_H_ +#define ART_RUNTIME_COMPILED_METHOD_H_ #include #include @@ -177,4 +177,4 @@ class CompiledMethod : public CompiledCode { } // namespace art -#endif // ART_SRC_COMPILED_METHOD_H_ +#endif // ART_RUNTIME_COMPILED_METHOD_H_ diff --git a/runtime/constants_arm.h b/runtime/constants_arm.h index 601c57247e..bbb9242def 100644 --- a/runtime/constants_arm.h +++ b/runtime/constants_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_ARM_H_ -#define ART_SRC_CONSTANTS_ARM_H_ +#ifndef ART_RUNTIME_CONSTANTS_ARM_H_ +#define ART_RUNTIME_CONSTANTS_ARM_H_ #include @@ -516,4 +516,4 @@ class Instr { } // namespace arm } // namespace art -#endif // ART_SRC_CONSTANTS_ARM_H_ +#endif // ART_RUNTIME_CONSTANTS_ARM_H_ diff --git a/runtime/constants_mips.h b/runtime/constants_mips.h index 87a13554fb..fb56493a14 100644 --- a/runtime/constants_mips.h +++ b/runtime/constants_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_MIPS_H_ -#define ART_SRC_CONSTANTS_MIPS_H_ +#ifndef ART_RUNTIME_CONSTANTS_MIPS_H_ +#define ART_RUNTIME_CONSTANTS_MIPS_H_ #include @@ -183,4 +183,4 @@ class Instr { } // namespace mips } // namespace art -#endif // ART_SRC_CONSTANTS_MIPS_H_ +#endif // ART_RUNTIME_CONSTANTS_MIPS_H_ diff --git a/runtime/constants_x86.h b/runtime/constants_x86.h index e48b281599..bb18b6b23b 100644 --- a/runtime/constants_x86.h +++ b/runtime/constants_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_X86_H_ -#define ART_SRC_CONSTANTS_X86_H_ +#ifndef ART_RUNTIME_CONSTANTS_X86_H_ +#define ART_RUNTIME_CONSTANTS_X86_H_ #include @@ -137,4 +137,4 @@ class Instr { } // namespace x86 } // namespace art -#endif // ART_SRC_CONSTANTS_X86_H_ +#endif // ART_RUNTIME_CONSTANTS_X86_H_ diff --git a/runtime/debugger.h b/runtime/debugger.h index eb17695249..94f3cbed76 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -18,8 +18,8 @@ * Dalvik-specific side of debugger support. (The JDWP code is intended to * be relatively generic.) */ -#ifndef ART_DEBUGGER_H_ -#define ART_DEBUGGER_H_ +#ifndef ART_RUNTIME_DEBUGGER_H_ +#define ART_RUNTIME_DEBUGGER_H_ #include @@ -429,4 +429,4 @@ class Dbg { } // namespace art -#endif // ART_DEBUGGER_H_ +#endif // ART_RUNTIME_DEBUGGER_H_ diff --git a/runtime/dex_file-inl.h b/runtime/dex_file-inl.h index 5d8216eda5..dee80269d6 100644 --- a/runtime/dex_file-inl.h +++ b/runtime/dex_file-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_INL_H_ -#define ART_SRC_DEX_FILE_INL_H_ +#ifndef ART_RUNTIME_DEX_FILE_INL_H_ +#define ART_RUNTIME_DEX_FILE_INL_H_ #include "base/logging.h" #include "dex_file.h" @@ -44,4 +44,4 @@ inline const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, u } // namespace art -#endif // ART_SRC_DEX_FILE_INL_H_ +#endif // ART_RUNTIME_DEX_FILE_INL_H_ diff --git a/runtime/dex_file.h b/runtime/dex_file.h index e09270e018..28e06cc5b9 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_H_ -#define ART_SRC_DEX_FILE_H_ +#ifndef ART_RUNTIME_DEX_FILE_H_ +#define ART_RUNTIME_DEX_FILE_H_ #include #include @@ -1220,4 +1220,4 @@ class CatchHandlerIterator { } // namespace art -#endif // ART_SRC_DEX_FILE_H_ +#endif // ART_RUNTIME_DEX_FILE_H_ diff --git a/runtime/dex_file_verifier.h b/runtime/dex_file_verifier.h index 5538d4aa75..3797dc77e5 100644 --- a/runtime/dex_file_verifier.h +++ b/runtime/dex_file_verifier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_VERIFIER_H_ -#define ART_SRC_DEX_FILE_VERIFIER_H_ +#ifndef ART_RUNTIME_DEX_FILE_VERIFIER_H_ +#define ART_RUNTIME_DEX_FILE_VERIFIER_H_ #include "dex_file.h" #include "safe_map.h" @@ -94,4 +94,4 @@ class DexFileVerifier { } // namespace art -#endif // ART_SRC_DEX_FILE_VERIFIER_H_ +#endif // ART_RUNTIME_DEX_FILE_VERIFIER_H_ diff --git a/runtime/dex_instruction-inl.h b/runtime/dex_instruction-inl.h index b426e66a1c..2cb5235417 100644 --- a/runtime/dex_instruction-inl.h +++ b/runtime/dex_instruction-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_INL_H_ -#define ART_SRC_DEX_INSTRUCTION_INL_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_INL_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_INL_H_ #include "dex_instruction.h" @@ -319,4 +319,4 @@ inline void Instruction::GetArgs(uint32_t arg[5]) const { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_INL_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_INL_H_ diff --git a/runtime/dex_instruction.h b/runtime/dex_instruction.h index 0407c57935..d2ad989395 100644 --- a/runtime/dex_instruction.h +++ b/runtime/dex_instruction.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_H_ -#define ART_SRC_DEX_INSTRUCTION_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_H_ #include "base/logging.h" #include "base/macros.h" @@ -443,4 +443,4 @@ struct DecodedInstruction { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_H_ diff --git a/runtime/dex_instruction_list.h b/runtime/dex_instruction_list.h index 8257c783e7..31d51c9b41 100644 --- a/runtime/dex_instruction_list.h +++ b/runtime/dex_instruction_list.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ + #define DEX_INSTRUCTION_LIST(V) \ V(0x00, NOP, "nop", k10x, false, kNone, kContinue, kVerifyNone) \ V(0x01, MOVE, "move", k12x, true, kNone, kContinue, kVerifyRegA | kVerifyRegB) \ @@ -297,3 +300,6 @@ V(k35c) \ V(k3rc) \ V(k51l) + +#endif // ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ +#undef ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ // the guard in this file is just for cpplint diff --git a/runtime/dex_instruction_visitor.h b/runtime/dex_instruction_visitor.h index ff4620f8f0..795b95bf76 100644 --- a/runtime/dex_instruction_visitor.h +++ b/runtime/dex_instruction_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_VISITOR_H_ -#define ART_SRC_DEX_INSTRUCTION_VISITOR_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ #include "base/macros.h" #include "dex_instruction.h" @@ -69,4 +69,4 @@ class DexInstructionVisitor { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_VISITOR_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ diff --git a/runtime/dex_method_iterator.h b/runtime/dex_method_iterator.h index dc2e712681..cb71cb5b11 100644 --- a/runtime/dex_method_iterator.h +++ b/runtime/dex_method_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_METHOD_ITERATOR_H_ -#define ART_SRC_DEX_METHOD_ITERATOR_H_ +#ifndef ART_RUNTIME_DEX_METHOD_ITERATOR_H_ +#define ART_RUNTIME_DEX_METHOD_ITERATOR_H_ #include @@ -147,4 +147,4 @@ class DexMethodIterator { } // namespace art -#endif // ART_SRC_DEX_METHOD_ITERATOR_H_ +#endif // ART_RUNTIME_DEX_METHOD_ITERATOR_H_ diff --git a/runtime/disassembler.h b/runtime/disassembler.h index 1f50bfc9c0..805ff4d079 100644 --- a/runtime/disassembler.h +++ b/runtime/disassembler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_H_ -#define ART_SRC_DISASSEMBLER_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_H_ +#define ART_RUNTIME_DISASSEMBLER_H_ #include @@ -45,4 +45,4 @@ class Disassembler { } // namespace art -#endif // ART_SRC_DISASSEMBLER_H_ +#endif // ART_RUNTIME_DISASSEMBLER_H_ diff --git a/runtime/disassembler_arm.h b/runtime/disassembler_arm.h index 103876f33b..cab9150108 100644 --- a/runtime/disassembler_arm.h +++ b/runtime/disassembler_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_ARM_H_ -#define ART_SRC_DISASSEMBLER_ARM_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_ARM_H_ +#define ART_RUNTIME_DISASSEMBLER_ARM_H_ #include @@ -48,4 +48,4 @@ class DisassemblerArm : public Disassembler { } // namespace arm } // namespace art -#endif // ART_SRC_DISASSEMBLER_ARM_H_ +#endif // ART_RUNTIME_DISASSEMBLER_ARM_H_ diff --git a/runtime/disassembler_mips.h b/runtime/disassembler_mips.h index ed45113db7..e248503963 100644 --- a/runtime/disassembler_mips.h +++ b/runtime/disassembler_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_MIPS_H_ -#define ART_SRC_DISASSEMBLER_MIPS_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_MIPS_H_ +#define ART_RUNTIME_DISASSEMBLER_MIPS_H_ #include @@ -37,4 +37,4 @@ class DisassemblerMips : public Disassembler { } // namespace mips } // namespace art -#endif // ART_SRC_DISASSEMBLER_MIPS_H_ +#endif // ART_RUNTIME_DISASSEMBLER_MIPS_H_ diff --git a/runtime/disassembler_x86.h b/runtime/disassembler_x86.h index 13f8503720..ff4322c8b8 100644 --- a/runtime/disassembler_x86.h +++ b/runtime/disassembler_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_X86_H_ -#define ART_SRC_DISASSEMBLER_X86_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_X86_H_ +#define ART_RUNTIME_DISASSEMBLER_X86_H_ #include "disassembler.h" @@ -35,4 +35,4 @@ class DisassemblerX86 : public Disassembler { } // namespace x86 } // namespace art -#endif // ART_SRC_DISASSEMBLER_X86_H_ +#endif // ART_RUNTIME_DISASSEMBLER_X86_H_ diff --git a/runtime/elf_file.h b/runtime/elf_file.h index cb95cb0df0..33b5fc3f9b 100644 --- a/runtime/elf_file.h +++ b/runtime/elf_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_FILE_H_ -#define ART_SRC_ELF_FILE_H_ +#ifndef ART_RUNTIME_ELF_FILE_H_ +#define ART_RUNTIME_ELF_FILE_H_ #include #include @@ -172,4 +172,4 @@ class ElfFile { } // namespace art -#endif // ART_SRC_ELF_FILE_H_ +#endif // ART_RUNTIME_ELF_FILE_H_ diff --git a/runtime/file_output_stream.h b/runtime/file_output_stream.h index b5eb4f8194..10405eff1f 100644 --- a/runtime/file_output_stream.h +++ b/runtime/file_output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_FILE_OUTPUT_STREAM_H_ -#define ART_SRC_FILE_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_FILE_OUTPUT_STREAM_H_ +#define ART_RUNTIME_FILE_OUTPUT_STREAM_H_ #include "output_stream.h" @@ -41,4 +41,4 @@ class FileOutputStream : public OutputStream { } // namespace art -#endif // ART_SRC_FILE_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_FILE_OUTPUT_STREAM_H_ diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h index 4e1c253bdf..5310c18ec6 100644 --- a/runtime/gc/accounting/atomic_stack.h +++ b/runtime/gc/accounting/atomic_stack.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ -#define ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ +#define ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ #include @@ -189,4 +189,4 @@ typedef AtomicStack ObjectStack; } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h index 1e7529084a..f8f2773582 100644 --- a/runtime/gc/accounting/card_table-inl.h +++ b/runtime/gc/accounting/card_table-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_CARDTABLE_INL_H_ -#define ART_SRC_GC_CARDTABLE_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ #include "base/logging.h" #include "card_table.h" @@ -210,4 +210,4 @@ inline void CardTable::CheckCardValid(byte* card) const { } // namespace gc } // namespace art -#endif // ART_SRC_GC_CARDTABLE_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h index cf85d15448..1acaf5bdfc 100644 --- a/runtime/gc/accounting/card_table.h +++ b/runtime/gc/accounting/card_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_CARDTABLE_H_ -#define ART_SRC_GC_CARDTABLE_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ +#define ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ #include "globals.h" #include "locks.h" @@ -153,4 +153,4 @@ class CardTable { } // namespace gc } // namespace art -#endif // ART_SRC_GC_CARDTABLE_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ diff --git a/runtime/gc/accounting/heap_bitmap-inl.h b/runtime/gc/accounting/heap_bitmap-inl.h index 8e3123b974..76226041d1 100644 --- a/runtime/gc/accounting/heap_bitmap-inl.h +++ b/runtime/gc/accounting/heap_bitmap-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ -#define ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ #include "heap_bitmap.h" @@ -47,4 +47,4 @@ inline void HeapBitmap::Visit(const Visitor& visitor) { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ diff --git a/runtime/gc/accounting/heap_bitmap.h b/runtime/gc/accounting/heap_bitmap.h index 5ff40c6426..a12809ea55 100644 --- a/runtime/gc/accounting/heap_bitmap.h +++ b/runtime/gc/accounting/heap_bitmap.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ -#define ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ +#define ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ #include "base/logging.h" #include "locks.h" @@ -126,4 +126,4 @@ class HeapBitmap { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ diff --git a/runtime/gc/accounting/mod_union_table-inl.h b/runtime/gc/accounting/mod_union_table-inl.h index 656af94853..32ac95f9f8 100644 --- a/runtime/gc/accounting/mod_union_table-inl.h +++ b/runtime/gc/accounting/mod_union_table-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MOD_UNION_TABLE_INL_H_ -#define ART_SRC_GC_MOD_UNION_TABLE_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ #include "mod_union_table.h" @@ -72,4 +72,4 @@ class ModUnionTableToAllocspace : public ModUnionTableReferenceCache { } // namespace gc } // namespace art -#endif // ART_SRC_GC_MOD_UNION_TABLE_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ diff --git a/runtime/gc/accounting/mod_union_table.h b/runtime/gc/accounting/mod_union_table.h index 5d25e05658..543562563b 100644 --- a/runtime/gc/accounting/mod_union_table.h +++ b/runtime/gc/accounting/mod_union_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ -#define ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#define ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ #include "globals.h" #include "safe_map.h" @@ -150,4 +150,4 @@ class ModUnionTableCardCache : public ModUnionTable { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ diff --git a/runtime/gc/accounting/space_bitmap-inl.h b/runtime/gc/accounting/space_bitmap-inl.h index a4fd330c8f..d074a0f578 100644 --- a/runtime/gc/accounting/space_bitmap-inl.h +++ b/runtime/gc/accounting/space_bitmap-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ -#define ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ #include "base/logging.h" #include "cutils/atomic-inline.h" @@ -144,4 +144,4 @@ inline bool SpaceBitmap::Modify(const mirror::Object* obj, bool do_set) { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h index bb487d88d0..32ab440f31 100644 --- a/runtime/gc/accounting/space_bitmap.h +++ b/runtime/gc/accounting/space_bitmap.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ -#define ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ +#define ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ #include "locks.h" #include "globals.h" @@ -262,4 +262,4 @@ std::ostream& operator << (std::ostream& stream, const SpaceBitmap& bitmap); } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ diff --git a/runtime/gc/allocator/dlmalloc.h b/runtime/gc/allocator/dlmalloc.h index 6b02a44ffe..07ebd1c0e3 100644 --- a/runtime/gc/allocator/dlmalloc.h +++ b/runtime/gc/allocator/dlmalloc.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ -#define ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ +#ifndef ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ +#define ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ // Configure dlmalloc for mspaces. #define HAVE_MMAP 0 @@ -37,4 +37,4 @@ extern "C" int dlmalloc_trim(size_t); // pages back to the kernel. extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_bytes, void* /*arg*/); -#endif // ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ +#endif // ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ diff --git a/runtime/gc/collector/garbage_collector.h b/runtime/gc/collector/garbage_collector.h index 1ab395775b..a22faac43b 100644 --- a/runtime/gc/collector/garbage_collector.h +++ b/runtime/gc/collector/garbage_collector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_GARBAGE_COLLECTOR_H_ -#define ART_SRC_GC_GARBAGE_COLLECTOR_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ +#define ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ #include "gc_type.h" #include "locks.h" @@ -119,4 +119,4 @@ class GarbageCollector { } // namespace gc } // namespace art -#endif // ART_SRC_GC_GARBAGE_COLLECTOR_H_ +#endif // ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ diff --git a/runtime/gc/collector/gc_type.h b/runtime/gc/collector/gc_type.h index bb25bb93f9..f18e40fa74 100644 --- a/runtime/gc/collector/gc_type.h +++ b/runtime/gc/collector/gc_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_COLLECTOR_GC_TYPE_H_ -#define ART_SRC_GC_COLLECTOR_GC_TYPE_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ +#define ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ #include @@ -43,4 +43,4 @@ std::ostream& operator<<(std::ostream& os, const GcType& policy); } // namespace gc } // namespace art -#endif // ART_SRC_GC_COLLECTOR_GC_TYPE_H_ +#endif // ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ diff --git a/runtime/gc/collector/mark_sweep-inl.h b/runtime/gc/collector/mark_sweep-inl.h index ea9fced84a..6b1b617eb4 100644 --- a/runtime/gc/collector/mark_sweep-inl.h +++ b/runtime/gc/collector/mark_sweep-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MARK_SWEEP_INL_H_ -#define ART_SRC_GC_MARK_SWEEP_INL_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_ +#define ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_ #include "gc/collector/mark_sweep.h" @@ -162,4 +162,4 @@ inline void MarkSweep::VisitObjectArrayReferences(const mirror::ObjectArray #include @@ -609,4 +609,4 @@ class Heap { } // namespace gc } // namespace art -#endif // ART_SRC_GC_HEAP_H_ +#endif // ART_RUNTIME_GC_HEAP_H_ diff --git a/runtime/gc/space/dlmalloc_space.h b/runtime/gc/space/dlmalloc_space.h index 00df0e6d42..8a4314c716 100644 --- a/runtime/gc/space/dlmalloc_space.h +++ b/runtime/gc/space/dlmalloc_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ -#define ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ #include "gc/allocator/dlmalloc.h" #include "space.h" @@ -182,4 +182,4 @@ class DlMallocSpace : public MemMapSpace, public AllocSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h index 833fb8d73a..fde2b419ac 100644 --- a/runtime/gc/space/image_space.h +++ b/runtime/gc/space/image_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_IMAGE_SPACE_H_ -#define ART_SRC_GC_SPACE_IMAGE_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ #include "space.h" @@ -115,4 +115,4 @@ class ImageSpace : public MemMapSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_IMAGE_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ diff --git a/runtime/gc/space/large_object_space.h b/runtime/gc/space/large_object_space.h index 197fad3854..74d9cca6db 100644 --- a/runtime/gc/space/large_object_space.h +++ b/runtime/gc/space/large_object_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ -#define ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ #include "dlmalloc_space.h" @@ -190,4 +190,4 @@ class FreeListSpace : public LargeObjectSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ diff --git a/runtime/gc/space/space-inl.h b/runtime/gc/space/space-inl.h index 54bf604822..2c3b93c60d 100644 --- a/runtime/gc/space/space-inl.h +++ b/runtime/gc/space/space-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_SPACE_INL_H_ -#define ART_SRC_GC_SPACE_SPACE_INL_H_ +#ifndef ART_RUNTIME_GC_SPACE_SPACE_INL_H_ +#define ART_RUNTIME_GC_SPACE_SPACE_INL_H_ #include "space.h" @@ -45,4 +45,4 @@ inline LargeObjectSpace* Space::AsLargeObjectSpace() { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_SPACE_INL_H_ +#endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_ diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h index ca01c55497..48f0579d83 100644 --- a/runtime/gc/space/space.h +++ b/runtime/gc/space/space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_SPACE_H_ -#define ART_SRC_GC_SPACE_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_SPACE_H_ #include @@ -292,4 +292,4 @@ class MemMapSpace : public ContinuousSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_SPACE_H_ diff --git a/runtime/gc_map.h b/runtime/gc_map.h index 473b39a629..33d09f29f6 100644 --- a/runtime/gc_map.h +++ b/runtime/gc_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MAP_H_ -#define ART_SRC_GC_MAP_H_ +#ifndef ART_RUNTIME_GC_MAP_H_ +#define ART_RUNTIME_GC_MAP_H_ #include @@ -108,4 +108,4 @@ class NativePcOffsetToReferenceMap { } // namespace art -#endif // ART_SRC_GC_MAP_H_ +#endif // ART_RUNTIME_GC_MAP_H_ diff --git a/runtime/globals.h b/runtime/globals.h index dc9341ae0f..c3974943cd 100644 --- a/runtime/globals.h +++ b/runtime/globals.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GLOBALS_H_ -#define ART_SRC_GLOBALS_H_ +#ifndef ART_RUNTIME_GLOBALS_H_ +#define ART_RUNTIME_GLOBALS_H_ #include #include @@ -75,4 +75,4 @@ const bool kIsTargetBuild = false; } // namespace art -#endif // ART_SRC_GLOBALS_H_ +#endif // ART_RUNTIME_GLOBALS_H_ diff --git a/runtime/hprof/hprof.h b/runtime/hprof/hprof.h index c6222dcb90..91684648a5 100644 --- a/runtime/hprof/hprof.h +++ b/runtime/hprof/hprof.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef HPROF_HPROF_H_ -#define HPROF_HPROF_H_ +#ifndef ART_RUNTIME_HPROF_HPROF_H_ +#define ART_RUNTIME_HPROF_HPROF_H_ namespace art { @@ -27,4 +27,4 @@ void DumpHeap(const char* filename, int fd, bool direct_to_ddms); } // namespace art -#endif // HPROF_HPROF_H_ +#endif // ART_RUNTIME_HPROF_HPROF_H_ diff --git a/runtime/image.h b/runtime/image.h index f14d7d190a..35e4c5cabd 100644 --- a/runtime/image.h +++ b/runtime/image.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_IMAGE_H_ -#define ART_SRC_IMAGE_H_ +#ifndef ART_RUNTIME_IMAGE_H_ +#define ART_RUNTIME_IMAGE_H_ #include @@ -131,4 +131,4 @@ class PACKED(4) ImageHeader { } // namespace art -#endif // ART_SRC_IMAGE_H_ +#endif // ART_RUNTIME_IMAGE_H_ diff --git a/runtime/indenter.h b/runtime/indenter.h index 4ac0c01163..c432e1ba8d 100644 --- a/runtime/indenter.h +++ b/runtime/indenter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INDENTER_H_ -#define ART_SRC_INDENTER_H_ +#ifndef ART_RUNTIME_INDENTER_H_ +#define ART_RUNTIME_INDENTER_H_ #include "base/macros.h" #include @@ -60,4 +60,4 @@ class Indenter : public std::streambuf { DISALLOW_COPY_AND_ASSIGN(Indenter); }; -#endif // ART_SRC_INDENTER_H_ +#endif // ART_RUNTIME_INDENTER_H_ diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h index e09043dba7..34b0f3abe2 100644 --- a/runtime/indirect_reference_table.h +++ b/runtime/indirect_reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INDIRECT_REFERENCE_TABLE_H_ -#define ART_SRC_INDIRECT_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ +#define ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ #include @@ -378,4 +378,4 @@ class IndirectReferenceTable { } // namespace art -#endif // ART_SRC_INDIRECT_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ diff --git a/runtime/instruction_set.h b/runtime/instruction_set.h index c4dae4dcb6..2217f7f76e 100644 --- a/runtime/instruction_set.h +++ b/runtime/instruction_set.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INSTRUCTION_SET_H_ -#define ART_SRC_INSTRUCTION_SET_H_ +#ifndef ART_RUNTIME_INSTRUCTION_SET_H_ +#define ART_RUNTIME_INSTRUCTION_SET_H_ #include @@ -33,4 +33,4 @@ std::ostream& operator<<(std::ostream& os, const InstructionSet& rhs); } // namespace art -#endif // ART_SRC_INSTRUCTION_SET_H_ +#endif // ART_RUNTIME_INSTRUCTION_SET_H_ diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 5fea34f388..e0f1fa978b 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INSTRUMENTATION_H_ -#define ART_SRC_INSTRUMENTATION_H_ +#ifndef ART_RUNTIME_INSTRUMENTATION_H_ +#define ART_RUNTIME_INSTRUMENTATION_H_ #include "base/macros.h" #include "locks.h" @@ -290,4 +290,4 @@ struct InstrumentationStackFrame { } // namespace instrumentation } // namespace art -#endif // ART_SRC_INSTRUMENTATION_H_ +#endif // ART_RUNTIME_INSTRUMENTATION_H_ diff --git a/runtime/intern_table.h b/runtime/intern_table.h index 1ff4f6d3c6..5031ce3c5a 100644 --- a/runtime/intern_table.h +++ b/runtime/intern_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INTERN_TABLE_H_ -#define ART_SRC_INTERN_TABLE_H_ +#ifndef ART_RUNTIME_INTERN_TABLE_H_ +#define ART_RUNTIME_INTERN_TABLE_H_ #include "base/mutex.h" #include "root_visitor.h" @@ -95,4 +95,4 @@ class InternTable { } // namespace art -#endif // ART_SRC_CLASS_LINKER_H_ +#endif // ART_RUNTIME_INTERN_TABLE_H_ diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index 20166ac545..17884b9a63 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INTERPRETER_INTERPRETER_H_ -#define ART_SRC_INTERPRETER_INTERPRETER_H_ +#ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_H_ +#define ART_RUNTIME_INTERPRETER_INTERPRETER_H_ #include "dex_file.h" #include "locks.h" @@ -55,4 +55,4 @@ extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, } // namespace interpreter } // namespace art -#endif // ART_SRC_INTERPRETER_INTERPRETER_H_ +#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_H_ diff --git a/runtime/invoke_arg_array_builder.h b/runtime/invoke_arg_array_builder.h index b57d60a70f..c1d8249fd3 100644 --- a/runtime/invoke_arg_array_builder.h +++ b/runtime/invoke_arg_array_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ -#define ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ +#ifndef ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ +#define ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ #include "mirror/object.h" #include "scoped_thread_state_change.h" @@ -180,4 +180,4 @@ class ArgArray { } // namespace art -#endif // ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ +#endif // ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ diff --git a/runtime/invoke_type.h b/runtime/invoke_type.h index d724fdb9c1..cdf9be87d9 100644 --- a/runtime/invoke_type.h +++ b/runtime/invoke_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INVOKE_TYPE_H_ -#define ART_SRC_INVOKE_TYPE_H_ +#ifndef ART_RUNTIME_INVOKE_TYPE_H_ +#define ART_RUNTIME_INVOKE_TYPE_H_ #include @@ -34,4 +34,4 @@ std::ostream& operator<<(std::ostream& os, const InvokeType& rhs); } // namespace art -#endif // ART_SRC_INVOKE_TYPE_H_ +#endif // ART_RUNTIME_INVOKE_TYPE_H_ diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index 436525c3d0..6a5d0d19fb 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_JDWP_JDWP_H_ -#define ART_JDWP_JDWP_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_H_ +#define ART_RUNTIME_JDWP_JDWP_H_ #include "base/mutex.h" #include "jdwp/jdwp_bits.h" @@ -429,4 +429,4 @@ class Request { } // namespace art -#endif // ART_JDWP_JDWP_H_ +#endif // ART_RUNTIME_JDWP_JDWP_H_ diff --git a/runtime/jdwp/jdwp_bits.h b/runtime/jdwp/jdwp_bits.h index 2a3c775164..9f80cbe307 100644 --- a/runtime/jdwp/jdwp_bits.h +++ b/runtime/jdwp/jdwp_bits.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_JDWP_BITS_H_ -#define ART_JDWP_BITS_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_BITS_H_ +#define ART_RUNTIME_JDWP_JDWP_BITS_H_ #include #include @@ -121,4 +121,4 @@ static inline void Write8BE(uint8_t** dst, uint64_t value) { } // namespace art -#endif // ART_JDWP_BITS_H_ +#endif // ART_RUNTIME_JDWP_JDWP_BITS_H_ diff --git a/runtime/jdwp/jdwp_constants.h b/runtime/jdwp/jdwp_constants.h index ebc575b6b6..a8db325c66 100644 --- a/runtime/jdwp/jdwp_constants.h +++ b/runtime/jdwp/jdwp_constants.h @@ -16,8 +16,8 @@ /* * These come out of the JDWP documentation. */ -#ifndef ART_JDWP_JDWPCONSTANTS_H_ -#define ART_JDWP_JDWPCONSTANTS_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ +#define ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ #include @@ -246,4 +246,4 @@ std::ostream& operator<<(std::ostream& os, const JdwpTag& value); } // namespace art -#endif // ART_JDWP_JDWPCONSTANTS_H_ +#endif // ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ diff --git a/runtime/jdwp/jdwp_event.h b/runtime/jdwp/jdwp_event.h index a6eabb1371..d269761999 100644 --- a/runtime/jdwp/jdwp_event.h +++ b/runtime/jdwp/jdwp_event.h @@ -16,8 +16,8 @@ /* * Handle registration of events, and debugger event notification. */ -#ifndef ART_JDWP_JDWPEVENT_H_ -#define ART_JDWP_JDWPEVENT_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_EVENT_H_ +#define ART_RUNTIME_JDWP_JDWP_EVENT_H_ #include "jdwp/jdwp.h" #include "jdwp/jdwp_constants.h" @@ -110,4 +110,4 @@ void EventFree(JdwpEvent* pEvent); } // namespace art -#endif // ART_JDWP_JDWPEVENT_H_ +#endif // ART_RUNTIME_JDWP_JDWP_EVENT_H_ diff --git a/runtime/jdwp/jdwp_expand_buf.h b/runtime/jdwp/jdwp_expand_buf.h index 820f62d6a0..81e01e2100 100644 --- a/runtime/jdwp/jdwp_expand_buf.h +++ b/runtime/jdwp/jdwp_expand_buf.h @@ -16,8 +16,8 @@ /* * Expanding byte buffer, with primitives for appending basic data types. */ -#ifndef ART_JDWP_EXPANDBUF_H_ -#define ART_JDWP_EXPANDBUF_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ +#define ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ #include @@ -67,4 +67,4 @@ void expandBufAddLocation(ExpandBuf* pReply, const JdwpLocation& location); } // namespace art -#endif // ART_JDWP_EXPANDBUF_H_ +#endif // ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ diff --git a/runtime/jdwp/jdwp_priv.h b/runtime/jdwp/jdwp_priv.h index c8a7b2686d..ab89339347 100644 --- a/runtime/jdwp/jdwp_priv.h +++ b/runtime/jdwp/jdwp_priv.h @@ -16,8 +16,8 @@ /* * JDWP internal interfaces. */ -#ifndef ART_JDWP_JDWPPRIV_H_ -#define ART_JDWP_JDWPPRIV_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_PRIV_H_ +#define ART_RUNTIME_JDWP_JDWP_PRIV_H_ #include "debugger.h" #include "jdwp/jdwp.h" @@ -101,4 +101,4 @@ class JdwpNetStateBase { } // namespace art -#endif // ART_JDWP_JDWPPRIV_H_ +#endif // ART_RUNTIME_JDWP_JDWP_PRIV_H_ diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h index d0ea59da71..345f0ad73a 100644 --- a/runtime/jdwp/object_registry.h +++ b/runtime/jdwp/object_registry.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ +#define ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ + #include #include @@ -98,3 +101,5 @@ class ObjectRegistry { }; } // namespace art + +#endif // ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index 7b43f95cb3..ad66ada329 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JNI_INTERNAL_H_ -#define ART_SRC_JNI_INTERNAL_H_ +#ifndef ART_RUNTIME_JNI_INTERNAL_H_ +#define ART_RUNTIME_JNI_INTERNAL_H_ #include "jni.h" @@ -198,4 +198,4 @@ class ScopedJniEnvLocalRefState { std::ostream& operator<<(std::ostream& os, const jobjectRefType& rhs); -#endif // ART_SRC_JNI_INTERNAL_H_ +#endif // ART_RUNTIME_JNI_INTERNAL_H_ diff --git a/runtime/jobject_comparator.h b/runtime/jobject_comparator.h index 17098aaebb..698d6678d6 100644 --- a/runtime/jobject_comparator.h +++ b/runtime/jobject_comparator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JOBJECT_COMPARATOR_H_ -#define ART_SRC_JOBJECT_COMPARATOR_H_ +#ifndef ART_RUNTIME_JOBJECT_COMPARATOR_H_ +#define ART_RUNTIME_JOBJECT_COMPARATOR_H_ #include @@ -27,4 +27,4 @@ struct JobjectComparator { } // namespace art -#endif // ART_SRC_JOBJECT_COMPARATOR_H_ +#endif // ART_RUNTIME_JOBJECT_COMPARATOR_H_ diff --git a/runtime/jvalue.h b/runtime/jvalue.h index 66cd93e2c0..0c1aadb462 100644 --- a/runtime/jvalue.h +++ b/runtime/jvalue.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JVALUE_H_ -#define ART_SRC_JVALUE_H_ +#ifndef ART_RUNTIME_JVALUE_H_ +#define ART_RUNTIME_JVALUE_H_ #include "base/macros.h" @@ -75,4 +75,4 @@ union PACKED(4) JValue { } // namespace art -#endif // ART_SRC_JVALUE_H_ +#endif // ART_RUNTIME_JVALUE_H_ diff --git a/runtime/leb128.h b/runtime/leb128.h index a5a6683aee..ca955b0921 100644 --- a/runtime/leb128.h +++ b/runtime/leb128.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_LEB128_H_ -#define ART_SRC_LEB128_H_ +#ifndef ART_RUNTIME_LEB128_H_ +#define ART_RUNTIME_LEB128_H_ #include "globals.h" @@ -121,4 +121,4 @@ static inline uint8_t* WriteUnsignedLeb128(uint8_t* ptr, uint32_t data) { } // namespace art -#endif // ART_SRC_LEB128_H_ +#endif // ART_RUNTIME_LEB128_H_ diff --git a/runtime/locks.h b/runtime/locks.h index 91437e1830..6b0e96f8b9 100644 --- a/runtime/locks.h +++ b/runtime/locks.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_LOCKS_H_ -#define ART_SRC_LOCKS_H_ +#ifndef ART_RUNTIME_LOCKS_H_ +#define ART_RUNTIME_LOCKS_H_ #include @@ -165,4 +165,4 @@ class Locks { } // namespace art -#endif // ART_SRC_LOCKS_H_ +#endif // ART_RUNTIME_LOCKS_H_ diff --git a/runtime/log_severity.h b/runtime/log_severity.h index 126019bdb6..bb7679d218 100644 --- a/runtime/log_severity.h +++ b/runtime/log_severity.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef BASE_LOG_SEVERITY_H_ -#define BASE_LOG_SEVERITY_H_ +#ifndef ART_RUNTIME_LOG_SEVERITY_H_ +#define ART_RUNTIME_LOG_SEVERITY_H_ typedef int LogSeverity; const int VERBOSE = 0, DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4, FATAL = 5; const int INTERNAL_FATAL = 6; // For Runtime::Abort. -#endif // BASE_LOG_SEVERITY_H_ +#endif // ART_RUNTIME_LOG_SEVERITY_H_ diff --git a/runtime/mem_map.h b/runtime/mem_map.h index 2eb7772705..7d418a5c6a 100644 --- a/runtime/mem_map.h +++ b/runtime/mem_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MEM_MAP_H_ -#define ART_SRC_MEM_MAP_H_ +#ifndef ART_RUNTIME_MEM_MAP_H_ +#define ART_RUNTIME_MEM_MAP_H_ #include @@ -101,4 +101,4 @@ class MemMap { } // namespace art -#endif // ART_SRC_MEM_MAP_H_ +#endif // ART_RUNTIME_MEM_MAP_H_ diff --git a/runtime/memory_region.h b/runtime/memory_region.h index cfbe42dddf..849ab1c420 100644 --- a/runtime/memory_region.h +++ b/runtime/memory_region.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MEMORY_REGION_H_ -#define ART_SRC_MEMORY_REGION_H_ +#ifndef ART_RUNTIME_MEMORY_REGION_H_ +#define ART_RUNTIME_MEMORY_REGION_H_ #include @@ -96,4 +96,4 @@ class MemoryRegion { } // namespace art -#endif // ART_MEMORY_REGION_H_ +#endif // ART_RUNTIME_MEMORY_REGION_H_ diff --git a/runtime/method_reference.h b/runtime/method_reference.h index ff8bf313f0..1ff4ea0942 100644 --- a/runtime/method_reference.h +++ b/runtime/method_reference.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_METHOD_REFERENCE_H_ -#define ART_SRC_METHOD_REFERENCE_H_ +#ifndef ART_RUNTIME_METHOD_REFERENCE_H_ +#define ART_RUNTIME_METHOD_REFERENCE_H_ namespace art { @@ -44,4 +44,4 @@ struct MethodReferenceComparator { } // namespace art -#endif // ART_SRC_METHOD_REFERENCE_H_ +#endif // ART_RUNTIME_METHOD_REFERENCE_H_ diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/abstract_method-inl.h index a8238867aa..6fcd705e55 100644 --- a/runtime/mirror/abstract_method-inl.h +++ b/runtime/mirror/abstract_method-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_METHOD_INL_H_ -#define ART_SRC_MIRROR_METHOD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ +#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ #include "abstract_method.h" @@ -196,4 +196,4 @@ inline bool AbstractMethod::IsResolutionMethod() const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_METHOD_INL_H_ +#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h index 339471dd5d..d909058e0d 100644 --- a/runtime/mirror/abstract_method.h +++ b/runtime/mirror/abstract_method.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_METHOD_H_ -#define ART_SRC_MIRROR_METHOD_H_ +#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ +#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ #include "class.h" #include "dex_file.h" @@ -515,4 +515,4 @@ class MANAGED AbstractMethodClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_METHOD_H_ +#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index b7f212f50f..eb73c7dd38 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_ARRAY_INL_H_ -#define ART_SRC_MIRROR_ARRAY_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ARRAY_INL_H_ +#define ART_RUNTIME_MIRROR_ARRAY_INL_H_ #include "array.h" @@ -36,4 +36,4 @@ inline size_t Array::SizeOf() const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_ARRAY_INL_H_ +#endif // ART_RUNTIME_MIRROR_ARRAY_INL_H_ diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h index 98b8ea0008..b195a87fc0 100644 --- a/runtime/mirror/array.h +++ b/runtime/mirror/array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_ARRAY_H_ -#define ART_SRC_MIRROR_ARRAY_H_ +#ifndef ART_RUNTIME_MIRROR_ARRAY_H_ +#define ART_RUNTIME_MIRROR_ARRAY_H_ #include "object.h" @@ -145,4 +145,4 @@ class MANAGED PrimitiveArray : public Array { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_ARRAY_H_ +#endif // ART_RUNTIME_MIRROR_ARRAY_H_ diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 6819fb2954..d323c3333b 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_CLASS_INL_H_ -#define ART_SRC_MIRROR_CLASS_INL_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_INL_H_ +#define ART_RUNTIME_MIRROR_CLASS_INL_H_ #include "class.h" @@ -346,4 +346,4 @@ inline void Class::SetName(String* name) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_CLASS_INL_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_INL_H_ diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 084aa24c7c..9a506c29af 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_CLASS_H_ -#define ART_SRC_MIRROR_CLASS_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_H_ +#define ART_RUNTIME_MIRROR_CLASS_H_ #include "modifiers.h" #include "object.h" @@ -882,4 +882,4 @@ class MANAGED ClassClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_CLASS_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_H_ diff --git a/runtime/mirror/class_loader.h b/runtime/mirror/class_loader.h index 0d635f1d21..415cb67c6c 100644 --- a/runtime/mirror/class_loader.h +++ b/runtime/mirror/class_loader.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LOADER_H_ -#define ART_SRC_CLASS_LOADER_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_LOADER_H_ +#define ART_RUNTIME_MIRROR_CLASS_LOADER_H_ #include @@ -43,4 +43,4 @@ class MANAGED ClassLoader : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_CLASS_LOADER_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_LOADER_H_ diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 3b17c428a5..369dc49ed0 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_DEX_CACHE_INL_H_ -#define ART_SRC_MIRROR_DEX_CACHE_INL_H_ +#ifndef ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ +#define ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ #include "dex_cache.h" @@ -37,4 +37,4 @@ inline AbstractMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_DEX_CACHE_INL_H_ +#endif // ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 307588b581..fd3f5f44b8 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_DEX_CACHE_H_ -#define ART_SRC_MIRROR_DEX_CACHE_H_ +#ifndef ART_RUNTIME_MIRROR_DEX_CACHE_H_ +#define ART_RUNTIME_MIRROR_DEX_CACHE_H_ #include "abstract_method.h" #include "class.h" @@ -179,4 +179,4 @@ class MANAGED DexCache : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_DEX_CACHE_H_ +#endif // ART_RUNTIME_MIRROR_DEX_CACHE_H_ diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h index be5dcab03d..3e3d6db4a6 100644 --- a/runtime/mirror/field-inl.h +++ b/runtime/mirror/field-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_FIELD_INL_H_ -#define ART_SRC_MIRROR_FIELD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_FIELD_INL_H_ +#define ART_RUNTIME_MIRROR_FIELD_INL_H_ #include "field.h" @@ -218,4 +218,4 @@ inline void Field::SetObject(Object* object, const Object* l) const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_FIELD_INL_H_ +#endif // ART_RUNTIME_MIRROR_FIELD_INL_H_ diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h index 4e7abe8550..6e508a362f 100644 --- a/runtime/mirror/field.h +++ b/runtime/mirror/field.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_FIELD_H_ -#define ART_SRC_MIRROR_FIELD_H_ +#ifndef ART_RUNTIME_MIRROR_FIELD_H_ +#define ART_RUNTIME_MIRROR_FIELD_H_ #include "class.h" #include "modifiers.h" @@ -165,4 +165,4 @@ class MANAGED FieldClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_FIELD_H_ +#endif // ART_RUNTIME_MIRROR_FIELD_H_ diff --git a/runtime/mirror/iftable-inl.h b/runtime/mirror/iftable-inl.h index 72803b8002..9d5fa7475a 100644 --- a/runtime/mirror/iftable-inl.h +++ b/runtime/mirror/iftable-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_IFTABLE_INL_H_ -#define ART_SRC_MIRROR_IFTABLE_INL_H_ +#ifndef ART_RUNTIME_MIRROR_IFTABLE_INL_H_ +#define ART_RUNTIME_MIRROR_IFTABLE_INL_H_ #include "iftable.h" @@ -32,4 +32,4 @@ inline void IfTable::SetInterface(int32_t i, Class* interface) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_IFTABLE_INL_H_ +#endif // ART_RUNTIME_MIRROR_IFTABLE_INL_H_ diff --git a/runtime/mirror/iftable.h b/runtime/mirror/iftable.h index ffb2e51582..aea8fddafe 100644 --- a/runtime/mirror/iftable.h +++ b/runtime/mirror/iftable.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_IFTABLE_H_ -#define ART_SRC_MIRROR_IFTABLE_H_ +#ifndef ART_RUNTIME_MIRROR_IFTABLE_H_ +#define ART_RUNTIME_MIRROR_IFTABLE_H_ #include "object_array.h" @@ -76,4 +76,4 @@ class MANAGED IfTable : public ObjectArray { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_IFTABLE_H_ +#endif // ART_RUNTIME_MIRROR_IFTABLE_H_ diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 1a91dd3e6f..5818a800bf 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_INL_H_ -#define ART_SRC_MIRROR_OBJECT_INL_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_INL_H_ +#define ART_RUNTIME_MIRROR_OBJECT_INL_H_ #include "object.h" @@ -272,4 +272,4 @@ inline void Object::VerifyObject(const Object* obj) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_INL_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_INL_H_ diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index 71b628db52..a40c906eb0 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_H_ -#define ART_SRC_MIRROR_OBJECT_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_H_ +#define ART_RUNTIME_MIRROR_OBJECT_H_ #include "base/casts.h" #include "base/logging.h" @@ -260,4 +260,4 @@ class MANAGED Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_H_ diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index b130dac514..8675c31b37 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_ARRAY_INL_H_ -#define ART_SRC_MIRROR_OBJECT_ARRAY_INL_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ +#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ #include "object_array.h" @@ -142,4 +142,4 @@ inline ObjectArray* ObjectArray::CopyOf(Thread* self, int32_t new_length) } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJET_ARRAY_INL_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ diff --git a/runtime/mirror/object_array.h b/runtime/mirror/object_array.h index 08a8d62567..09ff5193ae 100644 --- a/runtime/mirror/object_array.h +++ b/runtime/mirror/object_array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_ARRAY_H_ -#define ART_SRC_MIRROR_OBJECT_ARRAY_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ +#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ #include "array.h" @@ -61,4 +61,4 @@ class MANAGED ObjectArray : public Array { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_ARRAY_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ diff --git a/runtime/mirror/proxy.h b/runtime/mirror/proxy.h index cac028a731..7c5bc39429 100644 --- a/runtime/mirror/proxy.h +++ b/runtime/mirror/proxy.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_PROXY_H_ -#define ART_SRC_MIRROR_PROXY_H_ +#ifndef ART_RUNTIME_MIRROR_PROXY_H_ +#define ART_RUNTIME_MIRROR_PROXY_H_ #include "mirror/object.h" @@ -52,4 +52,4 @@ class MANAGED Proxy : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_PROXY_H_ +#endif // ART_RUNTIME_MIRROR_PROXY_H_ diff --git a/runtime/mirror/stack_trace_element.h b/runtime/mirror/stack_trace_element.h index d53c8602dc..a9751f9988 100644 --- a/runtime/mirror/stack_trace_element.h +++ b/runtime/mirror/stack_trace_element.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ -#define ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ +#ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ +#define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ #include "object.h" @@ -80,4 +80,4 @@ class MANAGED StackTraceElement : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ +#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index 8109dcb9a9..bf545eaefb 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_STRING_H_ -#define ART_SRC_MIRROR_STRING_H_ +#ifndef ART_RUNTIME_MIRROR_STRING_H_ +#define ART_RUNTIME_MIRROR_STRING_H_ #include "class.h" #include "gtest/gtest.h" @@ -164,4 +164,4 @@ class MANAGED StringClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_STRING_H_ +#endif // ART_RUNTIME_MIRROR_STRING_H_ diff --git a/runtime/mirror/throwable.h b/runtime/mirror/throwable.h index aafcc07d86..909228e4d9 100644 --- a/runtime/mirror/throwable.h +++ b/runtime/mirror/throwable.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_THROWABLE_H_ -#define ART_SRC_MIRROR_THROWABLE_H_ +#ifndef ART_RUNTIME_MIRROR_THROWABLE_H_ +#define ART_RUNTIME_MIRROR_THROWABLE_H_ #include "object.h" #include "string.h" @@ -72,4 +72,4 @@ class MANAGED Throwable : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_THROWABLE_H_ +#endif // ART_RUNTIME_MIRROR_THROWABLE_H_ diff --git a/runtime/modifiers.h b/runtime/modifiers.h index 85bc06da65..9b61ee0cf0 100644 --- a/runtime/modifiers.h +++ b/runtime/modifiers.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MODIFIERS_H_ -#define ART_SRC_MODIFIERS_H_ +#ifndef ART_RUNTIME_MODIFIERS_H_ +#define ART_RUNTIME_MODIFIERS_H_ #include @@ -63,5 +63,5 @@ static const uint32_t kAccReferenceFlagsMask = (kAccClassIsReference | kAccClassIsFinalizerReference | kAccClassIsPhantomReference); -#endif // ART_SRC_MODIFIERS_H_ +#endif // ART_RUNTIME_MODIFIERS_H_ diff --git a/runtime/monitor.h b/runtime/monitor.h index 9194c08ab4..9206131a5b 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MONITOR_H_ -#define ART_SRC_MONITOR_H_ +#ifndef ART_RUNTIME_MONITOR_H_ +#define ART_RUNTIME_MONITOR_H_ #include #include @@ -208,4 +208,4 @@ class MonitorInfo { } // namespace art -#endif // ART_SRC_MONITOR_H_ +#endif // ART_RUNTIME_MONITOR_H_ diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index c32a46aa02..e3593d805d 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_NTH_CALLER_VISITOR_H_ -#define ART_SRC_NTH_CALLER_VISITOR_H_ +#ifndef ART_RUNTIME_NTH_CALLER_VISITOR_H_ +#define ART_RUNTIME_NTH_CALLER_VISITOR_H_ #include "mirror/abstract_method.h" #include "locks.h" @@ -58,4 +58,4 @@ struct NthCallerVisitor : public StackVisitor { } // namespace art -#endif // ART_SRC_NTH_CALLER_VISITOR_H_ +#endif // ART_RUNTIME_NTH_CALLER_VISITOR_H_ diff --git a/runtime/oat.h b/runtime/oat.h index c67a1a6630..fb28962762 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_H_ -#define ART_SRC_OAT_H_ +#ifndef ART_RUNTIME_OAT_H_ +#define ART_RUNTIME_OAT_H_ #include @@ -113,4 +113,4 @@ class PACKED(4) OatMethodOffsets { } // namespace art -#endif // ART_SRC_OAT_H_ +#endif // ART_RUNTIME_OAT_H_ diff --git a/runtime/oat/runtime/argument_visitor.h b/runtime/oat/runtime/argument_visitor.h index 4ab05b9e4d..d92ff19d13 100644 --- a/runtime/oat/runtime/argument_visitor.h +++ b/runtime/oat/runtime/argument_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ -#define ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#define ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ #include "object_utils.h" @@ -246,4 +246,4 @@ class QuickArgumentVisitor { } -#endif // ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ diff --git a/runtime/oat/runtime/arm/context_arm.h b/runtime/oat/runtime/arm/context_arm.h index ec1d4cb7f6..0be85e3577 100644 --- a/runtime/oat/runtime/arm/context_arm.h +++ b/runtime/oat/runtime/arm/context_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ -#define ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#define ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ #include "locks.h" #include "constants_arm.h" @@ -64,4 +64,4 @@ class ArmContext : public Context { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ diff --git a/runtime/oat/runtime/callee_save_frame.h b/runtime/oat/runtime/callee_save_frame.h index dd2f3fa69e..59f46acbac 100644 --- a/runtime/oat/runtime/callee_save_frame.h +++ b/runtime/oat/runtime/callee_save_frame.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ -#define ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#define ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ #include "base/mutex.h" #include "thread-inl.h" @@ -38,4 +38,4 @@ static void FinishCalleeSaveFrameSetup(Thread* self, mirror::AbstractMethod** sp } // namespace art -#endif // ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ diff --git a/runtime/oat/runtime/context.h b/runtime/oat/runtime/context.h index 895abf99ed..ac43e9a7e9 100644 --- a/runtime/oat/runtime/context.h +++ b/runtime/oat/runtime/context.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_CONTEXT_H_ -#define ART_SRC_OAT_RUNTIME_CONTEXT_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ +#define ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ #include #include @@ -67,4 +67,4 @@ class Context { } // namespace art -#endif // ART_SRC_OAT_RUNTIME_CONTEXT_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ diff --git a/runtime/oat/runtime/mips/context_mips.h b/runtime/oat/runtime/mips/context_mips.h index fc8ef9655f..f27124c79b 100644 --- a/runtime/oat/runtime/mips/context_mips.h +++ b/runtime/oat/runtime/mips/context_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ -#define ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#define ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ #include "constants_mips.h" #include "oat/runtime/context.h" @@ -61,4 +61,4 @@ class MipsContext : public Context { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ diff --git a/runtime/oat/runtime/oat_support_entrypoints.h b/runtime/oat/runtime/oat_support_entrypoints.h index c1a2587c45..546ee01c6f 100644 --- a/runtime/oat/runtime/oat_support_entrypoints.h +++ b/runtime/oat/runtime/oat_support_entrypoints.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ -#define ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#define ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ #include "dex_file-inl.h" #include "runtime.h" @@ -174,4 +174,4 @@ void ChangeDebuggerEntryPoint(EntryPoints* points, bool enabled); } // namespace art -#endif // ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ diff --git a/runtime/oat/runtime/x86/context_x86.h b/runtime/oat/runtime/x86/context_x86.h index 7928fd860f..4ecfc51b04 100644 --- a/runtime/oat/runtime/x86/context_x86.h +++ b/runtime/oat/runtime/x86/context_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ -#define ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#define ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ #include "constants_x86.h" #include "oat/runtime/context.h" @@ -64,4 +64,4 @@ class X86Context : public Context { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ diff --git a/runtime/oat/utils/arm/assembler_arm.h b/runtime/oat/utils/arm/assembler_arm.h index 06e0a55f63..b8c79d21b9 100644 --- a/runtime/oat/utils/arm/assembler_arm.h +++ b/runtime/oat/utils/arm/assembler_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ -#define ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#define ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ #include @@ -656,4 +656,4 @@ class ArmExceptionSlowPath : public SlowPath { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#endif // ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ diff --git a/runtime/oat/utils/arm/managed_register_arm.h b/runtime/oat/utils/arm/managed_register_arm.h index b069f6dedd..01596bb6b1 100644 --- a/runtime/oat/utils/arm/managed_register_arm.h +++ b/runtime/oat/utils/arm/managed_register_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ -#define ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#define ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ #include "base/logging.h" #include "constants_arm.h" @@ -271,4 +271,4 @@ inline arm::ArmManagedRegister ManagedRegister::AsArm() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#endif // ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ diff --git a/runtime/oat/utils/assembler.h b/runtime/oat/utils/assembler.h index cbf145b949..05e2732c5f 100644 --- a/runtime/oat/utils/assembler.h +++ b/runtime/oat/utils/assembler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ASSEMBLER_H_ -#define ART_SRC_OAT_UTILS_ASSEMBLER_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ +#define ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ #include @@ -456,4 +456,4 @@ class Assembler { } // namespace art -#endif // ART_SRC_OAT_UTILS_ASSEMBLER_H_ +#endif // ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ diff --git a/runtime/oat/utils/managed_register.h b/runtime/oat/utils/managed_register.h index a3d5795665..4dd2acd8fe 100644 --- a/runtime/oat/utils/managed_register.h +++ b/runtime/oat/utils/managed_register.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ -#define ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ +#define ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ namespace art { @@ -69,4 +69,4 @@ class ManagedRegister { } // namespace art -#endif // ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ +#endif // ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ diff --git a/runtime/oat/utils/mips/assembler_mips.h b/runtime/oat/utils/mips/assembler_mips.h index 02759e4efb..eeb4a57db2 100644 --- a/runtime/oat/utils/mips/assembler_mips.h +++ b/runtime/oat/utils/mips/assembler_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ -#define ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#define ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ #include @@ -510,4 +510,4 @@ class MipsExceptionSlowPath : public SlowPath { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#endif // ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ diff --git a/runtime/oat/utils/mips/managed_register_mips.h b/runtime/oat/utils/mips/managed_register_mips.h index aaaabfcc0c..b335ff9649 100644 --- a/runtime/oat/utils/mips/managed_register_mips.h +++ b/runtime/oat/utils/mips/managed_register_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ -#define ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#define ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ #include "constants_mips.h" #include "oat/utils/managed_register.h" @@ -225,4 +225,4 @@ inline mips::MipsManagedRegister ManagedRegister::AsMips() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#endif // ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ diff --git a/runtime/oat/utils/x86/assembler_x86.h b/runtime/oat/utils/x86/assembler_x86.h index dddb9b1885..390f7aa898 100644 --- a/runtime/oat/utils/x86/assembler_x86.h +++ b/runtime/oat/utils/x86/assembler_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ -#define ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#ifndef ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#define ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ #include #include "base/macros.h" @@ -652,4 +652,4 @@ class X86ExceptionSlowPath : public SlowPath { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#endif // ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ diff --git a/runtime/oat/utils/x86/managed_register_x86.h b/runtime/oat/utils/x86/managed_register_x86.h index 4481456315..b564a8396f 100644 --- a/runtime/oat/utils/x86/managed_register_x86.h +++ b/runtime/oat/utils/x86/managed_register_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ -#define ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#ifndef ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#define ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ #include "constants_x86.h" #include "oat/utils/managed_register.h" @@ -215,4 +215,4 @@ inline x86::X86ManagedRegister ManagedRegister::AsX86() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#endif // ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ diff --git a/runtime/oat_file.h b/runtime/oat_file.h index ecc8d0c965..fff6c8a1a6 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_FILE_H_ -#define ART_SRC_OAT_FILE_H_ +#ifndef ART_RUNTIME_OAT_FILE_H_ +#define ART_RUNTIME_OAT_FILE_H_ #include #include @@ -265,4 +265,4 @@ class OatFile { } // namespace art -#endif // ART_SRC_OAT_WRITER_H_ +#endif // ART_RUNTIME_OAT_FILE_H_ diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 4af5d4c30b..fa7763e11f 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OBJECT_UTILS_H_ -#define ART_SRC_OBJECT_UTILS_H_ +#ifndef ART_RUNTIME_OBJECT_UTILS_H_ +#define ART_RUNTIME_OBJECT_UTILS_H_ #include "class_linker-inl.h" #include "dex_file.h" @@ -684,4 +684,4 @@ class MethodHelper { } // namespace art -#endif // ART_SRC_OBJECT_UTILS_H_ +#endif // ART_RUNTIME_OBJECT_UTILS_H_ diff --git a/runtime/offsets.h b/runtime/offsets.h index f37dbd4413..94ae805e4a 100644 --- a/runtime/offsets.h +++ b/runtime/offsets.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OFFSETS_H_ -#define ART_SRC_OFFSETS_H_ +#ifndef ART_RUNTIME_OFFSETS_H_ +#define ART_RUNTIME_OFFSETS_H_ #include // NOLINT #include "globals.h" @@ -59,4 +59,4 @@ class MemberOffset : public Offset { } // namespace art -#endif // ART_SRC_OFFSETS_H_ +#endif // ART_RUNTIME_OFFSETS_H_ diff --git a/runtime/os.h b/runtime/os.h index 3428b6afb3..6767566673 100644 --- a/runtime/os.h +++ b/runtime/os.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OS_H_ -#define ART_SRC_OS_H_ +#ifndef ART_RUNTIME_OS_H_ +#define ART_RUNTIME_OS_H_ namespace unix_file { class FdFile; @@ -41,4 +41,4 @@ class OS { } // namespace art -#endif // ART_SRC_OS_H_ +#endif // ART_RUNTIME_OS_H_ diff --git a/runtime/output_stream.h b/runtime/output_stream.h index b03092ddf7..d2a77d898e 100644 --- a/runtime/output_stream.h +++ b/runtime/output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OUTPUT_STREAM_H_ -#define ART_SRC_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_OUTPUT_STREAM_H_ +#define ART_RUNTIME_OUTPUT_STREAM_H_ #include @@ -53,4 +53,4 @@ class OutputStream { } // namespace art -#endif // ART_SRC_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_OUTPUT_STREAM_H_ diff --git a/runtime/primitive.h b/runtime/primitive.h index eaa04cd054..5e07311073 100644 --- a/runtime/primitive.h +++ b/runtime/primitive.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_PRIMITIVE_H_ -#define ART_SRC_PRIMITIVE_H_ +#ifndef ART_RUNTIME_PRIMITIVE_H_ +#define ART_RUNTIME_PRIMITIVE_H_ #include @@ -123,4 +123,4 @@ std::ostream& operator<<(std::ostream& os, const Primitive::Type& state); } // namespace art -#endif // ART_SRC_PRIMITIVE_H_ +#endif // ART_RUNTIME_PRIMITIVE_H_ diff --git a/runtime/reference_table.h b/runtime/reference_table.h index 5abb5c7b46..4b6b50e183 100644 --- a/runtime/reference_table.h +++ b/runtime/reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_REFERENCE_TABLE_H_ -#define ART_SRC_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_REFERENCE_TABLE_H_ +#define ART_RUNTIME_REFERENCE_TABLE_H_ #include #include @@ -62,4 +62,4 @@ class ReferenceTable { } // namespace art -#endif // ART_SRC_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_REFERENCE_TABLE_H_ diff --git a/runtime/reflection.h b/runtime/reflection.h index e9f4e0893e..56ab4712db 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_REFLECTION_H_ -#define ART_SRC_REFLECTION_H_ +#ifndef ART_RUNTIME_REFLECTION_H_ +#define ART_RUNTIME_REFLECTION_H_ #include "jni.h" #include "primitive.h" @@ -56,4 +56,4 @@ bool VerifyObjectInClass(mirror::Object* o, mirror::Class* c) } // namespace art -#endif // ART_SRC_REFLECTION_H_ +#endif // ART_RUNTIME_REFLECTION_H_ diff --git a/runtime/root_visitor.h b/runtime/root_visitor.h index d53acd3621..3aa9b4bac0 100644 --- a/runtime/root_visitor.h +++ b/runtime/root_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ROOT_VISITOR_H_ -#define ART_SRC_ROOT_VISITOR_H_ +#ifndef ART_RUNTIME_ROOT_VISITOR_H_ +#define ART_RUNTIME_ROOT_VISITOR_H_ namespace art { namespace mirror { @@ -30,4 +30,4 @@ typedef bool (IsMarkedTester)(const mirror::Object* object, void* arg); } // namespace art -#endif // ART_SRC_ROOT_VISITOR_H_ +#endif // ART_RUNTIME_ROOT_VISITOR_H_ diff --git a/runtime/runtime.h b/runtime/runtime.h index 97b7c2518b..58f985fae7 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_H_ -#define ART_SRC_RUNTIME_H_ +#ifndef ART_RUNTIME_RUNTIME_H_ +#define ART_RUNTIME_RUNTIME_H_ #include #include @@ -476,4 +476,4 @@ class Runtime { } // namespace art -#endif // ART_SRC_RUNTIME_H_ +#endif // ART_RUNTIME_RUNTIME_H_ diff --git a/runtime/runtime_stats.h b/runtime/runtime_stats.h index 55e57ecc1d..05d3fbb60f 100644 --- a/runtime/runtime_stats.h +++ b/runtime/runtime_stats.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_STATS_H_ -#define ART_SRC_RUNTIME_STATS_H_ +#ifndef ART_RUNTIME_RUNTIME_STATS_H_ +#define ART_RUNTIME_RUNTIME_STATS_H_ #include @@ -111,4 +111,4 @@ struct PACKED(4) RuntimeStats { } // namespace art -#endif // ART_SRC_HEAP_H_ +#endif // ART_RUNTIME_RUNTIME_STATS_H_ diff --git a/runtime/runtime_support.h b/runtime/runtime_support.h index 0cb82a5466..051981f99e 100644 --- a/runtime/runtime_support.h +++ b/runtime/runtime_support.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_SUPPORT_H_ -#define ART_SRC_RUNTIME_SUPPORT_H_ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_H_ #include "class_linker.h" #include "common_throws.h" @@ -412,4 +412,4 @@ static inline void* GetJniDlsymLookupStub() { } // namespace art -#endif // ART_SRC_RUNTIME_SUPPORT_H_ +#endif // ART_RUNTIME_RUNTIME_SUPPORT_H_ diff --git a/runtime/runtime_support_llvm.h b/runtime/runtime_support_llvm.h index af99842089..566f7bcb16 100644 --- a/runtime/runtime_support_llvm.h +++ b/runtime/runtime_support_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ extern "C" { @@ -27,4 +27,4 @@ void* art_portable_find_runtime_support_func(void* context, const char* name); } // extern "C" -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ +#endif // ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ diff --git a/runtime/runtime_support_llvm_func_list.h b/runtime/runtime_support_llvm_func_list.h index a58b061e16..d371421a16 100644 --- a/runtime/runtime_support_llvm_func_list.h +++ b/runtime/runtime_support_llvm_func_list.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ + #define RUNTIME_SUPPORT_FUNC_LIST(V) \ V(LockObject, art_portable_lock_object_from_code) \ V(UnlockObject, art_portable_unlock_object_from_code) \ @@ -74,3 +77,6 @@ V(JniMethodEndSynchronized, art_portable_jni_method_end_synchronized) \ V(JniMethodEndWithReference, art_portable_jni_method_end_with_reference) \ V(JniMethodEndWithReferenceSynchronized, art_portable_jni_method_end_with_reference_synchronized) + +#endif // ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ +#undef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ // the guard in this file is just for cpplint diff --git a/runtime/safe_map.h b/runtime/safe_map.h index b9a6ecf5e7..dcc172de01 100644 --- a/runtime/safe_map.h +++ b/runtime/safe_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_SAFE_MAP_H_ -#define ART_SRC_SAFE_MAP_H_ +#ifndef ART_RUNTIME_SAFE_MAP_H_ +#define ART_RUNTIME_SAFE_MAP_H_ #include @@ -102,4 +102,4 @@ bool operator!=(const SafeMap& lhs, const SafeMap @@ -59,4 +59,4 @@ class SignalSet { } // namespace art -#endif // ART_SRC_SIGNAL_SET_H_ +#endif // ART_RUNTIME_SIGNAL_SET_H_ diff --git a/runtime/sirt_ref.h b/runtime/sirt_ref.h index 12f8326347..81f0dff217 100644 --- a/runtime/sirt_ref.h +++ b/runtime/sirt_ref.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_SIRT_REF_H_ -#define ART_SRC_SIRT_REF_H_ +#ifndef ART_RUNTIME_SIRT_REF_H_ +#define ART_RUNTIME_SIRT_REF_H_ #include "base/logging.h" #include "base/macros.h" @@ -52,4 +52,4 @@ class SirtRef { } // namespace art -#endif // ART_SRC_SIRT_REF_H_ +#endif // ART_RUNTIME_SIRT_REF_H_ diff --git a/runtime/stack.h b/runtime/stack.h index fbfacb1733..0e2c4c5b86 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STACK_H_ -#define ART_SRC_STACK_H_ +#ifndef ART_RUNTIME_STACK_H_ +#define ART_RUNTIME_STACK_H_ #include "dex_file.h" #include "instrumentation.h" @@ -644,4 +644,4 @@ class VmapTable { } // namespace art -#endif // ART_SRC_STACK_H_ +#endif // ART_RUNTIME_STACK_H_ diff --git a/runtime/stack_indirect_reference_table.h b/runtime/stack_indirect_reference_table.h index dd106344de..4c9b038423 100644 --- a/runtime/stack_indirect_reference_table.h +++ b/runtime/stack_indirect_reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ -#define ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ +#define ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ #include "base/logging.h" #include "base/macros.h" @@ -96,4 +96,4 @@ class StackIndirectReferenceTable { } // namespace art -#endif // ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ diff --git a/runtime/strutil.h b/runtime/strutil.h index b8769183da..c8d39e2311 100644 --- a/runtime/strutil.h +++ b/runtime/strutil.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STRUTIL_H_ -#define ART_SRC_STRUTIL_H_ +#ifndef ART_RUNTIME_STRUTIL_H_ +#define ART_RUNTIME_STRUTIL_H_ #include @@ -37,4 +37,4 @@ struct CStringEq { } // namespace art -#endif // ART_SRC_STRUTIL_H_ +#endif // ART_RUNTIME_STRUTIL_H_ diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h index 2fc5987306..c22f2cd921 100644 --- a/runtime/thread-inl.h +++ b/runtime/thread-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_INL_H_ -#define ART_SRC_THREAD_INL_H_ +#ifndef ART_RUNTIME_THREAD_INL_H_ +#define ART_RUNTIME_THREAD_INL_H_ #include "thread.h" @@ -133,4 +133,4 @@ inline void Thread::VerifyStack() { } // namespace art -#endif // ART_SRC_THREAD_INL_H_ +#endif // ART_RUNTIME_THREAD_INL_H_ diff --git a/runtime/thread.h b/runtime/thread.h index 0daf763359..64ff7c22fa 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_H_ -#define ART_SRC_THREAD_H_ +#ifndef ART_RUNTIME_THREAD_H_ +#define ART_RUNTIME_THREAD_H_ #include @@ -788,4 +788,4 @@ std::ostream& operator<<(std::ostream& os, const ThreadState& state); } // namespace art -#endif // ART_SRC_THREAD_H_ +#endif // ART_RUNTIME_THREAD_H_ diff --git a/runtime/thread_list.h b/runtime/thread_list.h index 0470cfc3b9..87abbda479 100644 --- a/runtime/thread_list.h +++ b/runtime/thread_list.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_LIST_H_ -#define ART_SRC_THREAD_LIST_H_ +#ifndef ART_RUNTIME_THREAD_LIST_H_ +#define ART_RUNTIME_THREAD_LIST_H_ #include "base/mutex.h" #include "root_visitor.h" @@ -144,4 +144,4 @@ class ThreadList { } // namespace art -#endif // ART_SRC_THREAD_LIST_H_ +#endif // ART_RUNTIME_THREAD_LIST_H_ diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index 814e654ad7..3462d5efbb 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_POOL_H_ -#define ART_SRC_THREAD_POOL_H_ +#ifndef ART_RUNTIME_THREAD_POOL_H_ +#define ART_RUNTIME_THREAD_POOL_H_ #include #include @@ -177,4 +177,4 @@ class WorkStealingThreadPool : public ThreadPool { } // namespace art -#endif // ART_SRC_THREAD_POOL_H_ +#endif // ART_RUNTIME_THREAD_POOL_H_ diff --git a/runtime/thread_state.h b/runtime/thread_state.h index 52f092efa0..fc4812a427 100644 --- a/runtime/thread_state.h +++ b/runtime/thread_state.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_STATE_H_ -#define ART_SRC_THREAD_STATE_H_ +#ifndef ART_RUNTIME_THREAD_STATE_H_ +#define ART_RUNTIME_THREAD_STATE_H_ namespace art { @@ -44,4 +44,4 @@ enum ThreadState { } // namespace art -#endif // ART_SRC_THREAD_STATE_H_ +#endif // ART_RUNTIME_THREAD_STATE_H_ diff --git a/runtime/throw_location.h b/runtime/throw_location.h index 8c1b9410af..b2cd4d5803 100644 --- a/runtime/throw_location.h +++ b/runtime/throw_location.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THROW_LOCATION_H_ -#define ART_SRC_THROW_LOCATION_H_ +#ifndef ART_RUNTIME_THROW_LOCATION_H_ +#define ART_RUNTIME_THROW_LOCATION_H_ #include "base/macros.h" #include "root_visitor.h" @@ -75,4 +75,4 @@ class PACKED(4) ThrowLocation { } // namespace art -#endif // ART_SRC_THROW_LOCATION_H_ +#endif // ART_RUNTIME_THROW_LOCATION_H_ diff --git a/runtime/trace.h b/runtime/trace.h index 9432e718ff..5bd6a8d5ca 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_TRACE_H_ -#define ART_SRC_TRACE_H_ +#ifndef ART_RUNTIME_TRACE_H_ +#define ART_RUNTIME_TRACE_H_ #include #include @@ -129,4 +129,4 @@ class Trace : public instrumentation::InstrumentationListener { } // namespace art -#endif // ART_SRC_TRACE_H_ +#endif // ART_RUNTIME_TRACE_H_ diff --git a/runtime/utf.h b/runtime/utf.h index 57c811f21d..4c9a1d959e 100644 --- a/runtime/utf.h +++ b/runtime/utf.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTF_H_ -#define ART_SRC_UTF_H_ +#ifndef ART_RUNTIME_UTF_H_ +#define ART_RUNTIME_UTF_H_ #include "base/macros.h" @@ -94,4 +94,4 @@ uint16_t GetUtf16FromUtf8(const char** utf8_data_in); } // namespace art -#endif // ART_SRC_UTF_H_ +#endif // ART_RUNTIME_UTF_H_ diff --git a/runtime/utils.h b/runtime/utils.h index e5028bae86..a08e46524b 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTILS_H_ -#define ART_SRC_UTILS_H_ +#ifndef ART_RUNTIME_UTILS_H_ +#define ART_RUNTIME_UTILS_H_ #include @@ -372,4 +372,4 @@ class VoidFunctor { } // namespace art -#endif // ART_SRC_UTILS_H_ +#endif // ART_RUNTIME_UTILS_H_ diff --git a/runtime/vector_output_stream.h b/runtime/vector_output_stream.h index 3546c8d577..7daa39ffa5 100644 --- a/runtime/vector_output_stream.h +++ b/runtime/vector_output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VECTOR_OUTPUT_STREAM_H_ -#define ART_SRC_VECTOR_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ +#define ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ #include "output_stream.h" @@ -62,4 +62,4 @@ class VectorOutputStream : public OutputStream { } // namespace art -#endif // ART_SRC_VECTOR_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ diff --git a/runtime/verifier/dex_gc_map.h b/runtime/verifier/dex_gc_map.h index 673112b213..be7415e1d6 100644 --- a/runtime/verifier/dex_gc_map.h +++ b/runtime/verifier/dex_gc_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_DEX_GC_MAP_H_ -#define ART_SRC_VERIFIER_DEX_GC_MAP_H_ +#ifndef ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ +#define ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ #include @@ -119,4 +119,4 @@ class DexPcToReferenceMap { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_DEX_GC_MAP_H_ +#endif // ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ diff --git a/runtime/verifier/instruction_flags.h b/runtime/verifier/instruction_flags.h index 9dc3ea7a7c..df89beecfb 100644 --- a/runtime/verifier/instruction_flags.h +++ b/runtime/verifier/instruction_flags.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ -#define ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ +#ifndef ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ +#define ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ #include "base/logging.h" @@ -113,4 +113,4 @@ class InstructionFlags { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ +#endif // ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index ac0de9e1f7..57d630de5a 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_METHOD_VERIFIER_H_ -#define ART_SRC_VERIFIER_METHOD_VERIFIER_H_ +#ifndef ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ +#define ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ #include #include @@ -723,4 +723,4 @@ std::ostream& operator<<(std::ostream& os, const MethodVerifier::FailureKind& rh } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_METHOD_VERIFIER_H_ +#endif // ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ diff --git a/runtime/verifier/reg_type.h b/runtime/verifier/reg_type.h index 9ac0ecac8a..1553f1e554 100644 --- a/runtime/verifier/reg_type.h +++ b/runtime/verifier/reg_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_H_ -#define ART_SRC_VERIFIER_REG_TYPE_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_H_ #include "base/macros.h" #include "globals.h" @@ -922,4 +922,4 @@ std::ostream& operator<<(std::ostream& os, const RegType& rhs) } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_H_ diff --git a/runtime/verifier/reg_type_cache-inl.h b/runtime/verifier/reg_type_cache-inl.h index 42474d1849..295e27198d 100644 --- a/runtime/verifier/reg_type_cache-inl.h +++ b/runtime/verifier/reg_type_cache-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ -#define ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ #include "reg_type.h" #include "reg_type_cache.h" @@ -43,4 +43,4 @@ inline const art::verifier::RegType& RegTypeCache::GetFromId(uint16_t id) const } } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ diff --git a/runtime/verifier/reg_type_cache.h b/runtime/verifier/reg_type_cache.h index d70123c2de..814dff79f6 100644 --- a/runtime/verifier/reg_type_cache.h +++ b/runtime/verifier/reg_type_cache.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ -#define ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ #include "base/casts.h" #include "base/macros.h" @@ -163,4 +163,4 @@ class RegTypeCache { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ diff --git a/runtime/verifier/register_line-inl.h b/runtime/verifier/register_line-inl.h index 157e136cc1..b3a28470db 100644 --- a/runtime/verifier/register_line-inl.h +++ b/runtime/verifier/register_line-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ -#define ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ +#ifndef ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ +#define ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ #include "register_line.h" #include "method_verifier.h" @@ -32,4 +32,4 @@ inline const RegType& RegisterLine::GetRegisterType(uint32_t vsrc) const { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ +#endif // ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ diff --git a/runtime/verifier/register_line.h b/runtime/verifier/register_line.h index 5f17049e8e..cde7b9b0be 100644 --- a/runtime/verifier/register_line.h +++ b/runtime/verifier/register_line.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REGISTER_LINE_H_ -#define ART_SRC_VERIFIER_REGISTER_LINE_H_ +#ifndef ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ +#define ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ #include #include @@ -355,4 +355,4 @@ std::ostream& operator<<(std::ostream& os, const RegisterLine& rhs); } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REGISTER_LINE_H_ +#endif // ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index 8170520d45..a8069bc9cb 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_WELL_KNOWN_CLASSES_H_ -#define ART_SRC_WELL_KNOWN_CLASSES_H_ +#ifndef ART_RUNTIME_WELL_KNOWN_CLASSES_H_ +#define ART_RUNTIME_WELL_KNOWN_CLASSES_H_ #include "base/mutex.h" #include "jni.h" @@ -104,4 +104,4 @@ struct WellKnownClasses { } // namespace art -#endif // ART_SRC_WELL_KNOWN_CLASSES_H_ +#endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ diff --git a/runtime/zip_archive.h b/runtime/zip_archive.h index ef3148696e..d648517aae 100644 --- a/runtime/zip_archive.h +++ b/runtime/zip_archive.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ZIP_ARCHIVE_H_ -#define ART_SRC_ZIP_ARCHIVE_H_ +#ifndef ART_RUNTIME_ZIP_ARCHIVE_H_ +#define ART_RUNTIME_ZIP_ARCHIVE_H_ #include #include @@ -129,4 +129,4 @@ class ZipArchive { } // namespace art -#endif // ART_SRC_ZIP_ARCHIVE_H_ +#endif // ART_RUNTIME_ZIP_ARCHIVE_H_ diff --git a/tools/cpplint.py b/tools/cpplint.py index ff92d70f06..30c712856e 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -726,7 +726,11 @@ class FileInfo: os.path.exists(os.path.join(root_dir, ".hg")) or os.path.exists(os.path.join(root_dir, ".svn"))): prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] + # BEGIN android-changed + # return fullname[len(prefix) + 1:] + return "art/" + fullname[len(prefix) + 1:] + # END android-changed + # Don't know what to do; header guard warnings may be wrong... return fullname @@ -1032,7 +1036,6 @@ def GetHeaderGuardCPPVariable(filename): # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) - fileinfo = FileInfo(filename) return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' -- cgit v1.2.3-59-g8ed1b From 0177fe200efc1bf4d433955ee7920c683fdf5901 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Sun, 21 Jul 2013 12:21:36 -0700 Subject: Remove CompilerDriver::IsDebuggingSupported Change-Id: Ib67e3ef67462fe5dae81148f7fe8cc76b3887f11 --- compiler/driver/compiler_driver.cc | 4 +--- compiler/driver/compiler_driver.h | 8 +------- dex2oat/dex2oat.cc | 16 ++++------------ runtime/common_test.h | 2 +- runtime/oat_test.cc | 3 +-- 5 files changed, 8 insertions(+), 25 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index f1082db9bc..6558f8acfe 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -335,8 +335,7 @@ extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image, DescriptorSet* image_classes, - size_t thread_count, bool support_debugging, - bool dump_stats, bool dump_timings) + size_t thread_count, bool dump_stats, bool dump_timings) : compiler_backend_(compiler_backend), instruction_set_(instruction_set), freezing_constructor_lock_("freezing constructor lock"), @@ -345,7 +344,6 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet image_(image), image_classes_(image_classes), thread_count_(thread_count), - support_debugging_(support_debugging), start_ns_(0), stats_(new AOTCompilationStats), dump_stats_(dump_stats), diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 80cc89b95f..902fda7f0c 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -72,8 +72,7 @@ class CompilerDriver { // classes. explicit CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image, DescriptorSet* image_classes, - size_t thread_count, bool support_debugging, - bool dump_stats, bool dump_timings); + size_t thread_count, bool dump_stats, bool dump_timings); ~CompilerDriver(); @@ -84,10 +83,6 @@ class CompilerDriver { void CompileOne(const mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsDebuggingSupported() { - return support_debugging_; - } - InstructionSet GetInstructionSet() const { return instruction_set_; } @@ -362,7 +357,6 @@ class CompilerDriver { UniquePtr image_classes_; size_t thread_count_; - bool support_debugging_; uint64_t start_ns_; UniquePtr stats_; diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 9e23d3e7d3..75e1afe09a 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -149,14 +149,13 @@ static void Usage(const char* fmt, ...) { class Dex2Oat { public: static bool Create(Dex2Oat** p_dex2oat, Runtime::Options& options, CompilerBackend compiler_backend, - InstructionSet instruction_set, size_t thread_count, bool support_debugging) + InstructionSet instruction_set, size_t thread_count) SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_) { if (!CreateRuntime(options, instruction_set)) { *p_dex2oat = NULL; return false; } - *p_dex2oat = new Dex2Oat(Runtime::Current(), compiler_backend, instruction_set, thread_count, - support_debugging); + *p_dex2oat = new Dex2Oat(Runtime::Current(), compiler_backend, instruction_set, thread_count); return true; } @@ -249,7 +248,6 @@ class Dex2Oat { image, image_classes.release(), thread_count_, - support_debugging_, dump_stats, dump_timings)); @@ -336,12 +334,11 @@ class Dex2Oat { private: explicit Dex2Oat(Runtime* runtime, CompilerBackend compiler_backend, InstructionSet instruction_set, - size_t thread_count, bool support_debugging) + size_t thread_count) : compiler_backend_(compiler_backend), instruction_set_(instruction_set), runtime_(runtime), thread_count_(thread_count), - support_debugging_(support_debugging), start_ns_(NanoTime()) { } @@ -402,7 +399,6 @@ class Dex2Oat { Runtime* runtime_; size_t thread_count_; - bool support_debugging_; uint64_t start_ns_; DISALLOW_IMPLICIT_CONSTRUCTORS(Dex2Oat); @@ -596,7 +592,6 @@ static int dex2oat(int argc, char** argv) { std::string android_root; std::vector runtime_args; int thread_count = sysconf(_SC_NPROCESSORS_CONF); - bool support_debugging = false; #if defined(ART_USE_PORTABLE_COMPILER) CompilerBackend compiler_backend = kPortable; #else @@ -643,8 +638,6 @@ static int dex2oat(int argc, char** argv) { if (!ParseInt(oat_fd_str, &oat_fd)) { Usage("could not parse --oat-fd argument '%s' as an integer", oat_fd_str); } - } else if (option == "-g") { - support_debugging = true; } else if (option == "--watch-dog") { watch_dog_enabled = true; } else if (option == "--no-watch-dog") { @@ -866,8 +859,7 @@ static int dex2oat(int argc, char** argv) { Dex2Oat* p_dex2oat; - if (!Dex2Oat::Create(&p_dex2oat, options, compiler_backend, instruction_set, thread_count, - support_debugging)) { + if (!Dex2Oat::Create(&p_dex2oat, options, compiler_backend, instruction_set, thread_count)) { LOG(ERROR) << "Failed to create dex2oat"; return EXIT_FAILURE; } diff --git a/runtime/common_test.h b/runtime/common_test.h index 03a45aa20b..13626a5eac 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -349,7 +349,7 @@ class CommonTest : public testing::Test { class_linker_->FixupDexCaches(runtime_->GetResolutionMethod()); compiler_driver_.reset(new CompilerDriver(compiler_backend, instruction_set, true, new CompilerDriver::DescriptorSet, - 2, false, true, true)); + 2, true, true)); } // We typically don't generate an image in unit tests, disable this optimization by default. compiler_driver_->SetSupportBootImageFixup(false); diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 70c2e9e88e..7f24564eb2 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -74,8 +74,7 @@ TEST_F(OatTest, WriteRead) { #else CompilerBackend compiler_backend = kQuick; #endif - compiler_driver_.reset(new CompilerDriver(compiler_backend, kThumb2, false, NULL, 2, false, - true, true)); + compiler_driver_.reset(new CompilerDriver(compiler_backend, kThumb2, false, NULL, 2, true, true)); jobject class_loader = NULL; if (compile) { compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath()); -- cgit v1.2.3-59-g8ed1b From 4560248d4c85cade7f4fc7b30c3fb41b95a04a7f Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Sun, 21 Jul 2013 22:07:55 -0700 Subject: Move TimingLogger creation to dex2oat Change-Id: I4fdb6afd4ce2ac0d91c6c968893606d593b6ea18 --- compiler/driver/compiler_driver.cc | 18 ++------- compiler/driver/compiler_driver.h | 8 ++-- compiler/driver/compiler_driver_test.cc | 5 ++- dex2oat/dex2oat.cc | 65 +++++++++++++++++++++++---------- runtime/common_test.h | 5 ++- runtime/image_test.cc | 3 +- runtime/oat_test.cc | 8 ++-- 7 files changed, 68 insertions(+), 44 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 6558f8acfe..b1b205e067 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -335,7 +335,7 @@ extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image, DescriptorSet* image_classes, - size_t thread_count, bool dump_stats, bool dump_timings) + size_t thread_count, bool dump_stats) : compiler_backend_(compiler_backend), instruction_set_(instruction_set), freezing_constructor_lock_("freezing constructor lock"), @@ -347,7 +347,6 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet start_ns_(0), stats_(new AOTCompilationStats), dump_stats_(dump_stats), - dump_timings_(dump_timings), compiler_library_(NULL), compiler_(NULL), compiler_context_(NULL), @@ -495,20 +494,12 @@ const std::vector* CompilerDriver::CreateInterpreterToQuickEntry() cons } void CompilerDriver::CompileAll(jobject class_loader, - const std::vector& dex_files) { + const std::vector& dex_files, + TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); - UniquePtr thread_pool(new ThreadPool(thread_count_)); - TimingLogger timings("compiler", false); - PreCompile(class_loader, dex_files, *thread_pool.get(), timings); - Compile(class_loader, dex_files, *thread_pool.get(), timings); - - if (dump_timings_ && timings.GetTotalNs() > MsToNs(1000)) { - LOG(INFO) << Dumpable(timings); - } - if (dump_stats_) { stats_->Dump(); } @@ -537,7 +528,7 @@ static bool IsDexToDexCompilationAllowed(mirror::ClassLoader* class_loader, return klass->IsVerified(); } -void CompilerDriver::CompileOne(const mirror::AbstractMethod* method) { +void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); Thread* self = Thread::Current(); jobject jclass_loader; @@ -560,7 +551,6 @@ void CompilerDriver::CompileOne(const mirror::AbstractMethod* method) { dex_files.push_back(dex_file); UniquePtr thread_pool(new ThreadPool(1U)); - TimingLogger timings("CompileOne", false); PreCompile(jclass_loader, dex_files, *thread_pool.get(), timings); uint32_t method_idx = method->GetDexMethodIndex(); diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 902fda7f0c..1799057ea6 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -72,15 +72,16 @@ class CompilerDriver { // classes. explicit CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set, bool image, DescriptorSet* image_classes, - size_t thread_count, bool dump_stats, bool dump_timings); + size_t thread_count, bool dump_stats); ~CompilerDriver(); - void CompileAll(jobject class_loader, const std::vector& dex_files) + void CompileAll(jobject class_loader, const std::vector& dex_files, + TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); // Compile a single Method - void CompileOne(const mirror::AbstractMethod* method) + void CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); InstructionSet GetInstructionSet() const { @@ -362,7 +363,6 @@ class CompilerDriver { UniquePtr stats_; bool dump_stats_; - bool dump_timings_; typedef void (*CompilerCallbackFn)(CompilerDriver& driver); typedef MutexLock* (*CompilerMutexLockFn)(CompilerDriver& driver); diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 6a160f75c6..78cacaf08e 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -36,7 +36,10 @@ namespace art { class CompilerDriverTest : public CommonTest { protected: void CompileAll(jobject class_loader) LOCKS_EXCLUDED(Locks::mutator_lock_) { - compiler_driver_->CompileAll(class_loader, Runtime::Current()->GetCompileTimeClassPath(class_loader)); + TimingLogger timings("CompilerDriverTest::CompileAll", false); + compiler_driver_->CompileAll(class_loader, + Runtime::Current()->GetCompileTimeClassPath(class_loader), + timings); MakeAllExecutable(class_loader); } diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 75e1afe09a..995f6d4052 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -83,8 +83,8 @@ static void Usage(const char* fmt, ...) { UsageError(" containing a classes.dex file to compile."); UsageError(" Example: --zip-fd=5"); UsageError(""); - UsageError(" --zip-location=: specifies a symbolic name for the file corresponding"); - UsageError(" to the file descriptor specified by --zip-fd."); + UsageError(" --zip-location=: specifies a symbolic name for the file"); + UsageError(" corresponding to the file descriptor specified by --zip-fd."); UsageError(" Example: --zip-location=/system/app/Calculator.apk"); UsageError(""); UsageError(" --oat-file=: specifies the oat output destination via a filename."); @@ -148,8 +148,11 @@ static void Usage(const char* fmt, ...) { class Dex2Oat { public: - static bool Create(Dex2Oat** p_dex2oat, Runtime::Options& options, CompilerBackend compiler_backend, - InstructionSet instruction_set, size_t thread_count) + static bool Create(Dex2Oat** p_dex2oat, + Runtime::Options& options, + CompilerBackend compiler_backend, + InstructionSet instruction_set, + size_t thread_count) SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_) { if (!CreateRuntime(options, instruction_set)) { *p_dex2oat = NULL; @@ -161,13 +164,15 @@ class Dex2Oat { ~Dex2Oat() { delete runtime_; - LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) << " (threads: " << thread_count_ << ")"; + LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) + << " (threads: " << thread_count_ << ")"; } - // Reads the class names (java.lang.Object) and returns as set of class descriptors (Ljava/lang/Object;) + // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;) CompilerDriver::DescriptorSet* ReadImageClassesFromFile(const char* image_classes_filename) { - UniquePtr image_classes_file(new std::ifstream(image_classes_filename, std::ifstream::in)); + UniquePtr image_classes_file(new std::ifstream(image_classes_filename, + std::ifstream::in)); if (image_classes_file.get() == NULL) { LOG(ERROR) << "Failed to open image classes file " << image_classes_filename; return NULL; @@ -191,8 +196,9 @@ class Dex2Oat { return image_classes.release(); } - // Reads the class names (java.lang.Object) and returns as set of class descriptors (Ljava/lang/Object;) - CompilerDriver::DescriptorSet* ReadImageClassesFromZip(const std::string& zip_filename, const char* image_classes_filename) { + // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;) + CompilerDriver::DescriptorSet* ReadImageClassesFromZip(const std::string& zip_filename, + const char* image_classes_filename) { UniquePtr zip_archive(ZipArchive::Open(zip_filename)); if (zip_archive.get() == NULL) { LOG(ERROR) << "Failed to open zip file " << zip_filename; @@ -224,7 +230,7 @@ class Dex2Oat { bool image, UniquePtr& image_classes, bool dump_stats, - bool dump_timings) + TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // SirtRef and ClassLoader creation needs to come after Runtime::Create jobject class_loader = NULL; @@ -248,8 +254,7 @@ class Dex2Oat { image, image_classes.release(), thread_count_, - dump_stats, - dump_timings)); + dump_stats)); if (compiler_backend_ == kPortable) { driver->SetBitcodeFileName(bitcode_filename); @@ -258,7 +263,8 @@ class Dex2Oat { Thread::Current()->TransitionFromRunnableToSuspended(kNative); - driver->CompileAll(class_loader, dex_files); + timings.AddSplit("dex2oat Setup"); + driver->CompileAll(class_loader, dex_files, timings); Thread::Current()->TransitionFromSuspendedToRunnable(); @@ -294,11 +300,13 @@ class Dex2Oat { LOG(ERROR) << "Failed to create oat file " << oat_file->GetPath(); return NULL; } + timings.AddSplit("dex2oat OatWriter"); if (!driver->WriteElf(android_root, is_host, dex_files, oat_contents, oat_file)) { LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath(); return NULL; } + timings.AddSplit("dex2oat ElfWriter"); return driver.release(); } @@ -333,7 +341,9 @@ class Dex2Oat { } private: - explicit Dex2Oat(Runtime* runtime, CompilerBackend compiler_backend, InstructionSet instruction_set, + explicit Dex2Oat(Runtime* runtime, + CompilerBackend compiler_backend, + InstructionSet instruction_set, size_t thread_count) : compiler_backend_(compiler_backend), instruction_set_(instruction_set), @@ -365,7 +375,8 @@ class Dex2Oat { // Appends to dex_files any elements of class_path that it doesn't already // contain. This will open those dex files as necessary. - static void OpenClassPathFiles(const std::string& class_path, std::vector& dex_files) { + static void OpenClassPathFiles(const std::string& class_path, + std::vector& dex_files) { std::vector parsed; Split(class_path, ':', parsed); // Take Locks::mutator_lock_ so that lock ordering on the ClassLinker::dex_lock_ is maintained. @@ -384,7 +395,8 @@ class Dex2Oat { } // Returns true if dex_files has a dex with the named location. - static bool DexFilesContains(const std::vector& dex_files, const std::string& location) { + static bool DexFilesContains(const std::vector& dex_files, + const std::string& location) { for (size_t i = 0; i < dex_files.size(); ++i) { if (dex_files[i]->GetLocation() == location) { return true; @@ -564,6 +576,8 @@ const unsigned int WatchDog::kWatchDogWarningSeconds; const unsigned int WatchDog::kWatchDogTimeoutSeconds; static int dex2oat(int argc, char** argv) { + TimingLogger timings("compiler", false); + InitLogging(argv); // Skip over argv[0]. @@ -937,7 +951,7 @@ static int dex2oat(int argc, char** argv) { image, image_classes, dump_stats, - dump_timings)); + timings)); if (compiler.get() == NULL) { LOG(ERROR) << "Failed to create oat file: " << oat_location; @@ -959,7 +973,7 @@ static int dex2oat(int argc, char** argv) { // | alloc spaces | // +--------------+ // - // There are several constraints on the loading of the imag and boot.oat. + // There are several constraints on the loading of the image and boot.oat. // // 1. The image is expected to be loaded at an absolute address and // contains Objects with absolute pointers within the image. @@ -977,7 +991,7 @@ static int dex2oat(int argc, char** argv) { // // 1. We have already created that oat file above with // CreateOatFile. Originally this was just our own proprietary file - // but now it is contained within an ELF dynamic object (aka .so + // but now it is contained within an ELF dynamic object (aka an .so // file). The Compiler returned by CreateOatFile provides // PatchInformation for references to oat code and Methods that need // to be update once we know where the oat file will be located @@ -1003,6 +1017,7 @@ static int dex2oat(int argc, char** argv) { oat_unstripped, oat_location, *compiler.get()); + timings.AddSplit("dex2oat ImageWriter"); Thread::Current()->TransitionFromSuspendedToRunnable(); LOG(INFO) << "Image written successfully: " << image_filename; if (!image_creation_success) { @@ -1011,9 +1026,13 @@ static int dex2oat(int argc, char** argv) { } if (is_host) { + if (dump_timings && timings.GetTotalNs() > MsToNs(1000)) { + LOG(INFO) << Dumpable(timings); + } return EXIT_SUCCESS; } +#if ART_USE_PORTABLE_COMPILER // We currently only generate symbols on Portable // If we don't want to strip in place, copy from unstripped location to stripped location. // We need to strip after image creation because FixupElf needs to use .strtab. if (oat_unstripped != oat_stripped) { @@ -1031,6 +1050,7 @@ static int dex2oat(int argc, char** argv) { CHECK(write_ok); } oat_file.reset(out.release()); + timings.AddSplit("dex2oat OatFile copy"); LOG(INFO) << "Oat file copied successfully (stripped): " << oat_stripped; } @@ -1038,12 +1058,19 @@ static int dex2oat(int argc, char** argv) { off_t seek_actual = lseek(oat_file->Fd(), 0, SEEK_SET); CHECK_EQ(0, seek_actual); ElfStripper::Strip(oat_file.get()); + timings.AddSplit("dex2oat ElfStripper"); // We wrote the oat file successfully, and want to keep it. LOG(INFO) << "Oat file written successfully (stripped): " << oat_location; +#endif // ART_USE_PORTABLE_COMPILER + + if (dump_timings && timings.GetTotalNs() > MsToNs(1000)) { + LOG(INFO) << Dumpable(timings); + } return EXIT_SUCCESS; } + } // namespace art int main(int argc, char** argv) { diff --git a/runtime/common_test.h b/runtime/common_test.h index 13626a5eac..09ad7fd7b7 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -349,7 +349,7 @@ class CommonTest : public testing::Test { class_linker_->FixupDexCaches(runtime_->GetResolutionMethod()); compiler_driver_.reset(new CompilerDriver(compiler_backend, instruction_set, true, new CompilerDriver::DescriptorSet, - 2, true, true)); + 2, true)); } // We typically don't generate an image in unit tests, disable this optimization by default. compiler_driver_->SetSupportBootImageFixup(false); @@ -473,7 +473,8 @@ class CommonTest : public testing::Test { void CompileMethod(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); - compiler_driver_->CompileOne(method); + TimingLogger timings("CommonTest::CompileMethod", false); + compiler_driver_->CompileOne(method, timings); MakeExecutable(method); } diff --git a/runtime/image_test.cc b/runtime/image_test.cc index ee50118b06..11218ad513 100644 --- a/runtime/image_test.cc +++ b/runtime/image_test.cc @@ -45,7 +45,8 @@ TEST_F(ImageTest, WriteRead) { { jobject class_loader = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath()); + TimingLogger timings("ImageTest::WriteRead", false); + compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); ScopedObjectAccess soa(Thread::Current()); VectorOutputStream output_stream(tmp_elf.GetFilename(), oat_contents); diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 7f24564eb2..9a6bc19b13 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -74,10 +74,11 @@ TEST_F(OatTest, WriteRead) { #else CompilerBackend compiler_backend = kQuick; #endif - compiler_driver_.reset(new CompilerDriver(compiler_backend, kThumb2, false, NULL, 2, true, true)); + compiler_driver_.reset(new CompilerDriver(compiler_backend, kThumb2, false, NULL, 2, true)); jobject class_loader = NULL; if (compile) { - compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath()); + TimingLogger timings("OatTest::WriteRead", false); + compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); } ScopedObjectAccess soa(Thread::Current()); @@ -99,7 +100,8 @@ TEST_F(OatTest, WriteRead) { ASSERT_TRUE(success_elf); if (compile) { // OatWriter strips the code, regenerate to compare - compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath()); + TimingLogger timings("CommonTest::WriteRead", false); + compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); } UniquePtr oat_file(OatFile::Open(tmp.GetFilename(), tmp.GetFilename(), NULL, false)); ASSERT_TRUE(oat_file.get() != NULL); -- cgit v1.2.3-59-g8ed1b From c50d8e11a098cc5c6239aa86b47d4fcf8cbb4899 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Tue, 23 Jul 2013 22:35:16 -0700 Subject: Remove OatWriter buffering to memory for ElfWriterQuick This allows the oat contents to be directly written to the file. Change-Id: Ibc7ddf57477b152f07784b52f7334be73fd22833 --- compiler/driver/compiler_driver.cc | 6 +- compiler/driver/compiler_driver.h | 3 +- compiler/elf_writer.h | 3 +- compiler/elf_writer_mclinker.cc | 15 ++- compiler/elf_writer_mclinker.h | 4 +- compiler/elf_writer_quick.cc | 23 ++-- compiler/elf_writer_quick.h | 4 +- compiler/image_writer.cc | 4 + compiler/oat_writer.cc | 215 ++++++++++++++++++++----------------- compiler/oat_writer.h | 51 +++++---- dex2oat/dex2oat.cc | 27 ++--- runtime/image_test.cc | 20 ++-- runtime/oat_test.cc | 26 ++--- 13 files changed, 211 insertions(+), 190 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 1f667308bd..ea2291cb44 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -2343,13 +2343,13 @@ bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex bool CompilerDriver::WriteElf(const std::string& android_root, bool is_host, const std::vector& dex_files, - std::vector& oat_contents, + OatWriter& oat_writer, art::File* file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #if defined(ART_USE_PORTABLE_COMPILER) - return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, *this); + return art::ElfWriterMclinker::Create(file, oat_writer, dex_files, android_root, is_host, *this); #else - return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, *this); + return art::ElfWriterQuick::Create(file, oat_writer, dex_files, android_root, is_host, *this); #endif } void CompilerDriver::InstructionSetToLLVMTarget(InstructionSet instruction_set, diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 1799057ea6..f3f72dd3c7 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -39,6 +39,7 @@ namespace art { class AOTCompilationStats; class ParallelCompilationManager; class DexCompilationUnit; +class OatWriter; class TimingLogger; enum CompilerBackend { @@ -192,7 +193,7 @@ class CompilerDriver { bool WriteElf(const std::string& android_root, bool is_host, const std::vector& dex_files, - std::vector& oat_contents, + OatWriter& oat_writer, File* file); // TODO: move to a common home for llvm helpers once quick/portable are merged diff --git a/compiler/elf_writer.h b/compiler/elf_writer.h index 0dfce6e40f..0ef4185431 100644 --- a/compiler/elf_writer.h +++ b/compiler/elf_writer.h @@ -33,6 +33,7 @@ namespace art { class CompilerDriver; class DexFile; class ElfFile; +class OatWriter; class ElfWriter { public: @@ -49,7 +50,7 @@ class ElfWriter { ElfWriter(const CompilerDriver& driver, File* elf_file); virtual ~ElfWriter(); - virtual bool Write(std::vector& oat_contents, + virtual bool Write(OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host) diff --git a/compiler/elf_writer_mclinker.cc b/compiler/elf_writer_mclinker.cc index 05f3b025e7..2a9bc35559 100644 --- a/compiler/elf_writer_mclinker.cc +++ b/compiler/elf_writer_mclinker.cc @@ -36,7 +36,9 @@ #include "mirror/abstract_method.h" #include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" +#include "oat_writer.h" #include "scoped_thread_state_change.h" +#include "vector_output_stream.h" namespace art { @@ -46,19 +48,25 @@ ElfWriterMclinker::ElfWriterMclinker(const CompilerDriver& driver, File* elf_fil ElfWriterMclinker::~ElfWriterMclinker() {} bool ElfWriterMclinker::Create(File* elf_file, - std::vector& oat_contents, + OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host, const CompilerDriver& driver) { ElfWriterMclinker elf_writer(driver, elf_file); - return elf_writer.Write(oat_contents, dex_files, android_root, is_host); + return elf_writer.Write(oat_writer, dex_files, android_root, is_host); } -bool ElfWriterMclinker::Write(std::vector& oat_contents, +bool ElfWriterMclinker::Write(OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host) { + std::vector oat_contents; + oat_contents.reserve(oat_writer.GetSize()); + VectorOutputStream output_stream("oat contents", oat_contents); + CHECK(oat_writer.Write(output_stream)); + CHECK_EQ(oat_writer.GetSize(), oat_contents.size()); + Init(); AddOatInput(oat_contents); #if defined(ART_USE_PORTABLE_COMPILER) @@ -68,6 +76,7 @@ bool ElfWriterMclinker::Write(std::vector& oat_contents, if (!Link()) { return false; } + oat_contents.clear(); #if defined(ART_USE_PORTABLE_COMPILER) FixupOatMethodOffsets(dex_files); #endif diff --git a/compiler/elf_writer_mclinker.h b/compiler/elf_writer_mclinker.h index 3b33bc4986..bdadf8f206 100644 --- a/compiler/elf_writer_mclinker.h +++ b/compiler/elf_writer_mclinker.h @@ -40,7 +40,7 @@ class ElfWriterMclinker : public ElfWriter { public: // Write an ELF file. Returns true on success, false on failure. static bool Create(File* file, - std::vector& oat_contents, + OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host, @@ -48,7 +48,7 @@ class ElfWriterMclinker : public ElfWriter { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); protected: - virtual bool Write(std::vector& oat_contents, + virtual bool Write(OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host) diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc index 9de96d271e..f2db5d834c 100644 --- a/compiler/elf_writer_quick.cc +++ b/compiler/elf_writer_quick.cc @@ -19,8 +19,10 @@ #include "base/logging.h" #include "base/unix_file/fd_file.h" #include "driver/compiler_driver.h" +#include "file_output_stream.h" #include "globals.h" #include "oat.h" +#include "oat_writer.h" #include "utils.h" namespace art { @@ -31,16 +33,16 @@ ElfWriterQuick::ElfWriterQuick(const CompilerDriver& driver, File* elf_file) ElfWriterQuick::~ElfWriterQuick() {} bool ElfWriterQuick::Create(File* elf_file, - std::vector& oat_contents, + OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host, const CompilerDriver& driver) { ElfWriterQuick elf_writer(driver, elf_file); - return elf_writer.Write(oat_contents, dex_files, android_root, is_host); + return elf_writer.Write(oat_writer, dex_files, android_root, is_host); } -bool ElfWriterQuick::Write(std::vector& oat_contents, +bool ElfWriterQuick::Write(OatWriter& oat_writer, const std::vector& dex_files_unused, const std::string& android_root_unused, bool is_host_unused) { @@ -193,9 +195,9 @@ bool ElfWriterQuick::Write(std::vector& oat_contents, // .rodata uint32_t oat_data_alignment = kPageSize; uint32_t oat_data_offset = expected_offset = RoundUp(expected_offset, oat_data_alignment); - const OatHeader* oat_header = reinterpret_cast(&oat_contents[0]); - CHECK(oat_header->IsValid()); - uint32_t oat_data_size = oat_header->GetExecutableOffset(); + const OatHeader& oat_header = oat_writer.GetOatHeader(); + CHECK(oat_header.IsValid()); + uint32_t oat_data_size = oat_header.GetExecutableOffset(); expected_offset += oat_data_size; if (debug) { LOG(INFO) << "oat_data_offset=" << oat_data_offset << std::hex << " " << oat_data_offset; @@ -206,9 +208,9 @@ bool ElfWriterQuick::Write(std::vector& oat_contents, uint32_t oat_exec_alignment = kPageSize; CHECK_ALIGNED(expected_offset, kPageSize); uint32_t oat_exec_offset = expected_offset = RoundUp(expected_offset, oat_exec_alignment); - uint32_t oat_exec_size = oat_contents.size() - oat_data_size; + uint32_t oat_exec_size = oat_writer.GetSize() - oat_data_size; expected_offset += oat_exec_size; - CHECK_EQ(oat_data_offset + oat_contents.size(), expected_offset); + CHECK_EQ(oat_data_offset + oat_writer.GetSize(), expected_offset); if (debug) { LOG(INFO) << "oat_exec_offset=" << oat_exec_offset << std::hex << " " << oat_exec_offset; LOG(INFO) << "oat_exec_size=" << oat_exec_size << std::hex << " " << oat_exec_size; @@ -617,13 +619,14 @@ bool ElfWriterQuick::Write(std::vector& oat_contents, << " for " << elf_file_->GetPath(); return false; } - if (!elf_file_->WriteFully(&oat_contents[0], oat_contents.size())) { + FileOutputStream output_stream(elf_file_); + if (!oat_writer.Write(output_stream)) { PLOG(ERROR) << "Failed to write .rodata and .text for " << elf_file_->GetPath(); return false; } // .dynamic - DCHECK_LE(oat_data_offset + oat_contents.size(), dynamic_offset); + DCHECK_LE(oat_data_offset + oat_writer.GetSize(), dynamic_offset); if (static_cast(dynamic_offset) != lseek(elf_file_->Fd(), dynamic_offset, SEEK_SET)) { PLOG(ERROR) << "Failed to seek to .dynamic offset " << dynamic_offset << " for " << elf_file_->GetPath(); diff --git a/compiler/elf_writer_quick.h b/compiler/elf_writer_quick.h index a15c239de9..f36d06f79d 100644 --- a/compiler/elf_writer_quick.h +++ b/compiler/elf_writer_quick.h @@ -25,7 +25,7 @@ class ElfWriterQuick : public ElfWriter { public: // Write an ELF file. Returns true on success, false on failure. static bool Create(File* file, - std::vector& oat_contents, + OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host, @@ -33,7 +33,7 @@ class ElfWriterQuick : public ElfWriter { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); protected: - virtual bool Write(std::vector& oat_contents, + virtual bool Write(OatWriter& oat_writer, const std::vector& dex_files, const std::string& android_root, bool is_host) diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index f395428c7d..1612f7eb33 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -85,6 +85,10 @@ bool ImageWriter::Write(const std::string& image_filename, return false; } oat_file_ = OatFile::OpenWritable(oat_file.get(), oat_location); + if (oat_file_ == NULL) { + LOG(ERROR) << "Failed to open writable oat file " << oat_filename << " for " << oat_location; + return false; + } class_linker->RegisterOatFile(*oat_file_); interpreter_to_interpreter_entry_offset_ = oat_file_->GetOatHeader().GetInterpreterToInterpreterEntryOffset(); interpreter_to_quick_entry_offset_ = oat_file_->GetOatHeader().GetInterpreterToQuickEntryOffset(); diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index da05c49e0e..5eb837b25c 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -35,20 +35,6 @@ namespace art { -bool OatWriter::Create(OutputStream& output_stream, - const std::vector& dex_files, - uint32_t image_file_location_oat_checksum, - uint32_t image_file_location_oat_begin, - const std::string& image_file_location, - const CompilerDriver& driver) { - OatWriter oat_writer(dex_files, - image_file_location_oat_checksum, - image_file_location_oat_begin, - image_file_location, - &driver); - return oat_writer.Write(output_stream); -} - OatWriter::OatWriter(const std::vector& dex_files, uint32_t image_file_location_oat_checksum, uint32_t image_file_location_oat_begin, @@ -89,6 +75,7 @@ OatWriter::OatWriter(const std::vector& dex_files, offset = InitOatClasses(offset); offset = InitOatCode(offset); offset = InitOatCodeDexFiles(offset); + size_ = offset; CHECK_EQ(dex_files_->size(), oat_dex_files_.size()); CHECK(image_file_location.empty() == compiler->IsImage()); @@ -190,7 +177,8 @@ size_t OatWriter::InitOatCode(size_t offset) { if (compiler_driver_->IsImage()) { InstructionSet instruction_set = compiler_driver_->GetInstructionSet(); oat_header_->SetInterpreterToInterpreterEntryOffset(offset); - interpreter_to_interpreter_entry_.reset(compiler_driver_->CreateInterpreterToInterpreterEntry()); + interpreter_to_interpreter_entry_.reset( + compiler_driver_->CreateInterpreterToInterpreterEntry()); offset += interpreter_to_interpreter_entry_->size(); offset = CompiledCode::AlignCode(offset, instruction_set); @@ -336,7 +324,8 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, mapping_table_offset = (mapping_table_size == 0) ? 0 : offset; // Deduplicate mapping tables - SafeMap*, uint32_t>::iterator mapping_iter = mapping_table_offsets_.find(&mapping_table); + SafeMap*, uint32_t>::iterator mapping_iter = + mapping_table_offsets_.find(&mapping_table); if (mapping_iter != mapping_table_offsets_.end()) { mapping_table_offset = mapping_iter->second; } else { @@ -350,7 +339,8 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, vmap_table_offset = (vmap_table_size == 0) ? 0 : offset; // Deduplicate vmap tables - SafeMap*, uint32_t>::iterator vmap_iter = vmap_table_offsets_.find(&vmap_table); + SafeMap*, uint32_t>::iterator vmap_iter = + vmap_table_offsets_.find(&vmap_table); if (vmap_iter != vmap_table_offsets_.end()) { vmap_table_offset = vmap_iter->second; } else { @@ -382,7 +372,8 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, #endif // Deduplicate GC maps - SafeMap*, uint32_t>::iterator gc_map_iter = gc_map_offsets_.find(&gc_map); + SafeMap*, uint32_t>::iterator gc_map_iter = + gc_map_offsets_.find(&gc_map); if (gc_map_iter != gc_map_offsets_.end()) { gc_map_offset = gc_map_iter->second; } else { @@ -392,14 +383,14 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, } } - oat_class->method_offsets_[class_def_method_index] - = OatMethodOffsets(code_offset, - frame_size_in_bytes, - core_spill_mask, - fp_spill_mask, - mapping_table_offset, - vmap_table_offset, - gc_map_offset); + oat_class->method_offsets_[class_def_method_index] = + OatMethodOffsets(code_offset, + frame_size_in_bytes, + core_spill_mask, + fp_spill_mask, + mapping_table_offset, + vmap_table_offset, + gc_map_offset); if (compiler_driver_->IsImage()) { ClassLinker* linker = Runtime::Current()->GetClassLinker(); @@ -428,12 +419,16 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, } #define DCHECK_OFFSET() \ - DCHECK_EQ(static_cast(offset), out.Seek(0, kSeekCurrent)) + DCHECK_EQ(static_cast(file_offset + relative_offset), out.Seek(0, kSeekCurrent)) \ + << "file_offset=" << file_offset << " relative_offset=" << relative_offset #define DCHECK_OFFSET_() \ - DCHECK_EQ(static_cast(offset_), out.Seek(0, kSeekCurrent)) + DCHECK_EQ(static_cast(file_offset + offset_), out.Seek(0, kSeekCurrent)) \ + << "file_offset=" << file_offset << " offset_=" << offset_ bool OatWriter::Write(OutputStream& out) { + const size_t file_offset = out.Seek(0, kSeekCurrent); + if (!out.WriteFully(oat_header_, sizeof(*oat_header_))) { PLOG(ERROR) << "Failed to write oat header to " << out.GetLocation(); return false; @@ -446,19 +441,19 @@ bool OatWriter::Write(OutputStream& out) { } size_oat_header_image_file_location_ += image_file_location_.size(); - if (!WriteTables(out)) { + if (!WriteTables(out, file_offset)) { LOG(ERROR) << "Failed to write oat tables to " << out.GetLocation(); return false; } - size_t code_offset = WriteCode(out); - if (code_offset == 0) { + size_t relative_offset = WriteCode(out, file_offset); + if (relative_offset == 0) { LOG(ERROR) << "Failed to write oat code to " << out.GetLocation(); return false; } - code_offset = WriteCodeDexFiles(out, code_offset); - if (code_offset == 0) { + relative_offset = WriteCodeDexFiles(out, file_offset, relative_offset); + if (relative_offset == 0) { LOG(ERROR) << "Failed to write oat code for dex files to " << out.GetLocation(); return false; } @@ -495,21 +490,25 @@ bool OatWriter::Write(OutputStream& out) { #undef DO_STAT LOG(INFO) << "size_total=" << PrettySize(size_total) << " (" << size_total << "B)"; \ - CHECK_EQ(size_total, static_cast(out.Seek(0, kSeekCurrent))); + CHECK_EQ(file_offset + size_total, static_cast(out.Seek(0, kSeekCurrent))); + CHECK_EQ(size_, size_total); } + CHECK_EQ(file_offset + size_, static_cast(out.Seek(0, kSeekCurrent))); + CHECK_EQ(size_, relative_offset); + return true; } -bool OatWriter::WriteTables(OutputStream& out) { +bool OatWriter::WriteTables(OutputStream& out, const size_t file_offset) { for (size_t i = 0; i != oat_dex_files_.size(); ++i) { - if (!oat_dex_files_[i]->Write(this, out)) { + if (!oat_dex_files_[i]->Write(this, out, file_offset)) { PLOG(ERROR) << "Failed to write oat dex information to " << out.GetLocation(); return false; } } for (size_t i = 0; i != oat_dex_files_.size(); ++i) { - uint32_t expected_offset = oat_dex_files_[i]->dex_file_offset_; + uint32_t expected_offset = file_offset + oat_dex_files_[i]->dex_file_offset_; off_t actual_offset = out.Seek(expected_offset, kSeekSet); if (static_cast(actual_offset) != expected_offset) { const DexFile* dex_file = (*dex_files_)[i]; @@ -519,13 +518,14 @@ bool OatWriter::WriteTables(OutputStream& out) { } const DexFile* dex_file = (*dex_files_)[i]; if (!out.WriteFully(&dex_file->GetHeader(), dex_file->GetHeader().file_size_)) { - PLOG(ERROR) << "Failed to write dex file " << dex_file->GetLocation() << " to " << out.GetLocation(); + PLOG(ERROR) << "Failed to write dex file " << dex_file->GetLocation() + << " to " << out.GetLocation(); return false; } size_dex_file_ += dex_file->GetHeader().file_size_; } for (size_t i = 0; i != oat_classes_.size(); ++i) { - if (!oat_classes_[i]->Write(this, out)) { + if (!oat_classes_[i]->Write(this, out, file_offset)) { PLOG(ERROR) << "Failed to write oat methods information to " << out.GetLocation(); return false; } @@ -533,27 +533,29 @@ bool OatWriter::WriteTables(OutputStream& out) { return true; } -size_t OatWriter::WriteCode(OutputStream& out) { - uint32_t offset = oat_header_->GetExecutableOffset(); +size_t OatWriter::WriteCode(OutputStream& out, const size_t file_offset) { + size_t relative_offset = oat_header_->GetExecutableOffset(); off_t new_offset = out.Seek(size_executable_offset_alignment_, kSeekCurrent); - if (static_cast(new_offset) != offset) { + size_t expected_file_offset = file_offset + relative_offset; + if (static_cast(new_offset) != expected_file_offset) { PLOG(ERROR) << "Failed to seek to oat code section. Actual: " << new_offset - << " Expected: " << offset << " File: " << out.GetLocation(); + << " Expected: " << expected_file_offset << " File: " << out.GetLocation(); return 0; } DCHECK_OFFSET(); if (compiler_driver_->IsImage()) { InstructionSet instruction_set = compiler_driver_->GetInstructionSet(); - if (!out.WriteFully(&(*interpreter_to_interpreter_entry_)[0], interpreter_to_interpreter_entry_->size())) { + if (!out.WriteFully(&(*interpreter_to_interpreter_entry_)[0], + interpreter_to_interpreter_entry_->size())) { PLOG(ERROR) << "Failed to write interpreter to interpreter entry to " << out.GetLocation(); return false; } size_interpreter_to_interpreter_entry_ += interpreter_to_interpreter_entry_->size(); - offset += interpreter_to_interpreter_entry_->size(); + relative_offset += interpreter_to_interpreter_entry_->size(); DCHECK_OFFSET(); - uint32_t aligned_offset = CompiledCode::AlignCode(offset, instruction_set); - uint32_t alignment_padding = aligned_offset - offset; + uint32_t aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); + uint32_t alignment_padding = aligned_offset - relative_offset; out.Seek(alignment_padding, kSeekCurrent); size_stubs_alignment_ += alignment_padding; if (!out.WriteFully(&(*interpreter_to_quick_entry_)[0], interpreter_to_quick_entry_->size())) { @@ -561,60 +563,67 @@ size_t OatWriter::WriteCode(OutputStream& out) { return false; } size_interpreter_to_quick_entry_ += interpreter_to_quick_entry_->size(); - offset += alignment_padding + interpreter_to_quick_entry_->size(); + relative_offset += alignment_padding + interpreter_to_quick_entry_->size(); DCHECK_OFFSET(); - aligned_offset = CompiledCode::AlignCode(offset, instruction_set); - alignment_padding = aligned_offset - offset; + aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); + alignment_padding = aligned_offset - relative_offset; out.Seek(alignment_padding, kSeekCurrent); size_stubs_alignment_ += alignment_padding; - if (!out.WriteFully(&(*portable_resolution_trampoline_)[0], portable_resolution_trampoline_->size())) { + if (!out.WriteFully(&(*portable_resolution_trampoline_)[0], + portable_resolution_trampoline_->size())) { PLOG(ERROR) << "Failed to write portable resolution trampoline to " << out.GetLocation(); return false; } size_portable_resolution_trampoline_ += portable_resolution_trampoline_->size(); - offset += alignment_padding + portable_resolution_trampoline_->size(); + relative_offset += alignment_padding + portable_resolution_trampoline_->size(); DCHECK_OFFSET(); - aligned_offset = CompiledCode::AlignCode(offset, instruction_set); - alignment_padding = aligned_offset - offset; + aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); + alignment_padding = aligned_offset - relative_offset; out.Seek(alignment_padding, kSeekCurrent); size_stubs_alignment_ += alignment_padding; - if (!out.WriteFully(&(*quick_resolution_trampoline_)[0], quick_resolution_trampoline_->size())) { + if (!out.WriteFully(&(*quick_resolution_trampoline_)[0], + quick_resolution_trampoline_->size())) { PLOG(ERROR) << "Failed to write quick resolution trampoline to " << out.GetLocation(); return false; } size_quick_resolution_trampoline_ += quick_resolution_trampoline_->size(); - offset += alignment_padding + quick_resolution_trampoline_->size(); + relative_offset += alignment_padding + quick_resolution_trampoline_->size(); DCHECK_OFFSET(); } - return offset; + return relative_offset; } -size_t OatWriter::WriteCodeDexFiles(OutputStream& out, size_t code_offset) { +size_t OatWriter::WriteCodeDexFiles(OutputStream& out, + const size_t file_offset, + size_t relative_offset) { size_t oat_class_index = 0; for (size_t i = 0; i != oat_dex_files_.size(); ++i) { const DexFile* dex_file = (*dex_files_)[i]; CHECK(dex_file != NULL); - code_offset = WriteCodeDexFile(out, code_offset, oat_class_index, *dex_file); - if (code_offset == 0) { + relative_offset = WriteCodeDexFile(out, file_offset, relative_offset, oat_class_index, + *dex_file); + if (relative_offset == 0) { return 0; } } - return code_offset; + return relative_offset; } -size_t OatWriter::WriteCodeDexFile(OutputStream& out, size_t code_offset, size_t& oat_class_index, +size_t OatWriter::WriteCodeDexFile(OutputStream& out, const size_t file_offset, + size_t relative_offset, size_t& oat_class_index, const DexFile& dex_file) { for (size_t class_def_index = 0; class_def_index < dex_file.NumClassDefs(); class_def_index++, oat_class_index++) { const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); - code_offset = WriteCodeClassDef(out, code_offset, oat_class_index, dex_file, class_def); - if (code_offset == 0) { + relative_offset = WriteCodeClassDef(out, file_offset, relative_offset, oat_class_index, + dex_file, class_def); + if (relative_offset == 0) { return 0; } } - return code_offset; + return relative_offset; } void OatWriter::ReportWriteFailure(const char* what, uint32_t method_idx, @@ -624,13 +633,15 @@ void OatWriter::ReportWriteFailure(const char* what, uint32_t method_idx, } size_t OatWriter::WriteCodeClassDef(OutputStream& out, - size_t code_offset, size_t oat_class_index, + const size_t file_offset, + size_t relative_offset, + size_t oat_class_index, const DexFile& dex_file, const DexFile::ClassDef& class_def) { const byte* class_data = dex_file.GetClassData(class_def); if (class_data == NULL) { // ie. an empty class such as a marker interface - return code_offset; + return relative_offset; } ClassDataItemIterator it(dex_file, class_data); // Skip fields @@ -644,27 +655,29 @@ size_t OatWriter::WriteCodeClassDef(OutputStream& out, size_t class_def_method_index = 0; while (it.HasNextDirectMethod()) { bool is_static = (it.GetMemberAccessFlags() & kAccStatic) != 0; - code_offset = WriteCodeMethod(out, code_offset, oat_class_index, class_def_method_index, - is_static, it.GetMemberIndex(), dex_file); - if (code_offset == 0) { + relative_offset = WriteCodeMethod(out, file_offset, relative_offset, oat_class_index, + class_def_method_index, is_static, it.GetMemberIndex(), + dex_file); + if (relative_offset == 0) { return 0; } class_def_method_index++; it.Next(); } while (it.HasNextVirtualMethod()) { - code_offset = WriteCodeMethod(out, code_offset, oat_class_index, class_def_method_index, - false, it.GetMemberIndex(), dex_file); - if (code_offset == 0) { + relative_offset = WriteCodeMethod(out, file_offset, relative_offset, oat_class_index, + class_def_method_index, false, it.GetMemberIndex(), dex_file); + if (relative_offset == 0) { return 0; } class_def_method_index++; it.Next(); } - return code_offset; + return relative_offset; } -size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_class_index, +size_t OatWriter::WriteCodeMethod(OutputStream& out, const size_t file_offset, + size_t relative_offset, size_t oat_class_index, size_t class_def_method_index, bool is_static, uint32_t method_idx, const DexFile& dex_file) { const CompiledMethod* compiled_method = @@ -676,26 +689,27 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c if (compiled_method != NULL) { // ie. not an abstract method #if !defined(ART_USE_PORTABLE_COMPILER) - uint32_t aligned_offset = compiled_method->AlignCode(offset); - uint32_t aligned_code_delta = aligned_offset - offset; + uint32_t aligned_offset = compiled_method->AlignCode(relative_offset); + uint32_t aligned_code_delta = aligned_offset - relative_offset; if (aligned_code_delta != 0) { off_t new_offset = out.Seek(aligned_code_delta, kSeekCurrent); size_code_alignment_ += aligned_code_delta; - if (static_cast(new_offset) != aligned_offset) { + uint32_t expected_offset = file_offset + aligned_offset; + if (static_cast(new_offset) != expected_offset) { PLOG(ERROR) << "Failed to seek to align oat code. Actual: " << new_offset - << " Expected: " << aligned_offset << " File: " << out.GetLocation(); + << " Expected: " << expected_offset << " File: " << out.GetLocation(); return 0; } - offset += aligned_code_delta; + relative_offset += aligned_code_delta; DCHECK_OFFSET(); } - DCHECK_ALIGNED(offset, kArmAlignment); + DCHECK_ALIGNED(relative_offset, kArmAlignment); const std::vector& code = compiled_method->GetCode(); uint32_t code_size = code.size() * sizeof(code[0]); CHECK_NE(code_size, 0U); // Deduplicate code arrays - size_t code_offset = offset + sizeof(code_size) + compiled_method->CodeDelta(); + size_t code_offset = relative_offset + sizeof(code_size) + compiled_method->CodeDelta(); SafeMap*, uint32_t>::iterator code_iter = code_offsets_.find(&code); if (code_iter != code_offsets_.end() && code_offset != method_offsets.code_offset_) { DCHECK(code_iter->second == method_offsets.code_offset_) @@ -707,14 +721,14 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c return 0; } size_code_size_ += sizeof(code_size); - offset += sizeof(code_size); + relative_offset += sizeof(code_size); DCHECK_OFFSET(); if (!out.WriteFully(&code[0], code_size)) { ReportWriteFailure("method code", method_idx, dex_file, out); return 0; } size_code_ += code_size; - offset += code_size; + relative_offset += code_size; } DCHECK_OFFSET(); #endif @@ -726,20 +740,20 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c SafeMap*, uint32_t>::iterator mapping_iter = mapping_table_offsets_.find(&mapping_table); if (mapping_iter != mapping_table_offsets_.end() && - offset != method_offsets.mapping_table_offset_) { + relative_offset != method_offsets.mapping_table_offset_) { DCHECK((mapping_table_size == 0 && method_offsets.mapping_table_offset_ == 0) || mapping_iter->second == method_offsets.mapping_table_offset_) << PrettyMethod(method_idx, dex_file); } else { DCHECK((mapping_table_size == 0 && method_offsets.mapping_table_offset_ == 0) - || offset == method_offsets.mapping_table_offset_) + || relative_offset == method_offsets.mapping_table_offset_) << PrettyMethod(method_idx, dex_file); if (!out.WriteFully(&mapping_table[0], mapping_table_size)) { ReportWriteFailure("mapping table", method_idx, dex_file, out); return 0; } size_mapping_table_ += mapping_table_size; - offset += mapping_table_size; + relative_offset += mapping_table_size; } DCHECK_OFFSET(); @@ -750,20 +764,20 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c SafeMap*, uint32_t>::iterator vmap_iter = vmap_table_offsets_.find(&vmap_table); if (vmap_iter != vmap_table_offsets_.end() && - offset != method_offsets.vmap_table_offset_) { + relative_offset != method_offsets.vmap_table_offset_) { DCHECK((vmap_table_size == 0 && method_offsets.vmap_table_offset_ == 0) || vmap_iter->second == method_offsets.vmap_table_offset_) << PrettyMethod(method_idx, dex_file); } else { DCHECK((vmap_table_size == 0 && method_offsets.vmap_table_offset_ == 0) - || offset == method_offsets.vmap_table_offset_) + || relative_offset == method_offsets.vmap_table_offset_) << PrettyMethod(method_idx, dex_file); if (!out.WriteFully(&vmap_table[0], vmap_table_size)) { ReportWriteFailure("vmap table", method_idx, dex_file, out); return 0; } size_vmap_table_ += vmap_table_size; - offset += vmap_table_size; + relative_offset += vmap_table_size; } DCHECK_OFFSET(); @@ -774,25 +788,25 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_c SafeMap*, uint32_t>::iterator gc_map_iter = gc_map_offsets_.find(&gc_map); if (gc_map_iter != gc_map_offsets_.end() && - offset != method_offsets.gc_map_offset_) { + relative_offset != method_offsets.gc_map_offset_) { DCHECK((gc_map_size == 0 && method_offsets.gc_map_offset_ == 0) || gc_map_iter->second == method_offsets.gc_map_offset_) << PrettyMethod(method_idx, dex_file); } else { DCHECK((gc_map_size == 0 && method_offsets.gc_map_offset_ == 0) - || offset == method_offsets.gc_map_offset_) + || relative_offset == method_offsets.gc_map_offset_) << PrettyMethod(method_idx, dex_file); if (!out.WriteFully(&gc_map[0], gc_map_size)) { ReportWriteFailure("GC map", method_idx, dex_file, out); return 0; } size_gc_map_ += gc_map_size; - offset += gc_map_size; + relative_offset += gc_map_size; } DCHECK_OFFSET(); } - return offset; + return relative_offset; } OatWriter::OatDexFile::OatDexFile(size_t offset, const DexFile& dex_file) { @@ -822,7 +836,9 @@ void OatWriter::OatDexFile::UpdateChecksum(OatHeader& oat_header) const { sizeof(methods_offsets_[0]) * methods_offsets_.size()); } -bool OatWriter::OatDexFile::Write(OatWriter* oat_writer, OutputStream& out) const { +bool OatWriter::OatDexFile::Write(OatWriter* oat_writer, + OutputStream& out, + const size_t file_offset) const { DCHECK_OFFSET_(); if (!out.WriteFully(&dex_file_location_size_, sizeof(dex_file_location_size_))) { PLOG(ERROR) << "Failed to write dex file location length to " << out.GetLocation(); @@ -881,14 +897,16 @@ void OatWriter::OatClass::UpdateChecksum(OatHeader& oat_header) const { sizeof(method_offsets_[0]) * method_offsets_.size()); } -bool OatWriter::OatClass::Write(OatWriter* oat_writer, OutputStream& out) const { +bool OatWriter::OatClass::Write(OatWriter* oat_writer, + OutputStream& out, + const size_t file_offset) const { DCHECK_OFFSET_(); if (!out.WriteFully(&status_, sizeof(status_))) { PLOG(ERROR) << "Failed to write class status to " << out.GetLocation(); return false; } oat_writer->size_oat_class_status_ += sizeof(status_); - DCHECK_EQ(static_cast(GetOatMethodOffsetsOffsetFromOatHeader(0)), + DCHECK_EQ(static_cast(file_offset + GetOatMethodOffsetsOffsetFromOatHeader(0)), out.Seek(0, kSeekCurrent)); if (!out.WriteFully(&method_offsets_[0], sizeof(method_offsets_[0]) * method_offsets_.size())) { @@ -896,7 +914,8 @@ bool OatWriter::OatClass::Write(OatWriter* oat_writer, OutputStream& out) const return false; } oat_writer->size_oat_class_method_offsets_ += sizeof(method_offsets_[0]) * method_offsets_.size(); - DCHECK_EQ(static_cast(GetOatMethodOffsetsOffsetFromOatHeader(method_offsets_.size())), + DCHECK_EQ(static_cast(file_offset + + GetOatMethodOffsetsOffsetFromOatHeader(method_offsets_.size())), out.Seek(0, kSeekCurrent)); return true; } diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index ea7156ea49..f2c5626b4d 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -62,23 +62,25 @@ class OutputStream; // class OatWriter { public: - // Write an oat file. Returns true on success, false on failure. - static bool Create(OutputStream& out, - const std::vector& dex_files, - uint32_t image_file_location_oat_checksum, - uint32_t image_file_location_oat_begin, - const std::string& image_file_location, - const CompilerDriver& compiler) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - private: OatWriter(const std::vector& dex_files, uint32_t image_file_location_oat_checksum, uint32_t image_file_location_oat_begin, const std::string& image_file_location, const CompilerDriver* compiler) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + const OatHeader& GetOatHeader() const { + return *oat_header_; + } + + size_t GetSize() const { + return size_; + } + + bool Write(OutputStream& out); + ~OatWriter(); + private: size_t InitOatHeader(); size_t InitOatDexFiles(size_t offset); size_t InitDexFiles(size_t offset); @@ -101,17 +103,17 @@ class OatWriter { uint32_t method_idx, const DexFile*) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool Write(OutputStream& out); - bool WriteTables(OutputStream& out); - size_t WriteCode(OutputStream& out); - size_t WriteCodeDexFiles(OutputStream& out, size_t offset); - size_t WriteCodeDexFile(OutputStream& out, size_t offset, size_t& oat_class_index, - const DexFile& dex_file); - size_t WriteCodeClassDef(OutputStream& out, size_t offset, size_t oat_class_index, - const DexFile& dex_file, const DexFile::ClassDef& class_def); - size_t WriteCodeMethod(OutputStream& out, size_t offset, size_t oat_class_index, - size_t class_def_method_index, bool is_static, uint32_t method_idx, - const DexFile& dex_file); + bool WriteTables(OutputStream& out, const size_t file_offset); + size_t WriteCode(OutputStream& out, const size_t file_offset); + size_t WriteCodeDexFiles(OutputStream& out, const size_t file_offset, size_t relative_offset); + size_t WriteCodeDexFile(OutputStream& out, const size_t file_offset, size_t relative_offset, + size_t& oat_class_index, const DexFile& dex_file); + size_t WriteCodeClassDef(OutputStream& out, const size_t file_offset, size_t relative_offset, + size_t oat_class_index, const DexFile& dex_file, + const DexFile::ClassDef& class_def); + size_t WriteCodeMethod(OutputStream& out, const size_t file_offset, size_t relative_offset, + size_t oat_class_index, size_t class_def_method_index, bool is_static, + uint32_t method_idx, const DexFile& dex_file); void ReportWriteFailure(const char* what, uint32_t method_idx, const DexFile& dex_file, OutputStream& out) const; @@ -121,7 +123,7 @@ class OatWriter { explicit OatDexFile(size_t offset, const DexFile& dex_file); size_t SizeOf() const; void UpdateChecksum(OatHeader& oat_header) const; - bool Write(OatWriter* oat_writer, OutputStream& out) const; + bool Write(OatWriter* oat_writer, OutputStream& out, const size_t file_offset) const; // Offset of start of OatDexFile from beginning of OatHeader. It is // used to validate file position when writing. @@ -145,7 +147,7 @@ class OatWriter { size_t GetOatMethodOffsetsOffsetFromOatClass(size_t class_def_method_index_) const; size_t SizeOf() const; void UpdateChecksum(OatHeader& oat_header) const; - bool Write(OatWriter* oat_writer, OutputStream& out) const; + bool Write(OatWriter* oat_writer, OutputStream& out, const size_t file_offset) const; // Offset of start of OatClass from beginning of OatHeader. It is // used to validate file position when writing. For Portable, it @@ -167,6 +169,9 @@ class OatWriter { // note OatFile does not take ownership of the DexFiles const std::vector* dex_files_; + // Size required for Oat data structures. + size_t size_; + // dependencies on the image. uint32_t image_file_location_oat_checksum_; uint32_t image_file_location_oat_begin_; diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 0e32f0b9f2..1a6a98a2af 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -282,27 +282,14 @@ class Dex2Oat { } } - std::vector oat_contents; - // TODO: change ElfWriterQuick to not require the creation of oat_contents. The old pre-mclinker - // OatWriter streamed directly to disk. The new could can be adapted to do it as follows: - // 1.) use first pass of OatWriter to calculate size of oat structure, - // 2.) call ElfWriterQuick with pointer to OatWriter instead of contents, - // 3.) have ElfWriterQuick call back to OatWriter to stream generate the output directly in - // place in the elf file. - oat_contents.reserve(5 * MB); - VectorOutputStream vector_output_stream(oat_file->GetPath(), oat_contents); - if (!OatWriter::Create(vector_output_stream, - dex_files, - image_file_location_oat_checksum, - image_file_location_oat_data_begin, - image_file_location, - *driver.get())) { - LOG(ERROR) << "Failed to create oat file " << oat_file->GetPath(); - return NULL; - } + OatWriter oat_writer(dex_files, + image_file_location_oat_checksum, + image_file_location_oat_data_begin, + image_file_location, + driver.get()); timings.AddSplit("dex2oat OatWriter"); - if (!driver->WriteElf(android_root, is_host, dex_files, oat_contents, oat_file)) { + if (!driver->WriteElf(android_root, is_host, dex_files, oat_writer, oat_file)) { LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath(); return NULL; } @@ -1019,10 +1006,10 @@ static int dex2oat(int argc, char** argv) { *compiler.get()); timings.AddSplit("dex2oat ImageWriter"); Thread::Current()->TransitionFromSuspendedToRunnable(); - LOG(INFO) << "Image written successfully: " << image_filename; if (!image_creation_success) { return EXIT_FAILURE; } + LOG(INFO) << "Image written successfully: " << image_filename; } if (is_host) { diff --git a/runtime/image_test.cc b/runtime/image_test.cc index 11218ad513..75eead4d8f 100644 --- a/runtime/image_test.cc +++ b/runtime/image_test.cc @@ -41,7 +41,6 @@ class ImageTest : public CommonTest { TEST_F(ImageTest, WriteRead) { ScratchFile tmp_elf; { - std::vector oat_contents; { jobject class_loader = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -49,17 +48,14 @@ TEST_F(ImageTest, WriteRead) { compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); ScopedObjectAccess soa(Thread::Current()); - VectorOutputStream output_stream(tmp_elf.GetFilename(), oat_contents); - bool success_oat = OatWriter::Create(output_stream, class_linker->GetBootClassPath(), - 0, 0, "", *compiler_driver_.get()); - ASSERT_TRUE(success_oat); - - bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(), - !kIsTargetBuild, - class_linker->GetBootClassPath(), - oat_contents, - tmp_elf.GetFile()); - ASSERT_TRUE(success_elf); + OatWriter oat_writer(class_linker->GetBootClassPath(), + 0, 0, "", compiler_driver_.get()); + bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(), + !kIsTargetBuild, + class_linker->GetBootClassPath(), + oat_writer, + tmp_elf.GetFile()); + ASSERT_TRUE(success); } } // Workound bug that mcld::Linker::emit closes tmp_elf by reopening as tmp_oat. diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 9a6bc19b13..3f2e43e985 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -83,21 +83,17 @@ TEST_F(OatTest, WriteRead) { ScopedObjectAccess soa(Thread::Current()); ScratchFile tmp; - std::vector oat_contents; - VectorOutputStream output_stream(tmp.GetFilename(), oat_contents); - bool success_oat = OatWriter::Create(output_stream, - class_linker->GetBootClassPath(), - 42U, - 4096U, - "lue.art", - *compiler_driver_.get()); - ASSERT_TRUE(success_oat); - bool success_elf = compiler_driver_->WriteElf(GetTestAndroidRoot(), - !kIsTargetBuild, - class_linker->GetBootClassPath(), - oat_contents, - tmp.GetFile()); - ASSERT_TRUE(success_elf); + OatWriter oat_writer(class_linker->GetBootClassPath(), + 42U, + 4096U, + "lue.art", + compiler_driver_.get()); + bool success = compiler_driver_->WriteElf(GetTestAndroidRoot(), + !kIsTargetBuild, + class_linker->GetBootClassPath(), + oat_writer, + tmp.GetFile()); + ASSERT_TRUE(success); if (compile) { // OatWriter strips the code, regenerate to compare TimingLogger timings("CommonTest::WriteRead", false); -- cgit v1.2.3-59-g8ed1b From 6f28d91aab952e3244fbb4e707fa38f85538f374 Mon Sep 17 00:00:00 2001 From: Anwar Ghuloum Date: Wed, 24 Jul 2013 15:02:53 -0700 Subject: Add systrace support to NewTimingLogger, migrate compiler timing logging to NewTimingLogger Rpleaced old TimingLogger by NewTimingLogger, renamed NewTimingLogger to TimingLogger, added systrace support to TimingLogger. Tests passing, phone booting, systrace working. Change-Id: I2aeffb8bcb7f0fd979d8a2a3a8bcfbaa02413679 --- compiler/driver/compiler_driver.cc | 41 ++++++++--------- compiler/driver/compiler_driver.h | 26 +++++------ compiler/driver/compiler_driver_test.cc | 2 +- dex2oat/dex2oat.cc | 22 ++++----- runtime/base/timing_logger.cc | 77 +++++++------------------------- runtime/base/timing_logger.h | 35 +++------------ runtime/common_test.h | 2 +- runtime/gc/collector/garbage_collector.h | 4 +- runtime/gc/collector/mark_sweep.cc | 2 +- runtime/gc/heap.cc | 6 +-- runtime/gc/heap.h | 4 +- runtime/image_test.cc | 2 +- runtime/oat_test.cc | 4 +- 13 files changed, 83 insertions(+), 144 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index c2a1312354..2aa2a98efb 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -495,7 +495,7 @@ const std::vector* CompilerDriver::CreateInterpreterToQuickEntry() cons void CompilerDriver::CompileAll(jobject class_loader, const std::vector& dex_files, - TimingLogger& timings) { + base::TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); UniquePtr thread_pool(new ThreadPool(thread_count_)); PreCompile(class_loader, dex_files, *thread_pool.get(), timings); @@ -528,7 +528,7 @@ static bool IsDexToDexCompilationAllowed(mirror::ClassLoader* class_loader, return klass->IsVerified(); } -void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings) { +void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); Thread* self = Thread::Current(); jobject jclass_loader; @@ -572,7 +572,7 @@ void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, TimingLogg } void CompilerDriver::Resolve(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; CHECK(dex_file != NULL); @@ -581,7 +581,7 @@ void CompilerDriver::Resolve(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { LoadImageClasses(timings); Resolve(class_loader, dex_files, thread_pool, timings); @@ -666,12 +666,13 @@ static bool RecordImageClassesVisitor(mirror::Class* klass, void* arg) } // Make a list of descriptors for classes to include in the image -void CompilerDriver::LoadImageClasses(TimingLogger& timings) +void CompilerDriver::LoadImageClasses(base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_) { if (image_classes_.get() == NULL) { return; } + timings.NewSplit("LoadImageClasses"); // Make a first class to load all classes explicitly listed in the file Thread* self = Thread::Current(); ScopedObjectAccess soa(self); @@ -726,7 +727,6 @@ void CompilerDriver::LoadImageClasses(TimingLogger& timings) class_linker->VisitClasses(RecordImageClassesVisitor, image_classes_.get()); CHECK_NE(image_classes_->size(), 0U); - timings.AddSplit("LoadImageClasses"); } static void MaybeAddToImageClasses(mirror::Class* klass, CompilerDriver::DescriptorSet* image_classes) @@ -758,11 +758,13 @@ void CompilerDriver::FindClinitImageClassesCallback(mirror::Object* object, void MaybeAddToImageClasses(object->GetClass(), compiler_driver->image_classes_.get()); } -void CompilerDriver::UpdateImageClasses(TimingLogger& timings) { +void CompilerDriver::UpdateImageClasses(base::TimingLogger& timings) { if (image_classes_.get() == NULL) { return; } + timings.NewSplit("UpdateImageClasses"); + // Update image_classes_ with classes for objects created by methods. Thread* self = Thread::Current(); const char* old_cause = self->StartAssertNoThreadSuspension("ImageWriter"); @@ -772,7 +774,6 @@ void CompilerDriver::UpdateImageClasses(TimingLogger& timings) { heap->FlushAllocStack(); heap->GetLiveBitmap()->Walk(FindClinitImageClassesCallback, this); self->EndAssertNoThreadSuspension(old_cause); - timings.AddSplit("UpdateImageClasses"); } void CompilerDriver::RecordClassStatus(ClassReference ref, CompiledClass* compiled_class) { @@ -1551,22 +1552,22 @@ static void ResolveType(const ParallelCompilationManager* manager, size_t type_i } void CompilerDriver::ResolveDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); // TODO: we could resolve strings here, although the string table is largely filled with class // and method names. + timings.NewSplit(strdup(("Resolve " + dex_file.GetLocation() + " Types").c_str())); ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, thread_pool); context.ForAll(0, dex_file.NumTypeIds(), ResolveType, thread_count_); - timings.AddSplit("Resolve " + dex_file.GetLocation() + " Types"); + timings.NewSplit(strdup(("Resolve " + dex_file.GetLocation() + " MethodsAndFields").c_str())); context.ForAll(0, dex_file.NumClassDefs(), ResolveClassFieldsAndMethods, thread_count_); - timings.AddSplit("Resolve " + dex_file.GetLocation() + " MethodsAndFields"); } void CompilerDriver::Verify(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; CHECK(dex_file != NULL); @@ -1620,11 +1621,11 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ } void CompilerDriver::VerifyDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { + timings.NewSplit(strdup(("Verify " + dex_file.GetLocation()).c_str())); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, thread_pool); context.ForAll(0, dex_file.NumClassDefs(), VerifyClass, thread_count_); - timings.AddSplit("Verify " + dex_file.GetLocation()); } static const char* class_initializer_black_list[] = { @@ -2116,7 +2117,8 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl } void CompilerDriver::InitializeClasses(jobject jni_class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { + timings.NewSplit(strdup(("InitializeNoClinit " + dex_file.GetLocation()).c_str())); #ifndef NDEBUG for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) { const char* descriptor = class_initializer_black_list[i]; @@ -2126,12 +2128,11 @@ void CompilerDriver::InitializeClasses(jobject jni_class_loader, const DexFile& ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ParallelCompilationManager context(class_linker, jni_class_loader, this, &dex_file, thread_pool); context.ForAll(0, dex_file.NumClassDefs(), InitializeClass, thread_count_); - timings.AddSplit("InitializeNoClinit " + dex_file.GetLocation()); } void CompilerDriver::InitializeClasses(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; CHECK(dex_file != NULL); @@ -2140,7 +2141,7 @@ void CompilerDriver::InitializeClasses(jobject class_loader, } void CompilerDriver::Compile(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; CHECK(dex_file != NULL); @@ -2220,10 +2221,10 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz } void CompilerDriver::CompileDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) { + ThreadPool& thread_pool, base::TimingLogger& timings) { + timings.NewSplit(strdup(("Compile " + dex_file.GetLocation()).c_str())); ParallelCompilationManager context(NULL, class_loader, this, &dex_file, thread_pool); context.ForAll(0, dex_file.NumClassDefs(), CompilerDriver::CompileClass, thread_count_); - timings.AddSplit("Compile " + dex_file.GetLocation()); } void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index f3f72dd3c7..a7a47ed876 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -78,11 +78,11 @@ class CompilerDriver { ~CompilerDriver(); void CompileAll(jobject class_loader, const std::vector& dex_files, - TimingLogger& timings) + base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); // Compile a single Method - void CompileOne(const mirror::AbstractMethod* method, TimingLogger& timings) + void CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); InstructionSet GetInstructionSet() const { @@ -284,42 +284,42 @@ class CompilerDriver { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void PreCompile(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); - void LoadImageClasses(TimingLogger& timings); + void LoadImageClasses(base::TimingLogger& timings); // Attempt to resolve all type, methods, fields, and strings // referenced from code in the dex file following PathClassLoader // ordering semantics. void Resolve(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void ResolveDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void Verify(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings); + ThreadPool& thread_pool, base::TimingLogger& timings); void VerifyDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void InitializeClasses(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void InitializeClasses(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_, compiled_classes_lock_); - void UpdateImageClasses(TimingLogger& timings); + void UpdateImageClasses(base::TimingLogger& timings); static void FindClinitImageClassesCallback(mirror::Object* object, void* arg) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void Compile(jobject class_loader, const std::vector& dex_files, - ThreadPool& thread_pool, TimingLogger& timings); + ThreadPool& thread_pool, base::TimingLogger& timings); void CompileDexFile(jobject class_loader, const DexFile& dex_file, - ThreadPool& thread_pool, TimingLogger& timings) + ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint32_t class_def_idx, uint32_t method_idx, diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 78cacaf08e..b06a3180fb 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -36,7 +36,7 @@ namespace art { class CompilerDriverTest : public CommonTest { protected: void CompileAll(jobject class_loader) LOCKS_EXCLUDED(Locks::mutator_lock_) { - TimingLogger timings("CompilerDriverTest::CompileAll", false); + base::TimingLogger timings("CompilerDriverTest::CompileAll", false, false); compiler_driver_->CompileAll(class_loader, Runtime::Current()->GetCompileTimeClassPath(class_loader), timings); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 1a6a98a2af..fb6f775675 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -230,7 +230,7 @@ class Dex2Oat { bool image, UniquePtr& image_classes, bool dump_stats, - TimingLogger& timings) + base::TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // SirtRef and ClassLoader creation needs to come after Runtime::Create jobject class_loader = NULL; @@ -263,11 +263,11 @@ class Dex2Oat { Thread::Current()->TransitionFromRunnableToSuspended(kNative); - timings.AddSplit("dex2oat Setup"); driver->CompileAll(class_loader, dex_files, timings); Thread::Current()->TransitionFromSuspendedToRunnable(); + timings.NewSplit("dex2oat OatWriter"); std::string image_file_location; uint32_t image_file_location_oat_checksum = 0; uint32_t image_file_location_oat_data_begin = 0; @@ -287,13 +287,11 @@ class Dex2Oat { image_file_location_oat_data_begin, image_file_location, driver.get()); - timings.AddSplit("dex2oat OatWriter"); if (!driver->WriteElf(android_root, is_host, dex_files, oat_writer, oat_file)) { LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath(); return NULL; } - timings.AddSplit("dex2oat ElfWriter"); return driver.release(); } @@ -563,7 +561,7 @@ const unsigned int WatchDog::kWatchDogWarningSeconds; const unsigned int WatchDog::kWatchDogTimeoutSeconds; static int dex2oat(int argc, char** argv) { - TimingLogger timings("compiler", false); + base::TimingLogger timings("compiler", false, false); InitLogging(argv); @@ -928,6 +926,7 @@ static int dex2oat(int argc, char** argv) { } } + timings.StartSplit("dex2oat Setup"); UniquePtr compiler(dex2oat->CreateOatFile(boot_image_option, host_prefix.get(), android_root, @@ -998,13 +997,13 @@ static int dex2oat(int argc, char** argv) { // Elf32_Phdr.p_vaddr values by the desired base address. // if (image) { + timings.NewSplit("dex2oat ImageWriter"); Thread::Current()->TransitionFromRunnableToSuspended(kNative); bool image_creation_success = dex2oat->CreateImageFile(image_filename, image_base, oat_unstripped, oat_location, *compiler.get()); - timings.AddSplit("dex2oat ImageWriter"); Thread::Current()->TransitionFromSuspendedToRunnable(); if (!image_creation_success) { return EXIT_FAILURE; @@ -1014,7 +1013,7 @@ static int dex2oat(int argc, char** argv) { if (is_host) { if (dump_timings && timings.GetTotalNs() > MsToNs(1000)) { - LOG(INFO) << Dumpable(timings); + LOG(INFO) << Dumpable(timings); } return EXIT_SUCCESS; } @@ -1022,6 +1021,7 @@ static int dex2oat(int argc, char** argv) { // If we don't want to strip in place, copy from unstripped location to stripped location. // We need to strip after image creation because FixupElf needs to use .strtab. if (oat_unstripped != oat_stripped) { + timings.NewSplit("dex2oat OatFile copy"); oat_file.reset(); UniquePtr in(OS::OpenFile(oat_unstripped.c_str(), false)); UniquePtr out(OS::OpenFile(oat_stripped.c_str(), true)); @@ -1036,23 +1036,25 @@ static int dex2oat(int argc, char** argv) { CHECK(write_ok); } oat_file.reset(out.release()); - timings.AddSplit("dex2oat OatFile copy"); LOG(INFO) << "Oat file copied successfully (stripped): " << oat_stripped; } #if ART_USE_PORTABLE_COMPILER // We currently only generate symbols on Portable + timings.NewSplit("dex2oat ElfStripper"); // Strip unneeded sections for target off_t seek_actual = lseek(oat_file->Fd(), 0, SEEK_SET); CHECK_EQ(0, seek_actual); ElfStripper::Strip(oat_file.get()); - timings.AddSplit("dex2oat ElfStripper"); + // We wrote the oat file successfully, and want to keep it. LOG(INFO) << "Oat file written successfully (stripped): " << oat_location; #endif // ART_USE_PORTABLE_COMPILER + timings.EndSplit(); + if (dump_timings && timings.GetTotalNs() > MsToNs(1000)) { - LOG(INFO) << Dumpable(timings); + LOG(INFO) << Dumpable(timings); } return EXIT_SUCCESS; } diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc index bf6fd17a49..dfb0220d46 100644 --- a/runtime/base/timing_logger.cc +++ b/runtime/base/timing_logger.cc @@ -14,6 +14,11 @@ * limitations under the License. */ + +#define ATRACE_TAG ATRACE_TAG_DALVIK +#include +#include + #include "timing_logger.h" #include "base/logging.h" @@ -26,49 +31,6 @@ namespace art { -void TimingLogger::Reset() { - times_.clear(); - labels_.clear(); - AddSplit(""); -} - -TimingLogger::TimingLogger(const std::string &name, bool precise) - : name_(name), - precise_(precise) { - AddSplit(""); -} - -void TimingLogger::AddSplit(const std::string &label) { - times_.push_back(NanoTime()); - labels_.push_back(label); -} - -uint64_t TimingLogger::GetTotalNs() const { - return times_.back() - times_.front(); -} - -void TimingLogger::Dump(std::ostream &os) const { - uint64_t largest_time = 0; - os << name_ << ": begin\n"; - for (size_t i = 1; i < times_.size(); ++i) { - uint64_t delta_time = times_[i] - times_[i - 1]; - largest_time = std::max(largest_time, delta_time); - } - // Compute which type of unit we will use for printing the timings. - TimeUnit tu = GetAppropriateTimeUnit(largest_time); - uint64_t divisor = GetNsToTimeUnitDivisor(tu); - for (size_t i = 1; i < times_.size(); ++i) { - uint64_t delta_time = times_[i] - times_[i - 1]; - if (!precise_ && divisor >= 1000) { - // Make the fraction 0. - delta_time -= delta_time % (divisor / 1000); - } - os << name_ << ": " << std::setw(8) << FormatDuration(delta_time, tu) << " " - << labels_[i] << "\n"; - } - os << name_ << ": end, " << NsToMs(GetTotalNs()) << " ms\n"; -} - CumulativeLogger::CumulativeLogger(const std::string& name) : name_(name), lock_name_("CumulativeLoggerLock" + name), @@ -112,17 +74,8 @@ uint64_t CumulativeLogger::GetTotalTime() const { return total; } -void CumulativeLogger::AddLogger(const TimingLogger &logger) { - MutexLock mu(Thread::Current(), lock_); - DCHECK_EQ(logger.times_.size(), logger.labels_.size()); - for (size_t i = 1; i < logger.times_.size(); ++i) { - const uint64_t delta_time = logger.times_[i] - logger.times_[i - 1]; - const std::string &label = logger.labels_[i]; - AddPair(label, delta_time); - } -} -void CumulativeLogger::AddNewLogger(const base::NewTimingLogger &logger) { +void CumulativeLogger::AddLogger(const base::TimingLogger &logger) { MutexLock mu(Thread::Current(), lock_); const std::vector >& splits = logger.GetSplits(); typedef std::vector >::const_iterator It; @@ -183,51 +136,55 @@ void CumulativeLogger::DumpHistogram(std::ostream &os) { namespace base { -NewTimingLogger::NewTimingLogger(const char* name, bool precise, bool verbose) +TimingLogger::TimingLogger(const char* name, bool precise, bool verbose) : name_(name), precise_(precise), verbose_(verbose), current_split_(NULL), current_split_start_ns_(0) { } -void NewTimingLogger::Reset() { +void TimingLogger::Reset() { current_split_ = NULL; current_split_start_ns_ = 0; splits_.clear(); } -void NewTimingLogger::StartSplit(const char* new_split_label) { +void TimingLogger::StartSplit(const char* new_split_label) { DCHECK(current_split_ == NULL); if (verbose_) { LOG(INFO) << "Begin: " << new_split_label; } current_split_ = new_split_label; + ATRACE_BEGIN(current_split_); current_split_start_ns_ = NanoTime(); } // Ends the current split and starts the one given by the label. -void NewTimingLogger::NewSplit(const char* new_split_label) { +void TimingLogger::NewSplit(const char* new_split_label) { DCHECK(current_split_ != NULL); uint64_t current_time = NanoTime(); uint64_t split_time = current_time - current_split_start_ns_; + ATRACE_END(); splits_.push_back(std::pair(split_time, current_split_)); if (verbose_) { LOG(INFO) << "End: " << current_split_ << " " << PrettyDuration(split_time) << "\n" << "Begin: " << new_split_label; } current_split_ = new_split_label; + ATRACE_BEGIN(current_split_); current_split_start_ns_ = current_time; } -void NewTimingLogger::EndSplit() { +void TimingLogger::EndSplit() { DCHECK(current_split_ != NULL); uint64_t current_time = NanoTime(); uint64_t split_time = current_time - current_split_start_ns_; + ATRACE_END(); if (verbose_) { LOG(INFO) << "End: " << current_split_ << " " << PrettyDuration(split_time); } splits_.push_back(std::pair(split_time, current_split_)); } -uint64_t NewTimingLogger::GetTotalNs() const { +uint64_t TimingLogger::GetTotalNs() const { uint64_t total_ns = 0; typedef std::vector >::const_iterator It; for (It it = splits_.begin(), end = splits_.end(); it != end; ++it) { @@ -237,7 +194,7 @@ uint64_t NewTimingLogger::GetTotalNs() const { return total_ns; } -void NewTimingLogger::Dump(std::ostream &os) const { +void TimingLogger::Dump(std::ostream &os) const { uint64_t longest_split = 0; uint64_t total_ns = 0; typedef std::vector >::const_iterator It; diff --git a/runtime/base/timing_logger.h b/runtime/base/timing_logger.h index 0f00a046e5..0998837517 100644 --- a/runtime/base/timing_logger.h +++ b/runtime/base/timing_logger.h @@ -26,27 +26,8 @@ namespace art { -class CumulativeLogger; - -class TimingLogger { - public: - explicit TimingLogger(const std::string& name, bool precise); - void AddSplit(const std::string& label); - void Dump(std::ostream& os) const; - void Reset(); - uint64_t GetTotalNs() const; - - protected: - const std::string name_; - const bool precise_; - std::vector times_; - std::vector labels_; - - friend class CumulativeLogger; -}; - namespace base { - class NewTimingLogger; + class TimingLogger; } // namespace base class CumulativeLogger { @@ -62,8 +43,7 @@ class CumulativeLogger { // Allow the name to be modified, particularly when the cumulative logger is a field within a // parent class that is unable to determine the "name" of a sub-class. void SetName(const std::string& name); - void AddLogger(const TimingLogger& logger) LOCKS_EXCLUDED(lock_); - void AddNewLogger(const base::NewTimingLogger& logger) LOCKS_EXCLUDED(lock_); + void AddLogger(const base::TimingLogger& logger) LOCKS_EXCLUDED(lock_); private: void AddPair(const std::string &label, uint64_t delta_time) @@ -84,16 +64,15 @@ class CumulativeLogger { namespace base { // A replacement to timing logger that know when a split starts for the purposes of logging. -// TODO: replace uses of TimingLogger with base::NewTimingLogger. -class NewTimingLogger { +class TimingLogger { public: - explicit NewTimingLogger(const char* name, bool precise, bool verbose); + explicit TimingLogger(const char* name, bool precise, bool verbose); // Clears current splits and labels. void Reset(); // Starts a split, a split shouldn't be in progress. - void StartSplit(const char* new_split_label); + void StartSplit(const char* new_split_label); // Ends the current split and starts the one given by the label. void NewSplit(const char* new_split_label); @@ -111,7 +90,7 @@ class NewTimingLogger { protected: // The name of the timing logger. - const std::string name_; + const char* name_; // Do we want to print the exactly recorded split (true) or round down to the time unit being // used (false). @@ -130,7 +109,7 @@ class NewTimingLogger { std::vector > splits_; private: - DISALLOW_COPY_AND_ASSIGN(NewTimingLogger); + DISALLOW_COPY_AND_ASSIGN(TimingLogger); }; } // namespace base diff --git a/runtime/common_test.h b/runtime/common_test.h index 09ad7fd7b7..4fe9be6d8f 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -473,7 +473,7 @@ class CommonTest : public testing::Test { void CompileMethod(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); - TimingLogger timings("CommonTest::CompileMethod", false); + base::TimingLogger timings("CommonTest::CompileMethod", false, false); compiler_driver_->CompileOne(method, timings); MakeExecutable(method); } diff --git a/runtime/gc/collector/garbage_collector.h b/runtime/gc/collector/garbage_collector.h index 1684664eff..0f566c954b 100644 --- a/runtime/gc/collector/garbage_collector.h +++ b/runtime/gc/collector/garbage_collector.h @@ -64,7 +64,7 @@ class GarbageCollector { void RegisterPause(uint64_t nano_length); - base::NewTimingLogger& GetTimings() { + base::TimingLogger& GetTimings() { return timings_; } @@ -101,7 +101,7 @@ class GarbageCollector { const bool verbose_; uint64_t duration_ns_; - base::NewTimingLogger timings_; + base::TimingLogger timings_; // Cumulative statistics. uint64_t total_time_ns_; diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index c8e60322d6..0cbd6fb267 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -1509,7 +1509,7 @@ void MarkSweep::FinishPhase() { // Update the cumulative loggers. cumulative_timings_.Start(); - cumulative_timings_.AddNewLogger(timings_); + cumulative_timings_.AddLogger(timings_); cumulative_timings_.End(); // Clear all of the spaces' mark bitmaps. diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 1c1818873a..b0ba8b6874 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -1131,7 +1131,7 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCaus << PrettySize(total_memory) << ", " << "paused " << pause_string.str() << " total " << PrettyDuration((duration / 1000) * 1000); if (VLOG_IS_ON(heap)) { - LOG(INFO) << Dumpable(collector->GetTimings()); + LOG(INFO) << Dumpable(collector->GetTimings()); } } @@ -1149,7 +1149,7 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCaus return gc_type; } -void Heap::UpdateAndMarkModUnion(collector::MarkSweep* mark_sweep, base::NewTimingLogger& timings, +void Heap::UpdateAndMarkModUnion(collector::MarkSweep* mark_sweep, base::TimingLogger& timings, collector::GcType gc_type) { if (gc_type == collector::kGcTypeSticky) { // Don't need to do anything for mod union table in this case since we are only scanning dirty @@ -1441,7 +1441,7 @@ void Heap::SwapStacks() { } } -void Heap::ProcessCards(base::NewTimingLogger& timings) { +void Heap::ProcessCards(base::TimingLogger& timings) { // Clear cards and keep track of cards cleared in the mod-union table. typedef std::vector::iterator It; for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index b7b2e84942..b71c2bc421 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -379,7 +379,7 @@ class Heap { EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); // Update and mark mod union table based on gc type. - void UpdateAndMarkModUnion(collector::MarkSweep* mark_sweep, base::NewTimingLogger& timings, + void UpdateAndMarkModUnion(collector::MarkSweep* mark_sweep, base::TimingLogger& timings, collector::GcType gc_type) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); @@ -472,7 +472,7 @@ class Heap { void SwapStacks(); // Clear cards and update the mod union table. - void ProcessCards(base::NewTimingLogger& timings); + void ProcessCards(base::TimingLogger& timings); // All-known continuous spaces, where objects lie within fixed bounds. std::vector continuous_spaces_; diff --git a/runtime/image_test.cc b/runtime/image_test.cc index 75eead4d8f..92ee1f83c6 100644 --- a/runtime/image_test.cc +++ b/runtime/image_test.cc @@ -44,7 +44,7 @@ TEST_F(ImageTest, WriteRead) { { jobject class_loader = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - TimingLogger timings("ImageTest::WriteRead", false); + base::TimingLogger timings("ImageTest::WriteRead", false, false); compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); ScopedObjectAccess soa(Thread::Current()); diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 3f2e43e985..217e2d8743 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -77,7 +77,7 @@ TEST_F(OatTest, WriteRead) { compiler_driver_.reset(new CompilerDriver(compiler_backend, kThumb2, false, NULL, 2, true)); jobject class_loader = NULL; if (compile) { - TimingLogger timings("OatTest::WriteRead", false); + base::TimingLogger timings("OatTest::WriteRead", false, false); compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); } @@ -96,7 +96,7 @@ TEST_F(OatTest, WriteRead) { ASSERT_TRUE(success); if (compile) { // OatWriter strips the code, regenerate to compare - TimingLogger timings("CommonTest::WriteRead", false); + base::TimingLogger timings("CommonTest::WriteRead", false, false); compiler_driver_->CompileAll(class_loader, class_linker->GetBootClassPath(), timings); } UniquePtr oat_file(OatFile::Open(tmp.GetFilename(), tmp.GetFilename(), NULL, false)); -- cgit v1.2.3-59-g8ed1b From 75021222d9c03a80fa5c136db0d5fb8d82d04031 Mon Sep 17 00:00:00 2001 From: Sebastien Hertz Date: Tue, 16 Jul 2013 18:34:50 +0200 Subject: Adds a DEX-to-DEX compilation level. This CL adds a DEX-to-DEX compilation level which allows the DEX-to-DEX compiler to ensure correctness on classes with soft-failed verification. Bug: 9307738 Change-Id: If051336bf81370bca55872c8c75ccd573d8ca391 --- compiler/dex/dex_to_dex_compiler.cc | 35 ++++++++++++-------- compiler/driver/compiler_driver.cc | 64 +++++++++++++++++++++---------------- compiler/driver/compiler_driver.h | 17 ++++++++-- 3 files changed, 74 insertions(+), 42 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 3c491ce20f..1ee29cbae1 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -36,9 +36,11 @@ const bool kEnableCheckCastEllision = true; class DexCompiler { public: DexCompiler(art::CompilerDriver& compiler, - const DexCompilationUnit& unit) + const DexCompilationUnit& unit, + DexToDexCompilationLevel dex_to_dex_compilation_level) : driver_(compiler), - unit_(unit) {} + unit_(unit), + dex_to_dex_compilation_level_(dex_to_dex_compilation_level) {} ~DexCompiler() {} @@ -55,6 +57,10 @@ class DexCompiler { return *const_cast(unit_.GetDexFile()); } + bool PerformOptimizations() const { + return dex_to_dex_compilation_level_ >= kOptimize; + } + // Compiles a RETURN-VOID into a RETURN-VOID-BARRIER within a constructor where // a barrier is required. void CompileReturnVoid(Instruction* inst, uint32_t dex_pc); @@ -84,6 +90,7 @@ class DexCompiler { CompilerDriver& driver_; const DexCompilationUnit& unit_; + const DexToDexCompilationLevel dex_to_dex_compilation_level_; DISALLOW_COPY_AND_ASSIGN(DexCompiler); }; @@ -138,6 +145,7 @@ class ScopedDexWriteAccess { }; void DexCompiler::Compile() { + DCHECK_GE(dex_to_dex_compilation_level_, kRequired); const DexFile::CodeItem* code_item = unit_.GetCodeItem(); const uint16_t* insns = code_item->insns_; const uint32_t insns_size = code_item->insns_size_in_code_units_; @@ -220,7 +228,7 @@ void DexCompiler::CompileReturnVoid(Instruction* inst, uint32_t dex_pc) { } Instruction* DexCompiler::CompileCheckCast(Instruction* inst, uint32_t dex_pc) { - if (!kEnableCheckCastEllision) { + if (!kEnableCheckCastEllision || !PerformOptimizations()) { return inst; } MethodReference referrer(&GetDexFile(), unit_.GetDexMethodIndex()); @@ -253,7 +261,7 @@ void DexCompiler::CompileInstanceFieldAccess(Instruction* inst, uint32_t dex_pc, Instruction::Code new_opcode, bool is_put) { - if (!kEnableQuickening) { + if (!kEnableQuickening || !PerformOptimizations()) { return; } uint32_t field_idx = inst->VRegC_22c(); @@ -280,7 +288,7 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, uint32_t dex_pc, Instruction::Code new_opcode, bool is_range) { - if (!kEnableQuickening) { + if (!kEnableQuickening || !PerformOptimizations()) { return; } uint32_t method_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); @@ -320,14 +328,15 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, } // namespace optimizer } // namespace art -extern "C" art::CompiledMethod* - ArtCompileDEX(art::CompilerDriver& compiler, const art::DexFile::CodeItem* code_item, +extern "C" void ArtCompileDEX(art::CompilerDriver& compiler, 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) { - art::DexCompilationUnit unit(NULL, class_loader, art::Runtime::Current()->GetClassLinker(), - dex_file, code_item, class_def_idx, method_idx, access_flags); - art::optimizer::DexCompiler dex_compiler(compiler, unit); - dex_compiler.Compile(); - return NULL; + const art::DexFile& dex_file, + art::DexToDexCompilationLevel dex_to_dex_compilation_level) { + if (dex_to_dex_compilation_level != art::kDontDexToDexCompile) { + art::DexCompilationUnit unit(NULL, class_loader, art::Runtime::Current()->GetClassLinker(), + dex_file, code_item, class_def_idx, method_idx, access_flags); + art::optimizer::DexCompiler dex_compiler(compiler, unit, dex_to_dex_compilation_level); + dex_compiler.Compile(); + } } diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 49aba4d6a9..38d00a0804 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -369,7 +369,7 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet compiler_ = reinterpret_cast(ArtQuickCompileMethod); } - dex_to_dex_compiler_ = reinterpret_cast(ArtCompileDEX); + dex_to_dex_compiler_ = reinterpret_cast(ArtCompileDEX); #ifdef ART_SEA_IR_MODE sea_ir_compiler_ = NULL; @@ -505,16 +505,10 @@ void CompilerDriver::CompileAll(jobject class_loader, } } -static bool IsDexToDexCompilationAllowed(mirror::ClassLoader* class_loader, - const DexFile& dex_file, - const DexFile::ClassDef& class_def) +static DexToDexCompilationLevel GetDexToDexCompilationlevel(mirror::ClassLoader* class_loader, + const DexFile& dex_file, + const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - // Do not allow DEX-to-DEX compilation of image classes. This is to prevent the - // verifier from passing on "quick" instruction at compilation time. It must - // only pass on quick instructions at runtime. - if (class_loader == NULL) { - return false; - } const char* descriptor = dex_file.GetClassDescriptor(class_def); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); mirror::Class* klass = class_linker->FindClass(descriptor, class_loader); @@ -522,10 +516,27 @@ static bool IsDexToDexCompilationAllowed(mirror::ClassLoader* class_loader, Thread* self = Thread::Current(); CHECK(self->IsExceptionPending()); self->ClearException(); - return false; + return kDontDexToDexCompile; + } + // The verifier can only run on "quick" instructions at runtime (see usage of + // FindAccessedFieldAtDexPc and FindInvokedMethodAtDexPc in ThrowNullPointerExceptionFromDexPC + // function). Since image classes can be verified again while compiling an application, + // we must prevent the DEX-to-DEX compiler from introducing them. + // TODO: find a way to enable "quick" instructions for image classes and remove this check. + bool compiling_image_classes = (class_loader == NULL); + if (compiling_image_classes) { + return kRequired; + } else if (klass->IsVerified()) { + // Class is verified so we can enable DEX-to-DEX compilation for performance. + return kOptimize; + } else if (klass->IsCompileTimeVerified()) { + // Class verification has soft-failed. Anyway, ensure at least correctness. + DCHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime); + return kRequired; + } else { + // Class verification has failed: do not run DEX-to-DEX compilation. + return kDontDexToDexCompile; } - // DEX-to-DEX compilation is only allowed on preverified classes. - return klass->IsVerified(); } void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) { @@ -556,15 +567,15 @@ void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, base::Timi uint32_t method_idx = method->GetDexMethodIndex(); const DexFile::CodeItem* code_item = dex_file->GetCodeItem(method->GetCodeItemOffset()); // Can we run DEX-to-DEX compiler on this class ? - bool allow_dex_compilation; + DexToDexCompilationLevel dex_to_dex_compilation_level = kDontDexToDexCompile; { ScopedObjectAccess soa(Thread::Current()); const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_idx); mirror::ClassLoader* class_loader = soa.Decode(jclass_loader); - allow_dex_compilation = IsDexToDexCompilationAllowed(class_loader, *dex_file, class_def); + dex_to_dex_compilation_level = GetDexToDexCompilationlevel(class_loader, *dex_file, class_def); } CompileMethod(code_item, method->GetAccessFlags(), method->GetInvokeType(), - class_def_idx, method_idx, jclass_loader, *dex_file, allow_dex_compilation); + class_def_idx, method_idx, jclass_loader, *dex_file, dex_to_dex_compilation_level); self->GetJniEnv()->DeleteGlobalRef(jclass_loader); @@ -2171,11 +2182,11 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz return; } // Can we run DEX-to-DEX compiler on this class ? - bool allow_dex_compilation; + DexToDexCompilationLevel dex_to_dex_compilation_level = kDontDexToDexCompile; { ScopedObjectAccess soa(Thread::Current()); mirror::ClassLoader* class_loader = soa.Decode(jclass_loader); - allow_dex_compilation = IsDexToDexCompilationAllowed(class_loader, dex_file, class_def); + dex_to_dex_compilation_level = GetDexToDexCompilationlevel(class_loader, dex_file, class_def); } ClassDataItemIterator it(dex_file, class_data); // Skip fields @@ -2198,7 +2209,7 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz previous_direct_method_idx = method_idx; manager->GetCompiler()->CompileMethod(it.GetMethodCodeItem(), it.GetMemberAccessFlags(), it.GetMethodInvokeType(class_def), class_def_index, - method_idx, jclass_loader, dex_file, allow_dex_compilation); + method_idx, jclass_loader, dex_file, dex_to_dex_compilation_level); it.Next(); } // Compile virtual methods @@ -2214,7 +2225,7 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz previous_virtual_method_idx = method_idx; manager->GetCompiler()->CompileMethod(it.GetMethodCodeItem(), it.GetMemberAccessFlags(), it.GetMethodInvokeType(class_def), class_def_index, - method_idx, jclass_loader, dex_file, allow_dex_compilation); + method_idx, jclass_loader, dex_file, dex_to_dex_compilation_level); it.Next(); } DCHECK(!it.HasNext()); @@ -2231,7 +2242,7 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t InvokeType invoke_type, uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, - bool allow_dex_to_dex_compilation) { + DexToDexCompilationLevel dex_to_dex_compilation_level) { CompiledMethod* compiled_method = NULL; uint64_t start_ns = NanoTime(); @@ -2253,13 +2264,12 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t compiled_method = (*compiler)(*this, code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); CHECK(compiled_method != NULL) << PrettyMethod(method_idx, dex_file); - } else if (allow_dex_to_dex_compilation) { + } else if (dex_to_dex_compilation_level != kDontDexToDexCompile) { // TODO: add a mode to disable DEX-to-DEX compilation ? - compiled_method = (*dex_to_dex_compiler_)(*this, code_item, access_flags, - invoke_type, class_def_idx, - method_idx, class_loader, dex_file); - // No native code is generated. - CHECK(compiled_method == NULL) << PrettyMethod(method_idx, dex_file); + (*dex_to_dex_compiler_)(*this, code_item, access_flags, + invoke_type, class_def_idx, + method_idx, class_loader, dex_file, + dex_to_dex_compilation_level); } } uint64_t duration_ns = NanoTime() - start_ns; diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index a7a47ed876..18f852dc6f 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -48,6 +48,12 @@ enum CompilerBackend { kNoBackend }; +enum DexToDexCompilationLevel { + kDontDexToDexCompile, // Only meaning wrt image time interpretation. + kRequired, // Dex-to-dex compilation required for correctness. + kOptimize // Perform required transformation and peep-hole optimizations. +}; + // Thread-local storage compiler worker threads class CompilerTls { public: @@ -324,7 +330,7 @@ class CompilerDriver { void CompileMethod(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, - bool allow_dex_to_dex_compilation) + DexToDexCompilationLevel dex_to_dex_compilation_level) LOCKS_EXCLUDED(compiled_methods_lock_); static void CompileClass(const ParallelCompilationManager* context, size_t class_def_index) @@ -375,12 +381,19 @@ class CompilerDriver { uint32_t access_flags, InvokeType invoke_type, uint32_t class_dex_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file); + + typedef void (*DexToDexCompilerFn)(CompilerDriver& driver, + const DexFile::CodeItem* code_item, + uint32_t access_flags, InvokeType invoke_type, + uint32_t class_dex_idx, uint32_t method_idx, + jobject class_loader, const DexFile& dex_file, + DexToDexCompilationLevel dex_to_dex_compilation_level); CompilerFn compiler_; #ifdef ART_SEA_IR_MODE CompilerFn sea_ir_compiler_; #endif - CompilerFn dex_to_dex_compiler_; + DexToDexCompilerFn dex_to_dex_compiler_; void* compiler_context_; -- cgit v1.2.3-59-g8ed1b From 848871b4d8481229c32e0d048a9856e5a9a17ef9 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Mon, 5 Aug 2013 10:56:33 -0700 Subject: Entry point clean up. Create set of entry points needed for image methods to avoid fix-up at load time: - interpreter - bridge to interpreter, bridge to compiled code - jni - dlsym lookup - quick - resolution and bridge to interpreter - portable - resolution and bridge to interpreter Fix JNI work around to use JNI work around argument rewriting code that'd been accidentally disabled. Remove abstact method error stub, use interpreter bridge instead. Consolidate trampoline (previously stub) generation in generic helper. Simplify trampolines to jump directly into assembly code, keeps stack crawlable. Dex: replace use of int with ThreadOffset for values that are thread offsets. Tidy entry point routines between interpreter, jni, quick and portable. Change-Id: I52a7c2bbb1b7e0ff8a3c3100b774212309d0828e --- compiler/Android.mk | 3 +- compiler/dex/quick/arm/call_arm.cc | 6 +- compiler/dex/quick/arm/codegen_arm.h | 6 +- compiler/dex/quick/arm/int_arm.cc | 6 +- compiler/dex/quick/arm/target_arm.cc | 4 +- compiler/dex/quick/arm/utility_arm.cc | 2 +- compiler/dex/quick/gen_common.cc | 96 ++-- compiler/dex/quick/gen_invoke.cc | 67 +-- compiler/dex/quick/mips/call_mips.cc | 6 +- compiler/dex/quick/mips/codegen_mips.h | 6 +- compiler/dex/quick/mips/fp_mips.cc | 2 +- compiler/dex/quick/mips/int_mips.cc | 4 +- compiler/dex/quick/mips/target_mips.cc | 4 +- compiler/dex/quick/mips/utility_mips.cc | 2 +- compiler/dex/quick/mir_to_lir.h | 44 +- compiler/dex/quick/x86/call_x86.cc | 8 +- compiler/dex/quick/x86/codegen_x86.h | 8 +- compiler/dex/quick/x86/int_x86.cc | 12 +- compiler/dex/quick/x86/target_x86.cc | 2 +- compiler/dex/quick/x86/utility_x86.cc | 4 +- compiler/driver/compiler_driver.cc | 78 +-- compiler/driver/compiler_driver.h | 23 +- compiler/image_writer.cc | 107 ++-- compiler/image_writer.h | 11 +- compiler/jni/quick/jni_compiler.cc | 6 +- compiler/oat_writer.cc | 128 +++-- compiler/oat_writer.h | 16 +- compiler/stubs/portable/stubs.cc | 138 ----- compiler/stubs/quick/stubs.cc | 263 ---------- compiler/stubs/stubs.h | 59 --- compiler/utils/arm/assembler_arm.cc | 10 +- compiler/utils/mips/assembler_mips.cc | 33 +- runtime/Android.mk | 7 +- runtime/arch/arm/asm_support_arm.S | 7 + runtime/arch/arm/entrypoints_init_arm.cc | 193 +++---- runtime/arch/arm/jni_entrypoints_arm.S | 7 +- runtime/arch/arm/portable_entrypoints_arm.S | 3 + runtime/arch/arm/quick_entrypoints_arm.S | 183 +++---- runtime/arch/mips/asm_support_mips.S | 8 + runtime/arch/mips/entrypoints_init_mips.cc | 192 +++---- runtime/arch/mips/jni_entrypoints_mips.S | 4 +- runtime/arch/mips/portable_entrypoints_mips.S | 12 +- runtime/arch/mips/quick_entrypoints_mips.S | 186 +++---- runtime/arch/x86/asm_support_x86.S | 12 + runtime/arch/x86/entrypoints_init_x86.cc | 246 ++++----- runtime/arch/x86/portable_entrypoints_x86.S | 19 +- runtime/arch/x86/quick_entrypoints_x86.S | 209 ++++---- runtime/class_linker.cc | 99 ++-- runtime/class_linker.h | 20 +- runtime/common_test.h | 11 +- runtime/entrypoints/entrypoint_utils.h | 71 +-- .../interpreter/interpreter_entrypoints.cc | 43 ++ .../interpreter/interpreter_entrypoints.h | 47 ++ runtime/entrypoints/jni/jni_entrypoints.cc | 87 +++- runtime/entrypoints/jni/jni_entrypoints.h | 37 ++ .../entrypoints/portable/portable_entrypoints.h | 8 +- runtime/entrypoints/quick/quick_argument_visitor.h | 138 ----- runtime/entrypoints/quick/quick_entrypoints.h | 74 ++- .../quick/quick_instrumentation_entrypoints.cc | 2 +- .../quick/quick_interpreter_entrypoints.cc | 128 ----- runtime/entrypoints/quick/quick_jni_entrypoints.cc | 74 --- .../entrypoints/quick/quick_proxy_entrypoints.cc | 126 ----- .../entrypoints/quick/quick_stub_entrypoints.cc | 295 ----------- .../quick/quick_trampoline_entrypoints.cc | 558 +++++++++++++++++++++ runtime/instrumentation.cc | 26 +- runtime/interpreter/interpreter.cc | 16 +- runtime/interpreter/interpreter.h | 6 +- runtime/jni_internal.h | 4 + runtime/mirror/abstract_method-inl.h | 4 +- runtime/mirror/abstract_method.cc | 7 +- runtime/native/dalvik_system_VMRuntime.cc | 7 - runtime/oat.cc | 112 ++++- runtime/oat.h | 33 +- runtime/oat_test.cc | 2 +- runtime/object_utils.h | 4 + runtime/stack.cc | 2 +- runtime/thread.cc | 82 +-- runtime/thread.h | 30 +- 78 files changed, 2129 insertions(+), 2476 deletions(-) delete mode 100644 compiler/stubs/portable/stubs.cc delete mode 100644 compiler/stubs/quick/stubs.cc delete mode 100644 compiler/stubs/stubs.h create mode 100644 runtime/entrypoints/interpreter/interpreter_entrypoints.cc create mode 100644 runtime/entrypoints/interpreter/interpreter_entrypoints.h create mode 100644 runtime/entrypoints/jni/jni_entrypoints.h delete mode 100644 runtime/entrypoints/quick/quick_argument_visitor.h delete mode 100644 runtime/entrypoints/quick/quick_interpreter_entrypoints.cc delete mode 100644 runtime/entrypoints/quick/quick_proxy_entrypoints.cc delete mode 100644 runtime/entrypoints/quick/quick_stub_entrypoints.cc create mode 100644 runtime/entrypoints/quick/quick_trampoline_entrypoints.cc (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/Android.mk b/compiler/Android.mk index 82103f8fe7..417fe6d32a 100644 --- a/compiler/Android.mk +++ b/compiler/Android.mk @@ -74,8 +74,7 @@ LIBART_COMPILER_SRC_FILES := \ llvm/runtime_support_builder_arm.cc \ llvm/runtime_support_builder_thumb2.cc \ llvm/runtime_support_builder_x86.cc \ - stubs/portable/stubs.cc \ - stubs/quick/stubs.cc \ + trampolines/trampoline_compiler.cc \ utils/arm/assembler_arm.cc \ utils/arm/managed_register_arm.cc \ utils/assembler.cc \ diff --git a/compiler/dex/quick/arm/call_arm.cc b/compiler/dex/quick/arm/call_arm.cc index 745e43dc38..2d8e24f58e 100644 --- a/compiler/dex/quick/arm/call_arm.cc +++ b/compiler/dex/quick/arm/call_arm.cc @@ -432,7 +432,7 @@ void ArmMir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { // Making a call - use explicit registers FlushAllRegs(); /* Everything to home location */ LoadValueDirectFixed(rl_src, r0); - LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode), + LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayData).Int32Value(), rARM_LR); // Materialize a pointer to the fill data image NewLIR3(kThumb2Adr, r1, 0, reinterpret_cast(tab_rec)); @@ -488,7 +488,7 @@ void ArmMir2Lir::GenMonitorEnter(int opt_flags, RegLocation rl_src) { OpRegImm(kOpCmp, r1, 0); OpIT(kCondNe, "T"); // Go expensive route - artLockObjectFromCode(self, obj); - LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pLockObjectFromCode), rARM_LR); + LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pLockObject).Int32Value(), rARM_LR); ClobberCalleeSave(); LIR* call_inst = OpReg(kOpBlx, rARM_LR); MarkSafepointPC(call_inst); @@ -519,7 +519,7 @@ void ArmMir2Lir::GenMonitorExit(int opt_flags, RegLocation rl_src) { OpIT(kCondEq, "EE"); StoreWordDisp(r0, mirror::Object::MonitorOffset().Int32Value(), r3); // Go expensive route - UnlockObjectFromCode(obj); - LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pUnlockObjectFromCode), rARM_LR); + LoadWordDisp(rARM_SELF, QUICK_ENTRYPOINT_OFFSET(pUnlockObject).Int32Value(), rARM_LR); ClobberCalleeSave(); LIR* call_inst = OpReg(kOpBlx, rARM_LR); MarkSafepointPC(call_inst); diff --git a/compiler/dex/quick/arm/codegen_arm.h b/compiler/dex/quick/arm/codegen_arm.h index 1599941ef6..f1ccfa015e 100644 --- a/compiler/dex/quick/arm/codegen_arm.h +++ b/compiler/dex/quick/arm/codegen_arm.h @@ -28,7 +28,7 @@ class ArmMir2Lir : public Mir2Lir { // Required for target - codegen helpers. bool SmallLiteralDivide(Instruction::Code dalvik_opcode, RegLocation rl_src, RegLocation rl_dest, int lit); - int LoadHelper(int offset); + int LoadHelper(ThreadOffset offset); LIR* LoadBaseDisp(int rBase, int displacement, int r_dest, OpSize size, int s_reg); LIR* LoadBaseDispWide(int rBase, int displacement, int r_dest_lo, int r_dest_hi, int s_reg); @@ -153,12 +153,12 @@ class ArmMir2Lir : public Mir2Lir { LIR* OpRegRegImm(OpKind op, int r_dest, int r_src1, int value); LIR* OpRegRegReg(OpKind op, int r_dest, int r_src1, int r_src2); LIR* OpTestSuspend(LIR* target); - LIR* OpThreadMem(OpKind op, int thread_offset); + LIR* OpThreadMem(OpKind op, ThreadOffset thread_offset); LIR* OpVldm(int rBase, int count); LIR* OpVstm(int rBase, int count); void OpLea(int rBase, int reg1, int reg2, int scale, int offset); void OpRegCopyWide(int dest_lo, int dest_hi, int src_lo, int src_hi); - void OpTlsCmp(int offset, int val); + void OpTlsCmp(ThreadOffset offset, int val); RegLocation ArgLoc(RegLocation loc); LIR* LoadBaseDispBody(int rBase, int displacement, int r_dest, int r_dest_hi, OpSize size, diff --git a/compiler/dex/quick/arm/int_arm.cc b/compiler/dex/quick/arm/int_arm.cc index 9db1016efa..c258019daa 100644 --- a/compiler/dex/quick/arm/int_arm.cc +++ b/compiler/dex/quick/arm/int_arm.cc @@ -498,7 +498,7 @@ void ArmMir2Lir::OpLea(int rBase, int reg1, int reg2, int scale, int offset) { LOG(FATAL) << "Unexpected use of OpLea for Arm"; } -void ArmMir2Lir::OpTlsCmp(int offset, int val) { +void ArmMir2Lir::OpTlsCmp(ThreadOffset offset, int val) { LOG(FATAL) << "Unexpected use of OpTlsCmp for Arm"; } @@ -665,7 +665,7 @@ void ArmMir2Lir::GenMulLong(RegLocation rl_dest, RegLocation rl_src1, */ RegLocation rl_result; if (BadOverlap(rl_src1, rl_dest) || (BadOverlap(rl_src2, rl_dest))) { - int func_offset = QUICK_ENTRYPOINT_OFFSET(pLmul); + ThreadOffset func_offset = QUICK_ENTRYPOINT_OFFSET(pLmul); FlushAllRegs(); CallRuntimeHelperRegLocationRegLocation(func_offset, rl_src1, rl_src2, false); rl_result = GetReturnWide(false); @@ -956,7 +956,7 @@ void ArmMir2Lir::GenArrayObjPut(int opt_flags, RegLocation rl_array, // Get the array's class. LoadWordDisp(r_array, mirror::Object::ClassOffset().Int32Value(), r_array_class); - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElementFromCode), r_value, + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElement), r_value, r_array_class, true); // Redo LoadValues in case they didn't survive the call. LoadValueDirectFixed(rl_array, r_array); // Reload array diff --git a/compiler/dex/quick/arm/target_arm.cc b/compiler/dex/quick/arm/target_arm.cc index 6f3779879c..47d3d974ef 100644 --- a/compiler/dex/quick/arm/target_arm.cc +++ b/compiler/dex/quick/arm/target_arm.cc @@ -714,8 +714,8 @@ void ArmMir2Lir::FreeCallTemps() { FreeTemp(r3); } -int ArmMir2Lir::LoadHelper(int offset) { - LoadWordDisp(rARM_SELF, offset, rARM_LR); +int ArmMir2Lir::LoadHelper(ThreadOffset offset) { + LoadWordDisp(rARM_SELF, offset.Int32Value(), rARM_LR); return rARM_LR; } diff --git a/compiler/dex/quick/arm/utility_arm.cc b/compiler/dex/quick/arm/utility_arm.cc index afc8a66d8a..c63de69284 100644 --- a/compiler/dex/quick/arm/utility_arm.cc +++ b/compiler/dex/quick/arm/utility_arm.cc @@ -1029,7 +1029,7 @@ LIR* ArmMir2Lir::OpFpRegCopy(int r_dest, int r_src) { return res; } -LIR* ArmMir2Lir::OpThreadMem(OpKind op, int thread_offset) { +LIR* ArmMir2Lir::OpThreadMem(OpKind op, ThreadOffset thread_offset) { LOG(FATAL) << "Unexpected use of OpThreadMem for Arm"; return NULL; } diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index ebe10bb57e..298d3898c8 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -208,12 +208,12 @@ void Mir2Lir::GenIntNarrowing(Instruction::Code opcode, RegLocation rl_dest, void Mir2Lir::GenNewArray(uint32_t type_idx, RegLocation rl_dest, RegLocation rl_src) { FlushAllRegs(); /* Everything to home location */ - int func_offset; + ThreadOffset func_offset(-1); if (cu_->compiler_driver->CanAccessTypeWithoutChecks(cu_->method_idx, *cu_->dex_file, type_idx)) { - func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArrayFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArray); } else { - func_offset= QUICK_ENTRYPOINT_OFFSET(pAllocArrayFromCodeWithAccessCheck); + func_offset= QUICK_ENTRYPOINT_OFFSET(pAllocArrayWithAccessCheck); } CallRuntimeHelperImmMethodRegLocation(func_offset, type_idx, rl_src, true); RegLocation rl_result = GetReturn(false); @@ -230,12 +230,12 @@ void Mir2Lir::GenFilledNewArray(CallInfo* info) { int elems = info->num_arg_words; int type_idx = info->index; FlushAllRegs(); /* Everything to home location */ - int func_offset; + ThreadOffset func_offset(-1); if (cu_->compiler_driver->CanAccessTypeWithoutChecks(cu_->method_idx, *cu_->dex_file, type_idx)) { - func_offset = QUICK_ENTRYPOINT_OFFSET(pCheckAndAllocArrayFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pCheckAndAllocArray); } else { - func_offset = QUICK_ENTRYPOINT_OFFSET(pCheckAndAllocArrayFromCodeWithAccessCheck); + func_offset = QUICK_ENTRYPOINT_OFFSET(pCheckAndAllocArrayWithAccessCheck); } CallRuntimeHelperImmMethodImm(func_offset, type_idx, elems, true); FreeTemp(TargetReg(kArg2)); @@ -408,9 +408,10 @@ void Mir2Lir::GenSput(uint32_t field_idx, RegLocation rl_src, bool is_long_or_do FreeTemp(rBase); } else { FlushAllRegs(); // Everything to home locations - int setter_offset = is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pSet64Static) : - (is_object ? QUICK_ENTRYPOINT_OFFSET(pSetObjStatic) - : QUICK_ENTRYPOINT_OFFSET(pSet32Static)); + ThreadOffset setter_offset = + is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pSet64Static) + : (is_object ? QUICK_ENTRYPOINT_OFFSET(pSetObjStatic) + : QUICK_ENTRYPOINT_OFFSET(pSet32Static)); CallRuntimeHelperImmRegLocation(setter_offset, field_idx, rl_src, true); } } @@ -483,9 +484,10 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, } } else { FlushAllRegs(); // Everything to home locations - int getterOffset = is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pGet64Static) : - (is_object ? QUICK_ENTRYPOINT_OFFSET(pGetObjStatic) - : QUICK_ENTRYPOINT_OFFSET(pGet32Static)); + ThreadOffset getterOffset = + is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pGet64Static) + :(is_object ? QUICK_ENTRYPOINT_OFFSET(pGetObjStatic) + : QUICK_ENTRYPOINT_OFFSET(pGet32Static)); CallRuntimeHelperImm(getterOffset, field_idx, true); if (is_long_or_double) { RegLocation rl_result = GetReturnWide(rl_dest.fp); @@ -499,7 +501,7 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, void Mir2Lir::HandleSuspendLaunchPads() { int num_elems = suspend_launchpads_.Size(); - int helper_offset = QUICK_ENTRYPOINT_OFFSET(pTestSuspendFromCode); + ThreadOffset helper_offset = QUICK_ENTRYPOINT_OFFSET(pTestSuspend); for (int i = 0; i < num_elems; i++) { ResetRegPool(); ResetDefTracking(); @@ -539,13 +541,13 @@ void Mir2Lir::HandleThrowLaunchPads() { LIR* lab = throw_launchpads_.Get(i); current_dalvik_offset_ = lab->operands[1]; AppendLIR(lab); - int func_offset = 0; + ThreadOffset func_offset(-1); int v1 = lab->operands[2]; int v2 = lab->operands[3]; bool target_x86 = (cu_->instruction_set == kX86); switch (lab->operands[0]) { case kThrowNullPointer: - func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowNullPointerFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowNullPointer); break; case kThrowConstantArrayBounds: // v1 is length reg (for Arm/Mips), v2 constant index // v1 holds the constant array index. Mips/Arm uses v2 for length, x86 reloads. @@ -557,7 +559,7 @@ void Mir2Lir::HandleThrowLaunchPads() { // Make sure the following LoadConstant doesn't mess with kArg1. LockTemp(TargetReg(kArg1)); LoadConstant(TargetReg(kArg0), v2); - func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowArrayBoundsFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowArrayBounds); break; case kThrowArrayBounds: // Move v1 (array index) to kArg0 and v2 (array length) to kArg1 @@ -590,18 +592,18 @@ void Mir2Lir::HandleThrowLaunchPads() { OpRegCopy(TargetReg(kArg0), v1); } } - func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowArrayBoundsFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowArrayBounds); break; case kThrowDivZero: - func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowDivZeroFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowDivZero); break; case kThrowNoSuchMethod: OpRegCopy(TargetReg(kArg0), v1); func_offset = - QUICK_ENTRYPOINT_OFFSET(pThrowNoSuchMethodFromCode); + QUICK_ENTRYPOINT_OFFSET(pThrowNoSuchMethod); break; case kThrowStackOverflow: - func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowStackOverflowFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pThrowStackOverflow); // Restore stack alignment if (target_x86) { OpRegImm(kOpAdd, TargetReg(kSp), frame_size_); @@ -664,9 +666,10 @@ void Mir2Lir::GenIGet(uint32_t field_idx, int opt_flags, OpSize size, StoreValue(rl_dest, rl_result); } } else { - int getterOffset = is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pGet64Instance) : - (is_object ? QUICK_ENTRYPOINT_OFFSET(pGetObjInstance) - : QUICK_ENTRYPOINT_OFFSET(pGet32Instance)); + ThreadOffset getterOffset = + is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pGet64Instance) + : (is_object ? QUICK_ENTRYPOINT_OFFSET(pGetObjInstance) + : QUICK_ENTRYPOINT_OFFSET(pGet32Instance)); CallRuntimeHelperImmRegLocation(getterOffset, field_idx, rl_obj, true); if (is_long_or_double) { RegLocation rl_result = GetReturnWide(rl_dest.fp); @@ -719,9 +722,10 @@ void Mir2Lir::GenIPut(uint32_t field_idx, int opt_flags, OpSize size, } } } else { - int setter_offset = is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pSet64Instance) : - (is_object ? QUICK_ENTRYPOINT_OFFSET(pSetObjInstance) - : QUICK_ENTRYPOINT_OFFSET(pSet32Instance)); + ThreadOffset setter_offset = + is_long_or_double ? QUICK_ENTRYPOINT_OFFSET(pSet64Instance) + : (is_object ? QUICK_ENTRYPOINT_OFFSET(pSetObjInstance) + : QUICK_ENTRYPOINT_OFFSET(pSet32Instance)); CallRuntimeHelperImmRegLocationRegLocation(setter_offset, field_idx, rl_obj, rl_src, true); } } @@ -735,7 +739,7 @@ void Mir2Lir::GenConstClass(uint32_t type_idx, RegLocation rl_dest) { type_idx)) { // Call out to helper which resolves type and verifies access. // Resolved type returned in kRet0. - CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccessFromCode), + CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccess), type_idx, rl_method.low_reg, true); RegLocation rl_result = GetReturn(false); StoreValue(rl_dest, rl_result); @@ -764,7 +768,7 @@ void Mir2Lir::GenConstClass(uint32_t type_idx, RegLocation rl_dest) { // TUNING: move slow path to end & remove unconditional branch LIR* target1 = NewLIR0(kPseudoTargetLabel); // Call out to helper, which will return resolved type in kArg0 - CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeFromCode), type_idx, + CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeType), type_idx, rl_method.low_reg, true); RegLocation rl_result = GetReturn(false); StoreValue(rl_dest, rl_result); @@ -797,7 +801,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { LoadWordDisp(TargetReg(kArg2), mirror::AbstractMethod::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0)); // Might call out to helper, which will return resolved string in kRet0 - int r_tgt = CallHelperSetup(QUICK_ENTRYPOINT_OFFSET(pResolveStringFromCode)); + int r_tgt = CallHelperSetup(QUICK_ENTRYPOINT_OFFSET(pResolveString)); LoadWordDisp(TargetReg(kArg0), offset_of_string, TargetReg(kRet0)); LoadConstant(TargetReg(kArg1), string_idx); if (cu_->instruction_set == kThumb2) { @@ -821,7 +825,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { branch->target = target; } else { DCHECK_EQ(cu_->instruction_set, kX86); - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pResolveStringFromCode), TargetReg(kArg2), + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pResolveString), TargetReg(kArg2), TargetReg(kArg1), true); } GenBarrier(); @@ -845,12 +849,12 @@ void Mir2Lir::GenNewInstance(uint32_t type_idx, RegLocation rl_dest) { FlushAllRegs(); /* Everything to home location */ // alloc will always check for resolution, do we also need to verify // access because the verifier was unable to? - int func_offset; + ThreadOffset func_offset(-1); if (cu_->compiler_driver->CanAccessInstantiableTypeWithoutChecks( cu_->method_idx, *cu_->dex_file, type_idx)) { - func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocObjectFromCode); + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocObject); } else { - func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocObjectFromCodeWithAccessCheck); + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocObjectWithAccessCheck); } CallRuntimeHelperImmMethod(func_offset, type_idx, true); RegLocation rl_result = GetReturn(false); @@ -929,7 +933,7 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know if (needs_access_check) { // Check we have access to type_idx and if not throw IllegalAccessError, // returns Class* in kArg0 - CallRuntimeHelperImm(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccessFromCode), + CallRuntimeHelperImm(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccess), type_idx, true); OpRegCopy(class_reg, TargetReg(kRet0)); // Align usage with fast path LoadValueDirectFixed(rl_src, TargetReg(kArg0)); // kArg0 <= ref @@ -951,7 +955,7 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know LIR* hop_branch = OpCmpImmBranch(kCondNe, class_reg, 0, NULL); // Not resolved // Call out to helper, which will return resolved type in kRet0 - CallRuntimeHelperImm(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeFromCode), type_idx, true); + CallRuntimeHelperImm(QUICK_ENTRYPOINT_OFFSET(pInitializeType), type_idx, true); OpRegCopy(TargetReg(kArg2), TargetReg(kRet0)); // Align usage with fast path LoadValueDirectFixed(rl_src, TargetReg(kArg0)); /* reload Ref */ // Rejoin code paths @@ -986,7 +990,7 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know } } else { if (cu_->instruction_set == kThumb2) { - int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivialFromCode)); + int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivial)); if (!type_known_abstract) { /* Uses conditional nullification */ OpRegReg(kOpCmp, TargetReg(kArg1), TargetReg(kArg2)); // Same? @@ -1003,13 +1007,13 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know branchover = OpCmpBranch(kCondEq, TargetReg(kArg1), TargetReg(kArg2), NULL); } if (cu_->instruction_set != kX86) { - int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivialFromCode)); + int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivial)); OpRegCopy(TargetReg(kArg0), TargetReg(kArg2)); // .ne case - arg0 <= class OpReg(kOpBlx, r_tgt); // .ne case: helper(class, ref->class) FreeTemp(r_tgt); } else { OpRegCopy(TargetReg(kArg0), TargetReg(kArg2)); - OpThreadMem(kOpBlx, QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivialFromCode)); + OpThreadMem(kOpBlx, QUICK_ENTRYPOINT_OFFSET(pInstanceofNonTrivial)); } } } @@ -1069,7 +1073,7 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ // Check we have access to type_idx and if not throw IllegalAccessError, // returns Class* in kRet0 // InitializeTypeAndVerifyAccess(idx, method) - CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccessFromCode), + CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeAndVerifyAccess), type_idx, TargetReg(kArg1), true); OpRegCopy(class_reg, TargetReg(kRet0)); // Align usage with fast path } else if (use_declaring_class) { @@ -1089,7 +1093,7 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ // Not resolved // Call out to helper, which will return resolved type in kArg0 // InitializeTypeFromCode(idx, method) - CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeTypeFromCode), type_idx, + CallRuntimeHelperImmReg(QUICK_ENTRYPOINT_OFFSET(pInitializeType), type_idx, TargetReg(kArg1), true); OpRegCopy(class_reg, TargetReg(kRet0)); // Align usage with fast path // Rejoin code paths @@ -1109,7 +1113,7 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ if (!type_known_abstract) { branch2 = OpCmpBranch(kCondEq, TargetReg(kArg1), class_reg, NULL); } - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCheckCastFromCode), TargetReg(kArg1), + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCheckCast), TargetReg(kArg1), TargetReg(kArg2), true); /* branch target here */ LIR* target = NewLIR0(kPseudoTargetLabel); @@ -1168,7 +1172,7 @@ void Mir2Lir::GenLong3Addr(OpKind first_op, OpKind second_op, RegLocation rl_des void Mir2Lir::GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_shift) { - int func_offset = -1; // Make gcc happy + ThreadOffset func_offset(-1); switch (opcode) { case Instruction::SHL_LONG: @@ -1303,7 +1307,7 @@ void Mir2Lir::GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, } rl_result = GenDivRem(rl_dest, rl_src1.low_reg, rl_src2.low_reg, op == kOpDiv); } else { - int func_offset = QUICK_ENTRYPOINT_OFFSET(pIdivmod); + ThreadOffset func_offset = QUICK_ENTRYPOINT_OFFSET(pIdivmod); FlushAllRegs(); /* Send everything to home location */ LoadValueDirectFixed(rl_src2, TargetReg(kArg1)); int r_tgt = CallHelperSetup(func_offset); @@ -1558,7 +1562,7 @@ void Mir2Lir::GenArithOpIntLit(Instruction::Code opcode, RegLocation rl_dest, Re FlushAllRegs(); /* Everything to home location */ LoadValueDirectFixed(rl_src, TargetReg(kArg0)); Clobber(TargetReg(kArg0)); - int func_offset = QUICK_ENTRYPOINT_OFFSET(pIdivmod); + ThreadOffset func_offset = QUICK_ENTRYPOINT_OFFSET(pIdivmod); CallRuntimeHelperRegImm(func_offset, TargetReg(kArg0), lit, false); if (is_div) rl_result = GetReturn(false); @@ -1589,7 +1593,7 @@ void Mir2Lir::GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, OpKind second_op = kOpBkpt; bool call_out = false; bool check_zero = false; - int func_offset; + ThreadOffset func_offset(-1); int ret_reg = TargetReg(kRet0); switch (opcode) { @@ -1709,7 +1713,7 @@ void Mir2Lir::GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, } } -void Mir2Lir::GenConversionCall(int func_offset, +void Mir2Lir::GenConversionCall(ThreadOffset func_offset, RegLocation rl_dest, RegLocation rl_src) { /* * Don't optimize the register usage since it calls out to support diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 1b34e99a72..20d683a947 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -37,12 +37,12 @@ namespace art { * has a memory call operation, part 1 is a NOP for x86. For other targets, * load arguments between the two parts. */ -int Mir2Lir::CallHelperSetup(int helper_offset) { +int Mir2Lir::CallHelperSetup(ThreadOffset helper_offset) { return (cu_->instruction_set == kX86) ? 0 : LoadHelper(helper_offset); } /* NOTE: if r_tgt is a temp, it will be freed following use */ -LIR* Mir2Lir::CallHelper(int r_tgt, int helper_offset, bool safepoint_pc) { +LIR* Mir2Lir::CallHelper(int r_tgt, ThreadOffset helper_offset, bool safepoint_pc) { LIR* call_inst; if (cu_->instruction_set == kX86) { call_inst = OpThreadMem(kOpBlx, helper_offset); @@ -56,21 +56,22 @@ LIR* Mir2Lir::CallHelper(int r_tgt, int helper_offset, bool safepoint_pc) { return call_inst; } -void Mir2Lir::CallRuntimeHelperImm(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperImm(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadConstant(TargetReg(kArg0), arg0); ClobberCalleeSave(); CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperReg(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperReg(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg0), arg0); ClobberCalleeSave(); CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocation(int helper_offset, RegLocation arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegLocation(ThreadOffset helper_offset, RegLocation arg0, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg0.wide == 0) { LoadValueDirectFixed(arg0, TargetReg(kArg0)); @@ -81,7 +82,7 @@ void Mir2Lir::CallRuntimeHelperRegLocation(int helper_offset, RegLocation arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmImm(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperImmImm(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadConstant(TargetReg(kArg0), arg0); @@ -90,7 +91,7 @@ void Mir2Lir::CallRuntimeHelperImmImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmRegLocation(int helper_offset, int arg0, +void Mir2Lir::CallRuntimeHelperImmRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg1.wide == 0) { @@ -103,7 +104,7 @@ void Mir2Lir::CallRuntimeHelperImmRegLocation(int helper_offset, int arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocationImm(int helper_offset, RegLocation arg0, int arg1, +void Mir2Lir::CallRuntimeHelperRegLocationImm(ThreadOffset helper_offset, RegLocation arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadValueDirectFixed(arg0, TargetReg(kArg0)); @@ -112,7 +113,7 @@ void Mir2Lir::CallRuntimeHelperRegLocationImm(int helper_offset, RegLocation arg CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmReg(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperImmReg(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg1), arg1); @@ -121,8 +122,8 @@ void Mir2Lir::CallRuntimeHelperImmReg(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegImm(int helper_offset, int arg0, int arg1, - bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegImm(ThreadOffset helper_offset, int arg0, int arg1, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); OpRegCopy(TargetReg(kArg0), arg0); LoadConstant(TargetReg(kArg1), arg1); @@ -130,7 +131,7 @@ void Mir2Lir::CallRuntimeHelperRegImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethod(int helper_offset, int arg0, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperImmMethod(ThreadOffset helper_offset, int arg0, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadCurrMethodDirect(TargetReg(kArg1)); LoadConstant(TargetReg(kArg0), arg0); @@ -138,7 +139,7 @@ void Mir2Lir::CallRuntimeHelperImmMethod(int helper_offset, int arg0, bool safep CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(int helper_offset, RegLocation arg0, +void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(ThreadOffset helper_offset, RegLocation arg0, RegLocation arg1, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); if (arg0.wide == 0) { @@ -168,7 +169,8 @@ void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(int helper_offset, RegLoca CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegReg(int helper_offset, int arg0, int arg1, bool safepoint_pc) { +void Mir2Lir::CallRuntimeHelperRegReg(ThreadOffset helper_offset, int arg0, int arg1, + bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); DCHECK_NE(TargetReg(kArg0), arg1); // check copy into arg0 won't clobber arg1 OpRegCopy(TargetReg(kArg0), arg0); @@ -177,7 +179,7 @@ void Mir2Lir::CallRuntimeHelperRegReg(int helper_offset, int arg0, int arg1, boo CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperRegRegImm(int helper_offset, int arg0, int arg1, +void Mir2Lir::CallRuntimeHelperRegRegImm(ThreadOffset helper_offset, int arg0, int arg1, int arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); DCHECK_NE(TargetReg(kArg0), arg1); // check copy into arg0 won't clobber arg1 @@ -188,7 +190,7 @@ void Mir2Lir::CallRuntimeHelperRegRegImm(int helper_offset, int arg0, int arg1, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(int helper_offset, +void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadValueDirectFixed(arg2, TargetReg(kArg2)); @@ -198,7 +200,7 @@ void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(int helper_offset, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmMethodImm(int helper_offset, int arg0, +void Mir2Lir::CallRuntimeHelperImmMethodImm(ThreadOffset helper_offset, int arg0, int arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); LoadCurrMethodDirect(TargetReg(kArg1)); @@ -208,7 +210,7 @@ void Mir2Lir::CallRuntimeHelperImmMethodImm(int helper_offset, int arg0, CallHelper(r_tgt, helper_offset, safepoint_pc); } -void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation(int helper_offset, +void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, RegLocation arg2, bool safepoint_pc) { int r_tgt = CallHelperSetup(helper_offset); @@ -470,14 +472,14 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, // Disable sharpening direct_method = 0; } - int trampoline = (cu->instruction_set == kX86) ? 0 - : QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline); if (direct_method != 0) { switch (state) { case 0: // Load the trampoline target [sets kInvokeTgt]. if (cu->instruction_set != kX86) { - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), + cg->TargetReg(kInvokeTgt)); } // Get the interface Method* [sets kArg0] if (direct_method != static_cast(-1)) { @@ -506,7 +508,8 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, cg->LoadCurrMethodDirect(cg->TargetReg(kArg0)); // Load the trampoline target [sets kInvokeTgt]. if (cu->instruction_set != kX86) { - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), + cg->TargetReg(kInvokeTgt)); } break; case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0] @@ -528,7 +531,7 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, return state + 1; } -static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, +static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, ThreadOffset trampoline, int state, const MethodReference& target_method, uint32_t method_idx) { Mir2Lir* cg = static_cast(cu->cg.get()); @@ -539,7 +542,7 @@ static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, int trampoline, if (state == 0) { if (cu->instruction_set != kX86) { // Load trampoline target - cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline, cg->TargetReg(kInvokeTgt)); + cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), cg->TargetReg(kInvokeTgt)); } // Load kArg0 with method index CHECK_EQ(cu->dex_file, target_method.dex_file); @@ -555,7 +558,7 @@ static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeStaticTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -563,7 +566,7 @@ static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeDirectTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -571,7 +574,7 @@ static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeSuperTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -579,7 +582,7 @@ static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, const MethodReference& target_method, uint32_t method_idx, uintptr_t unused, uintptr_t unused2, InvokeType unused3) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeVirtualTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -589,7 +592,7 @@ static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu, uint32_t unused, uintptr_t unused2, uintptr_t unused3, InvokeType unused4) { - int trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck); + ThreadOffset trampoline = QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampolineWithAccessCheck); return NextInvokeInsnSP(cu, info, trampoline, state, target_method, 0); } @@ -1108,9 +1111,9 @@ bool Mir2Lir::GenInlinedStringCompareTo(CallInfo* info) { bool Mir2Lir::GenInlinedCurrentThread(CallInfo* info) { RegLocation rl_dest = InlineTarget(info); RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); - int offset = Thread::PeerOffset().Int32Value(); + ThreadOffset offset = Thread::PeerOffset(); if (cu_->instruction_set == kThumb2 || cu_->instruction_set == kMips) { - LoadWordDisp(TargetReg(kSelf), offset, rl_result.low_reg); + LoadWordDisp(TargetReg(kSelf), offset.Int32Value(), rl_result.low_reg); } else { CHECK(cu_->instruction_set == kX86); reinterpret_cast(this)->OpRegThreadMem(kOpMov, rl_result.low_reg, offset); @@ -1406,7 +1409,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) { call_inst = OpMem(kOpBlx, TargetReg(kArg0), mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); } else { - int trampoline = 0; + ThreadOffset trampoline(-1); switch (info->type) { case kInterface: trampoline = fast_path ? QUICK_ENTRYPOINT_OFFSET(pInvokeInterfaceTrampoline) diff --git a/compiler/dex/quick/mips/call_mips.cc b/compiler/dex/quick/mips/call_mips.cc index 846c055ac2..eaae0e1964 100644 --- a/compiler/dex/quick/mips/call_mips.cc +++ b/compiler/dex/quick/mips/call_mips.cc @@ -247,7 +247,7 @@ void MipsMir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { GenBarrier(); NewLIR0(kMipsCurrPC); // Really a jal to .+8 // Now, fill the branch delay slot with the helper load - int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode)); + int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayData)); GenBarrier(); // Scheduling barrier // Construct BaseLabel and set up table base register @@ -272,7 +272,7 @@ void MipsMir2Lir::GenMonitorEnter(int opt_flags, RegLocation rl_src) { LockCallTemps(); // Prepare for explicit register usage GenNullCheck(rl_src.s_reg_low, rMIPS_ARG0, opt_flags); // Go expensive route - artLockObjectFromCode(self, obj); - int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pLockObjectFromCode)); + int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pLockObject)); ClobberCalleeSave(); LIR* call_inst = OpReg(kOpBlx, r_tgt); MarkSafepointPC(call_inst); @@ -287,7 +287,7 @@ void MipsMir2Lir::GenMonitorExit(int opt_flags, RegLocation rl_src) { LockCallTemps(); // Prepare for explicit register usage GenNullCheck(rl_src.s_reg_low, rMIPS_ARG0, opt_flags); // Go expensive route - UnlockObjectFromCode(obj); - int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pUnlockObjectFromCode)); + int r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(pUnlockObject)); ClobberCalleeSave(); LIR* call_inst = OpReg(kOpBlx, r_tgt); MarkSafepointPC(call_inst); diff --git a/compiler/dex/quick/mips/codegen_mips.h b/compiler/dex/quick/mips/codegen_mips.h index 802ff625c9..6100396e5f 100644 --- a/compiler/dex/quick/mips/codegen_mips.h +++ b/compiler/dex/quick/mips/codegen_mips.h @@ -29,7 +29,7 @@ class MipsMir2Lir : public Mir2Lir { // Required for target - codegen utilities. bool SmallLiteralDivide(Instruction::Code dalvik_opcode, RegLocation rl_src, RegLocation rl_dest, int lit); - int LoadHelper(int offset); + int LoadHelper(ThreadOffset offset); LIR* LoadBaseDisp(int rBase, int displacement, int r_dest, OpSize size, int s_reg); LIR* LoadBaseDispWide(int rBase, int displacement, int r_dest_lo, int r_dest_hi, int s_reg); @@ -154,12 +154,12 @@ class MipsMir2Lir : public Mir2Lir { LIR* OpRegRegImm(OpKind op, int r_dest, int r_src1, int value); LIR* OpRegRegReg(OpKind op, int r_dest, int r_src1, int r_src2); LIR* OpTestSuspend(LIR* target); - LIR* OpThreadMem(OpKind op, int thread_offset); + LIR* OpThreadMem(OpKind op, ThreadOffset thread_offset); LIR* OpVldm(int rBase, int count); LIR* OpVstm(int rBase, int count); void OpLea(int rBase, int reg1, int reg2, int scale, int offset); void OpRegCopyWide(int dest_lo, int dest_hi, int src_lo, int src_hi); - void OpTlsCmp(int offset, int val); + void OpTlsCmp(ThreadOffset offset, int val); LIR* LoadBaseDispBody(int rBase, int displacement, int r_dest, int r_dest_hi, OpSize size, int s_reg); diff --git a/compiler/dex/quick/mips/fp_mips.cc b/compiler/dex/quick/mips/fp_mips.cc index 320301726b..9e2fea94de 100644 --- a/compiler/dex/quick/mips/fp_mips.cc +++ b/compiler/dex/quick/mips/fp_mips.cc @@ -176,7 +176,7 @@ void MipsMir2Lir::GenConversion(Instruction::Code opcode, RegLocation rl_dest, void MipsMir2Lir::GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) { bool wide = true; - int offset = -1; // Make gcc happy. + ThreadOffset offset(-1); switch (opcode) { case Instruction::CMPL_FLOAT: diff --git a/compiler/dex/quick/mips/int_mips.cc b/compiler/dex/quick/mips/int_mips.cc index bd044c66bd..4a48c87ed9 100644 --- a/compiler/dex/quick/mips/int_mips.cc +++ b/compiler/dex/quick/mips/int_mips.cc @@ -254,7 +254,7 @@ void MipsMir2Lir::OpLea(int rBase, int reg1, int reg2, int scale, int offset) { LOG(FATAL) << "Unexpected use of OpLea for Arm"; } -void MipsMir2Lir::OpTlsCmp(int offset, int val) { +void MipsMir2Lir::OpTlsCmp(ThreadOffset offset, int val) { LOG(FATAL) << "Unexpected use of OpTlsCmp for Arm"; } @@ -579,7 +579,7 @@ void MipsMir2Lir::GenArrayObjPut(int opt_flags, RegLocation rl_array, // Get the array's class. LoadWordDisp(r_array, mirror::Object::ClassOffset().Int32Value(), r_array_class); - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElementFromCode), r_value, + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElement), r_value, r_array_class, true); // Redo LoadValues in case they didn't survive the call. LoadValueDirectFixed(rl_array, r_array); // Reload array diff --git a/compiler/dex/quick/mips/target_mips.cc b/compiler/dex/quick/mips/target_mips.cc index 0a17fb1078..7a9e91a994 100644 --- a/compiler/dex/quick/mips/target_mips.cc +++ b/compiler/dex/quick/mips/target_mips.cc @@ -505,8 +505,8 @@ void MipsMir2Lir::FreeRegLocTemps(RegLocation rl_keep, RegLocation rl_free) { * ensure that all branch instructions can be restarted if * there is a trap in the shadow. Allocate a temp register. */ -int MipsMir2Lir::LoadHelper(int offset) { - LoadWordDisp(rMIPS_SELF, offset, r_T9); +int MipsMir2Lir::LoadHelper(ThreadOffset offset) { + LoadWordDisp(rMIPS_SELF, offset.Int32Value(), r_T9); return r_T9; } diff --git a/compiler/dex/quick/mips/utility_mips.cc b/compiler/dex/quick/mips/utility_mips.cc index 68b26f1936..5d9ae33921 100644 --- a/compiler/dex/quick/mips/utility_mips.cc +++ b/compiler/dex/quick/mips/utility_mips.cc @@ -632,7 +632,7 @@ LIR* MipsMir2Lir::StoreBaseDispWide(int rBase, int displacement, return StoreBaseDispBody(rBase, displacement, r_src_lo, r_src_hi, kLong); } -LIR* MipsMir2Lir::OpThreadMem(OpKind op, int thread_offset) { +LIR* MipsMir2Lir::OpThreadMem(OpKind op, ThreadOffset thread_offset) { LOG(FATAL) << "Unexpected use of OpThreadMem for MIPS"; return NULL; } diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index a34e9295e9..2794bf5e5b 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -424,42 +424,42 @@ class Mir2Lir : public Backend { RegLocation rl_src, int lit); void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2); - void GenConversionCall(int func_offset, RegLocation rl_dest, + void GenConversionCall(ThreadOffset func_offset, RegLocation rl_dest, RegLocation rl_src); void GenSuspendTest(int opt_flags); void GenSuspendTestAndBranch(int opt_flags, LIR* target); // Shared by all targets - implemented in gen_invoke.cc. - int CallHelperSetup(int helper_offset); - LIR* CallHelper(int r_tgt, int helper_offset, bool safepoint_pc); - void CallRuntimeHelperImm(int helper_offset, int arg0, bool safepoint_pc); - void CallRuntimeHelperReg(int helper_offset, int arg0, bool safepoint_pc); - void CallRuntimeHelperRegLocation(int helper_offset, RegLocation arg0, - bool safepoint_pc); - void CallRuntimeHelperImmImm(int helper_offset, int arg0, int arg1, + int CallHelperSetup(ThreadOffset helper_offset); + LIR* CallHelper(int r_tgt, ThreadOffset helper_offset, bool safepoint_pc); + void CallRuntimeHelperImm(ThreadOffset helper_offset, int arg0, bool safepoint_pc); + void CallRuntimeHelperReg(ThreadOffset helper_offset, int arg0, bool safepoint_pc); + void CallRuntimeHelperRegLocation(ThreadOffset helper_offset, RegLocation arg0, + bool safepoint_pc); + void CallRuntimeHelperImmImm(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc); - void CallRuntimeHelperImmRegLocation(int helper_offset, int arg0, + void CallRuntimeHelperImmRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, bool safepoint_pc); - void CallRuntimeHelperRegLocationImm(int helper_offset, RegLocation arg0, + void CallRuntimeHelperRegLocationImm(ThreadOffset helper_offset, RegLocation arg0, int arg1, bool safepoint_pc); - void CallRuntimeHelperImmReg(int helper_offset, int arg0, int arg1, + void CallRuntimeHelperImmReg(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc); - void CallRuntimeHelperRegImm(int helper_offset, int arg0, int arg1, + void CallRuntimeHelperRegImm(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc); - void CallRuntimeHelperImmMethod(int helper_offset, int arg0, + void CallRuntimeHelperImmMethod(ThreadOffset helper_offset, int arg0, bool safepoint_pc); - void CallRuntimeHelperRegLocationRegLocation(int helper_offset, + void CallRuntimeHelperRegLocationRegLocation(ThreadOffset helper_offset, RegLocation arg0, RegLocation arg1, bool safepoint_pc); - void CallRuntimeHelperRegReg(int helper_offset, int arg0, int arg1, + void CallRuntimeHelperRegReg(ThreadOffset helper_offset, int arg0, int arg1, bool safepoint_pc); - void CallRuntimeHelperRegRegImm(int helper_offset, int arg0, int arg1, + void CallRuntimeHelperRegRegImm(ThreadOffset helper_offset, int arg0, int arg1, int arg2, bool safepoint_pc); - void CallRuntimeHelperImmMethodRegLocation(int helper_offset, int arg0, + void CallRuntimeHelperImmMethodRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg2, bool safepoint_pc); - void CallRuntimeHelperImmMethodImm(int helper_offset, int arg0, int arg2, + void CallRuntimeHelperImmMethodImm(ThreadOffset helper_offset, int arg0, int arg2, bool safepoint_pc); - void CallRuntimeHelperImmRegLocationRegLocation(int helper_offset, + void CallRuntimeHelperImmRegLocationRegLocation(ThreadOffset helper_offset, int arg0, RegLocation arg1, RegLocation arg2, bool safepoint_pc); void GenInvoke(CallInfo* info); @@ -526,7 +526,7 @@ class Mir2Lir : public Backend { // Required for target - codegen helpers. virtual bool SmallLiteralDivide(Instruction::Code dalvik_opcode, RegLocation rl_src, RegLocation rl_dest, int lit) = 0; - virtual int LoadHelper(int offset) = 0; + virtual int LoadHelper(ThreadOffset offset) = 0; virtual LIR* LoadBaseDisp(int rBase, int displacement, int r_dest, OpSize size, int s_reg) = 0; virtual LIR* LoadBaseDispWide(int rBase, int displacement, int r_dest_lo, int r_dest_hi, int s_reg) = 0; @@ -674,14 +674,14 @@ class Mir2Lir : public Backend { virtual LIR* OpRegRegReg(OpKind op, int r_dest, int r_src1, int r_src2) = 0; virtual LIR* OpTestSuspend(LIR* target) = 0; - virtual LIR* OpThreadMem(OpKind op, int thread_offset) = 0; + virtual LIR* OpThreadMem(OpKind op, ThreadOffset thread_offset) = 0; virtual LIR* OpVldm(int rBase, int count) = 0; virtual LIR* OpVstm(int rBase, int count) = 0; virtual void OpLea(int rBase, int reg1, int reg2, int scale, int offset) = 0; virtual void OpRegCopyWide(int dest_lo, int dest_hi, int src_lo, int src_hi) = 0; - virtual void OpTlsCmp(int offset, int val) = 0; + virtual void OpTlsCmp(ThreadOffset offset, int val) = 0; virtual bool InexpensiveConstantInt(int32_t value) = 0; virtual bool InexpensiveConstantFloat(int32_t value) = 0; virtual bool InexpensiveConstantLong(int64_t value) = 0; diff --git a/compiler/dex/quick/x86/call_x86.cc b/compiler/dex/quick/x86/call_x86.cc index 1c395def55..6e3e55fc4e 100644 --- a/compiler/dex/quick/x86/call_x86.cc +++ b/compiler/dex/quick/x86/call_x86.cc @@ -148,7 +148,7 @@ void X86Mir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { NewLIR1(kX86StartOfMethod, rX86_ARG2); NewLIR2(kX86PcRelAdr, rX86_ARG1, reinterpret_cast(tab_rec)); NewLIR2(kX86Add32RR, rX86_ARG1, rX86_ARG2); - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode), rX86_ARG0, + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pHandleFillArrayData), rX86_ARG0, rX86_ARG1, true); } @@ -165,7 +165,7 @@ void X86Mir2Lir::GenMonitorEnter(int opt_flags, RegLocation rl_src) { NewLIR3(kX86LockCmpxchgMR, rCX, mirror::Object::MonitorOffset().Int32Value(), rDX); LIR* branch = NewLIR2(kX86Jcc8, 0, kX86CondEq); // If lock is held, go the expensive route - artLockObjectFromCode(self, obj); - CallRuntimeHelperReg(QUICK_ENTRYPOINT_OFFSET(pLockObjectFromCode), rCX, true); + CallRuntimeHelperReg(QUICK_ENTRYPOINT_OFFSET(pLockObject), rCX, true); branch->target = NewLIR0(kPseudoTargetLabel); } @@ -185,7 +185,7 @@ void X86Mir2Lir::GenMonitorExit(int opt_flags, RegLocation rl_src) { LIR* branch2 = NewLIR1(kX86Jmp8, 0); branch->target = NewLIR0(kPseudoTargetLabel); // Otherwise, go the expensive route - UnlockObjectFromCode(obj); - CallRuntimeHelperReg(QUICK_ENTRYPOINT_OFFSET(pUnlockObjectFromCode), rAX, true); + CallRuntimeHelperReg(QUICK_ENTRYPOINT_OFFSET(pUnlockObject), rAX, true); branch2->target = NewLIR0(kPseudoTargetLabel); } @@ -243,7 +243,7 @@ void X86Mir2Lir::GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) { if (!skip_overflow_check) { // cmp rX86_SP, fs:[stack_end_]; jcc throw_launchpad LIR* tgt = RawLIR(0, kPseudoThrowTarget, kThrowStackOverflow, 0, 0, 0, 0); - OpRegThreadMem(kOpCmp, rX86_SP, Thread::StackEndOffset().Int32Value()); + OpRegThreadMem(kOpCmp, rX86_SP, Thread::StackEndOffset()); OpCondBranch(kCondUlt, tgt); // Remember branch target - will process later throw_launchpads_.Insert(tgt); diff --git a/compiler/dex/quick/x86/codegen_x86.h b/compiler/dex/quick/x86/codegen_x86.h index edb5ae57c2..21328d5440 100644 --- a/compiler/dex/quick/x86/codegen_x86.h +++ b/compiler/dex/quick/x86/codegen_x86.h @@ -29,7 +29,7 @@ class X86Mir2Lir : public Mir2Lir { // Required for target - codegen helpers. bool SmallLiteralDivide(Instruction::Code dalvik_opcode, RegLocation rl_src, RegLocation rl_dest, int lit); - int LoadHelper(int offset); + int LoadHelper(ThreadOffset offset); LIR* LoadBaseDisp(int rBase, int displacement, int r_dest, OpSize size, int s_reg); LIR* LoadBaseDispWide(int rBase, int displacement, int r_dest_lo, int r_dest_hi, int s_reg); @@ -154,14 +154,14 @@ class X86Mir2Lir : public Mir2Lir { LIR* OpRegRegImm(OpKind op, int r_dest, int r_src1, int value); LIR* OpRegRegReg(OpKind op, int r_dest, int r_src1, int r_src2); LIR* OpTestSuspend(LIR* target); - LIR* OpThreadMem(OpKind op, int thread_offset); + LIR* OpThreadMem(OpKind op, ThreadOffset thread_offset); LIR* OpVldm(int rBase, int count); LIR* OpVstm(int rBase, int count); void OpLea(int rBase, int reg1, int reg2, int scale, int offset); void OpRegCopyWide(int dest_lo, int dest_hi, int src_lo, int src_hi); - void OpTlsCmp(int offset, int val); + void OpTlsCmp(ThreadOffset offset, int val); - void OpRegThreadMem(OpKind op, int r_dest, int thread_offset); + void OpRegThreadMem(OpKind op, int r_dest, ThreadOffset thread_offset); void SpillCoreRegs(); void UnSpillCoreRegs(); static const X86EncodingMap EncodingMap[kX86Last]; diff --git a/compiler/dex/quick/x86/int_x86.cc b/compiler/dex/quick/x86/int_x86.cc index 0b4b4be04e..377d134c80 100644 --- a/compiler/dex/quick/x86/int_x86.cc +++ b/compiler/dex/quick/x86/int_x86.cc @@ -240,8 +240,8 @@ void X86Mir2Lir::OpLea(int rBase, int reg1, int reg2, int scale, int offset) { NewLIR5(kX86Lea32RA, rBase, reg1, reg2, scale, offset); } -void X86Mir2Lir::OpTlsCmp(int offset, int val) { - NewLIR2(kX86Cmp16TI8, offset, val); +void X86Mir2Lir::OpTlsCmp(ThreadOffset offset, int val) { + NewLIR2(kX86Cmp16TI8, offset.Int32Value(), val); } bool X86Mir2Lir::GenInlinedCas32(CallInfo* info, bool need_write_barrier) { @@ -285,7 +285,7 @@ void X86Mir2Lir::GenDivZeroCheck(int reg_lo, int reg_hi) { // Test suspend flag, return target of taken suspend branch LIR* X86Mir2Lir::OpTestSuspend(LIR* target) { - OpTlsCmp(Thread::ThreadFlagsOffset().Int32Value(), 0); + OpTlsCmp(Thread::ThreadFlagsOffset(), 0); return OpCondBranch((target == NULL) ? kCondNe : kCondEq, target); } @@ -403,7 +403,7 @@ void X86Mir2Lir::GenNegLong(RegLocation rl_dest, RegLocation rl_src) { StoreValueWide(rl_dest, rl_result); } -void X86Mir2Lir::OpRegThreadMem(OpKind op, int r_dest, int thread_offset) { +void X86Mir2Lir::OpRegThreadMem(OpKind op, int r_dest, ThreadOffset thread_offset) { X86OpCode opcode = kX86Bkpt; switch (op) { case kOpCmp: opcode = kX86Cmp32RT; break; @@ -412,7 +412,7 @@ void X86Mir2Lir::OpRegThreadMem(OpKind op, int r_dest, int thread_offset) { LOG(FATAL) << "Bad opcode: " << op; break; } - NewLIR2(opcode, r_dest, thread_offset); + NewLIR2(opcode, r_dest, thread_offset.Int32Value()); } /* @@ -532,7 +532,7 @@ void X86Mir2Lir::GenArrayObjPut(int opt_flags, RegLocation rl_array, // Get the array's class. LoadWordDisp(r_array, mirror::Object::ClassOffset().Int32Value(), r_array_class); - CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElementFromCode), r_value, + CallRuntimeHelperRegReg(QUICK_ENTRYPOINT_OFFSET(pCanPutArrayElement), r_value, r_array_class, true); // Redo LoadValues in case they didn't survive the call. LoadValueDirectFixed(rl_array, r_array); // Reload array diff --git a/compiler/dex/quick/x86/target_x86.cc b/compiler/dex/quick/x86/target_x86.cc index 2c9b3c837c..699f3ae5bb 100644 --- a/compiler/dex/quick/x86/target_x86.cc +++ b/compiler/dex/quick/x86/target_x86.cc @@ -524,7 +524,7 @@ Mir2Lir* X86CodeGenerator(CompilationUnit* const cu, MIRGraph* const mir_graph, } // Not used in x86 -int X86Mir2Lir::LoadHelper(int offset) { +int X86Mir2Lir::LoadHelper(ThreadOffset offset) { LOG(FATAL) << "Unexpected use of LoadHelper in x86"; return INVALID_REG; } diff --git a/compiler/dex/quick/x86/utility_x86.cc b/compiler/dex/quick/x86/utility_x86.cc index e15995fef4..c519bfec44 100644 --- a/compiler/dex/quick/x86/utility_x86.cc +++ b/compiler/dex/quick/x86/utility_x86.cc @@ -292,7 +292,7 @@ LIR* X86Mir2Lir::OpRegRegImm(OpKind op, int r_dest, int r_src, return OpRegImm(op, r_dest, value); } -LIR* X86Mir2Lir::OpThreadMem(OpKind op, int thread_offset) { +LIR* X86Mir2Lir::OpThreadMem(OpKind op, ThreadOffset thread_offset) { X86OpCode opcode = kX86Bkpt; switch (op) { case kOpBlx: opcode = kX86CallT; break; @@ -300,7 +300,7 @@ LIR* X86Mir2Lir::OpThreadMem(OpKind op, int thread_offset) { LOG(FATAL) << "Bad opcode: " << op; break; } - return NewLIR1(opcode, thread_offset); + return NewLIR1(opcode, thread_offset.Int32Value()); } LIR* X86Mir2Lir::OpMem(OpKind op, int rBase, int disp) { diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 38d00a0804..8b09df7e92 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -41,9 +41,9 @@ #include "mirror/throwable.h" #include "scoped_thread_state_change.h" #include "ScopedLocalRef.h" -#include "stubs/stubs.h" #include "thread.h" #include "thread_pool.h" +#include "trampolines/trampoline_compiler.h" #include "verifier/method_verifier.h" #if defined(ART_USE_PORTABLE_COMPILER) @@ -433,64 +433,38 @@ CompilerTls* CompilerDriver::GetTls() { return res; } +const std::vector* CompilerDriver::CreateInterpreterToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kInterpreterAbi, + INTERPRETER_ENTRYPOINT_OFFSET(pInterpreterToInterpreterBridge)); +} + +const std::vector* CompilerDriver::CreateInterpreterToCompiledCodeBridge() const { + return CreateTrampoline(instruction_set_, kInterpreterAbi, + INTERPRETER_ENTRYPOINT_OFFSET(pInterpreterToCompiledCodeBridge)); +} + +const std::vector* CompilerDriver::CreateJniDlsymLookup() const { + return CreateTrampoline(instruction_set_, kJniAbi, JNI_ENTRYPOINT_OFFSET(pDlsymLookup)); +} + const std::vector* CompilerDriver::CreatePortableResolutionTrampoline() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreatePortableResolutionTrampoline(); - case kMips: - return mips::CreatePortableResolutionTrampoline(); - case kX86: - return x86::CreatePortableResolutionTrampoline(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } + return CreateTrampoline(instruction_set_, kPortableAbi, + PORTABLE_ENTRYPOINT_OFFSET(pPortableResolutionTrampoline)); } -const std::vector* CompilerDriver::CreateQuickResolutionTrampoline() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateQuickResolutionTrampoline(); - case kMips: - return mips::CreateQuickResolutionTrampoline(); - case kX86: - return x86::CreateQuickResolutionTrampoline(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreatePortableToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kPortableAbi, + PORTABLE_ENTRYPOINT_OFFSET(pPortableToInterpreterBridge)); } -const std::vector* CompilerDriver::CreateInterpreterToInterpreterEntry() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateInterpreterToInterpreterEntry(); - case kMips: - return mips::CreateInterpreterToInterpreterEntry(); - case kX86: - return x86::CreateInterpreterToInterpreterEntry(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreateQuickResolutionTrampoline() const { + return CreateTrampoline(instruction_set_, kQuickAbi, + QUICK_ENTRYPOINT_OFFSET(pQuickResolutionTrampoline)); } -const std::vector* CompilerDriver::CreateInterpreterToQuickEntry() const { - switch (instruction_set_) { - case kArm: - case kThumb2: - return arm::CreateInterpreterToQuickEntry(); - case kMips: - return mips::CreateInterpreterToQuickEntry(); - case kX86: - return x86::CreateInterpreterToQuickEntry(); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return NULL; - } +const std::vector* CompilerDriver::CreateQuickToInterpreterBridge() const { + return CreateTrampoline(instruction_set_, kQuickAbi, + QUICK_ENTRYPOINT_OFFSET(pQuickToInterpreterBridge)); } void CompilerDriver::CompileAll(jobject class_loader, diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 18f852dc6f..b5222c99b8 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -48,6 +48,17 @@ enum CompilerBackend { kNoBackend }; +enum EntryPointCallingConvention { + // ABI of invocations to a method's interpreter entry point. + kInterpreterAbi, + // ABI of calls to a method's native code, only used for native methods. + kJniAbi, + // ABI of calls to a method's portable code entry point. + kPortableAbi, + // ABI of calls to a method's quick code entry point. + kQuickAbi +}; + enum DexToDexCompilationLevel { kDontDexToDexCompile, // Only meaning wrt image time interpretation. kRequired, // Dex-to-dex compilation required for correctness. @@ -110,13 +121,19 @@ class CompilerDriver { CompilerTls* GetTls(); // Generate the trampolines that are invoked by unresolved direct methods. + const std::vector* CreateInterpreterToInterpreterBridge() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const std::vector* CreateInterpreterToCompiledCodeBridge() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const std::vector* CreateJniDlsymLookup() const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); const std::vector* CreatePortableResolutionTrampoline() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const std::vector* CreateQuickResolutionTrampoline() const + const std::vector* CreatePortableToInterpreterBridge() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const std::vector* CreateInterpreterToInterpreterEntry() const + const std::vector* CreateQuickResolutionTrampoline() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const std::vector* CreateInterpreterToQuickEntry() const + const std::vector* CreateQuickToInterpreterBridge() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); CompiledClass* GetCompiledClass(ClassReference ref) const diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index e73d021c0c..550d642753 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -90,11 +90,23 @@ bool ImageWriter::Write(const std::string& image_filename, return false; } class_linker->RegisterOatFile(*oat_file_); - interpreter_to_interpreter_entry_offset_ = oat_file_->GetOatHeader().GetInterpreterToInterpreterEntryOffset(); - interpreter_to_quick_entry_offset_ = oat_file_->GetOatHeader().GetInterpreterToQuickEntryOffset(); - portable_resolution_trampoline_offset_ = oat_file_->GetOatHeader().GetPortableResolutionTrampolineOffset(); - quick_resolution_trampoline_offset_ = oat_file_->GetOatHeader().GetQuickResolutionTrampolineOffset(); + interpreter_to_interpreter_bridge_offset_ = + oat_file_->GetOatHeader().GetInterpreterToInterpreterBridgeOffset(); + interpreter_to_compiled_code_bridge_offset_ = + oat_file_->GetOatHeader().GetInterpreterToCompiledCodeBridgeOffset(); + + jni_dlsym_lookup_offset_ = oat_file_->GetOatHeader().GetJniDlsymLookupOffset(); + + portable_resolution_trampoline_offset_ = + oat_file_->GetOatHeader().GetPortableResolutionTrampolineOffset(); + portable_to_interpreter_bridge_offset_ = + oat_file_->GetOatHeader().GetPortableToInterpreterBridgeOffset(); + + quick_resolution_trampoline_offset_ = + oat_file_->GetOatHeader().GetQuickResolutionTrampolineOffset(); + quick_to_interpreter_bridge_offset_ = + oat_file_->GetOatHeader().GetQuickToInterpreterBridgeOffset(); { Thread::Current()->TransitionFromSuspendedToRunnable(); PruneNonImageClasses(); // Remove junk @@ -490,57 +502,62 @@ void ImageWriter::FixupClass(const Class* orig, Class* copy) { void ImageWriter::FixupMethod(const AbstractMethod* orig, AbstractMethod* copy) { FixupInstanceFields(orig, copy); - // OatWriter replaces the code_ with an offset value. - // Here we readjust to a pointer relative to oat_begin_ - if (orig->IsAbstract()) { - // Code for abstract methods is set to the abstract method error stub when we load the image. - copy->SetEntryPointFromCompiledCode(NULL); - copy->SetEntryPointFromInterpreter(reinterpret_cast - (GetOatAddress(interpreter_to_interpreter_entry_offset_))); - return; - } else { - copy->SetEntryPointFromInterpreter(reinterpret_cast - (GetOatAddress(interpreter_to_quick_entry_offset_))); - } + // OatWriter replaces the code_ with an offset value. Here we re-adjust to a pointer relative to + // oat_begin_ - if (orig == Runtime::Current()->GetResolutionMethod()) { + // The resolution method has a special trampoline to call. + if (UNLIKELY(orig == Runtime::Current()->GetResolutionMethod())) { #if defined(ART_USE_PORTABLE_COMPILER) copy->SetEntryPointFromCompiledCode(GetOatAddress(portable_resolution_trampoline_offset_)); #else copy->SetEntryPointFromCompiledCode(GetOatAddress(quick_resolution_trampoline_offset_)); #endif - return; - } - - // Use original code if it exists. Otherwise, set the code pointer to the resolution trampoline. - const byte* code = GetOatAddress(orig->GetOatCodeOffset()); - if (code != NULL) { - copy->SetEntryPointFromCompiledCode(code); } else { + // We assume all methods have code. If they don't currently then we set them to the use the + // resolution trampoline. Abstract methods never have code and so we need to make sure their + // use results in an AbstractMethodError. We use the interpreter to achieve this. + if (UNLIKELY(orig->IsAbstract())) { #if defined(ART_USE_PORTABLE_COMPILER) - copy->SetEntryPointFromCompiledCode(GetOatAddress(portable_resolution_trampoline_offset_)); + copy->SetEntryPointFromCompiledCode(GetOatAddress(portable_to_interpreter_bridge_offset_)); #else - copy->SetEntryPointFromCompiledCode(GetOatAddress(quick_resolution_trampoline_offset_)); + copy->SetEntryPointFromCompiledCode(GetOatAddress(quick_to_interpreter_bridge_offset_)); #endif - } - - if (orig->IsNative()) { - // The native method's pointer is set to a stub to lookup via dlsym when we load the image. - // Note this is not the code_ pointer, that is handled above. - copy->SetNativeMethod(NULL); - } else { - // normal (non-abstract non-native) methods have mapping tables to relocate - uint32_t mapping_table_off = orig->GetOatMappingTableOffset(); - const byte* mapping_table = GetOatAddress(mapping_table_off); - copy->SetMappingTable(reinterpret_cast(mapping_table)); - - uint32_t vmap_table_offset = orig->GetOatVmapTableOffset(); - const byte* vmap_table = GetOatAddress(vmap_table_offset); - copy->SetVmapTable(reinterpret_cast(vmap_table)); - - uint32_t native_gc_map_offset = orig->GetOatNativeGcMapOffset(); - const byte* native_gc_map = GetOatAddress(native_gc_map_offset); - copy->SetNativeGcMap(reinterpret_cast(native_gc_map)); + copy->SetEntryPointFromInterpreter(reinterpret_cast + (GetOatAddress(interpreter_to_interpreter_bridge_offset_))); + } else { + copy->SetEntryPointFromInterpreter(reinterpret_cast + (GetOatAddress(interpreter_to_compiled_code_bridge_offset_))); + // Use original code if it exists. Otherwise, set the code pointer to the resolution + // trampoline. + const byte* code = GetOatAddress(orig->GetOatCodeOffset()); + if (code != NULL) { + copy->SetEntryPointFromCompiledCode(code); + } else { +#if defined(ART_USE_PORTABLE_COMPILER) + copy->SetEntryPointFromCompiledCode(GetOatAddress(portable_resolution_trampoline_offset_)); +#else + copy->SetEntryPointFromCompiledCode(GetOatAddress(quick_resolution_trampoline_offset_)); +#endif + } + if (orig->IsNative()) { + // The native method's pointer is set to a stub to lookup via dlsym. + // Note this is not the code_ pointer, that is handled above. + copy->SetNativeMethod(GetOatAddress(jni_dlsym_lookup_offset_)); + } else { + // Normal (non-abstract non-native) methods have various tables to relocate. + uint32_t mapping_table_off = orig->GetOatMappingTableOffset(); + const byte* mapping_table = GetOatAddress(mapping_table_off); + copy->SetMappingTable(reinterpret_cast(mapping_table)); + + uint32_t vmap_table_offset = orig->GetOatVmapTableOffset(); + const byte* vmap_table = GetOatAddress(vmap_table_offset); + copy->SetVmapTable(reinterpret_cast(vmap_table)); + + uint32_t native_gc_map_offset = orig->GetOatNativeGcMapOffset(); + const byte* native_gc_map = GetOatAddress(native_gc_map_offset); + copy->SetNativeGcMap(reinterpret_cast(native_gc_map)); + } + } } } diff --git a/compiler/image_writer.h b/compiler/image_writer.h index e43ec6338f..545534fff7 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -39,8 +39,8 @@ class ImageWriter { public: explicit ImageWriter(const CompilerDriver& compiler_driver) : compiler_driver_(compiler_driver), oat_file_(NULL), image_end_(0), image_begin_(NULL), - oat_data_begin_(NULL), interpreter_to_interpreter_entry_offset_(0), - interpreter_to_quick_entry_offset_(0), portable_resolution_trampoline_offset_(0), + oat_data_begin_(NULL), interpreter_to_interpreter_bridge_offset_(0), + interpreter_to_compiled_code_bridge_offset_(0), portable_resolution_trampoline_offset_(0), quick_resolution_trampoline_offset_(0) {} ~ImageWriter() {} @@ -195,10 +195,13 @@ class ImageWriter { const byte* oat_data_begin_; // Offset from oat_data_begin_ to the stubs. - uint32_t interpreter_to_interpreter_entry_offset_; - uint32_t interpreter_to_quick_entry_offset_; + uint32_t interpreter_to_interpreter_bridge_offset_; + uint32_t interpreter_to_compiled_code_bridge_offset_; + uint32_t jni_dlsym_lookup_offset_; uint32_t portable_resolution_trampoline_offset_; + uint32_t portable_to_interpreter_bridge_offset_; uint32_t quick_resolution_trampoline_offset_; + uint32_t quick_to_interpreter_bridge_offset_; // DexCaches seen while scanning for fixing up CodeAndDirectMethods typedef std::set Set; diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index b069fbd4a1..9713fe9da9 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -172,8 +172,8 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, // can occur. The result is the saved JNI local state that is restored by the exit call. We // abuse the JNI calling convention here, that is guaranteed to support passing 2 pointer // arguments. - uintptr_t jni_start = is_synchronized ? QUICK_ENTRYPOINT_OFFSET(pJniMethodStartSynchronized) - : QUICK_ENTRYPOINT_OFFSET(pJniMethodStart); + ThreadOffset jni_start = is_synchronized ? QUICK_ENTRYPOINT_OFFSET(pJniMethodStartSynchronized) + : QUICK_ENTRYPOINT_OFFSET(pJniMethodStart); main_jni_conv->ResetIterator(FrameOffset(main_out_arg_size)); FrameOffset locked_object_sirt_offset(0); if (is_synchronized) { @@ -301,7 +301,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, // 12. Call into JNI method end possibly passing a returned reference, the method and the current // thread. end_jni_conv->ResetIterator(FrameOffset(end_out_arg_size)); - uintptr_t jni_end; + ThreadOffset jni_end(-1); if (reference_return) { // Pass result. jni_end = is_synchronized ? QUICK_ENTRYPOINT_OFFSET(pJniMethodEndWithReferenceSynchronized) diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 5eb837b25c..21c5317b69 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -51,11 +51,14 @@ OatWriter::OatWriter(const std::vector& dex_files, size_oat_header_(0), size_oat_header_image_file_location_(0), size_dex_file_(0), - size_interpreter_to_interpreter_entry_(0), - size_interpreter_to_quick_entry_(0), + size_interpreter_to_interpreter_bridge_(0), + size_interpreter_to_compiled_code_bridge_(0), + size_jni_dlsym_lookup_(0), size_portable_resolution_trampoline_(0), + size_portable_to_interpreter_bridge_(0), size_quick_resolution_trampoline_(0), - size_stubs_alignment_(0), + size_quick_to_interpreter_bridge_(0), + size_trampoline_alignment_(0), size_code_size_(0), size_code_(0), size_code_alignment_(0), @@ -176,30 +179,30 @@ size_t OatWriter::InitOatCode(size_t offset) { size_executable_offset_alignment_ = offset - old_offset; if (compiler_driver_->IsImage()) { InstructionSet instruction_set = compiler_driver_->GetInstructionSet(); - oat_header_->SetInterpreterToInterpreterEntryOffset(offset); - interpreter_to_interpreter_entry_.reset( - compiler_driver_->CreateInterpreterToInterpreterEntry()); - offset += interpreter_to_interpreter_entry_->size(); - - offset = CompiledCode::AlignCode(offset, instruction_set); - oat_header_->SetInterpreterToQuickEntryOffset(offset); - interpreter_to_quick_entry_.reset(compiler_driver_->CreateInterpreterToQuickEntry()); - offset += interpreter_to_quick_entry_->size(); - - offset = CompiledCode::AlignCode(offset, instruction_set); - oat_header_->SetPortableResolutionTrampolineOffset(offset); - portable_resolution_trampoline_.reset(compiler_driver_->CreatePortableResolutionTrampoline()); - offset += portable_resolution_trampoline_->size(); - - offset = CompiledCode::AlignCode(offset, instruction_set); - oat_header_->SetQuickResolutionTrampolineOffset(offset); - quick_resolution_trampoline_.reset(compiler_driver_->CreateQuickResolutionTrampoline()); - offset += quick_resolution_trampoline_->size(); + + #define DO_TRAMPOLINE(field, fn_name) \ + offset = CompiledCode::AlignCode(offset, instruction_set); \ + oat_header_->Set ## fn_name ## Offset(offset); \ + field.reset(compiler_driver_->Create ## fn_name()); \ + offset += field->size(); + + DO_TRAMPOLINE(interpreter_to_interpreter_bridge_, InterpreterToInterpreterBridge); + DO_TRAMPOLINE(interpreter_to_compiled_code_bridge_, InterpreterToCompiledCodeBridge); + DO_TRAMPOLINE(jni_dlsym_lookup_, JniDlsymLookup); + DO_TRAMPOLINE(portable_resolution_trampoline_, PortableResolutionTrampoline); + DO_TRAMPOLINE(portable_to_interpreter_bridge_, PortableToInterpreterBridge); + DO_TRAMPOLINE(quick_resolution_trampoline_, QuickResolutionTrampoline); + DO_TRAMPOLINE(quick_to_interpreter_bridge_, QuickToInterpreterBridge); + + #undef DO_TRAMPOLINE } else { - oat_header_->SetInterpreterToInterpreterEntryOffset(0); - oat_header_->SetInterpreterToQuickEntryOffset(0); + oat_header_->SetInterpreterToInterpreterBridgeOffset(0); + oat_header_->SetInterpreterToCompiledCodeBridgeOffset(0); + oat_header_->SetJniDlsymLookupOffset(0); oat_header_->SetPortableResolutionTrampolineOffset(0); + oat_header_->SetPortableToInterpreterBridgeOffset(0); oat_header_->SetQuickResolutionTrampolineOffset(0); + oat_header_->SetQuickToInterpreterBridgeOffset(0); } return offset; } @@ -469,11 +472,14 @@ bool OatWriter::Write(OutputStream& out) { DO_STAT(size_oat_header_); DO_STAT(size_oat_header_image_file_location_); DO_STAT(size_dex_file_); - DO_STAT(size_interpreter_to_interpreter_entry_); - DO_STAT(size_interpreter_to_quick_entry_); + DO_STAT(size_interpreter_to_interpreter_bridge_); + DO_STAT(size_interpreter_to_compiled_code_bridge_); + DO_STAT(size_jni_dlsym_lookup_); DO_STAT(size_portable_resolution_trampoline_); + DO_STAT(size_portable_to_interpreter_bridge_); DO_STAT(size_quick_resolution_trampoline_); - DO_STAT(size_stubs_alignment_); + DO_STAT(size_quick_to_interpreter_bridge_); + DO_STAT(size_trampoline_alignment_); DO_STAT(size_code_size_); DO_STAT(size_code_); DO_STAT(size_code_alignment_); @@ -545,52 +551,30 @@ size_t OatWriter::WriteCode(OutputStream& out, const size_t file_offset) { DCHECK_OFFSET(); if (compiler_driver_->IsImage()) { InstructionSet instruction_set = compiler_driver_->GetInstructionSet(); - if (!out.WriteFully(&(*interpreter_to_interpreter_entry_)[0], - interpreter_to_interpreter_entry_->size())) { - PLOG(ERROR) << "Failed to write interpreter to interpreter entry to " << out.GetLocation(); - return false; - } - size_interpreter_to_interpreter_entry_ += interpreter_to_interpreter_entry_->size(); - relative_offset += interpreter_to_interpreter_entry_->size(); - DCHECK_OFFSET(); - - uint32_t aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); - uint32_t alignment_padding = aligned_offset - relative_offset; - out.Seek(alignment_padding, kSeekCurrent); - size_stubs_alignment_ += alignment_padding; - if (!out.WriteFully(&(*interpreter_to_quick_entry_)[0], interpreter_to_quick_entry_->size())) { - PLOG(ERROR) << "Failed to write interpreter to quick entry to " << out.GetLocation(); - return false; - } - size_interpreter_to_quick_entry_ += interpreter_to_quick_entry_->size(); - relative_offset += alignment_padding + interpreter_to_quick_entry_->size(); - DCHECK_OFFSET(); - aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); - alignment_padding = aligned_offset - relative_offset; - out.Seek(alignment_padding, kSeekCurrent); - size_stubs_alignment_ += alignment_padding; - if (!out.WriteFully(&(*portable_resolution_trampoline_)[0], - portable_resolution_trampoline_->size())) { - PLOG(ERROR) << "Failed to write portable resolution trampoline to " << out.GetLocation(); - return false; - } - size_portable_resolution_trampoline_ += portable_resolution_trampoline_->size(); - relative_offset += alignment_padding + portable_resolution_trampoline_->size(); - DCHECK_OFFSET(); - - aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); - alignment_padding = aligned_offset - relative_offset; - out.Seek(alignment_padding, kSeekCurrent); - size_stubs_alignment_ += alignment_padding; - if (!out.WriteFully(&(*quick_resolution_trampoline_)[0], - quick_resolution_trampoline_->size())) { - PLOG(ERROR) << "Failed to write quick resolution trampoline to " << out.GetLocation(); - return false; - } - size_quick_resolution_trampoline_ += quick_resolution_trampoline_->size(); - relative_offset += alignment_padding + quick_resolution_trampoline_->size(); - DCHECK_OFFSET(); + #define DO_TRAMPOLINE(field) \ + do { \ + uint32_t aligned_offset = CompiledCode::AlignCode(relative_offset, instruction_set); \ + uint32_t alignment_padding = aligned_offset - relative_offset; \ + out.Seek(alignment_padding, kSeekCurrent); \ + size_trampoline_alignment_ += alignment_padding; \ + if (!out.WriteFully(&(*field)[0], field->size())) { \ + PLOG(ERROR) << "Failed to write " # field " to " << out.GetLocation(); \ + return false; \ + } \ + size_ ## field += field->size(); \ + relative_offset += alignment_padding + field->size(); \ + DCHECK_OFFSET(); \ + } while (false) + + DO_TRAMPOLINE(interpreter_to_interpreter_bridge_); + DO_TRAMPOLINE(interpreter_to_compiled_code_bridge_); + DO_TRAMPOLINE(jni_dlsym_lookup_); + DO_TRAMPOLINE(portable_resolution_trampoline_); + DO_TRAMPOLINE(portable_to_interpreter_bridge_); + DO_TRAMPOLINE(quick_resolution_trampoline_); + DO_TRAMPOLINE(quick_to_interpreter_bridge_); + #undef DO_TRAMPOLINE } return relative_offset; } diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index f2c5626b4d..e6cc0bce80 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -181,10 +181,13 @@ class OatWriter { OatHeader* oat_header_; std::vector oat_dex_files_; std::vector oat_classes_; - UniquePtr > interpreter_to_interpreter_entry_; - UniquePtr > interpreter_to_quick_entry_; + UniquePtr > interpreter_to_interpreter_bridge_; + UniquePtr > interpreter_to_compiled_code_bridge_; + UniquePtr > jni_dlsym_lookup_; UniquePtr > portable_resolution_trampoline_; + UniquePtr > portable_to_interpreter_bridge_; UniquePtr > quick_resolution_trampoline_; + UniquePtr > quick_to_interpreter_bridge_; // output stats uint32_t size_dex_file_alignment_; @@ -192,11 +195,14 @@ class OatWriter { uint32_t size_oat_header_; uint32_t size_oat_header_image_file_location_; uint32_t size_dex_file_; - uint32_t size_interpreter_to_interpreter_entry_; - uint32_t size_interpreter_to_quick_entry_; + uint32_t size_interpreter_to_interpreter_bridge_; + uint32_t size_interpreter_to_compiled_code_bridge_; + uint32_t size_jni_dlsym_lookup_; uint32_t size_portable_resolution_trampoline_; + uint32_t size_portable_to_interpreter_bridge_; uint32_t size_quick_resolution_trampoline_; - uint32_t size_stubs_alignment_; + uint32_t size_quick_to_interpreter_bridge_; + uint32_t size_trampoline_alignment_; uint32_t size_code_size_; uint32_t size_code_; uint32_t size_code_alignment_; diff --git a/compiler/stubs/portable/stubs.cc b/compiler/stubs/portable/stubs.cc deleted file mode 100644 index def43e2bd2..0000000000 --- a/compiler/stubs/portable/stubs.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2011 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 "stubs/stubs.h" - -#include "entrypoints/quick/quick_entrypoints.h" -#include "jni_internal.h" -#include "utils/arm/assembler_arm.h" -#include "utils/mips/assembler_mips.h" -#include "utils/x86/assembler_x86.h" -#include "stack_indirect_reference_table.h" -#include "sirt_ref.h" - -#define __ assembler-> - -namespace art { - -namespace arm { -const std::vector* CreatePortableResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kArm))); - RegList save = (1 << R0) | (1 << R1) | (1 << R2) | (1 << R3) | (1 << LR); - - __ PushList(save); - __ LoadFromOffset(kLoadWord, R12, TR, - PORTABLE_ENTRYPOINT_OFFSET(pPortableResolutionTrampolineFromCode)); - __ mov(R3, ShifterOperand(TR)); // Pass Thread::Current() in R3 - __ mov(R2, ShifterOperand(SP)); // Pass sp for Method** callee_addr - __ IncreaseFrameSize(12); // 3 words of space for alignment - // Call to resolution trampoline (callee, receiver, callee_addr, Thread*) - __ blx(R12); - __ mov(R12, ShifterOperand(R0)); // Save code address returned into R12 - __ DecreaseFrameSize(12); - __ PopList(save); - __ cmp(R12, ShifterOperand(0)); - __ bx(R12, NE); // If R12 != 0 tail call method's code - __ bx(LR); // Return to caller to handle exception - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} -} // namespace arm - -namespace mips { -const std::vector* CreatePortableResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kMips))); - // Build frame and save argument registers and RA. - __ AddConstant(SP, SP, -32); - __ StoreToOffset(kStoreWord, RA, SP, 28); - __ StoreToOffset(kStoreWord, A3, SP, 12); - __ StoreToOffset(kStoreWord, A2, SP, 8); - __ StoreToOffset(kStoreWord, A1, SP, 4); - __ StoreToOffset(kStoreWord, A0, SP, 0); - - __ LoadFromOffset(kLoadWord, T9, S1, - PORTABLE_ENTRYPOINT_OFFSET(pPortableResolutionTrampolineFromCode)); - __ Move(A3, S1); // Pass Thread::Current() in A3 - __ Move(A2, SP); // Pass SP for Method** callee_addr - __ Jalr(T9); // Call to resolution trampoline (callee, receiver, callee_addr, Thread*) - - // Restore frame, argument registers, and RA. - __ LoadFromOffset(kLoadWord, A0, SP, 0); - __ LoadFromOffset(kLoadWord, A1, SP, 4); - __ LoadFromOffset(kLoadWord, A2, SP, 8); - __ LoadFromOffset(kLoadWord, A3, SP, 12); - __ LoadFromOffset(kLoadWord, RA, SP, 28); - __ AddConstant(SP, SP, 32); - - Label resolve_fail; - __ EmitBranch(V0, ZERO, &resolve_fail, true); - __ Jr(V0); // If V0 != 0 tail call method's code - __ Bind(&resolve_fail, false); - __ Jr(RA); // Return to caller to handle exception - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} -} // namespace mips - -namespace x86 { -const std::vector* CreatePortableResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kX86))); - - __ pushl(EBP); - __ movl(EBP, ESP); // save ESP - __ subl(ESP, Immediate(8)); // Align stack - __ movl(EAX, Address(EBP, 8)); // Method* called - __ leal(EDX, Address(EBP, 8)); // Method** called_addr - __ fs()->pushl(Address::Absolute(Thread::SelfOffset())); // pass thread - __ pushl(EDX); // pass called_addr - __ pushl(ECX); // pass receiver - __ pushl(EAX); // pass called - // Call to resolve method. - __ Call(ThreadOffset(PORTABLE_ENTRYPOINT_OFFSET(pPortableResolutionTrampolineFromCode)), - X86ManagedRegister::FromCpuRegister(ECX)); - __ leave(); - - Label resolve_fail; // forward declaration - __ cmpl(EAX, Immediate(0)); - __ j(kEqual, &resolve_fail); - __ jmp(EAX); - // Tail call to intended method. - __ Bind(&resolve_fail); - __ ret(); - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} -} // namespace x86 - -} // namespace art diff --git a/compiler/stubs/quick/stubs.cc b/compiler/stubs/quick/stubs.cc deleted file mode 100644 index 912f1c0746..0000000000 --- a/compiler/stubs/quick/stubs.cc +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2011 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 "stubs/stubs.h" - -#include "entrypoints/quick/quick_entrypoints.h" -#include "jni_internal.h" -#include "utils/arm/assembler_arm.h" -#include "utils/mips/assembler_mips.h" -#include "utils/x86/assembler_x86.h" -#include "sirt_ref.h" -#include "stack_indirect_reference_table.h" - -#define __ assembler-> - -namespace art { - -namespace arm { -const std::vector* CreateQuickResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kArm))); - // | Out args | - // | Method* | <- SP on entry - // | LR | return address into caller - // | ... | callee saves - // | R3 | possible argument - // | R2 | possible argument - // | R1 | possible argument - // | R0 | junk on call to QuickResolutionTrampolineFromCode, holds result Method* - // | Method* | Callee save Method* set up by QuickResoltuionTrampolineFromCode - // Save callee saves and ready frame for exception delivery - RegList save = (1 << R1) | (1 << R2) | (1 << R3) | (1 << R5) | (1 << R6) | (1 << R7) | (1 << R8) | - (1 << R10) | (1 << R11) | (1 << LR); - // TODO: enable when GetCalleeSaveMethod is available at stub generation time - // DCHECK_EQ(save, Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetCoreSpillMask()); - __ PushList(save); - __ LoadFromOffset(kLoadWord, R12, TR, QUICK_ENTRYPOINT_OFFSET(pQuickResolutionTrampolineFromCode)); - __ mov(R3, ShifterOperand(TR)); // Pass Thread::Current() in R3 - __ IncreaseFrameSize(8); // 2 words of space for alignment - __ mov(R2, ShifterOperand(SP)); // Pass SP - // Call to resolution trampoline (method_idx, receiver, sp, Thread*) - __ blx(R12); - __ mov(R12, ShifterOperand(R0)); // Save code address returned into R12 - // Restore registers which may have been modified by GC, "R0" will hold the Method* - __ DecreaseFrameSize(4); - __ PopList((1 << R0) | save); - __ bx(R12); // Leaf call to method's code - __ bkpt(0); - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} - -const std::vector* CreateInterpreterToInterpreterEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kArm))); - - __ LoadFromOffset(kLoadWord, PC, R0, QUICK_ENTRYPOINT_OFFSET(pInterpreterToInterpreterEntry)); - __ bkpt(0); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} - -const std::vector* CreateInterpreterToQuickEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kArm))); - - __ LoadFromOffset(kLoadWord, PC, R0, QUICK_ENTRYPOINT_OFFSET(pInterpreterToQuickEntry)); - __ bkpt(0); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} -} // namespace arm - -namespace mips { -const std::vector* CreateQuickResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kMips))); - // | Out args | - // | Method* | <- SP on entry - // | RA | return address into caller - // | ... | callee saves - // | A3 | possible argument - // | A2 | possible argument - // | A1 | possible argument - // | A0/Method* | Callee save Method* set up by UnresolvedDirectMethodTrampolineFromCode - // Save callee saves and ready frame for exception delivery - __ AddConstant(SP, SP, -64); - __ StoreToOffset(kStoreWord, RA, SP, 60); - __ StoreToOffset(kStoreWord, FP, SP, 56); - __ StoreToOffset(kStoreWord, GP, SP, 52); - __ StoreToOffset(kStoreWord, S7, SP, 48); - __ StoreToOffset(kStoreWord, S6, SP, 44); - __ StoreToOffset(kStoreWord, S5, SP, 40); - __ StoreToOffset(kStoreWord, S4, SP, 36); - __ StoreToOffset(kStoreWord, S3, SP, 32); - __ StoreToOffset(kStoreWord, S2, SP, 28); - __ StoreToOffset(kStoreWord, A3, SP, 12); - __ StoreToOffset(kStoreWord, A2, SP, 8); - __ StoreToOffset(kStoreWord, A1, SP, 4); - - __ LoadFromOffset(kLoadWord, T9, S1, QUICK_ENTRYPOINT_OFFSET(pQuickResolutionTrampolineFromCode)); - __ Move(A3, S1); // Pass Thread::Current() in A3 - __ Move(A2, SP); // Pass SP for Method** callee_addr - __ Jalr(T9); // Call to resolution trampoline (method_idx, receiver, sp, Thread*) - - // Restore registers which may have been modified by GC - __ LoadFromOffset(kLoadWord, A0, SP, 0); - __ LoadFromOffset(kLoadWord, A1, SP, 4); - __ LoadFromOffset(kLoadWord, A2, SP, 8); - __ LoadFromOffset(kLoadWord, A3, SP, 12); - __ LoadFromOffset(kLoadWord, S2, SP, 28); - __ LoadFromOffset(kLoadWord, S3, SP, 32); - __ LoadFromOffset(kLoadWord, S4, SP, 36); - __ LoadFromOffset(kLoadWord, S5, SP, 40); - __ LoadFromOffset(kLoadWord, S6, SP, 44); - __ LoadFromOffset(kLoadWord, S7, SP, 48); - __ LoadFromOffset(kLoadWord, GP, SP, 52); - __ LoadFromOffset(kLoadWord, FP, SP, 56); - __ LoadFromOffset(kLoadWord, RA, SP, 60); - __ AddConstant(SP, SP, 64); - - __ Move(T9, V0); // Put method's code in T9 - __ Jr(T9); // Leaf call to method's code - - __ Break(); - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} - -const std::vector* CreateInterpreterToInterpreterEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kMips))); - - __ LoadFromOffset(kLoadWord, T9, A0, QUICK_ENTRYPOINT_OFFSET(pInterpreterToInterpreterEntry)); - __ Jr(T9); - __ Break(); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} - -const std::vector* CreateInterpreterToQuickEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kMips))); - - __ LoadFromOffset(kLoadWord, T9, A0, QUICK_ENTRYPOINT_OFFSET(pInterpreterToInterpreterEntry)); - __ Jr(T9); - __ Break(); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} -} // namespace mips - -namespace x86 { -const std::vector* CreateQuickResolutionTrampoline() { - UniquePtr assembler(static_cast(Assembler::Create(kX86))); - // Set up the callee save frame to conform with Runtime::CreateCalleeSaveMethod(kRefsAndArgs) - // return address - __ pushl(EDI); - __ pushl(ESI); - __ pushl(EBP); - __ pushl(EBX); - __ pushl(EDX); - __ pushl(ECX); - __ pushl(EAX); // <-- callee save Method* to go here - __ movl(EDX, ESP); // save ESP - __ fs()->pushl(Address::Absolute(Thread::SelfOffset())); // pass Thread* - __ pushl(EDX); // pass ESP for Method* - __ pushl(ECX); // pass receiver - __ pushl(EAX); // pass Method* - - // Call to resolve method. - __ Call(ThreadOffset(QUICK_ENTRYPOINT_OFFSET(pQuickResolutionTrampolineFromCode)), - X86ManagedRegister::FromCpuRegister(ECX)); - - __ movl(EDI, EAX); // save code pointer in EDI - __ addl(ESP, Immediate(16)); // Pop arguments - __ popl(EAX); // Restore args. - __ popl(ECX); - __ popl(EDX); - __ popl(EBX); - __ popl(EBP); // Restore callee saves. - __ popl(ESI); - // Swap EDI callee save with code pointer - __ xchgl(EDI, Address(ESP, 0)); - // Tail call to intended method. - __ ret(); - - assembler->EmitSlowPaths(); - size_t cs = assembler->CodeSize(); - UniquePtr > resolution_trampoline(new std::vector(cs)); - MemoryRegion code(&(*resolution_trampoline)[0], resolution_trampoline->size()); - assembler->FinalizeInstructions(code); - - return resolution_trampoline.release(); -} - -const std::vector* CreateInterpreterToInterpreterEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kX86))); - - __ fs()->jmp(Address::Absolute(ThreadOffset(QUICK_ENTRYPOINT_OFFSET(pInterpreterToInterpreterEntry)))); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} - -const std::vector* CreateInterpreterToQuickEntry() { - UniquePtr assembler(static_cast(Assembler::Create(kX86))); - - __ fs()->jmp(Address::Absolute(ThreadOffset(QUICK_ENTRYPOINT_OFFSET(pInterpreterToQuickEntry)))); - - size_t cs = assembler->CodeSize(); - UniquePtr > entry_stub(new std::vector(cs)); - MemoryRegion code(&(*entry_stub)[0], entry_stub->size()); - assembler->FinalizeInstructions(code); - - return entry_stub.release(); -} -} // namespace x86 - -} // namespace art diff --git a/compiler/stubs/stubs.h b/compiler/stubs/stubs.h deleted file mode 100644 index d85eae8e1e..0000000000 --- a/compiler/stubs/stubs.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ - -#ifndef ART_COMPILER_STUBS_STUBS_H_ -#define ART_COMPILER_STUBS_STUBS_H_ - -#include "runtime.h" - -namespace art { - -namespace arm { -const std::vector* CreatePortableResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateQuickResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToInterpreterEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToQuickEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -} - -namespace mips { -const std::vector* CreatePortableResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateQuickResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToInterpreterEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToQuickEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -} - -namespace x86 { -const std::vector* CreatePortableResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateQuickResolutionTrampoline() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToInterpreterEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -const std::vector* CreateInterpreterToQuickEntry() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -} - -} // namespace art - -#endif // ART_COMPILER_STUBS_STUBS_H_ diff --git a/compiler/utils/arm/assembler_arm.cc b/compiler/utils/arm/assembler_arm.cc index fa202c3017..f0d11d8f90 100644 --- a/compiler/utils/arm/assembler_arm.cc +++ b/compiler/utils/arm/assembler_arm.cc @@ -1246,10 +1246,10 @@ bool Address::CanHoldStoreOffset(StoreOperandType type, int offset) { // Implementation note: this method must emit at most one instruction when // Address::CanHoldLoadOffset. void ArmAssembler::LoadFromOffset(LoadOperandType type, - Register reg, - Register base, - int32_t offset, - Condition cond) { + Register reg, + Register base, + int32_t offset, + Condition cond) { if (!Address::CanHoldLoadOffset(type, offset)) { CHECK(base != IP); LoadImmediate(IP, offset, cond); @@ -1884,7 +1884,7 @@ void ArmExceptionSlowPath::Emit(Assembler* sasm) { // Don't care about preserving R0 as this call won't return __ mov(R0, ShifterOperand(scratch_.AsCoreRegister())); // Set up call to Thread::Current()->pDeliverException - __ LoadFromOffset(kLoadWord, R12, TR, QUICK_ENTRYPOINT_OFFSET(pDeliverException)); + __ LoadFromOffset(kLoadWord, R12, TR, QUICK_ENTRYPOINT_OFFSET(pDeliverException).Int32Value()); __ blx(R12); // Call never returns __ bkpt(0); diff --git a/compiler/utils/mips/assembler_mips.cc b/compiler/utils/mips/assembler_mips.cc index 931d7ab0f7..2be3d56cfa 100644 --- a/compiler/utils/mips/assembler_mips.cc +++ b/compiler/utils/mips/assembler_mips.cc @@ -813,14 +813,7 @@ void MipsAssembler::Copy(ManagedRegister dest_base, Offset dest_offset, FrameOff void MipsAssembler::Copy(FrameOffset /*dest*/, FrameOffset /*src_base*/, Offset /*src_offset*/, ManagedRegister /*mscratch*/, size_t /*size*/) { - UNIMPLEMENTED(FATAL) << "no arm implementation"; -#if 0 - Register scratch = mscratch.AsMips().AsCoreRegister(); - CHECK_EQ(size, 4u); - movl(scratch, Address(ESP, src_base)); - movl(scratch, Address(scratch, src_offset)); - movl(Address(ESP, dest), scratch); -#endif + UNIMPLEMENTED(FATAL) << "no mips implementation"; } void MipsAssembler::Copy(ManagedRegister dest, Offset dest_offset, @@ -834,24 +827,11 @@ void MipsAssembler::Copy(ManagedRegister dest, Offset dest_offset, void MipsAssembler::Copy(FrameOffset /*dest*/, Offset /*dest_offset*/, FrameOffset /*src*/, Offset /*src_offset*/, ManagedRegister /*mscratch*/, size_t /*size*/) { - UNIMPLEMENTED(FATAL) << "no arm implementation"; -#if 0 - Register scratch = mscratch.AsMips().AsCoreRegister(); - CHECK_EQ(size, 4u); - CHECK_EQ(dest.Int32Value(), src.Int32Value()); - movl(scratch, Address(ESP, src)); - pushl(Address(scratch, src_offset)); - popl(Address(scratch, dest_offset)); -#endif + UNIMPLEMENTED(FATAL) << "no mips implementation"; } void MipsAssembler::MemoryBarrier(ManagedRegister) { - UNIMPLEMENTED(FATAL) << "NEEDS TO BE IMPLEMENTED"; -#if 0 -#if ANDROID_SMP != 0 - mfence(); -#endif -#endif + UNIMPLEMENTED(FATAL) << "no mips implementation"; } void MipsAssembler::CreateSirtEntry(ManagedRegister mout_reg, @@ -953,10 +933,7 @@ void MipsAssembler::Call(FrameOffset base, Offset offset, ManagedRegister mscrat } void MipsAssembler::Call(ThreadOffset /*offset*/, ManagedRegister /*mscratch*/) { - UNIMPLEMENTED(FATAL) << "no arm implementation"; -#if 0 - fs()->call(Address::Absolute(offset)); -#endif + UNIMPLEMENTED(FATAL) << "no mips implementation"; } void MipsAssembler::GetCurrentThread(ManagedRegister tr) { @@ -988,7 +965,7 @@ void MipsExceptionSlowPath::Emit(Assembler* sasm) { // Don't care about preserving A0 as this call won't return __ Move(A0, scratch_.AsCoreRegister()); // Set up call to Thread::Current()->pDeliverException - __ LoadFromOffset(kLoadWord, T9, S1, QUICK_ENTRYPOINT_OFFSET(pDeliverException)); + __ LoadFromOffset(kLoadWord, T9, S1, QUICK_ENTRYPOINT_OFFSET(pDeliverException).Int32Value()); __ Jr(T9); // Call never returns __ Break(); diff --git a/runtime/Android.mk b/runtime/Android.mk index 51bb3eb2d3..4f25c00546 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -142,6 +142,7 @@ LIBART_COMMON_SRC_FILES += \ arch/x86/registers_x86.cc \ arch/mips/registers_mips.cc \ entrypoints/entrypoint_utils.cc \ + entrypoints/interpreter/interpreter_entrypoints.cc \ entrypoints/jni/jni_entrypoints.cc \ entrypoints/math_entrypoints.cc \ entrypoints/portable/portable_alloc_entrypoints.cc \ @@ -163,15 +164,13 @@ LIBART_COMMON_SRC_FILES += \ entrypoints/quick/quick_field_entrypoints.cc \ entrypoints/quick/quick_fillarray_entrypoints.cc \ entrypoints/quick/quick_instrumentation_entrypoints.cc \ - entrypoints/quick/quick_interpreter_entrypoints.cc \ entrypoints/quick/quick_invoke_entrypoints.cc \ entrypoints/quick/quick_jni_entrypoints.cc \ entrypoints/quick/quick_lock_entrypoints.cc \ entrypoints/quick/quick_math_entrypoints.cc \ - entrypoints/quick/quick_proxy_entrypoints.cc \ - entrypoints/quick/quick_stub_entrypoints.cc \ entrypoints/quick/quick_thread_entrypoints.cc \ - entrypoints/quick/quick_throw_entrypoints.cc + entrypoints/quick/quick_throw_entrypoints.cc \ + entrypoints/quick/quick_trampoline_entrypoints.cc LIBART_TARGET_SRC_FILES := \ $(LIBART_COMMON_SRC_FILES) \ diff --git a/runtime/arch/arm/asm_support_arm.S b/runtime/arch/arm/asm_support_arm.S index ed655e95b1..559788f1ba 100644 --- a/runtime/arch/arm/asm_support_arm.S +++ b/runtime/arch/arm/asm_support_arm.S @@ -35,4 +35,11 @@ .size \name, .-\name .endm +.macro UNIMPLEMENTED name + ENTRY \name + bkpt + bkpt + END \name +.endm + #endif // ART_RUNTIME_ARCH_X86_ASM_SUPPORT_X86_S_ diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index b71a158289..848bacca52 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "entrypoints/interpreter/interpreter_entrypoints.h" #include "entrypoints/portable/portable_entrypoints.h" #include "entrypoints/quick/quick_entrypoints.h" #include "entrypoints/entrypoint_utils.h" @@ -21,49 +22,61 @@ namespace art { +// Interpreter entrypoints. +extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); +extern "C" void artInterperterToCompiledCodeBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); + +// Portable entrypoints. +extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); + // Alloc entrypoints. -extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method); -extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); -extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method); +extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method); +extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t); // Cast entrypoints. extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, const mirror::Class* ref_class); -extern "C" void art_quick_can_put_array_element_from_code(void*, void*); -extern "C" void art_quick_check_cast_from_code(void*, void*); +extern "C" void art_quick_can_put_array_element(void*, void*); +extern "C" void art_quick_check_cast(void*, void*); // DexCache entrypoints. -extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*); -extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t); +extern "C" void* art_quick_initialize_static_storage(uint32_t, void*); +extern "C" void* art_quick_initialize_type(uint32_t, void*); +extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*); +extern "C" void* art_quick_resolve_string(void*, uint32_t); // Exception entrypoints. extern "C" void* GetAndClearException(Thread*); // Field entrypoints. -extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t); -extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t); -extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t); -extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t); -extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*); -extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_static_from_code(uint32_t); -extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*); -extern "C" int64_t art_quick_get64_static_from_code(uint32_t); -extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*); -extern "C" void* art_quick_get_obj_static_from_code(uint32_t); +extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t); +extern "C" int art_quick_set32_static(uint32_t, int32_t); +extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t); +extern "C" int art_quick_set64_static(uint32_t, int64_t); +extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*); +extern "C" int art_quick_set_obj_static(uint32_t, void*); +extern "C" int32_t art_quick_get32_instance(uint32_t, void*); +extern "C" int32_t art_quick_get32_static(uint32_t); +extern "C" int64_t art_quick_get64_instance(uint32_t, void*); +extern "C" int64_t art_quick_get64_static(uint32_t); +extern "C" void* art_quick_get_obj_instance(uint32_t, void*); +extern "C" void* art_quick_get_obj_static(uint32_t); // FillArray entrypoint. -extern "C" void art_quick_handle_fill_data_from_code(void*, void*); +extern "C" void art_quick_handle_fill_data(void*, void*); // Lock entrypoints. -extern "C" void art_quick_lock_object_from_code(void*); -extern "C" void art_quick_unlock_object_from_code(void*); +extern "C" void art_quick_lock_object(void*); +extern "C" void art_quick_unlock_object(void*); // Math entrypoints. extern int32_t CmpgDouble(double a, double b); @@ -93,26 +106,14 @@ extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t); extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t); extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t); -// Interpreter entrypoints. -extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); -extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); - // Intrinsic entrypoints. extern "C" int32_t __memcmp16(void*, void*, int32_t); extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); +extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); @@ -125,49 +126,61 @@ extern void CheckSuspendFromCode(Thread* thread); extern "C" void art_quick_test_suspend(); // Throw entrypoints. -extern "C" void art_quick_deliver_exception_from_code(void*); -extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit); -extern "C" void art_quick_throw_div_zero_from_code(); -extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx); -extern "C" void art_quick_throw_null_pointer_exception_from_code(); -extern "C" void art_quick_throw_stack_overflow_from_code(void*); - -void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { +extern "C" void art_quick_deliver_exception(void*); +extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit); +extern "C" void art_quick_throw_div_zero(); +extern "C" void art_quick_throw_no_such_method(int32_t method_idx); +extern "C" void art_quick_throw_null_pointer_exception(); +extern "C" void art_quick_throw_stack_overflow(void*); + +void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, + PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { + // Interpreter + ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge; + ipoints->pInterpreterToCompiledCodeBridge = artInterperterToCompiledCodeBridge; + + // JNI + jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub; + + // Portable + ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline; + ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge; + // Alloc - qpoints->pAllocArrayFromCode = art_quick_alloc_array_from_code; - qpoints->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check; - qpoints->pAllocObjectFromCode = art_quick_alloc_object_from_code; - qpoints->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check; - qpoints->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code; - qpoints->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check; + qpoints->pAllocArray = art_quick_alloc_array; + qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check; + qpoints->pAllocObject = art_quick_alloc_object; + qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check; + qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array; + qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check; // Cast - qpoints->pInstanceofNonTrivialFromCode = artIsAssignableFromCode; - qpoints->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code; - qpoints->pCheckCastFromCode = art_quick_check_cast_from_code; + qpoints->pInstanceofNonTrivial = artIsAssignableFromCode; + qpoints->pCanPutArrayElement = art_quick_can_put_array_element; + qpoints->pCheckCast = art_quick_check_cast; // DexCache - qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code; - qpoints->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code; - qpoints->pInitializeTypeFromCode = art_quick_initialize_type_from_code; - qpoints->pResolveStringFromCode = art_quick_resolve_string_from_code; + qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage; + qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access; + qpoints->pInitializeType = art_quick_initialize_type; + qpoints->pResolveString = art_quick_resolve_string; // Field - qpoints->pSet32Instance = art_quick_set32_instance_from_code; - qpoints->pSet32Static = art_quick_set32_static_from_code; - qpoints->pSet64Instance = art_quick_set64_instance_from_code; - qpoints->pSet64Static = art_quick_set64_static_from_code; - qpoints->pSetObjInstance = art_quick_set_obj_instance_from_code; - qpoints->pSetObjStatic = art_quick_set_obj_static_from_code; - qpoints->pGet32Instance = art_quick_get32_instance_from_code; - qpoints->pGet64Instance = art_quick_get64_instance_from_code; - qpoints->pGetObjInstance = art_quick_get_obj_instance_from_code; - qpoints->pGet32Static = art_quick_get32_static_from_code; - qpoints->pGet64Static = art_quick_get64_static_from_code; - qpoints->pGetObjStatic = art_quick_get_obj_static_from_code; + qpoints->pSet32Instance = art_quick_set32_instance; + qpoints->pSet32Static = art_quick_set32_static; + qpoints->pSet64Instance = art_quick_set64_instance; + qpoints->pSet64Static = art_quick_set64_static; + qpoints->pSetObjInstance = art_quick_set_obj_instance; + qpoints->pSetObjStatic = art_quick_set_obj_static; + qpoints->pGet32Instance = art_quick_get32_instance; + qpoints->pGet64Instance = art_quick_get64_instance; + qpoints->pGetObjInstance = art_quick_get_obj_instance; + qpoints->pGet32Static = art_quick_get32_static; + qpoints->pGet64Static = art_quick_get64_static; + qpoints->pGetObjStatic = art_quick_get_obj_static; // FillArray - qpoints->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code; + qpoints->pHandleFillArrayData = art_quick_handle_fill_data; // JNI qpoints->pJniMethodStart = JniMethodStart; @@ -178,8 +191,8 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; // Locks - qpoints->pLockObjectFromCode = art_quick_lock_object_from_code; - qpoints->pUnlockObjectFromCode = art_quick_unlock_object_from_code; + qpoints->pLockObject = art_quick_lock_object; + qpoints->pUnlockObject = art_quick_unlock_object; // Math qpoints->pCmpgDouble = CmpgDouble; @@ -203,10 +216,6 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pShrLong = art_quick_shr_long; qpoints->pUshrLong = art_quick_ushr_long; - // Interpreter - qpoints->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry; - qpoints->pInterpreterToQuickEntry = artInterpreterToQuickEntry; - // Intrinsics qpoints->pIndexOf = art_quick_indexof; qpoints->pMemcmp16 = __memcmp16; @@ -214,7 +223,8 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pMemcpy = memcpy; // Invocation - qpoints->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline; + qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline; + qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge; qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline; qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; @@ -223,19 +233,16 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; // Thread - qpoints->pCheckSuspendFromCode = CheckSuspendFromCode; - qpoints->pTestSuspendFromCode = art_quick_test_suspend; + qpoints->pCheckSuspend = CheckSuspendFromCode; + qpoints->pTestSuspend = art_quick_test_suspend; // Throws - qpoints->pDeliverException = art_quick_deliver_exception_from_code; - qpoints->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code; - qpoints->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code; - qpoints->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code; - qpoints->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code; - qpoints->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code; - - // Portable - ppoints->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline; + qpoints->pDeliverException = art_quick_deliver_exception; + qpoints->pThrowArrayBounds = art_quick_throw_array_bounds; + qpoints->pThrowDivZero = art_quick_throw_div_zero; + qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method; + qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception; + qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow; }; } // namespace art diff --git a/runtime/arch/arm/jni_entrypoints_arm.S b/runtime/arch/arm/jni_entrypoints_arm.S index 0af470c540..f51f12183c 100644 --- a/runtime/arch/arm/jni_entrypoints_arm.S +++ b/runtime/arch/arm/jni_entrypoints_arm.S @@ -30,8 +30,7 @@ ENTRY art_jni_dlsym_lookup_stub sub sp, #12 @ pad stack pointer to align frame .pad #12 .cfi_adjust_cfa_offset 12 - mov r0, r9 @ pass Thread::Current - blx artFindNativeMethod @ (Thread*) + blx artFindNativeMethod mov r12, r0 @ save result in r12 add sp, #12 @ restore stack pointer .cfi_adjust_cfa_offset -12 @@ -46,7 +45,7 @@ END art_jni_dlsym_lookup_stub * Entry point of native methods when JNI bug compatibility is enabled. */ .extern artWorkAroundAppJniBugs -ENTRY art_quick_work_around_app_jni_bugs +ENTRY art_work_around_app_jni_bugs @ save registers that may contain arguments and LR that will be crushed by a call push {r0-r3, lr} .save {r0-r3, lr} @@ -64,4 +63,4 @@ ENTRY art_quick_work_around_app_jni_bugs pop {r0-r3, lr} @ restore possibly modified argument registers .cfi_adjust_cfa_offset -16 bx r12 @ tail call into JNI routine -END art_quick_work_around_app_jni_bugs +END art_work_around_app_jni_bugs diff --git a/runtime/arch/arm/portable_entrypoints_arm.S b/runtime/arch/arm/portable_entrypoints_arm.S index 56333bab96..adfd22b331 100644 --- a/runtime/arch/arm/portable_entrypoints_arm.S +++ b/runtime/arch/arm/portable_entrypoints_arm.S @@ -96,3 +96,6 @@ ENTRY art_portable_proxy_invoke_handler .cfi_adjust_cfa_offset -48 bx lr @ return END art_portable_proxy_invoke_handler + +UNIMPLEMENTED art_portable_resolution_trampoline +UNIMPLEMENTED art_portable_to_interpreter_bridge diff --git a/runtime/arch/arm/quick_entrypoints_arm.S b/runtime/arch/arm/quick_entrypoints_arm.S index 4de8c4d9f3..d9bb433c85 100644 --- a/runtime/arch/arm/quick_entrypoints_arm.S +++ b/runtime/arch/arm/quick_entrypoints_arm.S @@ -159,33 +159,33 @@ END \c_name * Called by managed code, saves callee saves and then calls artThrowException * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. */ -ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception_from_code, artDeliverExceptionFromCode +ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode /* * Called by managed code to create and deliver a NullPointerException. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode /* * Called by managed code to create and deliver an ArithmeticException. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero_from_code, artThrowDivZeroFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode /* * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds * index, arg2 holds limit. */ -TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds_from_code, artThrowArrayBoundsFromCode +TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode /* * Called by managed code to create and deliver a StackOverflowError. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow_from_code, artThrowStackOverflowFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode /* * Called by managed code to create and deliver a NoSuchMethodError. */ -ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode +ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode /* * All generated callsites for interface invokes and invocation slow paths will load arguments @@ -296,7 +296,7 @@ END art_quick_do_long_jump * failure. */ .extern artHandleFillArrayDataFromCode -ENTRY art_quick_handle_fill_data_from_code +ENTRY art_quick_handle_fill_data SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -305,25 +305,25 @@ ENTRY art_quick_handle_fill_data_from_code cmp r0, #0 @ success? bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_handle_fill_data_from_code +END art_quick_handle_fill_data /* * Entry from managed code that calls artLockObjectFromCode, may block for GC. */ .extern artLockObjectFromCode -ENTRY art_quick_lock_object_from_code +ENTRY art_quick_lock_object SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case we block mov r1, r9 @ pass Thread::Current mov r2, sp @ pass SP bl artLockObjectFromCode @ (Object* obj, Thread*, SP) RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN -END art_quick_lock_object_from_code +END art_quick_lock_object /* * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. */ .extern artUnlockObjectFromCode -ENTRY art_quick_unlock_object_from_code +ENTRY art_quick_unlock_object SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC mov r1, r9 @ pass Thread::Current mov r2, sp @ pass SP @@ -332,13 +332,13 @@ ENTRY art_quick_unlock_object_from_code cmp r0, #0 @ success? bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_unlock_object_from_code +END art_quick_unlock_object /* * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. */ .extern artCheckCastFromCode -ENTRY art_quick_check_cast_from_code +ENTRY art_quick_check_cast SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -347,14 +347,14 @@ ENTRY art_quick_check_cast_from_code cmp r0, #0 @ success? bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_check_cast_from_code +END art_quick_check_cast /* * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on * failure. */ .extern artCanPutArrayElementFromCode -ENTRY art_quick_can_put_array_element_from_code +ENTRY art_quick_can_put_array_element SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case exception allocation triggers GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -363,7 +363,7 @@ ENTRY art_quick_can_put_array_element_from_code cmp r0, #0 @ success? bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_can_put_array_element_from_code +END art_quick_can_put_array_element /* * Entry from managed code when uninitialized static storage, this stub will run the class @@ -371,7 +371,7 @@ END art_quick_can_put_array_element_from_code * returned. */ .extern artInitializeStaticStorageFromCode -ENTRY art_quick_initialize_static_storage_from_code +ENTRY art_quick_initialize_static_storage SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -381,13 +381,13 @@ ENTRY art_quick_initialize_static_storage_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_initialize_static_storage_from_code +END art_quick_initialize_static_storage /* * Entry from managed code when dex cache misses for a type_idx */ .extern artInitializeTypeFromCode -ENTRY art_quick_initialize_type_from_code +ENTRY art_quick_initialize_type SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -397,14 +397,14 @@ ENTRY art_quick_initialize_type_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_initialize_type_from_code +END art_quick_initialize_type /* * Entry from managed code when type_idx needs to be checked for access and dex cache may also * miss. */ .extern artInitializeTypeAndVerifyAccessFromCode -ENTRY art_quick_initialize_type_and_verify_access_from_code +ENTRY art_quick_initialize_type_and_verify_access SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -414,13 +414,13 @@ ENTRY art_quick_initialize_type_and_verify_access_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_initialize_type_and_verify_access_from_code +END art_quick_initialize_type_and_verify_access /* * Called by managed code to resolve a static field and load a 32-bit primitive value. */ .extern artGet32StaticFromCode -ENTRY art_quick_get32_static_from_code +ENTRY art_quick_get32_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r1, [sp, #32] @ pass referrer mov r2, r9 @ pass Thread::Current @@ -431,13 +431,13 @@ ENTRY art_quick_get32_static_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get32_static_from_code +END art_quick_get32_static /* * Called by managed code to resolve a static field and load a 64-bit primitive value. */ .extern artGet64StaticFromCode -ENTRY art_quick_get64_static_from_code +ENTRY art_quick_get64_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r1, [sp, #32] @ pass referrer mov r2, r9 @ pass Thread::Current @@ -448,13 +448,13 @@ ENTRY art_quick_get64_static_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get64_static_from_code +END art_quick_get64_static /* * Called by managed code to resolve a static field and load an object reference. */ .extern artGetObjStaticFromCode -ENTRY art_quick_get_obj_static_from_code +ENTRY art_quick_get_obj_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r1, [sp, #32] @ pass referrer mov r2, r9 @ pass Thread::Current @@ -465,13 +465,13 @@ ENTRY art_quick_get_obj_static_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get_obj_static_from_code +END art_quick_get_obj_static /* * Called by managed code to resolve an instance field and load a 32-bit primitive value. */ .extern artGet32InstanceFromCode -ENTRY art_quick_get32_instance_from_code +ENTRY art_quick_get32_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r2, [sp, #32] @ pass referrer mov r3, r9 @ pass Thread::Current @@ -484,13 +484,13 @@ ENTRY art_quick_get32_instance_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get32_instance_from_code +END art_quick_get32_instance /* * Called by managed code to resolve an instance field and load a 64-bit primitive value. */ .extern artGet64InstanceFromCode -ENTRY art_quick_get64_instance_from_code +ENTRY art_quick_get64_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r2, [sp, #32] @ pass referrer mov r3, r9 @ pass Thread::Current @@ -506,13 +506,13 @@ ENTRY art_quick_get64_instance_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get64_instance_from_code +END art_quick_get64_instance /* * Called by managed code to resolve an instance field and load an object reference. */ .extern artGetObjInstanceFromCode -ENTRY art_quick_get_obj_instance_from_code +ENTRY art_quick_get_obj_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r2, [sp, #32] @ pass referrer mov r3, r9 @ pass Thread::Current @@ -528,13 +528,13 @@ ENTRY art_quick_get_obj_instance_from_code cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_get_obj_instance_from_code +END art_quick_get_obj_instance /* * Called by managed code to resolve a static field and store a 32-bit primitive value. */ .extern artSet32StaticFromCode -ENTRY art_quick_set32_static_from_code +ENTRY art_quick_set32_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r2, [sp, #32] @ pass referrer mov r3, r9 @ pass Thread::Current @@ -549,14 +549,14 @@ ENTRY art_quick_set32_static_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set32_static_from_code +END art_quick_set32_static /* * Called by managed code to resolve a static field and store a 64-bit primitive value. * On entry r0 holds field index, r1:r2 hold new_val */ .extern artSet64StaticFromCode -ENTRY art_quick_set64_static_from_code +ENTRY art_quick_set64_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r3, r2 @ pass one half of wide argument mov r2, r1 @ pass other half of wide argument @@ -575,13 +575,13 @@ ENTRY art_quick_set64_static_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set64_static_from_code +END art_quick_set64_static /* * Called by managed code to resolve a static field and store an object reference. */ .extern artSetObjStaticFromCode -ENTRY art_quick_set_obj_static_from_code +ENTRY art_quick_set_obj_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r2, [sp, #32] @ pass referrer mov r3, r9 @ pass Thread::Current @@ -596,13 +596,13 @@ ENTRY art_quick_set_obj_static_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set_obj_static_from_code +END art_quick_set_obj_static /* * Called by managed code to resolve an instance field and store a 32-bit primitive value. */ .extern artSet32InstanceFromCode -ENTRY art_quick_set32_instance_from_code +ENTRY art_quick_set32_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r3, [sp, #32] @ pass referrer mov r12, sp @ save SP @@ -621,13 +621,13 @@ ENTRY art_quick_set32_instance_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set32_instance_from_code +END art_quick_set32_instance /* * Called by managed code to resolve an instance field and store a 64-bit primitive value. */ .extern artSet32InstanceFromCode -ENTRY art_quick_set64_instance_from_code +ENTRY art_quick_set64_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r12, sp @ save SP sub sp, #8 @ grow frame for alignment with stack args @@ -644,13 +644,13 @@ ENTRY art_quick_set64_instance_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set64_instance_from_code +END art_quick_set64_instance /* * Called by managed code to resolve an instance field and store an object reference. */ .extern artSetObjInstanceFromCode -ENTRY art_quick_set_obj_instance_from_code +ENTRY art_quick_set_obj_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC ldr r3, [sp, #32] @ pass referrer mov r12, sp @ save SP @@ -668,7 +668,7 @@ ENTRY art_quick_set_obj_instance_from_code cmp r0, #0 @ success if result is 0 bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_set_obj_instance_from_code +END art_quick_set_obj_instance /* * Entry from managed code to resolve a string, this stub will allocate a String and deliver an @@ -677,7 +677,7 @@ END art_quick_set_obj_instance_from_code * performed. */ .extern artResolveStringFromCode -ENTRY art_quick_resolve_string_from_code +ENTRY art_quick_resolve_string SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -687,13 +687,13 @@ ENTRY art_quick_resolve_string_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_resolve_string_from_code +END art_quick_resolve_string /* * Called by managed code to allocate an object */ .extern artAllocObjectFromCode -ENTRY art_quick_alloc_object_from_code +ENTRY art_quick_alloc_object SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -702,14 +702,14 @@ ENTRY art_quick_alloc_object_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_alloc_object_from_code +END art_quick_alloc_object /* * Called by managed code to allocate an object when the caller doesn't know whether it has * access to the created type. */ .extern artAllocObjectFromCodeWithAccessCheck -ENTRY art_quick_alloc_object_from_code_with_access_check +ENTRY art_quick_alloc_object_with_access_check SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r2, r9 @ pass Thread::Current mov r3, sp @ pass SP @@ -718,13 +718,13 @@ ENTRY art_quick_alloc_object_from_code_with_access_check cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_alloc_object_from_code_with_access_check +END art_quick_alloc_object_with_access_check /* * Called by managed code to allocate an array. */ .extern artAllocArrayFromCode -ENTRY art_quick_alloc_array_from_code +ENTRY art_quick_alloc_array SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r3, r9 @ pass Thread::Current mov r12, sp @@ -739,14 +739,14 @@ ENTRY art_quick_alloc_array_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_alloc_array_from_code +END art_quick_alloc_array /* * Called by managed code to allocate an array when the caller doesn't know whether it has * access to the created type. */ .extern artAllocArrayFromCodeWithAccessCheck -ENTRY art_quick_alloc_array_from_code_with_access_check +ENTRY art_quick_alloc_array_with_access_check SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r3, r9 @ pass Thread::Current mov r12, sp @@ -761,13 +761,13 @@ ENTRY art_quick_alloc_array_from_code_with_access_check cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_alloc_array_from_code_with_access_check +END art_quick_alloc_array_with_access_check /* * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. */ .extern artCheckAndAllocArrayFromCode -ENTRY art_quick_check_and_alloc_array_from_code +ENTRY art_quick_check_and_alloc_array SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r3, r9 @ pass Thread::Current mov r12, sp @@ -782,13 +782,13 @@ ENTRY art_quick_check_and_alloc_array_from_code cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_check_and_alloc_array_from_code +END art_quick_check_and_alloc_array /* * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. */ .extern artCheckAndAllocArrayFromCodeWithAccessCheck -ENTRY art_quick_check_and_alloc_array_from_code_with_access_check +ENTRY art_quick_check_and_alloc_array_with_access_check SETUP_REF_ONLY_CALLEE_SAVE_FRAME @ save callee saves in case of GC mov r3, r9 @ pass Thread::Current mov r12, sp @@ -803,7 +803,7 @@ ENTRY art_quick_check_and_alloc_array_from_code_with_access_check cmp r0, #0 @ success if result is non-null bxne lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_check_and_alloc_array_from_code_with_access_check +END art_quick_check_and_alloc_array_with_access_check /* * Called by managed code when the value in rSUSPEND has been decremented to 0. @@ -842,13 +842,33 @@ ENTRY art_quick_proxy_invoke_handler DELIVER_PENDING_EXCEPTION END art_quick_proxy_invoke_handler - .extern artInterpreterEntry -ENTRY art_quick_interpreter_entry + .extern artQuickResolutionTrampoline +ENTRY art_quick_resolution_trampoline + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + mov r2, r9 @ pass Thread::Current + mov r3, sp @ pass SP + blx artQuickResolutionTrampoline @ (Method* called, receiver, Thread*, SP) + cmp r0, #0 @ is code pointer null? + beq 1f @ goto exception + mov r12, r0 + ldr r0, [sp, #0] @ load resolved method in r0 + ldr r1, [sp, #8] @ restore non-callee save r1 + ldrd r2, [sp, #12] @ restore non-callee saves r2-r3 + ldr lr, [sp, #44] @ restore lr + add sp, #48 @ rewind sp + .cfi_adjust_cfa_offset -48 + bx r12 @ tail-call into actual code +1: + RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME + DELIVER_PENDING_EXCEPTION +END art_quick_resolution_trampoline + + .extern artQuickToInterpreterBridge +ENTRY art_quick_to_interpreter_bridge SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME - str r0, [sp, #0] @ place proxy method at bottom of frame mov r1, r9 @ pass Thread::Current mov r2, sp @ pass SP - blx artInterpreterEntry @ (Method* method, Thread*, SP) + blx artQuickToInterpreterBridge @ (Method* method, Thread*, SP) ldr r12, [r9, #THREAD_EXCEPTION_OFFSET] @ load Thread::Current()->exception_ ldr lr, [sp, #44] @ restore lr add sp, #48 @ pop frame @@ -856,14 +876,14 @@ ENTRY art_quick_interpreter_entry cmp r12, #0 @ success if no exception is pending bxeq lr @ return on success DELIVER_PENDING_EXCEPTION -END art_quick_interpreter_entry +END art_quick_to_interpreter_bridge /* * Routine that intercepts method calls and returns. */ .extern artInstrumentationMethodEntryFromCode .extern artInstrumentationMethodExitFromCode -ENTRY art_quick_instrumentation_entry_from_code +ENTRY art_quick_instrumentation_entry SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME str r0, [sp, #4] @ preserve r0 mov r12, sp @ remember sp @@ -879,11 +899,11 @@ ENTRY art_quick_instrumentation_entry_from_code mov r12, r0 @ r12 holds reference to code ldr r0, [sp, #4] @ restore r0 RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME - blx r12 @ call method with lr set to art_quick_instrumentation_exit_from_code -END art_quick_instrumentation_entry_from_code - .type art_quick_instrumentation_exit_from_code, #function - .global art_quick_instrumentation_exit_from_code -art_quick_instrumentation_exit_from_code: + blx r12 @ call method with lr set to art_quick_instrumentation_exit +END art_quick_instrumentation_entry + .type art_quick_instrumentation_exit, #function + .global art_quick_instrumentation_exit +art_quick_instrumentation_exit: .cfi_startproc .fnstart mov lr, #0 @ link register is to here, so clobber with 0 for later checks @@ -912,7 +932,7 @@ art_quick_instrumentation_exit_from_code: add sp, #32 @ remove callee save frame .cfi_adjust_cfa_offset -32 bx r2 @ return -END art_quick_instrumentation_exit_from_code +END art_quick_instrumentation_exit /* * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization @@ -926,25 +946,6 @@ ENTRY art_quick_deoptimize blx artDeoptimize @ artDeoptimize(Thread*, SP) END art_quick_deoptimize - /* - * Portable abstract method error stub. r0 contains method* on entry. SP unused in portable. - */ - .extern artThrowAbstractMethodErrorFromCode -ENTRY art_portable_abstract_method_error_stub - mov r1, r9 @ pass Thread::Current - b artThrowAbstractMethodErrorFromCode @ (Method*, Thread*, SP) -END art_portable_abstract_method_error_stub - - /* - * Quick abstract method error stub. r0 contains method* on entry. - */ -ENTRY art_quick_abstract_method_error_stub - SETUP_SAVE_ALL_CALLEE_SAVE_FRAME - mov r1, r9 @ pass Thread::Current - mov r2, sp @ pass SP - b artThrowAbstractMethodErrorFromCode @ (Method*, Thread*, SP) -END art_quick_abstract_method_error_stub - /* * Signed 64-bit integer multiply. * diff --git a/runtime/arch/mips/asm_support_mips.S b/runtime/arch/mips/asm_support_mips.S index 8a34b9dbd0..fe932d20c2 100644 --- a/runtime/arch/mips/asm_support_mips.S +++ b/runtime/arch/mips/asm_support_mips.S @@ -38,4 +38,12 @@ .cpload $t9 .endm +.macro UNIMPLEMENTED name + ENTRY \name + break + break + END \name +.endm + + #endif // ART_RUNTIME_ARCH_MIPS_ASM_SUPPORT_MIPS_S_ diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc index 0a62a4096d..a18079b628 100644 --- a/runtime/arch/mips/entrypoints_init_mips.cc +++ b/runtime/arch/mips/entrypoints_init_mips.cc @@ -21,49 +21,61 @@ namespace art { +// Interpreter entrypoints. +extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); +extern "C" void artInterperterToCompiledCodeBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); + +// Portable entrypoints. +extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); + // Alloc entrypoints. -extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method); -extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); -extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method); +extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method); +extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t); // Cast entrypoints. extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, const mirror::Class* ref_class); -extern "C" void art_quick_can_put_array_element_from_code(void*, void*); -extern "C" void art_quick_check_cast_from_code(void*, void*); +extern "C" void art_quick_can_put_array_element(void*, void*); +extern "C" void art_quick_check_cast(void*, void*); // DexCache entrypoints. -extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*); -extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t); +extern "C" void* art_quick_initialize_static_storage(uint32_t, void*); +extern "C" void* art_quick_initialize_type(uint32_t, void*); +extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*); +extern "C" void* art_quick_resolve_string(void*, uint32_t); // Exception entrypoints. extern "C" void* GetAndClearException(Thread*); // Field entrypoints. -extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t); -extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t); -extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t); -extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t); -extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*); -extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_static_from_code(uint32_t); -extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*); -extern "C" int64_t art_quick_get64_static_from_code(uint32_t); -extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*); -extern "C" void* art_quick_get_obj_static_from_code(uint32_t); +extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t); +extern "C" int art_quick_set32_static(uint32_t, int32_t); +extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t); +extern "C" int art_quick_set64_static(uint32_t, int64_t); +extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*); +extern "C" int art_quick_set_obj_static(uint32_t, void*); +extern "C" int32_t art_quick_get32_instance(uint32_t, void*); +extern "C" int32_t art_quick_get32_static(uint32_t); +extern "C" int64_t art_quick_get64_instance(uint32_t, void*); +extern "C" int64_t art_quick_get64_static(uint32_t); +extern "C" void* art_quick_get_obj_instance(uint32_t, void*); +extern "C" void* art_quick_get_obj_static(uint32_t); // FillArray entrypoint. -extern "C" void art_quick_handle_fill_data_from_code(void*, void*); +extern "C" void art_quick_handle_fill_data(void*, void*); // Lock entrypoints. -extern "C" void art_quick_lock_object_from_code(void*); -extern "C" void art_quick_unlock_object_from_code(void*); +extern "C" void art_quick_lock_object(void*); +extern "C" void art_quick_unlock_object(void*); // Math entrypoints. extern int32_t CmpgDouble(double a, double b); @@ -95,26 +107,14 @@ extern "C" uint64_t art_quick_shl_long(uint64_t, uint32_t); extern "C" uint64_t art_quick_shr_long(uint64_t, uint32_t); extern "C" uint64_t art_quick_ushr_long(uint64_t, uint32_t); -// Interpreter entrypoints. -extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); -extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); - // Intrinsic entrypoints. extern "C" int32_t __memcmp16(void*, void*, int32_t); extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); +extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); @@ -127,49 +127,61 @@ extern void CheckSuspendFromCode(Thread* thread); extern "C" void art_quick_test_suspend(); // Throw entrypoints. -extern "C" void art_quick_deliver_exception_from_code(void*); -extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit); -extern "C" void art_quick_throw_div_zero_from_code(); -extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx); -extern "C" void art_quick_throw_null_pointer_exception_from_code(); -extern "C" void art_quick_throw_stack_overflow_from_code(void*); - -void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { +extern "C" void art_quick_deliver_exception(void*); +extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit); +extern "C" void art_quick_throw_div_zero(); +extern "C" void art_quick_throw_no_such_method(int32_t method_idx); +extern "C" void art_quick_throw_null_pointer_exception(); +extern "C" void art_quick_throw_stack_overflow(void*); + +void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, + PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { + // Interpreter + ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge; + ipoints->pInterpreterToCompiledCodeBridge = artInterperterToCompiledCodeBridge; + + // JNI + jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub; + + // Portable + ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline; + ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge; + // Alloc - qpoints->pAllocArrayFromCode = art_quick_alloc_array_from_code; - qpoints->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check; - qpoints->pAllocObjectFromCode = art_quick_alloc_object_from_code; - qpoints->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check; - qpoints->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code; - qpoints->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check; + qpoints->pAllocArray = art_quick_alloc_array; + qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check; + qpoints->pAllocObject = art_quick_alloc_object; + qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check; + qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array; + qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check; // Cast - qpoints->pInstanceofNonTrivialFromCode = artIsAssignableFromCode; - qpoints->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code; - qpoints->pCheckCastFromCode = art_quick_check_cast_from_code; + qpoints->pInstanceofNonTrivial = artIsAssignableFromCode; + qpoints->pCanPutArrayElement = art_quick_can_put_array_element; + qpoints->pCheckCast = art_quick_check_cast; // DexCache - qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code; - qpoints->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code; - qpoints->pInitializeTypeFromCode = art_quick_initialize_type_from_code; - qpoints->pResolveStringFromCode = art_quick_resolve_string_from_code; + qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage; + qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access; + qpoints->pInitializeType = art_quick_initialize_type; + qpoints->pResolveString = art_quick_resolve_string; // Field - qpoints->pSet32Instance = art_quick_set32_instance_from_code; - qpoints->pSet32Static = art_quick_set32_static_from_code; - qpoints->pSet64Instance = art_quick_set64_instance_from_code; - qpoints->pSet64Static = art_quick_set64_static_from_code; - qpoints->pSetObjInstance = art_quick_set_obj_instance_from_code; - qpoints->pSetObjStatic = art_quick_set_obj_static_from_code; - qpoints->pGet32Instance = art_quick_get32_instance_from_code; - qpoints->pGet64Instance = art_quick_get64_instance_from_code; - qpoints->pGetObjInstance = art_quick_get_obj_instance_from_code; - qpoints->pGet32Static = art_quick_get32_static_from_code; - qpoints->pGet64Static = art_quick_get64_static_from_code; - qpoints->pGetObjStatic = art_quick_get_obj_static_from_code; + qpoints->pSet32Instance = art_quick_set32_instance; + qpoints->pSet32Static = art_quick_set32_static; + qpoints->pSet64Instance = art_quick_set64_instance; + qpoints->pSet64Static = art_quick_set64_static; + qpoints->pSetObjInstance = art_quick_set_obj_instance; + qpoints->pSetObjStatic = art_quick_set_obj_static; + qpoints->pGet32Instance = art_quick_get32_instance; + qpoints->pGet64Instance = art_quick_get64_instance; + qpoints->pGetObjInstance = art_quick_get_obj_instance; + qpoints->pGet32Static = art_quick_get32_static; + qpoints->pGet64Static = art_quick_get64_static; + qpoints->pGetObjStatic = art_quick_get_obj_static; // FillArray - qpoints->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code; + qpoints->pHandleFillArrayData = art_quick_handle_fill_data; // JNI qpoints->pJniMethodStart = JniMethodStart; @@ -180,8 +192,8 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; // Locks - qpoints->pLockObjectFromCode = art_quick_lock_object_from_code; - qpoints->pUnlockObjectFromCode = art_quick_unlock_object_from_code; + qpoints->pLockObject = art_quick_lock_object; + qpoints->pUnlockObject = art_quick_unlock_object; // Math qpoints->pCmpgDouble = CmpgDouble; @@ -204,10 +216,6 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pShrLong = art_quick_shr_long; qpoints->pUshrLong = art_quick_ushr_long; - // Interpreter - qpoints->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry; - qpoints->pInterpreterToQuickEntry = artInterpreterToQuickEntry; - // Intrinsics qpoints->pIndexOf = art_quick_indexof; qpoints->pMemcmp16 = __memcmp16; @@ -215,7 +223,8 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pMemcpy = memcpy; // Invocation - qpoints->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline; + qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline; + qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge; qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline; qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; @@ -224,19 +233,16 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; // Thread - qpoints->pCheckSuspendFromCode = CheckSuspendFromCode; - qpoints->pTestSuspendFromCode = art_quick_test_suspend; + qpoints->pCheckSuspend = CheckSuspendFromCode; + qpoints->pTestSuspend = art_quick_test_suspend; // Throws - qpoints->pDeliverException = art_quick_deliver_exception_from_code; - qpoints->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code; - qpoints->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code; - qpoints->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code; - qpoints->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code; - qpoints->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code; - - // Portable - ppoints->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline; + qpoints->pDeliverException = art_quick_deliver_exception; + qpoints->pThrowArrayBounds = art_quick_throw_array_bounds; + qpoints->pThrowDivZero = art_quick_throw_div_zero; + qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method; + qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception; + qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow; }; } // namespace art diff --git a/runtime/arch/mips/jni_entrypoints_mips.S b/runtime/arch/mips/jni_entrypoints_mips.S index fca6d777ab..ad7c021762 100644 --- a/runtime/arch/mips/jni_entrypoints_mips.S +++ b/runtime/arch/mips/jni_entrypoints_mips.S @@ -59,7 +59,7 @@ END art_jni_dlsym_lookup_stub * Entry point of native methods when JNI bug compatibility is enabled. */ .extern artWorkAroundAppJniBugs -ENTRY art_quick_work_around_app_jni_bugs +ENTRY art_work_around_app_jni_bugs GENERATE_GLOBAL_POINTER # save registers that may contain arguments and LR that will be crushed by a call addiu $sp, $sp, -32 @@ -86,4 +86,4 @@ ENTRY art_quick_work_around_app_jni_bugs jr $t9 # tail call into JNI routine addiu $sp, $sp, 32 .cfi_adjust_cfa_offset -32 -END art_quick_work_around_app_jni_bugs +END art_work_around_app_jni_bugs diff --git a/runtime/arch/mips/portable_entrypoints_mips.S b/runtime/arch/mips/portable_entrypoints_mips.S index e7a9b0fb60..9208a8a4f5 100644 --- a/runtime/arch/mips/portable_entrypoints_mips.S +++ b/runtime/arch/mips/portable_entrypoints_mips.S @@ -61,13 +61,5 @@ ENTRY art_portable_proxy_invoke_handler .cfi_adjust_cfa_offset -64 END art_portable_proxy_invoke_handler - /* - * Portable abstract method error stub. $a0 contains method* on entry. SP unused in portable. - */ - .extern artThrowAbstractMethodErrorFromCode -ENTRY art_portable_abstract_method_error_stub - GENERATE_GLOBAL_POINTER - la $t9, artThrowAbstractMethodErrorFromCode - jr $t9 # (Method*, Thread*, SP) - move $a1, $s1 # pass Thread::Current -END art_portable_abstract_method_error_stub +UNIMPLEMENTED art_portable_resolution_trampoline +UNIMPLEMENTED art_portable_to_interpreter_bridge diff --git a/runtime/arch/mips/quick_entrypoints_mips.S b/runtime/arch/mips/quick_entrypoints_mips.S index d32a2b4a15..004fda60f1 100644 --- a/runtime/arch/mips/quick_entrypoints_mips.S +++ b/runtime/arch/mips/quick_entrypoints_mips.S @@ -143,7 +143,7 @@ lw $a1, 4($sp) # restore non-callee save $a1 lw $a2, 8($sp) # restore non-callee save $a2 lw $a3, 12($sp) # restore non-callee save $a3 - addiu $sp, $sp, 64 # strip frame + addiu $sp, $sp, 64 # pop frame .cfi_adjust_cfa_offset -64 .endm @@ -268,79 +268,79 @@ END art_quick_do_long_jump * the bottom of the stack. artDeliverExceptionFromCode will place the callee save Method* at * the bottom of the thread. On entry r0 holds Throwable* */ -ENTRY art_quick_deliver_exception_from_code +ENTRY art_quick_deliver_exception GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a1, rSELF # pass Thread::Current la $t9, artDeliverExceptionFromCode jr $t9 # artDeliverExceptionFromCode(Throwable*, Thread*, $sp) move $a2, $sp # pass $sp -END art_quick_deliver_exception_from_code +END art_quick_deliver_exception /* * Called by managed code to create and deliver a NullPointerException */ .extern artThrowNullPointerExceptionFromCode -ENTRY art_quick_throw_null_pointer_exception_from_code +ENTRY art_quick_throw_null_pointer_exception GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a0, rSELF # pass Thread::Current la $t9, artThrowNullPointerExceptionFromCode jr $t9 # artThrowNullPointerExceptionFromCode(Thread*, $sp) move $a1, $sp # pass $sp -END art_quick_throw_null_pointer_exception_from_code +END art_quick_throw_null_pointer_exception /* * Called by managed code to create and deliver an ArithmeticException */ .extern artThrowDivZeroFromCode -ENTRY art_quick_throw_div_zero_from_code +ENTRY art_quick_throw_div_zero GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a0, rSELF # pass Thread::Current la $t9, artThrowDivZeroFromCode jr $t9 # artThrowDivZeroFromCode(Thread*, $sp) move $a1, $sp # pass $sp -END art_quick_throw_div_zero_from_code +END art_quick_throw_div_zero /* * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException */ .extern artThrowArrayBoundsFromCode -ENTRY art_quick_throw_array_bounds_from_code +ENTRY art_quick_throw_array_bounds GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a2, rSELF # pass Thread::Current la $t9, artThrowArrayBoundsFromCode jr $t9 # artThrowArrayBoundsFromCode(index, limit, Thread*, $sp) move $a3, $sp # pass $sp -END art_quick_throw_array_bounds_from_code +END art_quick_throw_array_bounds /* * Called by managed code to create and deliver a StackOverflowError. */ .extern artThrowStackOverflowFromCode -ENTRY art_quick_throw_stack_overflow_from_code +ENTRY art_quick_throw_stack_overflow GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a0, rSELF # pass Thread::Current la $t9, artThrowStackOverflowFromCode jr $t9 # artThrowStackOverflowFromCode(Thread*, $sp) move $a1, $sp # pass $sp -END art_quick_throw_stack_overflow_from_code +END art_quick_throw_stack_overflow /* * Called by managed code to create and deliver a NoSuchMethodError. */ .extern artThrowNoSuchMethodFromCode -ENTRY art_quick_throw_no_such_method_from_code +ENTRY art_quick_throw_no_such_method GENERATE_GLOBAL_POINTER SETUP_SAVE_ALL_CALLEE_SAVE_FRAME move $a1, rSELF # pass Thread::Current la $t9, artThrowNoSuchMethodFromCode jr $t9 # artThrowNoSuchMethodFromCode(method_idx, Thread*, $sp) move $a2, $sp # pass $sp -END art_quick_throw_no_such_method_from_code +END art_quick_throw_no_such_method /* * All generated callsites for interface invokes and invocation slow paths will load arguments @@ -466,67 +466,67 @@ END art_quick_invoke_stub * failure. */ .extern artHandleFillArrayDataFromCode -ENTRY art_quick_handle_fill_data_from_code +ENTRY art_quick_handle_fill_data GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC move $a2, rSELF # pass Thread::Current jal artHandleFillArrayDataFromCode # (Array*, const DexFile::Payload*, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_ZERO -END art_quick_handle_fill_data_from_code +END art_quick_handle_fill_data /* * Entry from managed code that calls artLockObjectFromCode, may block for GC. */ .extern artLockObjectFromCode -ENTRY art_quick_lock_object_from_code +ENTRY art_quick_lock_object GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case we block move $a1, rSELF # pass Thread::Current jal artLockObjectFromCode # (Object* obj, Thread*, $sp) move $a2, $sp # pass $sp RESTORE_REF_ONLY_CALLEE_SAVE_FRAME_AND_RETURN -END art_quick_lock_object_from_code +END art_quick_lock_object /* * Entry from managed code that calls artUnlockObjectFromCode and delivers exception on failure. */ .extern artUnlockObjectFromCode -ENTRY art_quick_unlock_object_from_code +ENTRY art_quick_unlock_object GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC move $a1, rSELF # pass Thread::Current jal artUnlockObjectFromCode # (Object* obj, Thread*, $sp) move $a2, $sp # pass $sp RETURN_IF_ZERO -END art_quick_unlock_object_from_code +END art_quick_unlock_object /* * Entry from managed code that calls artCheckCastFromCode and delivers exception on failure. */ .extern artCheckCastFromCode -ENTRY art_quick_check_cast_from_code +ENTRY art_quick_check_cast GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC move $a2, rSELF # pass Thread::Current jal artCheckCastFromCode # (Class* a, Class* b, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_ZERO -END art_quick_check_cast_from_code +END art_quick_check_cast /* * Entry from managed code that calls artCanPutArrayElementFromCode and delivers exception on * failure. */ .extern artCanPutArrayElementFromCode -ENTRY art_quick_can_put_array_element_from_code +ENTRY art_quick_can_put_array_element GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case exception allocation triggers GC move $a2, rSELF # pass Thread::Current jal artCanPutArrayElementFromCode # (Object* element, Class* array_class, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_ZERO -END art_quick_can_put_array_element_from_code +END art_quick_can_put_array_element /* * Entry from managed code when uninitialized static storage, this stub will run the class @@ -534,7 +534,7 @@ END art_quick_can_put_array_element_from_code * returned. */ .extern artInitializeStaticStorageFromCode -ENTRY art_quick_initialize_static_storage_from_code +ENTRY art_quick_initialize_static_storage GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current @@ -542,13 +542,13 @@ ENTRY art_quick_initialize_static_storage_from_code jal artInitializeStaticStorageFromCode move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_initialize_static_storage_from_code +END art_quick_initialize_static_storage /* * Entry from managed code when dex cache misses for a type_idx. */ .extern artInitializeTypeFromCode -ENTRY art_quick_initialize_type_from_code +ENTRY art_quick_initialize_type GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current @@ -556,14 +556,14 @@ ENTRY art_quick_initialize_type_from_code jal artInitializeTypeFromCode move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_initialize_type_from_code +END art_quick_initialize_type /* * Entry from managed code when type_idx needs to be checked for access and dex cache may also * miss. */ .extern artInitializeTypeAndVerifyAccessFromCode -ENTRY art_quick_initialize_type_and_verify_access_from_code +ENTRY art_quick_initialize_type_and_verify_access GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current @@ -571,13 +571,13 @@ ENTRY art_quick_initialize_type_and_verify_access_from_code jal artInitializeTypeAndVerifyAccessFromCode move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_initialize_type_and_verify_access_from_code +END art_quick_initialize_type_and_verify_access /* * Called by managed code to resolve a static field and load a 32-bit primitive value. */ .extern artGet32StaticFromCode -ENTRY art_quick_get32_static_from_code +ENTRY art_quick_get32_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a1, 64($sp) # pass referrer's Method* @@ -585,13 +585,13 @@ ENTRY art_quick_get32_static_from_code jal artGet32StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get32_static_from_code +END art_quick_get32_static /* * Called by managed code to resolve a static field and load a 64-bit primitive value. */ .extern artGet64StaticFromCode -ENTRY art_quick_get64_static_from_code +ENTRY art_quick_get64_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a1, 64($sp) # pass referrer's Method* @@ -599,13 +599,13 @@ ENTRY art_quick_get64_static_from_code jal artGet64StaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get64_static_from_code +END art_quick_get64_static /* * Called by managed code to resolve a static field and load an object reference. */ .extern artGetObjStaticFromCode -ENTRY art_quick_get_obj_static_from_code +ENTRY art_quick_get_obj_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a1, 64($sp) # pass referrer's Method* @@ -613,13 +613,13 @@ ENTRY art_quick_get_obj_static_from_code jal artGetObjStaticFromCode # (uint32_t field_idx, const Method* referrer, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get_obj_static_from_code +END art_quick_get_obj_static /* * Called by managed code to resolve an instance field and load a 32-bit primitive value. */ .extern artGet32InstanceFromCode -ENTRY art_quick_get32_instance_from_code +ENTRY art_quick_get32_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a2, 64($sp) # pass referrer's Method* @@ -627,13 +627,13 @@ ENTRY art_quick_get32_instance_from_code jal artGet32InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp) sw $sp, 16($sp) # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get32_instance_from_code +END art_quick_get32_instance /* * Called by managed code to resolve an instance field and load a 64-bit primitive value. */ .extern artGet64InstanceFromCode -ENTRY art_quick_get64_instance_from_code +ENTRY art_quick_get64_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a2, 64($sp) # pass referrer's Method* @@ -641,13 +641,13 @@ ENTRY art_quick_get64_instance_from_code jal artGet64InstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp) sw $sp, 16($sp) # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get64_instance_from_code +END art_quick_get64_instance /* * Called by managed code to resolve an instance field and load an object reference. */ .extern artGetObjInstanceFromCode -ENTRY art_quick_get_obj_instance_from_code +ENTRY art_quick_get_obj_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a2, 64($sp) # pass referrer's Method* @@ -655,13 +655,13 @@ ENTRY art_quick_get_obj_instance_from_code jal artGetObjInstanceFromCode # (field_idx, Object*, referrer, Thread*, $sp) sw $sp, 16($sp) # pass $sp RETURN_IF_NO_EXCEPTION -END art_quick_get_obj_instance_from_code +END art_quick_get_obj_instance /* * Called by managed code to resolve a static field and store a 32-bit primitive value. */ .extern artSet32StaticFromCode -ENTRY art_quick_set32_static_from_code +ENTRY art_quick_set32_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a2, 64($sp) # pass referrer's Method* @@ -669,13 +669,13 @@ ENTRY art_quick_set32_static_from_code jal artSet32StaticFromCode # (field_idx, new_val, referrer, Thread*, $sp) sw $sp, 16($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set32_static_from_code +END art_quick_set32_static /* * Called by managed code to resolve a static field and store a 64-bit primitive value. */ .extern artSet32StaticFromCode -ENTRY art_quick_set64_static_from_code +ENTRY art_quick_set64_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a1, 64($sp) # pass referrer's Method* @@ -683,13 +683,13 @@ ENTRY art_quick_set64_static_from_code jal artSet64StaticFromCode # (field_idx, referrer, new_val, Thread*, $sp) sw $sp, 20($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set64_static_from_code +END art_quick_set64_static /* * Called by managed code to resolve a static field and store an object reference. */ .extern artSetObjStaticFromCode -ENTRY art_quick_set_obj_static_from_code +ENTRY art_quick_set_obj_static GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a2, 64($sp) # pass referrer's Method* @@ -697,13 +697,13 @@ ENTRY art_quick_set_obj_static_from_code jal artSetObjStaticFromCode # (field_idx, new_val, referrer, Thread*, $sp) sw $sp, 16($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set_obj_static_from_code +END art_quick_set_obj_static /* * Called by managed code to resolve an instance field and store a 32-bit primitive value. */ .extern artSet32InstanceFromCode -ENTRY art_quick_set32_instance_from_code +ENTRY art_quick_set32_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a3, 64($sp) # pass referrer's Method* @@ -711,26 +711,26 @@ ENTRY art_quick_set32_instance_from_code jal artSet32InstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp) sw $sp, 20($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set32_instance_from_code +END art_quick_set32_instance /* * Called by managed code to resolve an instance field and store a 64-bit primitive value. */ .extern artSet32InstanceFromCode -ENTRY art_quick_set64_instance_from_code +ENTRY art_quick_set64_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC sw rSELF, 16($sp) # pass Thread::Current jal artSet64InstanceFromCode # (field_idx, Object*, new_val, Thread*, $sp) sw $sp, 20($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set64_instance_from_code +END art_quick_set64_instance /* * Called by managed code to resolve an instance field and store an object reference. */ .extern artSetObjInstanceFromCode -ENTRY art_quick_set_obj_instance_from_code +ENTRY art_quick_set_obj_instance GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC lw $a3, 64($sp) # pass referrer's Method* @@ -738,7 +738,7 @@ ENTRY art_quick_set_obj_instance_from_code jal artSetObjInstanceFromCode # (field_idx, Object*, new_val, referrer, Thread*, $sp) sw $sp, 20($sp) # pass $sp RETURN_IF_ZERO -END art_quick_set_obj_instance_from_code +END art_quick_set_obj_instance /* * Entry from managed code to resolve a string, this stub will allocate a String and deliver an @@ -747,7 +747,7 @@ END art_quick_set_obj_instance_from_code * performed. */ .extern artResolveStringFromCode -ENTRY art_quick_resolve_string_from_code +ENTRY art_quick_resolve_string GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current @@ -755,40 +755,40 @@ ENTRY art_quick_resolve_string_from_code jal artResolveStringFromCode move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_resolve_string_from_code +END art_quick_resolve_string /* * Called by managed code to allocate an object. */ .extern artAllocObjectFromCode -ENTRY art_quick_alloc_object_from_code +ENTRY art_quick_alloc_object GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current jal artAllocObjectFromCode # (uint32_t type_idx, Method* method, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_alloc_object_from_code +END art_quick_alloc_object /* * Called by managed code to allocate an object when the caller doesn't know whether it has * access to the created type. */ .extern artAllocObjectFromCodeWithAccessCheck -ENTRY art_quick_alloc_object_from_code_with_access_check +ENTRY art_quick_alloc_object_with_access_check GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a2, rSELF # pass Thread::Current jal artAllocObjectFromCodeWithAccessCheck # (uint32_t type_idx, Method* method, Thread*, $sp) move $a3, $sp # pass $sp RETURN_IF_NONZERO -END art_quick_alloc_object_from_code_with_access_check +END art_quick_alloc_object_with_access_check /* * Called by managed code to allocate an array. */ .extern artAllocArrayFromCode -ENTRY art_quick_alloc_array_from_code +ENTRY art_quick_alloc_array GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a3, rSELF # pass Thread::Current @@ -796,14 +796,14 @@ ENTRY art_quick_alloc_array_from_code jal artAllocArrayFromCode sw $sp, 16($sp) # pass $sp RETURN_IF_NONZERO -END art_quick_alloc_array_from_code +END art_quick_alloc_array /* * Called by managed code to allocate an array when the caller doesn't know whether it has * access to the created type. */ .extern artAllocArrayFromCodeWithAccessCheck -ENTRY art_quick_alloc_array_from_code_with_access_check +ENTRY art_quick_alloc_array_with_access_check GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a3, rSELF # pass Thread::Current @@ -811,13 +811,13 @@ ENTRY art_quick_alloc_array_from_code_with_access_check jal artAllocArrayFromCodeWithAccessCheck sw $sp, 16($sp) # pass $sp RETURN_IF_NONZERO -END art_quick_alloc_array_from_code_with_access_check +END art_quick_alloc_array_with_access_check /* * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. */ .extern artCheckAndAllocArrayFromCode -ENTRY art_quick_check_and_alloc_array_from_code +ENTRY art_quick_check_and_alloc_array GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a3, rSELF # pass Thread::Current @@ -825,13 +825,13 @@ ENTRY art_quick_check_and_alloc_array_from_code jal artCheckAndAllocArrayFromCode sw $sp, 16($sp) # pass $sp RETURN_IF_NONZERO -END art_quick_check_and_alloc_array_from_code +END art_quick_check_and_alloc_array /* * Called by managed code to allocate an array in a special case for FILLED_NEW_ARRAY. */ .extern artCheckAndAllocArrayFromCodeWithAccessCheck -ENTRY art_quick_check_and_alloc_array_from_code_with_access_check +ENTRY art_quick_check_and_alloc_array_with_access_check GENERATE_GLOBAL_POINTER SETUP_REF_ONLY_CALLEE_SAVE_FRAME # save callee saves in case of GC move $a3, rSELF # pass Thread::Current @@ -839,7 +839,7 @@ ENTRY art_quick_check_and_alloc_array_from_code_with_access_check jal artCheckAndAllocArrayFromCodeWithAccessCheck sw $sp, 16($sp) # pass $sp RETURN_IF_NONZERO -END art_quick_check_and_alloc_array_from_code_with_access_check +END art_quick_check_and_alloc_array_with_access_check /* * Called by managed code when the value in rSUSPEND has been decremented to 0. @@ -884,13 +884,33 @@ ENTRY art_quick_proxy_invoke_handler DELIVER_PENDING_EXCEPTION END art_quick_proxy_invoke_handler - .extern artInterpreterEntry -ENTRY art_quick_interpreter_entry + .extern artQuickResolutionTrampoline +ENTRY art_quick_resolution_trampoline + GENERATE_GLOBAL_POINTER + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + move $a2, rSELF # pass Thread::Current + jal artQuickProxyInvokeHandler # (Method* called, receiver, Thread*, SP) + move $a3, $sp # pass $sp + lw $gp, 52($sp) # restore $gp + lw $ra, 60($sp) # restore $ra + beqz $v0, 1f + lw $a0, 0($sp) # load resolved method to $a0 + lw $a1, 4($sp) # restore non-callee save $a1 + lw $a2, 8($sp) # restore non-callee save $a2 + lw $a3, 12($sp) # restore non-callee save $a3 + jr $v0 # tail call to method +1: + addiu $sp, $sp, 64 # pop frame + .cfi_adjust_cfa_offset -64 + DELIVER_PENDING_EXCEPTION +END art_quick_resolution_trampoline + + .extern artQuickToInterpreterBridge +ENTRY art_quick_to_interpreter_bridge GENERATE_GLOBAL_POINTER SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME - sw $a0, 0($sp) # place proxy method at bottom of frame move $a1, rSELF # pass Thread::Current - jal artInterpreterEntry # (Method* method, Thread*, SP) + jal artQuickToInterpreterBridge # (Method* method, Thread*, SP) move $a2, $sp # pass $sp lw $t0, THREAD_EXCEPTION_OFFSET(rSELF) # load Thread::Current()->exception_ lw $gp, 52($sp) # restore $gp @@ -902,14 +922,14 @@ ENTRY art_quick_interpreter_entry nop 1: DELIVER_PENDING_EXCEPTION -END art_quick_interpreter_entry +END art_quick_to_interpreter_bridge /* * Routine that intercepts method calls and returns. */ .extern artInstrumentationMethodEntryFromCode .extern artInstrumentationMethodExitFromCode -ENTRY art_quick_instrumentation_entry_from_code +ENTRY art_quick_instrumentation_entry GENERATE_GLOBAL_POINTER SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME move $t0, $sp # remember bottom of caller's frame @@ -927,10 +947,10 @@ ENTRY art_quick_instrumentation_entry_from_code RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME jalr $t9 # call method nop -END art_quick_instrumentation_entry_from_code +END art_quick_instrumentation_entry /* intentional fallthrough */ - .global art_quick_instrumentation_exit_from_code -art_quick_instrumentation_exit_from_code: + .global art_quick_instrumentation_exit +art_quick_instrumentation_exit: .cfi_startproc addiu $t9, $ra, 4 # put current address into $t9 to rebuild $gp GENERATE_GLOBAL_POINTER @@ -960,7 +980,7 @@ art_quick_instrumentation_exit_from_code: jr $t0 # return addiu $sp, $sp, 112 # 48 bytes of args + 64 bytes of callee save frame .cfi_adjust_cfa_offset -112 -END art_quick_instrumentation_exit_from_code +END art_quick_instrumentation_exit /* * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization @@ -977,18 +997,6 @@ ENTRY art_quick_deoptimize move $a1, $sp # pass $sp END art_quick_deoptimize - /* - * Quick abstract method error stub. $a0 contains method* on entry. - */ -ENTRY art_quick_abstract_method_error_stub - GENERATE_GLOBAL_POINTER - SETUP_SAVE_ALL_CALLEE_SAVE_FRAME - move $a1, $s1 # pass Thread::Current - la $t9, artThrowAbstractMethodErrorFromCode - jr $t9 # (Method*, Thread*, SP) - move $a2, $sp # pass SP -END art_quick_abstract_method_error_stub - /* * Long integer shift. This is different from the generic 32/64-bit * binary operations because vAA/vBB are 64-bit but vCC (the shift diff --git a/runtime/arch/x86/asm_support_x86.S b/runtime/arch/x86/asm_support_x86.S index 7e6dce9c6a..7a3fdfad30 100644 --- a/runtime/arch/x86/asm_support_x86.S +++ b/runtime/arch/x86/asm_support_x86.S @@ -88,4 +88,16 @@ MACRO1(POP, reg) .cfi_restore REG_VAR(reg,0) END_MACRO +MACRO1(UNIMPLEMENTED,name) + .type VAR(name, 0), @function + .globl VAR(name, 0) + ALIGN_FUNCTION_ENTRY +VAR(name, 0): + .cfi_startproc + int3 + int3 + .cfi_endproc + .size \name, .-\name +END_MACRO + #endif // ART_RUNTIME_ARCH_X86_ASM_SUPPORT_X86_S_ diff --git a/runtime/arch/x86/entrypoints_init_x86.cc b/runtime/arch/x86/entrypoints_init_x86.cc index d47dfef047..91526741cf 100644 --- a/runtime/arch/x86/entrypoints_init_x86.cc +++ b/runtime/arch/x86/entrypoints_init_x86.cc @@ -20,69 +20,73 @@ namespace art { +// Interpreter entrypoints. +extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); +extern "C" void artInterperterToCompiledCodeBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); + +// Portable entrypoints. +extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); + // Alloc entrypoints. -extern "C" void* art_quick_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); -extern "C" void* art_quick_alloc_object_from_code(uint32_t type_idx, void* method); -extern "C" void* art_quick_alloc_object_from_code_with_access_check(uint32_t type_idx, void* method); -extern "C" void* art_quick_check_and_alloc_array_from_code(uint32_t, void*, int32_t); -extern "C" void* art_quick_check_and_alloc_array_from_code_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_array_with_access_check(uint32_t, void*, int32_t); +extern "C" void* art_quick_alloc_object(uint32_t type_idx, void* method); +extern "C" void* art_quick_alloc_object_with_access_check(uint32_t type_idx, void* method); +extern "C" void* art_quick_check_and_alloc_array(uint32_t, void*, int32_t); +extern "C" void* art_quick_check_and_alloc_array_with_access_check(uint32_t, void*, int32_t); // Cast entrypoints. -extern "C" uint32_t art_quick_is_assignable_from_code(const mirror::Class* klass, +extern "C" uint32_t art_quick_is_assignable(const mirror::Class* klass, const mirror::Class* ref_class); -extern "C" void art_quick_can_put_array_element_from_code(void*, void*); -extern "C" void art_quick_check_cast_from_code(void*, void*); +extern "C" void art_quick_can_put_array_element(void*, void*); +extern "C" void art_quick_check_cast(void*, void*); // DexCache entrypoints. -extern "C" void* art_quick_initialize_static_storage_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_from_code(uint32_t, void*); -extern "C" void* art_quick_initialize_type_and_verify_access_from_code(uint32_t, void*); -extern "C" void* art_quick_resolve_string_from_code(void*, uint32_t); +extern "C" void* art_quick_initialize_static_storage(uint32_t, void*); +extern "C" void* art_quick_initialize_type(uint32_t, void*); +extern "C" void* art_quick_initialize_type_and_verify_access(uint32_t, void*); +extern "C" void* art_quick_resolve_string(void*, uint32_t); // Field entrypoints. -extern "C" int art_quick_set32_instance_from_code(uint32_t, void*, int32_t); -extern "C" int art_quick_set32_static_from_code(uint32_t, int32_t); -extern "C" int art_quick_set64_instance_from_code(uint32_t, void*, int64_t); -extern "C" int art_quick_set64_static_from_code(uint32_t, int64_t); -extern "C" int art_quick_set_obj_instance_from_code(uint32_t, void*, void*); -extern "C" int art_quick_set_obj_static_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_instance_from_code(uint32_t, void*); -extern "C" int32_t art_quick_get32_static_from_code(uint32_t); -extern "C" int64_t art_quick_get64_instance_from_code(uint32_t, void*); -extern "C" int64_t art_quick_get64_static_from_code(uint32_t); -extern "C" void* art_quick_get_obj_instance_from_code(uint32_t, void*); -extern "C" void* art_quick_get_obj_static_from_code(uint32_t); +extern "C" int art_quick_set32_instance(uint32_t, void*, int32_t); +extern "C" int art_quick_set32_static(uint32_t, int32_t); +extern "C" int art_quick_set64_instance(uint32_t, void*, int64_t); +extern "C" int art_quick_set64_static(uint32_t, int64_t); +extern "C" int art_quick_set_obj_instance(uint32_t, void*, void*); +extern "C" int art_quick_set_obj_static(uint32_t, void*); +extern "C" int32_t art_quick_get32_instance(uint32_t, void*); +extern "C" int32_t art_quick_get32_static(uint32_t); +extern "C" int64_t art_quick_get64_instance(uint32_t, void*); +extern "C" int64_t art_quick_get64_static(uint32_t); +extern "C" void* art_quick_get_obj_instance(uint32_t, void*); +extern "C" void* art_quick_get_obj_static(uint32_t); // FillArray entrypoint. -extern "C" void art_quick_handle_fill_data_from_code(void*, void*); +extern "C" void art_quick_handle_fill_data(void*, void*); // Lock entrypoints. -extern "C" void art_quick_lock_object_from_code(void*); -extern "C" void art_quick_unlock_object_from_code(void*); +extern "C" void art_quick_lock_object(void*); +extern "C" void art_quick_unlock_object(void*); // Math entrypoints. -extern "C" double art_quick_fmod_from_code(double, double); -extern "C" float art_quick_fmodf_from_code(float, float); -extern "C" double art_quick_l2d_from_code(int64_t); -extern "C" float art_quick_l2f_from_code(int64_t); -extern "C" int64_t art_quick_d2l_from_code(double); -extern "C" int64_t art_quick_f2l_from_code(float); -extern "C" int32_t art_quick_idivmod_from_code(int32_t, int32_t); -extern "C" int64_t art_quick_ldiv_from_code(int64_t, int64_t); -extern "C" int64_t art_quick_ldivmod_from_code(int64_t, int64_t); -extern "C" int64_t art_quick_lmul_from_code(int64_t, int64_t); -extern "C" uint64_t art_quick_lshl_from_code(uint64_t, uint32_t); -extern "C" uint64_t art_quick_lshr_from_code(uint64_t, uint32_t); -extern "C" uint64_t art_quick_lushr_from_code(uint64_t, uint32_t); - -// Interpreter entrypoints. -extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); -extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); +extern "C" double art_quick_fmod(double, double); +extern "C" float art_quick_fmodf(float, float); +extern "C" double art_quick_l2d(int64_t); +extern "C" float art_quick_l2f(int64_t); +extern "C" int64_t art_quick_d2l(double); +extern "C" int64_t art_quick_f2l(float); +extern "C" int32_t art_quick_idivmod(int32_t, int32_t); +extern "C" int64_t art_quick_ldiv(int64_t, int64_t); +extern "C" int64_t art_quick_ldivmod(int64_t, int64_t); +extern "C" int64_t art_quick_lmul(int64_t, int64_t); +extern "C" uint64_t art_quick_lshl(uint64_t, uint32_t); +extern "C" uint64_t art_quick_lshr(uint64_t, uint32_t); +extern "C" uint64_t art_quick_lushr(uint64_t, uint32_t); // Intrinsic entrypoints. extern "C" int32_t art_quick_memcmp16(void*, void*, int32_t); @@ -91,12 +95,8 @@ extern "C" int32_t art_quick_string_compareto(void*, void*); extern "C" void* art_quick_memcpy(void*, const void*, size_t); // Invoke entrypoints. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread); +extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); @@ -109,49 +109,61 @@ extern void CheckSuspendFromCode(Thread* thread); extern "C" void art_quick_test_suspend(); // Throw entrypoints. -extern "C" void art_quick_deliver_exception_from_code(void*); -extern "C" void art_quick_throw_array_bounds_from_code(int32_t index, int32_t limit); -extern "C" void art_quick_throw_div_zero_from_code(); -extern "C" void art_quick_throw_no_such_method_from_code(int32_t method_idx); -extern "C" void art_quick_throw_null_pointer_exception_from_code(); -extern "C" void art_quick_throw_stack_overflow_from_code(void*); - -void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { +extern "C" void art_quick_deliver_exception(void*); +extern "C" void art_quick_throw_array_bounds(int32_t index, int32_t limit); +extern "C" void art_quick_throw_div_zero(); +extern "C" void art_quick_throw_no_such_method(int32_t method_idx); +extern "C" void art_quick_throw_null_pointer_exception(); +extern "C" void art_quick_throw_stack_overflow(void*); + +void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, + PortableEntryPoints* ppoints, QuickEntryPoints* qpoints) { + // Interpreter + ipoints->pInterpreterToInterpreterBridge = artInterpreterToInterpreterBridge; + ipoints->pInterpreterToCompiledCodeBridge = artInterperterToCompiledCodeBridge; + + // JNI + jpoints->pDlsymLookup = art_jni_dlsym_lookup_stub; + + // Portable + ppoints->pPortableResolutionTrampoline = art_portable_resolution_trampoline; + ppoints->pPortableToInterpreterBridge = art_portable_to_interpreter_bridge; + // Alloc - qpoints->pAllocArrayFromCode = art_quick_alloc_array_from_code; - qpoints->pAllocArrayFromCodeWithAccessCheck = art_quick_alloc_array_from_code_with_access_check; - qpoints->pAllocObjectFromCode = art_quick_alloc_object_from_code; - qpoints->pAllocObjectFromCodeWithAccessCheck = art_quick_alloc_object_from_code_with_access_check; - qpoints->pCheckAndAllocArrayFromCode = art_quick_check_and_alloc_array_from_code; - qpoints->pCheckAndAllocArrayFromCodeWithAccessCheck = art_quick_check_and_alloc_array_from_code_with_access_check; + qpoints->pAllocArray = art_quick_alloc_array; + qpoints->pAllocArrayWithAccessCheck = art_quick_alloc_array_with_access_check; + qpoints->pAllocObject = art_quick_alloc_object; + qpoints->pAllocObjectWithAccessCheck = art_quick_alloc_object_with_access_check; + qpoints->pCheckAndAllocArray = art_quick_check_and_alloc_array; + qpoints->pCheckAndAllocArrayWithAccessCheck = art_quick_check_and_alloc_array_with_access_check; // Cast - qpoints->pInstanceofNonTrivialFromCode = art_quick_is_assignable_from_code; - qpoints->pCanPutArrayElementFromCode = art_quick_can_put_array_element_from_code; - qpoints->pCheckCastFromCode = art_quick_check_cast_from_code; + qpoints->pInstanceofNonTrivial = art_quick_is_assignable; + qpoints->pCanPutArrayElement = art_quick_can_put_array_element; + qpoints->pCheckCast = art_quick_check_cast; // DexCache - qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage_from_code; - qpoints->pInitializeTypeAndVerifyAccessFromCode = art_quick_initialize_type_and_verify_access_from_code; - qpoints->pInitializeTypeFromCode = art_quick_initialize_type_from_code; - qpoints->pResolveStringFromCode = art_quick_resolve_string_from_code; + qpoints->pInitializeStaticStorage = art_quick_initialize_static_storage; + qpoints->pInitializeTypeAndVerifyAccess = art_quick_initialize_type_and_verify_access; + qpoints->pInitializeType = art_quick_initialize_type; + qpoints->pResolveString = art_quick_resolve_string; // Field - qpoints->pSet32Instance = art_quick_set32_instance_from_code; - qpoints->pSet32Static = art_quick_set32_static_from_code; - qpoints->pSet64Instance = art_quick_set64_instance_from_code; - qpoints->pSet64Static = art_quick_set64_static_from_code; - qpoints->pSetObjInstance = art_quick_set_obj_instance_from_code; - qpoints->pSetObjStatic = art_quick_set_obj_static_from_code; - qpoints->pGet32Instance = art_quick_get32_instance_from_code; - qpoints->pGet64Instance = art_quick_get64_instance_from_code; - qpoints->pGetObjInstance = art_quick_get_obj_instance_from_code; - qpoints->pGet32Static = art_quick_get32_static_from_code; - qpoints->pGet64Static = art_quick_get64_static_from_code; - qpoints->pGetObjStatic = art_quick_get_obj_static_from_code; + qpoints->pSet32Instance = art_quick_set32_instance; + qpoints->pSet32Static = art_quick_set32_static; + qpoints->pSet64Instance = art_quick_set64_instance; + qpoints->pSet64Static = art_quick_set64_static; + qpoints->pSetObjInstance = art_quick_set_obj_instance; + qpoints->pSetObjStatic = art_quick_set_obj_static; + qpoints->pGet32Instance = art_quick_get32_instance; + qpoints->pGet64Instance = art_quick_get64_instance; + qpoints->pGetObjInstance = art_quick_get_obj_instance; + qpoints->pGet32Static = art_quick_get32_static; + qpoints->pGet64Static = art_quick_get64_static; + qpoints->pGetObjStatic = art_quick_get_obj_static; // FillArray - qpoints->pHandleFillArrayDataFromCode = art_quick_handle_fill_data_from_code; + qpoints->pHandleFillArrayData = art_quick_handle_fill_data; // JNI qpoints->pJniMethodStart = JniMethodStart; @@ -162,33 +174,29 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pJniMethodEndWithReferenceSynchronized = JniMethodEndWithReferenceSynchronized; // Locks - qpoints->pLockObjectFromCode = art_quick_lock_object_from_code; - qpoints->pUnlockObjectFromCode = art_quick_unlock_object_from_code; + qpoints->pLockObject = art_quick_lock_object; + qpoints->pUnlockObject = art_quick_unlock_object; // Math // points->pCmpgDouble = NULL; // Not needed on x86. // points->pCmpgFloat = NULL; // Not needed on x86. // points->pCmplDouble = NULL; // Not needed on x86. // points->pCmplFloat = NULL; // Not needed on x86. - qpoints->pFmod = art_quick_fmod_from_code; - qpoints->pL2d = art_quick_l2d_from_code; - qpoints->pFmodf = art_quick_fmodf_from_code; - qpoints->pL2f = art_quick_l2f_from_code; + qpoints->pFmod = art_quick_fmod; + qpoints->pL2d = art_quick_l2d; + qpoints->pFmodf = art_quick_fmodf; + qpoints->pL2f = art_quick_l2f; // points->pD2iz = NULL; // Not needed on x86. // points->pF2iz = NULL; // Not needed on x86. - qpoints->pIdivmod = art_quick_idivmod_from_code; - qpoints->pD2l = art_quick_d2l_from_code; - qpoints->pF2l = art_quick_f2l_from_code; - qpoints->pLdiv = art_quick_ldiv_from_code; - qpoints->pLdivmod = art_quick_ldivmod_from_code; - qpoints->pLmul = art_quick_lmul_from_code; - qpoints->pShlLong = art_quick_lshl_from_code; - qpoints->pShrLong = art_quick_lshr_from_code; - qpoints->pUshrLong = art_quick_lushr_from_code; - - // Interpreter - qpoints->pInterpreterToInterpreterEntry = artInterpreterToInterpreterEntry; - qpoints->pInterpreterToQuickEntry = artInterpreterToQuickEntry; + qpoints->pIdivmod = art_quick_idivmod; + qpoints->pD2l = art_quick_d2l; + qpoints->pF2l = art_quick_f2l; + qpoints->pLdiv = art_quick_ldiv; + qpoints->pLdivmod = art_quick_ldivmod; + qpoints->pLmul = art_quick_lmul; + qpoints->pShlLong = art_quick_lshl; + qpoints->pShrLong = art_quick_lshr; + qpoints->pUshrLong = art_quick_lushr; // Intrinsics qpoints->pIndexOf = art_quick_indexof; @@ -197,7 +205,8 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pMemcpy = art_quick_memcpy; // Invocation - qpoints->pQuickResolutionTrampolineFromCode = artQuickResolutionTrampoline; + qpoints->pQuickResolutionTrampoline = art_quick_resolution_trampoline; + qpoints->pQuickToInterpreterBridge = art_quick_to_interpreter_bridge; qpoints->pInvokeDirectTrampolineWithAccessCheck = art_quick_invoke_direct_trampoline_with_access_check; qpoints->pInvokeInterfaceTrampoline = art_quick_invoke_interface_trampoline; qpoints->pInvokeInterfaceTrampolineWithAccessCheck = art_quick_invoke_interface_trampoline_with_access_check; @@ -206,19 +215,16 @@ void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints) { qpoints->pInvokeVirtualTrampolineWithAccessCheck = art_quick_invoke_virtual_trampoline_with_access_check; // Thread - qpoints->pCheckSuspendFromCode = CheckSuspendFromCode; - qpoints->pTestSuspendFromCode = art_quick_test_suspend; + qpoints->pCheckSuspend = CheckSuspendFromCode; + qpoints->pTestSuspend = art_quick_test_suspend; // Throws - qpoints->pDeliverException = art_quick_deliver_exception_from_code; - qpoints->pThrowArrayBoundsFromCode = art_quick_throw_array_bounds_from_code; - qpoints->pThrowDivZeroFromCode = art_quick_throw_div_zero_from_code; - qpoints->pThrowNoSuchMethodFromCode = art_quick_throw_no_such_method_from_code; - qpoints->pThrowNullPointerFromCode = art_quick_throw_null_pointer_exception_from_code; - qpoints->pThrowStackOverflowFromCode = art_quick_throw_stack_overflow_from_code; - - // Portable - ppoints->pPortableResolutionTrampolineFromCode = artPortableResolutionTrampoline; + qpoints->pDeliverException = art_quick_deliver_exception; + qpoints->pThrowArrayBounds = art_quick_throw_array_bounds; + qpoints->pThrowDivZero = art_quick_throw_div_zero; + qpoints->pThrowNoSuchMethod = art_quick_throw_no_such_method; + qpoints->pThrowNullPointer = art_quick_throw_null_pointer_exception; + qpoints->pThrowStackOverflow = art_quick_throw_stack_overflow; }; } // namespace art diff --git a/runtime/arch/x86/portable_entrypoints_x86.S b/runtime/arch/x86/portable_entrypoints_x86.S index a0fca6cee3..0313d4b882 100644 --- a/runtime/arch/x86/portable_entrypoints_x86.S +++ b/runtime/arch/x86/portable_entrypoints_x86.S @@ -90,20 +90,5 @@ DEFINE_FUNCTION art_portable_proxy_invoke_handler ret END_FUNCTION art_portable_proxy_invoke_handler - /* - * Portable abstract method error stub. method* is at %esp + 4 on entry. - */ -DEFINE_FUNCTION art_portable_abstract_method_error_stub - PUSH ebp - movl %esp, %ebp // Remember SP. - .cfi_def_cfa_register ebp - subl LITERAL(12), %esp // Align stack. - PUSH esp // Pass sp (not used). - pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). - pushl 8(%ebp) // Pass Method*. - call SYMBOL(artThrowAbstractMethodErrorFromCode) // (Method*, Thread*, SP) - leave // Restore the stack and %ebp. - .cfi_def_cfa esp, 4 - .cfi_restore ebp - ret // Return to caller to handle pending exception. -END_FUNCTION art_portable_abstract_method_error_stub +UNIMPLEMENTED art_portable_resolution_trampoline +UNIMPLEMENTED art_portable_to_interpreter_bridge diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S index 89ea71a902..dbf552faaf 100644 --- a/runtime/arch/x86/quick_entrypoints_x86.S +++ b/runtime/arch/x86/quick_entrypoints_x86.S @@ -135,34 +135,34 @@ END_MACRO /* * Called by managed code to create and deliver a NullPointerException. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception_from_code, artThrowNullPointerExceptionFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_null_pointer_exception, artThrowNullPointerExceptionFromCode /* * Called by managed code to create and deliver an ArithmeticException. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero_from_code, artThrowDivZeroFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_div_zero, artThrowDivZeroFromCode /* * Called by managed code to create and deliver a StackOverflowError. */ -NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow_from_code, artThrowStackOverflowFromCode +NO_ARG_RUNTIME_EXCEPTION art_quick_throw_stack_overflow, artThrowStackOverflowFromCode /* * Called by managed code, saves callee saves and then calls artThrowException * that will place a mock Method* at the bottom of the stack. Arg1 holds the exception. */ -ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception_from_code, artDeliverExceptionFromCode +ONE_ARG_RUNTIME_EXCEPTION art_quick_deliver_exception, artDeliverExceptionFromCode /* * Called by managed code to create and deliver a NoSuchMethodError. */ -ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method_from_code, artThrowNoSuchMethodFromCode +ONE_ARG_RUNTIME_EXCEPTION art_quick_throw_no_such_method, artThrowNoSuchMethodFromCode /* * Called by managed code to create and deliver an ArrayIndexOutOfBoundsException. Arg1 holds * index, arg2 holds limit. */ -TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds_from_code, artThrowArrayBoundsFromCode +TWO_ARG_RUNTIME_EXCEPTION art_quick_throw_array_bounds, artThrowArrayBoundsFromCode /* * All generated callsites for interface invokes and invocation slow paths will load arguments @@ -382,24 +382,24 @@ MACRO0(RETURN_OR_DELIVER_PENDING_EXCEPTION) DELIVER_PENDING_EXCEPTION END_MACRO -TWO_ARG_DOWNCALL art_quick_alloc_object_from_code, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO -TWO_ARG_DOWNCALL art_quick_alloc_object_from_code_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO -THREE_ARG_DOWNCALL art_quick_alloc_array_from_code, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO -THREE_ARG_DOWNCALL art_quick_alloc_array_from_code_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO -THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_from_code, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO -THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_from_code_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_alloc_object, artAllocObjectFromCode, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_alloc_object_with_access_check, artAllocObjectFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO +THREE_ARG_DOWNCALL art_quick_alloc_array, artAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO +THREE_ARG_DOWNCALL art_quick_alloc_array_with_access_check, artAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO +THREE_ARG_DOWNCALL art_quick_check_and_alloc_array, artCheckAndAllocArrayFromCode, RETURN_IF_EAX_NOT_ZERO +THREE_ARG_DOWNCALL art_quick_check_and_alloc_array_with_access_check, artCheckAndAllocArrayFromCodeWithAccessCheck, RETURN_IF_EAX_NOT_ZERO -TWO_ARG_DOWNCALL art_quick_resolve_string_from_code, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO -TWO_ARG_DOWNCALL art_quick_initialize_static_storage_from_code, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO -TWO_ARG_DOWNCALL art_quick_initialize_type_from_code, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO -TWO_ARG_DOWNCALL art_quick_initialize_type_and_verify_access_from_code, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_initialize_static_storage, artInitializeStaticStorageFromCode, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_initialize_type, artInitializeTypeFromCode, RETURN_IF_EAX_NOT_ZERO +TWO_ARG_DOWNCALL art_quick_initialize_type_and_verify_access, artInitializeTypeAndVerifyAccessFromCode, RETURN_IF_EAX_NOT_ZERO -ONE_ARG_DOWNCALL art_quick_lock_object_from_code, artLockObjectFromCode, ret -ONE_ARG_DOWNCALL art_quick_unlock_object_from_code, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO +ONE_ARG_DOWNCALL art_quick_lock_object, artLockObjectFromCode, ret +ONE_ARG_DOWNCALL art_quick_unlock_object, artUnlockObjectFromCode, RETURN_IF_EAX_ZERO -TWO_ARG_DOWNCALL art_quick_handle_fill_data_from_code, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO +TWO_ARG_DOWNCALL art_quick_handle_fill_data, artHandleFillArrayDataFromCode, RETURN_IF_EAX_ZERO -DEFINE_FUNCTION art_quick_is_assignable_from_code +DEFINE_FUNCTION art_quick_is_assignable PUSH eax // alignment padding PUSH ecx // pass arg2 PUSH eax // pass arg1 @@ -407,7 +407,7 @@ DEFINE_FUNCTION art_quick_is_assignable_from_code addl LITERAL(12), %esp // pop arguments .cfi_adjust_cfa_offset -12 ret -END_FUNCTION art_quick_is_assignable_from_code +END_FUNCTION art_quick_is_assignable DEFINE_FUNCTION art_quick_memcpy PUSH edx // pass arg3 @@ -419,12 +419,12 @@ DEFINE_FUNCTION art_quick_memcpy ret END_FUNCTION art_quick_memcpy -TWO_ARG_DOWNCALL art_quick_check_cast_from_code, artCheckCastFromCode, RETURN_IF_EAX_ZERO -TWO_ARG_DOWNCALL art_quick_can_put_array_element_from_code, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO +TWO_ARG_DOWNCALL art_quick_check_cast, artCheckCastFromCode, RETURN_IF_EAX_ZERO +TWO_ARG_DOWNCALL art_quick_can_put_array_element, artCanPutArrayElementFromCode, RETURN_IF_EAX_ZERO NO_ARG_DOWNCALL art_quick_test_suspend, artTestSuspendFromCode, ret -DEFINE_FUNCTION art_quick_fmod_from_code +DEFINE_FUNCTION art_quick_fmod subl LITERAL(12), %esp // alignment padding .cfi_adjust_cfa_offset 12 PUSH ebx // pass arg4 b.hi @@ -437,9 +437,9 @@ DEFINE_FUNCTION art_quick_fmod_from_code addl LITERAL(28), %esp // pop arguments .cfi_adjust_cfa_offset -28 ret -END_FUNCTION art_quick_fmod_from_code +END_FUNCTION art_quick_fmod -DEFINE_FUNCTION art_quick_fmodf_from_code +DEFINE_FUNCTION art_quick_fmodf PUSH eax // alignment padding PUSH ecx // pass arg2 b PUSH eax // pass arg1 a @@ -449,9 +449,9 @@ DEFINE_FUNCTION art_quick_fmodf_from_code addl LITERAL(12), %esp // pop arguments .cfi_adjust_cfa_offset -12 ret -END_FUNCTION art_quick_fmodf_from_code +END_FUNCTION art_quick_fmodf -DEFINE_FUNCTION art_quick_l2d_from_code +DEFINE_FUNCTION art_quick_l2d PUSH ecx // push arg2 a.hi PUSH eax // push arg1 a.lo fildll (%esp) // load as integer and push into st0 @@ -460,9 +460,9 @@ DEFINE_FUNCTION art_quick_l2d_from_code addl LITERAL(8), %esp // pop arguments .cfi_adjust_cfa_offset -8 ret -END_FUNCTION art_quick_l2d_from_code +END_FUNCTION art_quick_l2d -DEFINE_FUNCTION art_quick_l2f_from_code +DEFINE_FUNCTION art_quick_l2f PUSH ecx // push arg2 a.hi PUSH eax // push arg1 a.lo fildll (%esp) // load as integer and push into st0 @@ -471,9 +471,9 @@ DEFINE_FUNCTION art_quick_l2f_from_code addl LITERAL(8), %esp // pop argument .cfi_adjust_cfa_offset -8 ret -END_FUNCTION art_quick_l2f_from_code +END_FUNCTION art_quick_l2f -DEFINE_FUNCTION art_quick_d2l_from_code +DEFINE_FUNCTION art_quick_d2l PUSH eax // alignment padding PUSH ecx // pass arg2 a.hi PUSH eax // pass arg1 a.lo @@ -481,9 +481,9 @@ DEFINE_FUNCTION art_quick_d2l_from_code addl LITERAL(12), %esp // pop arguments .cfi_adjust_cfa_offset -12 ret -END_FUNCTION art_quick_d2l_from_code +END_FUNCTION art_quick_d2l -DEFINE_FUNCTION art_quick_f2l_from_code +DEFINE_FUNCTION art_quick_f2l subl LITERAL(8), %esp // alignment padding .cfi_adjust_cfa_offset 8 PUSH eax // pass arg1 a @@ -491,9 +491,9 @@ DEFINE_FUNCTION art_quick_f2l_from_code addl LITERAL(12), %esp // pop arguments .cfi_adjust_cfa_offset -12 ret -END_FUNCTION art_quick_f2l_from_code +END_FUNCTION art_quick_f2l -DEFINE_FUNCTION art_quick_idivmod_from_code +DEFINE_FUNCTION art_quick_idivmod cmpl LITERAL(0x80000000), %eax je check_arg2 // special case args_ok: @@ -505,9 +505,9 @@ check_arg2: jne args_ok xorl %edx, %edx ret // eax already holds min int -END_FUNCTION art_quick_idivmod_from_code +END_FUNCTION art_quick_idivmod -DEFINE_FUNCTION art_quick_ldiv_from_code +DEFINE_FUNCTION art_quick_ldiv subl LITERAL(12), %esp // alignment padding .cfi_adjust_cfa_offset 12 PUSH ebx // pass arg4 b.hi @@ -518,9 +518,9 @@ DEFINE_FUNCTION art_quick_ldiv_from_code addl LITERAL(28), %esp // pop arguments .cfi_adjust_cfa_offset -28 ret -END_FUNCTION art_quick_ldiv_from_code +END_FUNCTION art_quick_ldiv -DEFINE_FUNCTION art_quick_ldivmod_from_code +DEFINE_FUNCTION art_quick_ldivmod subl LITERAL(12), %esp // alignment padding .cfi_adjust_cfa_offset 12 PUSH ebx // pass arg4 b.hi @@ -531,18 +531,18 @@ DEFINE_FUNCTION art_quick_ldivmod_from_code addl LITERAL(28), %esp // pop arguments .cfi_adjust_cfa_offset -28 ret -END_FUNCTION art_quick_ldivmod_from_code +END_FUNCTION art_quick_ldivmod -DEFINE_FUNCTION art_quick_lmul_from_code +DEFINE_FUNCTION art_quick_lmul imul %eax, %ebx // ebx = a.lo(eax) * b.hi(ebx) imul %edx, %ecx // ecx = b.lo(edx) * a.hi(ecx) mul %edx // edx:eax = a.lo(eax) * b.lo(edx) add %ebx, %ecx add %ecx, %edx // edx += (a.lo * b.hi) + (b.lo * a.hi) ret -END_FUNCTION art_quick_lmul_from_code +END_FUNCTION art_quick_lmul -DEFINE_FUNCTION art_quick_lshl_from_code +DEFINE_FUNCTION art_quick_lshl // ecx:eax << edx xchg %edx, %ecx shld %cl,%eax,%edx @@ -553,9 +553,9 @@ DEFINE_FUNCTION art_quick_lshl_from_code xor %eax, %eax 1: ret -END_FUNCTION art_quick_lshl_from_code +END_FUNCTION art_quick_lshl -DEFINE_FUNCTION art_quick_lshr_from_code +DEFINE_FUNCTION art_quick_lshr // ecx:eax >> edx xchg %edx, %ecx shrd %cl,%edx,%eax @@ -566,9 +566,9 @@ DEFINE_FUNCTION art_quick_lshr_from_code sar LITERAL(31), %edx 1: ret -END_FUNCTION art_quick_lshr_from_code +END_FUNCTION art_quick_lshr -DEFINE_FUNCTION art_quick_lushr_from_code +DEFINE_FUNCTION art_quick_lushr // ecx:eax >>> edx xchg %edx, %ecx shrd %cl,%edx,%eax @@ -579,9 +579,9 @@ DEFINE_FUNCTION art_quick_lushr_from_code xor %edx, %edx 1: ret -END_FUNCTION art_quick_lushr_from_code +END_FUNCTION art_quick_lushr -DEFINE_FUNCTION art_quick_set32_instance_from_code +DEFINE_FUNCTION art_quick_set32_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP subl LITERAL(8), %esp // alignment padding @@ -599,9 +599,9 @@ DEFINE_FUNCTION art_quick_set32_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set32_instance_from_code +END_FUNCTION art_quick_set32_instance -DEFINE_FUNCTION art_quick_set64_instance_from_code +DEFINE_FUNCTION art_quick_set64_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC subl LITERAL(8), %esp // alignment padding .cfi_adjust_cfa_offset 8 @@ -618,9 +618,9 @@ DEFINE_FUNCTION art_quick_set64_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set64_instance_from_code +END_FUNCTION art_quick_set64_instance -DEFINE_FUNCTION art_quick_set_obj_instance_from_code +DEFINE_FUNCTION art_quick_set_obj_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP subl LITERAL(8), %esp // alignment padding @@ -638,9 +638,9 @@ DEFINE_FUNCTION art_quick_set_obj_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set_obj_instance_from_code +END_FUNCTION art_quick_set_obj_instance -DEFINE_FUNCTION art_quick_get32_instance_from_code +DEFINE_FUNCTION art_quick_get32_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP mov 32(%esp), %edx // get referrer @@ -657,9 +657,9 @@ DEFINE_FUNCTION art_quick_get32_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get32_instance_from_code +END_FUNCTION art_quick_get32_instance -DEFINE_FUNCTION art_quick_get64_instance_from_code +DEFINE_FUNCTION art_quick_get64_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP mov 32(%esp), %edx // get referrer @@ -676,9 +676,9 @@ DEFINE_FUNCTION art_quick_get64_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get64_instance_from_code +END_FUNCTION art_quick_get64_instance -DEFINE_FUNCTION art_quick_get_obj_instance_from_code +DEFINE_FUNCTION art_quick_get_obj_instance SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP mov 32(%esp), %edx // get referrer @@ -695,9 +695,9 @@ DEFINE_FUNCTION art_quick_get_obj_instance_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get_obj_instance_from_code +END_FUNCTION art_quick_get_obj_instance -DEFINE_FUNCTION art_quick_set32_static_from_code +DEFINE_FUNCTION art_quick_set32_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP mov 32(%esp), %edx // get referrer @@ -714,9 +714,9 @@ DEFINE_FUNCTION art_quick_set32_static_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set32_static_from_code +END_FUNCTION art_quick_set32_static -DEFINE_FUNCTION art_quick_set64_static_from_code +DEFINE_FUNCTION art_quick_set64_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP subl LITERAL(8), %esp // alignment padding @@ -734,9 +734,9 @@ DEFINE_FUNCTION art_quick_set64_static_from_code .cfi_adjust_cfa_offset -32 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set64_static_from_code +END_FUNCTION art_quick_set64_static -DEFINE_FUNCTION art_quick_set_obj_static_from_code +DEFINE_FUNCTION art_quick_set_obj_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %ebx // remember SP mov 32(%esp), %edx // get referrer @@ -752,9 +752,9 @@ DEFINE_FUNCTION art_quick_set_obj_static_from_code addl LITERAL(32), %esp // pop arguments RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_IF_EAX_ZERO // return or deliver exception -END_FUNCTION art_quick_set_obj_static_from_code +END_FUNCTION art_quick_set_obj_static -DEFINE_FUNCTION art_quick_get32_static_from_code +DEFINE_FUNCTION art_quick_get32_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %edx // remember SP mov 32(%esp), %ecx // get referrer @@ -768,9 +768,9 @@ DEFINE_FUNCTION art_quick_get32_static_from_code .cfi_adjust_cfa_offset -16 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get32_static_from_code +END_FUNCTION art_quick_get32_static -DEFINE_FUNCTION art_quick_get64_static_from_code +DEFINE_FUNCTION art_quick_get64_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %edx // remember SP mov 32(%esp), %ecx // get referrer @@ -784,9 +784,9 @@ DEFINE_FUNCTION art_quick_get64_static_from_code .cfi_adjust_cfa_offset -16 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get64_static_from_code +END_FUNCTION art_quick_get64_static -DEFINE_FUNCTION art_quick_get_obj_static_from_code +DEFINE_FUNCTION art_quick_get_obj_static SETUP_REF_ONLY_CALLEE_SAVE_FRAME // save ref containing registers for GC mov %esp, %edx // remember SP mov 32(%esp), %ecx // get referrer @@ -800,7 +800,7 @@ DEFINE_FUNCTION art_quick_get_obj_static_from_code .cfi_adjust_cfa_offset -16 RESTORE_REF_ONLY_CALLEE_SAVE_FRAME // restore frame up to return address RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_get_obj_static_from_code +END_FUNCTION art_quick_get_obj_static DEFINE_FUNCTION art_quick_proxy_invoke_handler SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // save frame and Method* @@ -818,7 +818,32 @@ DEFINE_FUNCTION art_quick_proxy_invoke_handler RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception END_FUNCTION art_quick_proxy_invoke_handler -DEFINE_FUNCTION art_quick_interpreter_entry +DEFINE_FUNCTION art_quick_resolution_trampoline + SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME + PUSH esp // pass SP + pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() + .cfi_adjust_cfa_offset 4 + PUSH ecx // pass receiver + PUSH eax // pass method + call SYMBOL(artQuickResolutionTrampoline) // (Method* called, receiver, Thread*, SP) + movl %eax, %edi // remember code pointer in EDI + addl LITERAL(16), %esp // pop arguments + test %eax, %eax // if code pointer is NULL goto deliver pending exception + jz 1f + POP eax // called method + POP ecx // restore args + POP edx + POP ebx + POP ebp // restore callee saves except EDI + POP esi + xchgl 0(%esp),%edi // restore EDI and place code pointer as only value on stack + ret // tail call into method +1: + RESTORE_REF_AND_ARGS_CALLEE_SAVE_FRAME + DELIVER_PENDING_EXCEPTION +END_FUNCTION art_quick_resolution_trampoline + +DEFINE_FUNCTION art_quick_to_interpreter_bridge SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME // save frame mov %esp, %edx // remember SP PUSH eax // alignment padding @@ -826,19 +851,19 @@ DEFINE_FUNCTION art_quick_interpreter_entry pushl %fs:THREAD_SELF_OFFSET // pass Thread::Current() .cfi_adjust_cfa_offset 4 PUSH eax // pass method - call SYMBOL(artInterpreterEntry) // (method, Thread*, SP) + call SYMBOL(artQuickToInterpreterBridge) // (method, Thread*, SP) movd %eax, %xmm0 // place return value also into floating point return value movd %edx, %xmm1 punpckldq %xmm1, %xmm0 addl LITERAL(44), %esp // pop arguments .cfi_adjust_cfa_offset -44 RETURN_OR_DELIVER_PENDING_EXCEPTION // return or deliver exception -END_FUNCTION art_quick_interpreter_entry +END_FUNCTION art_quick_to_interpreter_bridge /* * Routine that intercepts method calls and returns. */ -DEFINE_FUNCTION art_quick_instrumentation_entry_from_code +DEFINE_FUNCTION art_quick_instrumentation_entry SETUP_REF_AND_ARGS_CALLEE_SAVE_FRAME movl %esp, %edx // Save SP. PUSH eax // Save eax which will be clobbered by the callee-save method. @@ -855,7 +880,7 @@ DEFINE_FUNCTION art_quick_instrumentation_entry_from_code addl LITERAL(28), %esp // Pop arguments upto saved Method*. movl 28(%esp), %edi // Restore edi. movl %eax, 28(%esp) // Place code* over edi, just under return pc. - movl LITERAL(SYMBOL(art_quick_instrumentation_exit_from_code)), 32(%esp) + movl LITERAL(SYMBOL(art_quick_instrumentation_exit)), 32(%esp) // Place instrumentation exit as return pc. movl (%esp), %eax // Restore eax. movl 8(%esp), %ecx // Restore ecx. @@ -865,9 +890,9 @@ DEFINE_FUNCTION art_quick_instrumentation_entry_from_code movl 24(%esp), %esi // Restore esi. addl LITERAL(28), %esp // Wind stack back upto code*. ret // Call method (and pop). -END_FUNCTION art_quick_instrumentation_entry_from_code +END_FUNCTION art_quick_instrumentation_entry -DEFINE_FUNCTION art_quick_instrumentation_exit_from_code +DEFINE_FUNCTION art_quick_instrumentation_exit pushl LITERAL(0) // Push a fake return PC as there will be none on the stack. SETUP_REF_ONLY_CALLEE_SAVE_FRAME mov %esp, %ecx // Remember SP @@ -900,7 +925,7 @@ DEFINE_FUNCTION art_quick_instrumentation_exit_from_code RESTORE_REF_ONLY_CALLEE_SAVE_FRAME addl LITERAL(4), %esp // Remove fake return pc. jmp *%ecx // Return. -END_FUNCTION art_quick_instrumentation_exit_from_code +END_FUNCTION art_quick_instrumentation_exit /* * Instrumentation has requested that we deoptimize into the interpreter. The deoptimization @@ -919,21 +944,6 @@ DEFINE_FUNCTION art_quick_deoptimize int3 // Unreachable. END_FUNCTION art_quick_deoptimize - /* - * Quick abstract method error stub. %eax contains method* on entry. - */ -DEFINE_FUNCTION art_quick_abstract_method_error_stub - SETUP_SAVE_ALL_CALLEE_SAVE_FRAME - movl %esp, %ecx // Remember SP. - PUSH eax // Align frame. - PUSH ecx // Pass SP for Method*. - pushl %fs:THREAD_SELF_OFFSET // Pass Thread::Current(). - .cfi_adjust_cfa_offset 4 - PUSH eax // Pass Method*. - call SYMBOL(artThrowAbstractMethodErrorFromCode) // (Method*, Thread*, SP) - int3 // Unreachable. -END_FUNCTION art_quick_abstract_method_error_stub - /* * String's indexOf. * @@ -1030,12 +1040,5 @@ not_equal: ret END_FUNCTION art_quick_string_compareto -MACRO1(UNIMPLEMENTED,name) - .globl VAR(name, 0) - ALIGN_FUNCTION_ENTRY -VAR(name, 0): - int3 -END_MACRO - // TODO: implement these! UNIMPLEMENTED art_quick_memcmp16 diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 84f186d4b3..962977559a 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -71,7 +71,7 @@ namespace art { -extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, +extern "C" void artInterperterToCompiledCodeBridge(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); @@ -920,6 +920,43 @@ const OatFile* ClassLinker::FindOatFileFromOatLocationLocked(const std::string& return oat_file; } +static void InitFromImageCallbackCommon(mirror::Object* obj, ClassLinker* class_linker, + bool interpret_only_mode) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(obj != NULL); + DCHECK(class_linker != NULL); + + if (obj->GetClass()->IsStringClass()) { + class_linker->GetInternTable()->RegisterStrong(obj->AsString()); + } else if (obj->IsClass()) { + // Restore class to ClassLinker::classes_ table. + mirror::Class* klass = obj->AsClass(); + ClassHelper kh(klass, class_linker); + mirror::Class* existing = class_linker->InsertClass(kh.GetDescriptor(), klass, true); + DCHECK(existing == NULL) << kh.GetDescriptor(); + } else if (interpret_only_mode && obj->IsMethod()) { + mirror::AbstractMethod* method = obj->AsMethod(); + if (!method->IsNative()) { + method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge); + if (method != Runtime::Current()->GetResolutionMethod()) { + method->SetEntryPointFromCompiledCode(GetCompiledCodeToInterpreterBridge()); + } + } + } +} + +static void InitFromImageCallback(mirror::Object* obj, void* arg) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + ClassLinker* class_linker = reinterpret_cast(arg); + InitFromImageCallbackCommon(obj, class_linker, false); +} + +static void InitFromImageInterpretOnlyCallback(mirror::Object* obj, void* arg) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + ClassLinker* class_linker = reinterpret_cast(arg); + InitFromImageCallbackCommon(obj, class_linker, true); +} + void ClassLinker::InitFromImage() { VLOG(startup) << "ClassLinker::InitFromImage entering"; CHECK(!init_done_); @@ -973,7 +1010,11 @@ void ClassLinker::InitFromImage() { { ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); heap->FlushAllocStack(); - heap->GetLiveBitmap()->Walk(InitFromImageCallback, this); + if (Runtime::Current()->GetInstrumentation()->InterpretOnly()) { + heap->GetLiveBitmap()->Walk(InitFromImageInterpretOnlyCallback, this); + } else { + heap->GetLiveBitmap()->Walk(InitFromImageCallback, this); + } } // reinit class_roots_ @@ -1001,40 +1042,6 @@ void ClassLinker::InitFromImage() { VLOG(startup) << "ClassLinker::InitFromImage exiting"; } -void ClassLinker::InitFromImageCallback(mirror::Object* obj, void* arg) { - DCHECK(obj != NULL); - DCHECK(arg != NULL); - ClassLinker* class_linker = reinterpret_cast(arg); - - if (obj->GetClass()->IsStringClass()) { - class_linker->intern_table_->RegisterStrong(obj->AsString()); - return; - } - if (obj->IsClass()) { - // restore class to ClassLinker::classes_ table - mirror::Class* klass = obj->AsClass(); - ClassHelper kh(klass, class_linker); - mirror::Class* existing = class_linker->InsertClass(kh.GetDescriptor(), klass, true); - DCHECK(existing == NULL) << kh.GetDescriptor(); - return; - } - - if (obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); - // Set entry points to interpreter for methods in interpreter only mode. - if (Runtime::Current()->GetInstrumentation()->InterpretOnly() && !method->IsNative()) { - method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterEntry); - if (method != Runtime::Current()->GetResolutionMethod()) { - method->SetEntryPointFromCompiledCode(GetInterpreterEntryPoint()); - } - } - // Populate native method pointer with jni lookup stub. - if (method->IsNative()) { - method->UnregisterNative(Thread::Current()); - } - } -} - // Keep in sync with InitCallback. Anything we visit, we need to // reinit references to when reinitializing a ClassLinker from a // mapped image. @@ -1534,7 +1541,7 @@ const void* ClassLinker::GetOatCodeFor(const mirror::AbstractMethod* method) { const void* result = GetOatMethodFor(method).GetCode(); if (result == NULL) { // No code? You must mean to go into the interpreter. - result = GetInterpreterEntryPoint(); + result = GetCompiledCodeToInterpreterBridge(); } return result; } @@ -1595,7 +1602,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { const bool enter_interpreter = NeedsInterpreter(method, code); if (enter_interpreter) { // Use interpreter entry point. - code = GetInterpreterEntryPoint(); + code = GetCompiledCodeToInterpreterBridge(); } runtime->GetInstrumentation()->UpdateMethodsCode(method, code); } @@ -1616,13 +1623,13 @@ static void LinkCode(SirtRef& method, const OatFile::Oat Runtime* runtime = Runtime::Current(); bool enter_interpreter = NeedsInterpreter(method.get(), method->GetEntryPointFromCompiledCode()); if (enter_interpreter) { - method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterEntry); + method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge); } else { - method->SetEntryPointFromInterpreter(artInterpreterToQuickEntry); + method->SetEntryPointFromInterpreter(artInterperterToCompiledCodeBridge); } if (method->IsAbstract()) { - method->SetEntryPointFromCompiledCode(GetAbstractMethodErrorStub()); + method->SetEntryPointFromCompiledCode(GetCompiledCodeToInterpreterBridge()); return; } @@ -1633,7 +1640,7 @@ static void LinkCode(SirtRef& method, const OatFile::Oat method->SetEntryPointFromCompiledCode(GetResolutionTrampoline(runtime->GetClassLinker())); } else if (enter_interpreter) { // Set entry point from compiled code if there's no code or in interpreter only mode. - method->SetEntryPointFromCompiledCode(GetInterpreterEntryPoint()); + method->SetEntryPointFromCompiledCode(GetCompiledCodeToInterpreterBridge()); } if (method->IsNative()) { @@ -2601,12 +2608,8 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRefSetCoreSpillMask(refs_and_args->GetCoreSpillMask()); method->SetFpSpillMask(refs_and_args->GetFpSpillMask()); method->SetFrameSizeInBytes(refs_and_args->GetFrameSizeInBytes()); -#if !defined(ART_USE_PORTABLE_COMPILER) - method->SetEntryPointFromCompiledCode(reinterpret_cast(art_quick_proxy_invoke_handler)); -#else - method->SetEntryPointFromCompiledCode(reinterpret_cast(art_portable_proxy_invoke_handler)); -#endif - method->SetEntryPointFromInterpreter(artInterpreterToQuickEntry); + method->SetEntryPointFromCompiledCode(GetProxyInvokeHandler()); + method->SetEntryPointFromInterpreter(artInterperterToCompiledCodeBridge); return method; } diff --git a/runtime/class_linker.h b/runtime/class_linker.h index fdf75c2301..060c26c3a7 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -347,6 +347,17 @@ class ClassLinker { return quick_resolution_trampoline_; } + InternTable* GetInternTable() const { + return intern_table_; + } + + // Attempts to insert a class into a class table. Returns NULL if + // the class was inserted, otherwise returns an existing class with + // the same descriptor and ClassLoader. + mirror::Class* InsertClass(const StringPiece& descriptor, mirror::Class* klass, bool image_class) + LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + private: explicit ClassLinker(InternTable*); @@ -362,8 +373,6 @@ class ClassLinker { OatFile& GetImageOatFile(gc::space::ImageSpace* space) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - static void InitFromImageCallback(mirror::Object* obj, void* arg) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FinishInit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -423,13 +432,6 @@ class ClassLinker { const OatFile::OatClass* GetOatClass(const DexFile& dex_file, const char* descriptor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Attempts to insert a class into a class table. Returns NULL if - // the class was inserted, otherwise returns an existing class with - // the same descriptor and ClassLoader. - mirror::Class* InsertClass(const StringPiece& descriptor, mirror::Class* klass, bool image_class) - LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void RegisterDexFileLocked(const DexFile& dex_file, SirtRef& dex_cache) EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/common_test.h b/runtime/common_test.h index 7ee6fe20b2..a54361706a 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -192,10 +192,7 @@ class CommonTest : public testing::Test { compiled_method = compiler_driver_->GetCompiledMethod(MethodReference(&dex_file, method->GetDexMethodIndex())); - -#ifndef ART_LIGHT_MODE CHECK(compiled_method != NULL) << PrettyMethod(method); -#endif } if (compiled_method != NULL) { const std::vector& code = compiled_method->GetCode(); @@ -213,12 +210,8 @@ class CommonTest : public testing::Test { oat_method.LinkMethod(method); } else { const void* method_code; - if (method->IsAbstract()) { - method_code = GetAbstractMethodErrorStub(); - } else { - // No code? You must mean to go into the interpreter. - method_code = GetInterpreterEntryPoint(); - } + // No code? You must mean to go into the interpreter. + method_code = GetCompiledCodeToInterpreterBridge(); LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code; OatFile::OatMethod oat_method = CreateOatMethod(method_code, kStackAlignment, diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index 3f28b5e41f..b6781c02b9 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -30,24 +30,13 @@ #include "object_utils.h" #include "thread.h" -extern "C" void art_interpreter_invoke_handler(); -extern "C" void art_jni_dlsym_lookup_stub(); -extern "C" void art_portable_abstract_method_error_stub(); -extern "C" void art_portable_proxy_invoke_handler(); -extern "C" void art_quick_abstract_method_error_stub(); -extern "C" void art_quick_deoptimize(); -extern "C" void art_quick_instrumentation_entry_from_code(void*); -extern "C" void art_quick_instrumentation_exit_from_code(); -extern "C" void art_quick_interpreter_entry(void*); -extern "C" void art_quick_proxy_invoke_handler(); -extern "C" void art_work_around_app_jni_bugs(); - namespace art { + namespace mirror { -class Class; -class Field; -class Object; -} + class Class; + class Field; + class Object; +} // namespace mirror // Given the context of a calling Method, use its DexCache to resolve a type to a Class. If it // cannot be resolved, throw an error. If it can, use it to create an instance. @@ -350,25 +339,43 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Entry point for deoptimization. -static inline uintptr_t GetDeoptimizationEntryPoint() { +extern "C" void art_quick_deoptimize(); +static inline uintptr_t GetQuickDeoptimizationEntryPoint() { return reinterpret_cast(art_quick_deoptimize); } // Return address of instrumentation stub. -static inline void* GetInstrumentationEntryPoint() { - return reinterpret_cast(art_quick_instrumentation_entry_from_code); +extern "C" void art_quick_instrumentation_entry(void*); +static inline void* GetQuickInstrumentationEntryPoint() { + return reinterpret_cast(art_quick_instrumentation_entry); } // The return_pc of instrumentation exit stub. -static inline uintptr_t GetInstrumentationExitPc() { - return reinterpret_cast(art_quick_instrumentation_exit_from_code); +extern "C" void art_quick_instrumentation_exit(); +static inline uintptr_t GetQuickInstrumentationExitPc() { + return reinterpret_cast(art_quick_instrumentation_exit); +} + +extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +static inline const void* GetPortableToInterpreterBridge() { + return reinterpret_cast(art_portable_to_interpreter_bridge); +} + +extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +static inline const void* GetQuickToInterpreterBridge() { + return reinterpret_cast(art_quick_to_interpreter_bridge); } // Return address of interpreter stub. -static inline void* GetInterpreterEntryPoint() { - return reinterpret_cast(art_quick_interpreter_entry); +static inline const void* GetCompiledCodeToInterpreterBridge() { +#if defined(ART_USE_PORTABLE_COMPILER) + return GetPortableToInterpreterBridge(); +#else + return GetQuickToInterpreterBridge(); +#endif } + static inline const void* GetPortableResolutionTrampoline(ClassLinker* class_linker) { return class_linker->GetPortableResolutionTrampoline(); } @@ -386,23 +393,25 @@ static inline const void* GetResolutionTrampoline(ClassLinker* class_linker) { #endif } -static inline void* GetPortableAbstractMethodErrorStub() { - return reinterpret_cast(art_portable_abstract_method_error_stub); +extern "C" void art_portable_proxy_invoke_handler(); +static inline const void* GetPortableProxyInvokeHandler() { + return reinterpret_cast(art_portable_proxy_invoke_handler); } -static inline void* GetQuickAbstractMethodErrorStub() { - return reinterpret_cast(art_quick_abstract_method_error_stub); +extern "C" void art_quick_proxy_invoke_handler(); +static inline const void* GetQuickProxyInvokeHandler() { + return reinterpret_cast(art_quick_proxy_invoke_handler); } -// Return address of abstract method error stub for defined compiler. -static inline void* GetAbstractMethodErrorStub() { +static inline const void* GetProxyInvokeHandler() { #if defined(ART_USE_PORTABLE_COMPILER) - return GetPortableAbstractMethodErrorStub(); + return GetPortableProxyInvokeHandler(); #else - return GetQuickAbstractMethodErrorStub(); + return GetQuickProxyInvokeHandler(); #endif } +extern "C" void* art_jni_dlsym_lookup_stub(JNIEnv*, jobject); static inline void* GetJniDlsymLookupStub() { return reinterpret_cast(art_jni_dlsym_lookup_stub); } diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc new file mode 100644 index 0000000000..d99c43e052 --- /dev/null +++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc @@ -0,0 +1,43 @@ +/* + * 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 "class_linker.h" +#include "interpreter/interpreter.h" +#include "invoke_arg_array_builder.h" +#include "mirror/abstract_method-inl.h" +#include "mirror/object-inl.h" +#include "object_utils.h" +#include "runtime.h" +#include "stack.h" + +namespace art { + +extern "C" void artInterperterToCompiledCodeBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::AbstractMethod* method = shadow_frame->GetMethod(); + // Ensure static methods are initialized. + if (method->IsStatic()) { + Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); + } + uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_; + ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); + arg_array.BuildArgArray(shadow_frame, arg_offset); + method->Invoke(self, arg_array.GetArray(), arg_array.GetNumBytes(), result, mh.GetShorty()[0]); +} + +} // namespace art diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.h b/runtime/entrypoints/interpreter/interpreter_entrypoints.h new file mode 100644 index 0000000000..c7df4e6b0a --- /dev/null +++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.h @@ -0,0 +1,47 @@ +/* + * 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. + */ + +#ifndef ART_RUNTIME_ENTRYPOINTS_INTERPRETER_INTERPRETER_ENTRYPOINTS_H_ +#define ART_RUNTIME_ENTRYPOINTS_INTERPRETER_INTERPRETER_ENTRYPOINTS_H_ + +#include "base/macros.h" +#include "dex_file.h" +#include "offsets.h" + +#define INTERPRETER_ENTRYPOINT_OFFSET(x) \ + ThreadOffset(static_cast(OFFSETOF_MEMBER(Thread, interpreter_entrypoints_)) + \ + static_cast(OFFSETOF_MEMBER(InterpreterEntryPoints, x))) + +namespace art { + +union JValue; +class MethodHelper; +class ShadowFrame; +class Thread; + +// Pointers to functions that are called by interpreter trampolines via thread-local storage. +struct PACKED(4) InterpreterEntryPoints { + void (*pInterpreterToInterpreterBridge)(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); + void (*pInterpreterToCompiledCodeBridge)(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result); +}; + +} // namespace art + +#endif // ART_RUNTIME_ENTRYPOINTS_INTERPRETER_INTERPRETER_ENTRYPOINTS_H_ diff --git a/runtime/entrypoints/jni/jni_entrypoints.cc b/runtime/entrypoints/jni/jni_entrypoints.cc index 98f7b1283c..88b4936255 100644 --- a/runtime/entrypoints/jni/jni_entrypoints.cc +++ b/runtime/entrypoints/jni/jni_entrypoints.cc @@ -15,23 +15,26 @@ */ #include "base/logging.h" -#include "mirror/abstract_method.h" +#include "entrypoints/entrypoint_utils.h" +#include "mirror/abstract_method-inl.h" +#include "mirror/object-inl.h" +#include "object_utils.h" #include "scoped_thread_state_change.h" #include "thread.h" namespace art { // Used by the JNI dlsym stub to find the native method to invoke if none is registered. -extern "C" void* artFindNativeMethod(Thread* self) { +extern "C" void* artFindNativeMethod() { + Thread* self = Thread::Current(); Locks::mutator_lock_->AssertNotHeld(self); // We come here as Native. - DCHECK(Thread::Current() == self); ScopedObjectAccess soa(self); mirror::AbstractMethod* method = self->GetCurrentMethod(NULL); DCHECK(method != NULL); - // Lookup symbol address for method, on failure we'll return NULL with an - // exception set, otherwise we return the address of the method we found. + // Lookup symbol address for method, on failure we'll return NULL with an exception set, + // otherwise we return the address of the method we found. void* native_code = soa.Vm()->FindCodeForNativeMethod(method); if (native_code == NULL) { DCHECK(self->IsExceptionPending()); @@ -43,4 +46,78 @@ extern "C" void* artFindNativeMethod(Thread* self) { } } +static void WorkAroundJniBugsForJobject(intptr_t* arg_ptr) { + intptr_t value = *arg_ptr; + mirror::Object** value_as_jni_rep = reinterpret_cast(value); + mirror::Object* value_as_work_around_rep = value_as_jni_rep != NULL ? *value_as_jni_rep : NULL; + CHECK(Runtime::Current()->GetHeap()->IsHeapAddress(value_as_work_around_rep)) + << value_as_work_around_rep; + *arg_ptr = reinterpret_cast(value_as_work_around_rep); +} + +extern "C" const void* artWorkAroundAppJniBugs(Thread* self, intptr_t* sp) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(Thread::Current() == self); + // TODO: this code is specific to ARM + // On entry the stack pointed by sp is: + // | arg3 | <- Calling JNI method's frame (and extra bit for out args) + // | LR | + // | R3 | arg2 + // | R2 | arg1 + // | R1 | jclass/jobject + // | R0 | JNIEnv + // | unused | + // | unused | + // | unused | <- sp + mirror::AbstractMethod* jni_method = self->GetCurrentMethod(NULL); + DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method); + intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack + // Fix up this/jclass argument + WorkAroundJniBugsForJobject(arg_ptr); + arg_ptr++; + // Fix up jobject arguments + MethodHelper mh(jni_method); + int reg_num = 2; // Current register being processed, -1 for stack arguments. + for (uint32_t i = 1; i < mh.GetShortyLength(); i++) { + char shorty_char = mh.GetShorty()[i]; + if (shorty_char == 'L') { + WorkAroundJniBugsForJobject(arg_ptr); + } + if (shorty_char == 'J' || shorty_char == 'D') { + if (reg_num == 2) { + arg_ptr = sp + 8; // skip to out arguments + reg_num = -1; + } else if (reg_num == 3) { + arg_ptr = sp + 10; // skip to out arguments plus 2 slots as long must be aligned + reg_num = -1; + } else { + DCHECK_EQ(reg_num, -1); + if ((reinterpret_cast(arg_ptr) & 7) == 4) { + arg_ptr += 3; // unaligned, pad and move through stack arguments + } else { + arg_ptr += 2; // aligned, move through stack arguments + } + } + } else { + if (reg_num == 2) { + arg_ptr++; // move through register arguments + reg_num++; + } else if (reg_num == 3) { + arg_ptr = sp + 8; // skip to outgoing stack arguments + reg_num = -1; + } else { + DCHECK_EQ(reg_num, -1); + arg_ptr++; // move through stack arguments + } + } + } + // Load expected destination, see Method::RegisterNative + const void* code = reinterpret_cast(jni_method->GetNativeGcMap()); + if (UNLIKELY(code == NULL)) { + code = GetJniDlsymLookupStub(); + jni_method->RegisterNative(self, code); + } + return code; +} + } // namespace art diff --git a/runtime/entrypoints/jni/jni_entrypoints.h b/runtime/entrypoints/jni/jni_entrypoints.h new file mode 100644 index 0000000000..0a53447cb4 --- /dev/null +++ b/runtime/entrypoints/jni/jni_entrypoints.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#ifndef ART_RUNTIME_ENTRYPOINTS_JNI_JNI_ENTRYPOINTS_H_ +#define ART_RUNTIME_ENTRYPOINTS_JNI_JNI_ENTRYPOINTS_H_ + +#include "base/macros.h" +#include "offsets.h" + +#define JNI_ENTRYPOINT_OFFSET(x) \ + ThreadOffset(static_cast(OFFSETOF_MEMBER(Thread, jni_entrypoints_)) + \ + static_cast(OFFSETOF_MEMBER(JniEntryPoints, x))) + +namespace art { + +// Pointers to functions that are called by JNI trampolines via thread-local storage. +struct PACKED(4) JniEntryPoints { + // Called when the JNI method isn't registered. + void* (*pDlsymLookup)(JNIEnv* env, jobject); +}; + +} // namespace art + +#endif // ART_RUNTIME_ENTRYPOINTS_JNI_JNI_ENTRYPOINTS_H_ diff --git a/runtime/entrypoints/portable/portable_entrypoints.h b/runtime/entrypoints/portable/portable_entrypoints.h index a229c76dbd..ec9e4f8a7d 100644 --- a/runtime/entrypoints/portable/portable_entrypoints.h +++ b/runtime/entrypoints/portable/portable_entrypoints.h @@ -28,15 +28,15 @@ namespace mirror { class Thread; #define PORTABLE_ENTRYPOINT_OFFSET(x) \ - (static_cast(OFFSETOF_MEMBER(Thread, portable_entrypoints_)) + \ - static_cast(OFFSETOF_MEMBER(PortableEntryPoints, x))) + ThreadOffset(static_cast(OFFSETOF_MEMBER(Thread, portable_entrypoints_)) + \ + static_cast(OFFSETOF_MEMBER(PortableEntryPoints, x))) // Pointers to functions that are called by code generated by compiler's adhering to the portable // compiler ABI. struct PACKED(4) PortableEntryPoints { // Invocation - const void* (*pPortableResolutionTrampolineFromCode)(mirror::AbstractMethod*, mirror::Object*, - mirror::AbstractMethod**, Thread*); + void (*pPortableResolutionTrampoline)(mirror::AbstractMethod*); + void (*pPortableToInterpreterBridge)(mirror::AbstractMethod*); }; } // namespace art diff --git a/runtime/entrypoints/quick/quick_argument_visitor.h b/runtime/entrypoints/quick/quick_argument_visitor.h deleted file mode 100644 index 35fa97269c..0000000000 --- a/runtime/entrypoints/quick/quick_argument_visitor.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ARGUMENT_VISITOR_H_ -#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ARGUMENT_VISITOR_H_ - -#include "object_utils.h" - -namespace art { - -// Visits the arguments as saved to the stack by a Runtime::kRefAndArgs callee save frame. -class QuickArgumentVisitor { - public: -// Offset to first (not the Method*) argument in a Runtime::kRefAndArgs callee save frame. -// Size of Runtime::kRefAndArgs callee save frame. -// Size of Method* and register parameters in out stack arguments. -#if defined(__arm__) -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 8 -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 48 -#define QUICK_STACK_ARG_SKIP 16 -#elif defined(__mips__) -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 4 -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 64 -#define QUICK_STACK_ARG_SKIP 16 -#elif defined(__i386__) -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 4 -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 32 -#define QUICK_STACK_ARG_SKIP 16 -#else -#error "Unsupported architecture" -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 0 -#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 0 -#define QUICK_STACK_ARG_SKIP 0 -#endif - - QuickArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : - caller_mh_(caller_mh), - args_in_regs_(ComputeArgsInRegs(caller_mh)), - num_params_(caller_mh.NumArgs()), - reg_args_(reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET), - stack_args_(reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE - + QUICK_STACK_ARG_SKIP), - cur_args_(reg_args_), - cur_arg_index_(0), - param_index_(0), - is_split_long_or_double_(false) { - } - - virtual ~QuickArgumentVisitor() {} - - virtual void Visit() = 0; - - bool IsParamAReference() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return caller_mh_.IsParamAReference(param_index_); - } - - bool IsParamALongOrDouble() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return caller_mh_.IsParamALongOrDouble(param_index_); - } - - Primitive::Type GetParamPrimitiveType() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return caller_mh_.GetParamPrimitiveType(param_index_); - } - - byte* GetParamAddress() const { - return cur_args_ + (cur_arg_index_ * kPointerSize); - } - - bool IsSplitLongOrDouble() const { - return is_split_long_or_double_; - } - - uint64_t ReadSplitLongParam() const { - DCHECK(IsSplitLongOrDouble()); - uint64_t low_half = *reinterpret_cast(GetParamAddress()); - uint64_t high_half = *reinterpret_cast(stack_args_); - return (low_half & 0xffffffffULL) | (high_half << 32); - } - - void VisitArguments() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - for (cur_arg_index_ = 0; cur_arg_index_ < args_in_regs_ && param_index_ < num_params_; ) { - is_split_long_or_double_ = (cur_arg_index_ == 2) && IsParamALongOrDouble(); - Visit(); - cur_arg_index_ += (IsParamALongOrDouble() ? 2 : 1); - param_index_++; - } - cur_args_ = stack_args_; - cur_arg_index_ = is_split_long_or_double_ ? 1 : 0; - is_split_long_or_double_ = false; - while (param_index_ < num_params_) { - Visit(); - cur_arg_index_ += (IsParamALongOrDouble() ? 2 : 1); - param_index_++; - } - } - - private: - static size_t ComputeArgsInRegs(MethodHelper& mh) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - size_t args_in_regs = 0; - size_t num_params = mh.NumArgs(); - for (size_t i = 0; i < num_params; i++) { - args_in_regs = args_in_regs + (mh.IsParamALongOrDouble(i) ? 2 : 1); - if (args_in_regs > 3) { - args_in_regs = 3; - break; - } - } - return args_in_regs; - } - MethodHelper& caller_mh_; - const size_t args_in_regs_; - const size_t num_params_; - byte* const reg_args_; - byte* const stack_args_; - byte* cur_args_; - size_t cur_arg_index_; - size_t param_index_; - // Does a 64bit parameter straddle the register and stack arguments? - bool is_split_long_or_double_; -}; - -} // namespace art - -#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ARGUMENT_VISITOR_H_ diff --git a/runtime/entrypoints/quick/quick_entrypoints.h b/runtime/entrypoints/quick/quick_entrypoints.h index 74b8cfd09b..e76679b91f 100644 --- a/runtime/entrypoints/quick/quick_entrypoints.h +++ b/runtime/entrypoints/quick/quick_entrypoints.h @@ -17,44 +17,45 @@ #ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ #define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_H_ -#include "dex_file-inl.h" -#include "runtime.h" +#include + +#include "base/macros.h" +#include "offsets.h" #define QUICK_ENTRYPOINT_OFFSET(x) \ - (static_cast(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \ - static_cast(OFFSETOF_MEMBER(QuickEntryPoints, x))) + ThreadOffset(static_cast(OFFSETOF_MEMBER(Thread, quick_entrypoints_)) + \ + static_cast(OFFSETOF_MEMBER(QuickEntryPoints, x))) namespace art { + namespace mirror { class AbstractMethod; class Class; class Object; } // namespace mirror -class DvmDex; -class MethodHelper; -class ShadowFrame; + class Thread; // Pointers to functions that are called by quick compiler generated code via thread-local storage. struct PACKED(4) QuickEntryPoints { // Alloc - void* (*pAllocArrayFromCode)(uint32_t, void*, int32_t); - void* (*pAllocArrayFromCodeWithAccessCheck)(uint32_t, void*, int32_t); - void* (*pAllocObjectFromCode)(uint32_t, void*); - void* (*pAllocObjectFromCodeWithAccessCheck)(uint32_t, void*); - void* (*pCheckAndAllocArrayFromCode)(uint32_t, void*, int32_t); - void* (*pCheckAndAllocArrayFromCodeWithAccessCheck)(uint32_t, void*, int32_t); + void* (*pAllocArray)(uint32_t, void*, int32_t); + void* (*pAllocArrayWithAccessCheck)(uint32_t, void*, int32_t); + void* (*pAllocObject)(uint32_t, void*); + void* (*pAllocObjectWithAccessCheck)(uint32_t, void*); + void* (*pCheckAndAllocArray)(uint32_t, void*, int32_t); + void* (*pCheckAndAllocArrayWithAccessCheck)(uint32_t, void*, int32_t); // Cast - uint32_t (*pInstanceofNonTrivialFromCode)(const mirror::Class*, const mirror::Class*); - void (*pCanPutArrayElementFromCode)(void*, void*); - void (*pCheckCastFromCode)(void*, void*); + uint32_t (*pInstanceofNonTrivial)(const mirror::Class*, const mirror::Class*); + void (*pCanPutArrayElement)(void*, void*); + void (*pCheckCast)(void*, void*); // DexCache void* (*pInitializeStaticStorage)(uint32_t, void*); - void* (*pInitializeTypeAndVerifyAccessFromCode)(uint32_t, void*); - void* (*pInitializeTypeFromCode)(uint32_t, void*); - void* (*pResolveStringFromCode)(void*, uint32_t); + void* (*pInitializeTypeAndVerifyAccess)(uint32_t, void*); + void* (*pInitializeType)(uint32_t, void*); + void* (*pResolveString)(void*, uint32_t); // Field int (*pSet32Instance)(uint32_t, void*, int32_t); // field_idx, obj, src @@ -71,7 +72,7 @@ struct PACKED(4) QuickEntryPoints { void* (*pGetObjStatic)(uint32_t); // FillArray - void (*pHandleFillArrayDataFromCode)(void*, void*); + void (*pHandleFillArrayData)(void*, void*); // JNI uint32_t (*pJniMethodStart)(Thread*); @@ -83,8 +84,8 @@ struct PACKED(4) QuickEntryPoints { jobject locked, Thread* self); // Locks - void (*pLockObjectFromCode)(void*); - void (*pUnlockObjectFromCode)(void*); + void (*pLockObject)(void*); + void (*pUnlockObject)(void*); // Math int32_t (*pCmpgDouble)(double, double); @@ -108,14 +109,6 @@ struct PACKED(4) QuickEntryPoints { uint64_t (*pShrLong)(uint64_t, uint32_t); uint64_t (*pUshrLong)(uint64_t, uint32_t); - // Interpreter - void (*pInterpreterToInterpreterEntry)(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); - void (*pInterpreterToQuickEntry)(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result); - // Intrinsics int32_t (*pIndexOf)(void*, uint32_t, uint32_t, uint32_t); int32_t (*pMemcmp16)(void*, void*, int32_t); @@ -123,8 +116,8 @@ struct PACKED(4) QuickEntryPoints { void* (*pMemcpy)(void*, const void*, size_t); // Invocation - const void* (*pQuickResolutionTrampolineFromCode)(mirror::AbstractMethod*, mirror::Object*, - mirror::AbstractMethod**, Thread*); + void (*pQuickResolutionTrampoline)(mirror::AbstractMethod*); + void (*pQuickToInterpreterBridge)(mirror::AbstractMethod*); void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*); void (*pInvokeInterfaceTrampoline)(uint32_t, void*); void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*); @@ -133,22 +126,21 @@ struct PACKED(4) QuickEntryPoints { void (*pInvokeVirtualTrampolineWithAccessCheck)(uint32_t, void*); // Thread - void (*pCheckSuspendFromCode)(Thread*); // Stub that is called when the suspend count is non-zero - void (*pTestSuspendFromCode)(); // Stub that is periodically called to test the suspend count + void (*pCheckSuspend)(Thread*); // Stub that is called when the suspend count is non-zero + void (*pTestSuspend)(); // Stub that is periodically called to test the suspend count // Throws void (*pDeliverException)(void*); - void (*pThrowArrayBoundsFromCode)(int32_t, int32_t); - void (*pThrowDivZeroFromCode)(); - void (*pThrowNoSuchMethodFromCode)(int32_t); - void (*pThrowNullPointerFromCode)(); - void (*pThrowStackOverflowFromCode)(void*); + void (*pThrowArrayBounds)(int32_t, int32_t); + void (*pThrowDivZero)(); + void (*pThrowNoSuchMethod)(int32_t); + void (*pThrowNullPointer)(); + void (*pThrowStackOverflow)(void*); }; // JNI entrypoints. -extern uint32_t JniMethodStart(Thread* self) - UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; +extern uint32_t JniMethodStart(Thread* self) UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; extern uint32_t JniMethodStartSynchronized(jobject to_lock, Thread* self) UNLOCK_FUNCTION(Locks::mutator_lock_) HOT_ATTR; extern void JniMethodEnd(uint32_t saved_local_ref_cookie, Thread* self) diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc index 7ecd296742..0e61942209 100644 --- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc @@ -32,7 +32,7 @@ extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMet FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); const void* result = instrumentation->GetQuickCodeFor(method); - bool interpreter_entry = (result == GetInterpreterEntryPoint()); + bool interpreter_entry = (result == GetQuickToInterpreterBridge()); instrumentation->PushInstrumentationStackFrame(self, method->IsStatic() ? NULL : this_object, method, lr, interpreter_entry); CHECK(result != NULL) << PrettyMethod(method); diff --git a/runtime/entrypoints/quick/quick_interpreter_entrypoints.cc b/runtime/entrypoints/quick/quick_interpreter_entrypoints.cc deleted file mode 100644 index 656df8de5b..0000000000 --- a/runtime/entrypoints/quick/quick_interpreter_entrypoints.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 "quick_argument_visitor.h" -#include "callee_save_frame.h" -#include "dex_file-inl.h" -#include "interpreter/interpreter.h" -#include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/class-inl.h" -#include "mirror/object-inl.h" -#include "mirror/object_array-inl.h" -#include "object_utils.h" - -namespace art { - -// Visits arguments on the stack placing them into the shadow frame. -class BuildShadowFrameVisitor : public QuickArgumentVisitor { - public: - BuildShadowFrameVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, - ShadowFrame& sf, size_t first_arg_reg) : - QuickArgumentVisitor(caller_mh, sp), sf_(sf), cur_reg_(first_arg_reg) {} - - virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Primitive::Type type = GetParamPrimitiveType(); - switch (type) { - case Primitive::kPrimLong: // Fall-through. - case Primitive::kPrimDouble: - if (IsSplitLongOrDouble()) { - sf_.SetVRegLong(cur_reg_, ReadSplitLongParam()); - } else { - sf_.SetVRegLong(cur_reg_, *reinterpret_cast(GetParamAddress())); - } - ++cur_reg_; - break; - case Primitive::kPrimNot: - sf_.SetVRegReference(cur_reg_, *reinterpret_cast(GetParamAddress())); - break; - case Primitive::kPrimBoolean: // Fall-through. - case Primitive::kPrimByte: // Fall-through. - case Primitive::kPrimChar: // Fall-through. - case Primitive::kPrimShort: // Fall-through. - case Primitive::kPrimInt: // Fall-through. - case Primitive::kPrimFloat: - sf_.SetVReg(cur_reg_, *reinterpret_cast(GetParamAddress())); - break; - case Primitive::kPrimVoid: - LOG(FATAL) << "UNREACHABLE"; - break; - } - ++cur_reg_; - } - - private: - ShadowFrame& sf_; - size_t cur_reg_; - - DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor); -}; - -extern "C" uint64_t artInterpreterEntry(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - // Ensure we don't get thread suspension until the object arguments are safely in the shadow - // frame. - const char* old_cause = self->StartAssertNoThreadSuspension("Building interpreter shadow frame"); - FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); - - MethodHelper mh(method); - const DexFile::CodeItem* code_item = mh.GetCodeItem(); - uint16_t num_regs = code_item->registers_size_; - void* memory = alloca(ShadowFrame::ComputeSize(num_regs)); - ShadowFrame* shadow_frame(ShadowFrame::Create(num_regs, NULL, // No last shadow coming from quick. - method, 0, memory)); - size_t first_arg_reg = code_item->registers_size_ - code_item->ins_size_; - BuildShadowFrameVisitor shadow_frame_builder(mh, sp, *shadow_frame, first_arg_reg); - shadow_frame_builder.VisitArguments(); - // Push a transition back into managed code onto the linked list in thread. - ManagedStack fragment; - self->PushManagedStackFragment(&fragment); - self->PushShadowFrame(shadow_frame); - self->EndAssertNoThreadSuspension(old_cause); - - if (method->IsStatic() && !method->GetDeclaringClass()->IsInitializing()) { - // Ensure static method's class is initialized. - if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), - true, true)) { - DCHECK(Thread::Current()->IsExceptionPending()); - self->PopManagedStackFragment(fragment); - return 0; - } - } - - JValue result = interpreter::EnterInterpreterFromStub(self, mh, code_item, *shadow_frame); - // Pop transition. - self->PopManagedStackFragment(fragment); - return result.GetJ(); -} - -extern "C" void artInterpreterToQuickEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = shadow_frame->GetMethod(); - // Ensure static methods are initialized. - if (method->IsStatic()) { - Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); - } - uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_; - ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); - arg_array.BuildArgArray(shadow_frame, arg_offset); - method->Invoke(self, arg_array.GetArray(), arg_array.GetNumBytes(), result, mh.GetShorty()[0]); -} - -} // namespace art diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc index 23a28f9cce..9907c043ee 100644 --- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc @@ -94,78 +94,4 @@ extern mirror::Object* JniMethodEndWithReferenceSynchronized(jobject result, return o; } -static void WorkAroundJniBugsForJobject(intptr_t* arg_ptr) { - intptr_t value = *arg_ptr; - mirror::Object** value_as_jni_rep = reinterpret_cast(value); - mirror::Object* value_as_work_around_rep = value_as_jni_rep != NULL ? *value_as_jni_rep : NULL; - CHECK(Runtime::Current()->GetHeap()->IsHeapAddress(value_as_work_around_rep)) - << value_as_work_around_rep; - *arg_ptr = reinterpret_cast(value_as_work_around_rep); -} - -extern "C" const void* artWorkAroundAppJniBugs(Thread* self, intptr_t* sp) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(Thread::Current() == self); - // TODO: this code is specific to ARM - // On entry the stack pointed by sp is: - // | arg3 | <- Calling JNI method's frame (and extra bit for out args) - // | LR | - // | R3 | arg2 - // | R2 | arg1 - // | R1 | jclass/jobject - // | R0 | JNIEnv - // | unused | - // | unused | - // | unused | <- sp - mirror::AbstractMethod* jni_method = self->GetCurrentMethod(NULL); - DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method); - intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack - // Fix up this/jclass argument - WorkAroundJniBugsForJobject(arg_ptr); - arg_ptr++; - // Fix up jobject arguments - MethodHelper mh(jni_method); - int reg_num = 2; // Current register being processed, -1 for stack arguments. - for (uint32_t i = 1; i < mh.GetShortyLength(); i++) { - char shorty_char = mh.GetShorty()[i]; - if (shorty_char == 'L') { - WorkAroundJniBugsForJobject(arg_ptr); - } - if (shorty_char == 'J' || shorty_char == 'D') { - if (reg_num == 2) { - arg_ptr = sp + 8; // skip to out arguments - reg_num = -1; - } else if (reg_num == 3) { - arg_ptr = sp + 10; // skip to out arguments plus 2 slots as long must be aligned - reg_num = -1; - } else { - DCHECK_EQ(reg_num, -1); - if ((reinterpret_cast(arg_ptr) & 7) == 4) { - arg_ptr += 3; // unaligned, pad and move through stack arguments - } else { - arg_ptr += 2; // aligned, move through stack arguments - } - } - } else { - if (reg_num == 2) { - arg_ptr++; // move through register arguments - reg_num++; - } else if (reg_num == 3) { - arg_ptr = sp + 8; // skip to outgoing stack arguments - reg_num = -1; - } else { - DCHECK_EQ(reg_num, -1); - arg_ptr++; // move through stack arguments - } - } - } - // Load expected destination, see Method::RegisterNative - const void* code = reinterpret_cast(jni_method->GetNativeGcMap()); - if (UNLIKELY(code == NULL)) { - code = GetJniDlsymLookupStub(); - jni_method->RegisterNative(self, code); - } - return code; -} - } // namespace art diff --git a/runtime/entrypoints/quick/quick_proxy_entrypoints.cc b/runtime/entrypoints/quick/quick_proxy_entrypoints.cc deleted file mode 100644 index 4e3d749e27..0000000000 --- a/runtime/entrypoints/quick/quick_proxy_entrypoints.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 "quick_argument_visitor.h" -#include "dex_file-inl.h" -#include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/object_array-inl.h" -#include "mirror/object-inl.h" -#include "object_utils.h" -#include "reflection.h" -#include "scoped_thread_state_change.h" -#include "thread.h" -#include "well_known_classes.h" - -#include "ScopedLocalRef.h" - -namespace art { - -// Visits arguments on the stack placing them into the args vector, Object* arguments are converted -// to jobjects. -class BuildQuickArgumentVisitor : public QuickArgumentVisitor { - public: - BuildQuickArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, - ScopedObjectAccessUnchecked& soa, std::vector& args) : - QuickArgumentVisitor(caller_mh, sp), soa_(soa), args_(args) {} - - virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - jvalue val; - Primitive::Type type = GetParamPrimitiveType(); - switch (type) { - case Primitive::kPrimNot: { - mirror::Object* obj = *reinterpret_cast(GetParamAddress()); - val.l = soa_.AddLocalReference(obj); - break; - } - case Primitive::kPrimLong: // Fall-through. - case Primitive::kPrimDouble: - if (IsSplitLongOrDouble()) { - val.j = ReadSplitLongParam(); - } else { - val.j = *reinterpret_cast(GetParamAddress()); - } - break; - case Primitive::kPrimBoolean: // Fall-through. - case Primitive::kPrimByte: // Fall-through. - case Primitive::kPrimChar: // Fall-through. - case Primitive::kPrimShort: // Fall-through. - case Primitive::kPrimInt: // Fall-through. - case Primitive::kPrimFloat: - val.i = *reinterpret_cast(GetParamAddress()); - break; - case Primitive::kPrimVoid: - LOG(FATAL) << "UNREACHABLE"; - val.j = 0; - break; - } - args_.push_back(val); - } - - private: - ScopedObjectAccessUnchecked& soa_; - std::vector& args_; - - DISALLOW_COPY_AND_ASSIGN(BuildQuickArgumentVisitor); -}; - -// Handler for invocation on proxy methods. On entry a frame will exist for the proxy object method -// which is responsible for recording callee save registers. We explicitly place into jobjects the -// incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a -// field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_method, - mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - // Ensure we don't get thread suspension until the object arguments are safely in jobjects. - const char* old_cause = - self->StartAssertNoThreadSuspension("Adding to IRT proxy object arguments"); - // Register the top of the managed stack, making stack crawlable. - DCHECK_EQ(*sp, proxy_method); - self->SetTopOfStack(sp, 0); - DCHECK_EQ(proxy_method->GetFrameSizeInBytes(), - Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); - self->VerifyStack(); - // Start new JNI local reference state. - JNIEnvExt* env = self->GetJniEnv(); - ScopedObjectAccessUnchecked soa(env); - ScopedJniEnvLocalRefState env_state(env); - // Create local ref. copies of proxy method and the receiver. - jobject rcvr_jobj = soa.AddLocalReference(receiver); - - // Placing arguments into args vector and remove the receiver. - MethodHelper proxy_mh(proxy_method); - std::vector args; - BuildQuickArgumentVisitor local_ref_visitor(proxy_mh, sp, soa, args); - local_ref_visitor.VisitArguments(); - args.erase(args.begin()); - - // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); - DCHECK(interface_method != NULL); - DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); - jobject interface_method_jobj = soa.AddLocalReference(interface_method); - - // All naked Object*s should now be in jobjects, so its safe to go into the main invoke code - // that performs allocations. - self->EndAssertNoThreadSuspension(old_cause); - JValue result = InvokeProxyInvocationHandler(soa, proxy_mh.GetShorty(), - rcvr_jobj, interface_method_jobj, args); - return result.GetJ(); -} - -} // namespace art diff --git a/runtime/entrypoints/quick/quick_stub_entrypoints.cc b/runtime/entrypoints/quick/quick_stub_entrypoints.cc deleted file mode 100644 index d78bbf3bc8..0000000000 --- a/runtime/entrypoints/quick/quick_stub_entrypoints.cc +++ /dev/null @@ -1,295 +0,0 @@ -/* - * 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 "callee_save_frame.h" -#include "class_linker-inl.h" -#include "dex_file-inl.h" -#include "dex_instruction-inl.h" -#include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/object_array-inl.h" -#include "mirror/object-inl.h" -#include "object_utils.h" -#include "scoped_thread_state_change.h" - -// Architecture specific assembler helper to deliver exception. -extern "C" void art_quick_deliver_exception_from_code(void*); - -namespace art { - -// Lazily resolve a method for quick. Called by stub code. -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, - mirror::Object* receiver, - mirror::AbstractMethod** sp, Thread* thread) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { -#if defined(__arm__) - // On entry the stack pointed by sp is: - // | argN | | - // | ... | | - // | arg4 | | - // | arg3 spill | | Caller's frame - // | arg2 spill | | - // | arg1 spill | | - // | Method* | --- - // | LR | - // | ... | callee saves - // | R3 | arg3 - // | R2 | arg2 - // | R1 | arg1 - // | R0 | - // | Method* | <- sp - DCHECK_EQ(48U, Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); - mirror::AbstractMethod** caller_sp = reinterpret_cast(reinterpret_cast(sp) + 48); - uintptr_t* regs = reinterpret_cast(reinterpret_cast(sp) + kPointerSize); - uint32_t pc_offset = 10; - uintptr_t caller_pc = regs[pc_offset]; -#elif defined(__i386__) - // On entry the stack pointed by sp is: - // | argN | | - // | ... | | - // | arg4 | | - // | arg3 spill | | Caller's frame - // | arg2 spill | | - // | arg1 spill | | - // | Method* | --- - // | Return | - // | EBP,ESI,EDI | callee saves - // | EBX | arg3 - // | EDX | arg2 - // | ECX | arg1 - // | EAX/Method* | <- sp - DCHECK_EQ(32U, Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); - mirror::AbstractMethod** caller_sp = reinterpret_cast(reinterpret_cast(sp) + 32); - uintptr_t* regs = reinterpret_cast(reinterpret_cast(sp)); - uintptr_t caller_pc = regs[7]; -#elif defined(__mips__) - // On entry the stack pointed by sp is: - // | argN | | - // | ... | | - // | arg4 | | - // | arg3 spill | | Caller's frame - // | arg2 spill | | - // | arg1 spill | | - // | Method* | --- - // | RA | - // | ... | callee saves - // | A3 | arg3 - // | A2 | arg2 - // | A1 | arg1 - // | A0/Method* | <- sp - DCHECK_EQ(64U, Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); - mirror::AbstractMethod** caller_sp = reinterpret_cast(reinterpret_cast(sp) + 64); - uintptr_t* regs = reinterpret_cast(reinterpret_cast(sp)); - uint32_t pc_offset = 15; - uintptr_t caller_pc = regs[pc_offset]; -#else - UNIMPLEMENTED(FATAL); - mirror::AbstractMethod** caller_sp = NULL; - uintptr_t* regs = NULL; - uintptr_t caller_pc = 0; -#endif - FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsAndArgs); - // Start new JNI local reference state - JNIEnvExt* env = thread->GetJniEnv(); - ScopedObjectAccessUnchecked soa(env); - ScopedJniEnvLocalRefState env_state(env); - - // Compute details about the called method (avoid GCs) - ClassLinker* linker = Runtime::Current()->GetClassLinker(); - mirror::AbstractMethod* caller = *caller_sp; - InvokeType invoke_type; - uint32_t dex_method_idx; -#if !defined(__i386__) - const char* shorty; - uint32_t shorty_len; -#endif - if (called->IsRuntimeMethod()) { - uint32_t dex_pc = caller->ToDexPc(caller_pc); - const DexFile::CodeItem* code = MethodHelper(caller).GetCodeItem(); - CHECK_LT(dex_pc, code->insns_size_in_code_units_); - const Instruction* instr = Instruction::At(&code->insns_[dex_pc]); - Instruction::Code instr_code = instr->Opcode(); - bool is_range; - switch (instr_code) { - case Instruction::INVOKE_DIRECT: - invoke_type = kDirect; - is_range = false; - break; - case Instruction::INVOKE_DIRECT_RANGE: - invoke_type = kDirect; - is_range = true; - break; - case Instruction::INVOKE_STATIC: - invoke_type = kStatic; - is_range = false; - break; - case Instruction::INVOKE_STATIC_RANGE: - invoke_type = kStatic; - is_range = true; - break; - case Instruction::INVOKE_SUPER: - invoke_type = kSuper; - is_range = false; - break; - case Instruction::INVOKE_SUPER_RANGE: - invoke_type = kSuper; - is_range = true; - break; - case Instruction::INVOKE_VIRTUAL: - invoke_type = kVirtual; - is_range = false; - break; - case Instruction::INVOKE_VIRTUAL_RANGE: - invoke_type = kVirtual; - is_range = true; - break; - case Instruction::INVOKE_INTERFACE: - invoke_type = kInterface; - is_range = false; - break; - case Instruction::INVOKE_INTERFACE_RANGE: - invoke_type = kInterface; - is_range = true; - break; - default: - LOG(FATAL) << "Unexpected call into trampoline: " << instr->DumpString(NULL); - // Avoid used uninitialized warnings. - invoke_type = kDirect; - is_range = false; - } - dex_method_idx = (is_range) ? instr->VRegB_3rc() : instr->VRegB_35c(); -#if !defined(__i386__) - shorty = linker->MethodShorty(dex_method_idx, caller, &shorty_len); -#endif - } else { - invoke_type = kStatic; - dex_method_idx = called->GetDexMethodIndex(); -#if !defined(__i386__) - MethodHelper mh(called); - shorty = mh.GetShorty(); - shorty_len = mh.GetShortyLength(); -#endif - } -#if !defined(__i386__) - // Discover shorty (avoid GCs) - size_t args_in_regs = 0; - for (size_t i = 1; i < shorty_len; i++) { - char c = shorty[i]; - args_in_regs = args_in_regs + (c == 'J' || c == 'D' ? 2 : 1); - if (args_in_regs > 3) { - args_in_regs = 3; - break; - } - } - // Place into local references incoming arguments from the caller's register arguments - size_t cur_arg = 1; // skip method_idx in R0, first arg is in R1 - if (invoke_type != kStatic) { - mirror::Object* obj = reinterpret_cast(regs[cur_arg]); - cur_arg++; - if (args_in_regs < 3) { - // If we thought we had fewer than 3 arguments in registers, account for the receiver - args_in_regs++; - } - soa.AddLocalReference(obj); - } - size_t shorty_index = 1; // skip return value - // Iterate while arguments and arguments in registers (less 1 from cur_arg which is offset to skip - // R0) - while ((cur_arg - 1) < args_in_regs && shorty_index < shorty_len) { - char c = shorty[shorty_index]; - shorty_index++; - if (c == 'L') { - mirror::Object* obj = reinterpret_cast(regs[cur_arg]); - soa.AddLocalReference(obj); - } - cur_arg = cur_arg + (c == 'J' || c == 'D' ? 2 : 1); - } - // Place into local references incoming arguments from the caller's stack arguments - cur_arg += pc_offset + 1; // skip LR/RA, Method* and spills for R1-R3/A1-A3 and callee saves - while (shorty_index < shorty_len) { - char c = shorty[shorty_index]; - shorty_index++; - if (c == 'L') { - mirror::Object* obj = reinterpret_cast(regs[cur_arg]); - soa.AddLocalReference(obj); - } - cur_arg = cur_arg + (c == 'J' || c == 'D' ? 2 : 1); - } -#endif - // Resolve method filling in dex cache - if (called->IsRuntimeMethod()) { - called = linker->ResolveMethod(dex_method_idx, caller, invoke_type); - } - const void* code = NULL; - if (LIKELY(!thread->IsExceptionPending())) { - // Incompatible class change should have been handled in resolve method. - CHECK(!called->CheckIncompatibleClassChange(invoke_type)); - // Refine called method based on receiver. - if (invoke_type == kVirtual) { - called = receiver->GetClass()->FindVirtualMethodForVirtual(called); - } else if (invoke_type == kInterface) { - called = receiver->GetClass()->FindVirtualMethodForInterface(called); - } - // Ensure that the called method's class is initialized. - mirror::Class* called_class = called->GetDeclaringClass(); - linker->EnsureInitialized(called_class, true, true); - if (LIKELY(called_class->IsInitialized())) { - code = called->GetEntryPointFromCompiledCode(); - } else if (called_class->IsInitializing()) { - if (invoke_type == kStatic) { - // Class is still initializing, go to oat and grab code (trampoline must be left in place - // until class is initialized to stop races between threads). - code = linker->GetOatCodeFor(called); - } else { - // No trampoline for non-static methods. - code = called->GetEntryPointFromCompiledCode(); - } - } else { - DCHECK(called_class->IsErroneous()); - } - } - if (UNLIKELY(code == NULL)) { - // Something went wrong in ResolveMethod or EnsureInitialized, - // go into deliver exception with the pending exception in r0 - CHECK(thread->IsExceptionPending()); - code = reinterpret_cast(art_quick_deliver_exception_from_code); - regs[0] = reinterpret_cast(thread->GetException(NULL)); - thread->ClearException(); - } else { - // Expect class to at least be initializing. - DCHECK(called->GetDeclaringClass()->IsInitializing()); - // Don't want infinite recursion. - DCHECK(code != GetResolutionTrampoline(linker)); - // Set up entry into main method - regs[0] = reinterpret_cast(called); - } - return code; -} - -// Called by the abstract method error stub. -extern "C" void artThrowAbstractMethodErrorFromCode(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { -#if !defined(ART_USE_PORTABLE_COMPILER) - FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); -#else - UNUSED(sp); -#endif - ThrowAbstractMethodError(method); - self->QuickDeliverException(); -} - -} // namespace art diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc new file mode 100644 index 0000000000..9bf02e8c8e --- /dev/null +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -0,0 +1,558 @@ +/* + * 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 "callee_save_frame.h" +#include "dex_file-inl.h" +#include "dex_instruction-inl.h" +#include "interpreter/interpreter.h" +#include "invoke_arg_array_builder.h" +#include "mirror/abstract_method-inl.h" +#include "mirror/class-inl.h" +#include "mirror/object-inl.h" +#include "mirror/object_array-inl.h" +#include "object_utils.h" +#include "runtime.h" + +namespace art { + +// Visits the arguments as saved to the stack by a Runtime::kRefAndArgs callee save frame. +class QuickArgumentVisitor { + public: +// Offset to first (not the Method*) argument in a Runtime::kRefAndArgs callee save frame. +// Size of Runtime::kRefAndArgs callee save frame. +// Size of Method* and register parameters in out stack arguments. +#if defined(__arm__) + // The callee save frame is pointed to by SP. + // | argN | | + // | ... | | + // | arg4 | | + // | arg3 spill | | Caller's frame + // | arg2 spill | | + // | arg1 spill | | + // | Method* | --- + // | LR | + // | ... | callee saves + // | R3 | arg3 + // | R2 | arg2 + // | R1 | arg1 + // | R0 | + // | Method* | <- sp +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 8 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET 44 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 48 +#define QUICK_STACK_ARG_SKIP 16 +#elif defined(__mips__) + // The callee save frame is pointed to by SP. + // | argN | | + // | ... | | + // | arg4 | | + // | arg3 spill | | Caller's frame + // | arg2 spill | | + // | arg1 spill | | + // | Method* | --- + // | RA | + // | ... | callee saves + // | A3 | arg3 + // | A2 | arg2 + // | A1 | arg1 + // | A0/Method* | <- sp +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 4 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET 60 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 64 +#define QUICK_STACK_ARG_SKIP 16 +#elif defined(__i386__) + // The callee save frame is pointed to by SP. + // | argN | | + // | ... | | + // | arg4 | | + // | arg3 spill | | Caller's frame + // | arg2 spill | | + // | arg1 spill | | + // | Method* | --- + // | Return | + // | EBP,ESI,EDI | callee saves + // | EBX | arg3 + // | EDX | arg2 + // | ECX | arg1 + // | EAX/Method* | <- sp +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 4 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET 28 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 32 +#define QUICK_STACK_ARG_SKIP 16 +#else +#error "Unsupported architecture" +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET 0 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET 0 +#define QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE 0 +#define QUICK_STACK_ARG_SKIP 0 +#endif + + static mirror::AbstractMethod* GetCallingMethod(mirror::AbstractMethod** sp) { + byte* previous_sp = reinterpret_cast(sp) + + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE; + return *reinterpret_cast(previous_sp); + } + + static uintptr_t GetCallingPc(mirror::AbstractMethod** sp) { + byte* lr = reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET; + return *reinterpret_cast(lr); + } + + QuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, + const char* shorty, uint32_t shorty_len) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : + is_static_(is_static), shorty_(shorty), shorty_len_(shorty_len), + args_in_regs_(ComputeArgsInRegs(is_static, shorty, shorty_len)), + num_params_((is_static ? 0 : 1) + shorty_len - 1), // +1 for this, -1 for return type + reg_args_(reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__R1_OFFSET), + stack_args_(reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE + + QUICK_STACK_ARG_SKIP), + cur_args_(reg_args_), + cur_arg_index_(0), + param_index_(0), + is_split_long_or_double_(false) { + DCHECK_EQ(static_cast(QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE), + Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); + } + + virtual ~QuickArgumentVisitor() {} + + virtual void Visit() = 0; + + Primitive::Type GetParamPrimitiveType() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + size_t index = param_index_; + if (is_static_) { + index++; // 0th argument must skip return value at start of the shorty + } else if (index == 0) { + return Primitive::kPrimNot; + } + CHECK_LT(index, shorty_len_); + return Primitive::GetType(shorty_[index]); + } + + byte* GetParamAddress() const { + return cur_args_ + (cur_arg_index_ * kPointerSize); + } + + bool IsSplitLongOrDouble() const { + return is_split_long_or_double_; + } + + bool IsParamAReference() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return GetParamPrimitiveType() == Primitive::kPrimNot; + } + + bool IsParamALongOrDouble() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + Primitive::Type type = GetParamPrimitiveType(); + return type == Primitive::kPrimLong || type == Primitive::kPrimDouble; + } + + uint64_t ReadSplitLongParam() const { + DCHECK(IsSplitLongOrDouble()); + uint64_t low_half = *reinterpret_cast(GetParamAddress()); + uint64_t high_half = *reinterpret_cast(stack_args_); + return (low_half & 0xffffffffULL) | (high_half << 32); + } + + void VisitArguments() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + for (cur_arg_index_ = 0; cur_arg_index_ < args_in_regs_ && param_index_ < num_params_; ) { + is_split_long_or_double_ = (cur_arg_index_ == 2) && IsParamALongOrDouble(); + Visit(); + cur_arg_index_ += (IsParamALongOrDouble() ? 2 : 1); + param_index_++; + } + cur_args_ = stack_args_; + cur_arg_index_ = is_split_long_or_double_ ? 1 : 0; + is_split_long_or_double_ = false; + while (param_index_ < num_params_) { + Visit(); + cur_arg_index_ += (IsParamALongOrDouble() ? 2 : 1); + param_index_++; + } + } + + private: + static size_t ComputeArgsInRegs(bool is_static, const char* shorty, uint32_t shorty_len) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + size_t args_in_regs = (is_static ? 0 : 1); + for (size_t i = 0; i < shorty_len; i++) { + char s = shorty[i]; + if (s == 'J' || s == 'D') { + args_in_regs += 2; + } else { + args_in_regs++; + } + if (args_in_regs > 3) { + args_in_regs = 3; + break; + } + } + return args_in_regs; + } + + const bool is_static_; + const char* const shorty_; + const uint32_t shorty_len_; + const size_t args_in_regs_; + const size_t num_params_; + byte* const reg_args_; + byte* const stack_args_; + byte* cur_args_; + size_t cur_arg_index_; + size_t param_index_; + // Does a 64bit parameter straddle the register and stack arguments? + bool is_split_long_or_double_; +}; + +// Visits arguments on the stack placing them into the shadow frame. +class BuildShadowFrameVisitor : public QuickArgumentVisitor { + public: + BuildShadowFrameVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) : + QuickArgumentVisitor(sp, is_static, shorty, shorty_len), sf_(sf), cur_reg_(first_arg_reg) {} + + virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + Primitive::Type type = GetParamPrimitiveType(); + switch (type) { + case Primitive::kPrimLong: // Fall-through. + case Primitive::kPrimDouble: + if (IsSplitLongOrDouble()) { + sf_.SetVRegLong(cur_reg_, ReadSplitLongParam()); + } else { + sf_.SetVRegLong(cur_reg_, *reinterpret_cast(GetParamAddress())); + } + ++cur_reg_; + break; + case Primitive::kPrimNot: + sf_.SetVRegReference(cur_reg_, *reinterpret_cast(GetParamAddress())); + break; + case Primitive::kPrimBoolean: // Fall-through. + case Primitive::kPrimByte: // Fall-through. + case Primitive::kPrimChar: // Fall-through. + case Primitive::kPrimShort: // Fall-through. + case Primitive::kPrimInt: // Fall-through. + case Primitive::kPrimFloat: + sf_.SetVReg(cur_reg_, *reinterpret_cast(GetParamAddress())); + break; + case Primitive::kPrimVoid: + LOG(FATAL) << "UNREACHABLE"; + break; + } + ++cur_reg_; + } + + private: + ShadowFrame& sf_; + size_t cur_reg_; + + DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor); +}; + +extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, + mirror::AbstractMethod** sp) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + // Ensure we don't get thread suspension until the object arguments are safely in the shadow + // frame. + FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); + + if (method->IsAbstract()) { + ThrowAbstractMethodError(method); + return 0; + } else { + const char* old_cause = self->StartAssertNoThreadSuspension("Building interpreter shadow frame"); + MethodHelper mh(method); + const DexFile::CodeItem* code_item = mh.GetCodeItem(); + uint16_t num_regs = code_item->registers_size_; + void* memory = alloca(ShadowFrame::ComputeSize(num_regs)); + ShadowFrame* shadow_frame(ShadowFrame::Create(num_regs, NULL, // No last shadow coming from quick. + method, 0, memory)); + size_t first_arg_reg = code_item->registers_size_ - code_item->ins_size_; + BuildShadowFrameVisitor shadow_frame_builder(sp, mh.IsStatic(), mh.GetShorty(), + mh.GetShortyLength(), + *shadow_frame, first_arg_reg); + shadow_frame_builder.VisitArguments(); + // Push a transition back into managed code onto the linked list in thread. + ManagedStack fragment; + self->PushManagedStackFragment(&fragment); + self->PushShadowFrame(shadow_frame); + self->EndAssertNoThreadSuspension(old_cause); + + if (method->IsStatic() && !method->GetDeclaringClass()->IsInitializing()) { + // Ensure static method's class is initialized. + if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), + true, true)) { + DCHECK(Thread::Current()->IsExceptionPending()); + self->PopManagedStackFragment(fragment); + return 0; + } + } + + JValue result = interpreter::EnterInterpreterFromStub(self, mh, code_item, *shadow_frame); + // Pop transition. + self->PopManagedStackFragment(fragment); + return result.GetJ(); + } +} + +// Visits arguments on the stack placing them into the args vector, Object* arguments are converted +// to jobjects. +class BuildQuickArgumentVisitor : public QuickArgumentVisitor { + public: + BuildQuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + uint32_t shorty_len, ScopedObjectAccessUnchecked* soa, + std::vector* args) : + QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa), args_(args) {} + + virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + jvalue val; + Primitive::Type type = GetParamPrimitiveType(); + switch (type) { + case Primitive::kPrimNot: { + mirror::Object* obj = *reinterpret_cast(GetParamAddress()); + val.l = soa_->AddLocalReference(obj); + break; + } + case Primitive::kPrimLong: // Fall-through. + case Primitive::kPrimDouble: + if (IsSplitLongOrDouble()) { + val.j = ReadSplitLongParam(); + } else { + val.j = *reinterpret_cast(GetParamAddress()); + } + break; + case Primitive::kPrimBoolean: // Fall-through. + case Primitive::kPrimByte: // Fall-through. + case Primitive::kPrimChar: // Fall-through. + case Primitive::kPrimShort: // Fall-through. + case Primitive::kPrimInt: // Fall-through. + case Primitive::kPrimFloat: + val.i = *reinterpret_cast(GetParamAddress()); + break; + case Primitive::kPrimVoid: + LOG(FATAL) << "UNREACHABLE"; + val.j = 0; + break; + } + args_->push_back(val); + } + + private: + ScopedObjectAccessUnchecked* soa_; + std::vector* args_; + + DISALLOW_COPY_AND_ASSIGN(BuildQuickArgumentVisitor); +}; + +// Handler for invocation on proxy methods. On entry a frame will exist for the proxy object method +// which is responsible for recording callee save registers. We explicitly place into jobjects the +// incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a +// field within the proxy object, which will box the primitive arguments and deal with error cases. +extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_method, + mirror::Object* receiver, + Thread* self, mirror::AbstractMethod** sp) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + // Ensure we don't get thread suspension until the object arguments are safely in jobjects. + const char* old_cause = + self->StartAssertNoThreadSuspension("Adding to IRT proxy object arguments"); + // Register the top of the managed stack, making stack crawlable. + DCHECK_EQ(*sp, proxy_method); + self->SetTopOfStack(sp, 0); + DCHECK_EQ(proxy_method->GetFrameSizeInBytes(), + Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs)->GetFrameSizeInBytes()); + self->VerifyStack(); + // Start new JNI local reference state. + JNIEnvExt* env = self->GetJniEnv(); + ScopedObjectAccessUnchecked soa(env); + ScopedJniEnvLocalRefState env_state(env); + // Create local ref. copies of proxy method and the receiver. + jobject rcvr_jobj = soa.AddLocalReference(receiver); + + // Placing arguments into args vector and remove the receiver. + MethodHelper proxy_mh(proxy_method); + std::vector args; + BuildQuickArgumentVisitor local_ref_visitor(sp, proxy_mh.IsStatic(), proxy_mh.GetShorty(), + proxy_mh.GetShortyLength(), &soa, &args); + local_ref_visitor.VisitArguments(); + args.erase(args.begin()); + + // Convert proxy method into expected interface method. + mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + DCHECK(interface_method != NULL); + DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); + jobject interface_method_jobj = soa.AddLocalReference(interface_method); + + // All naked Object*s should now be in jobjects, so its safe to go into the main invoke code + // that performs allocations. + self->EndAssertNoThreadSuspension(old_cause); + JValue result = InvokeProxyInvocationHandler(soa, proxy_mh.GetShorty(), + rcvr_jobj, interface_method_jobj, args); + return result.GetJ(); +} + +// Read object references held in arguments from quick frames and place in a JNI local references, +// so they don't get garbage collected. +class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { + public: + RememberFoGcArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) : + QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {} + + virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + if (IsParamAReference()) { + soa_->AddLocalReference(*reinterpret_cast(GetParamAddress())); + } + } + + private: + ScopedObjectAccessUnchecked* soa_; + + DISALLOW_COPY_AND_ASSIGN(RememberFoGcArgumentVisitor); +}; + +// Lazily resolve a method for quick. Called by stub code. +extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, + mirror::Object* receiver, + Thread* thread, mirror::AbstractMethod** sp) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsAndArgs); + // Start new JNI local reference state + JNIEnvExt* env = thread->GetJniEnv(); + ScopedObjectAccessUnchecked soa(env); + ScopedJniEnvLocalRefState env_state(env); + const char* old_cause = thread->StartAssertNoThreadSuspension("Quick method resolution set up"); + + // Compute details about the called method (avoid GCs) + ClassLinker* linker = Runtime::Current()->GetClassLinker(); + mirror::AbstractMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); + InvokeType invoke_type; + const DexFile* dex_file; + uint32_t dex_method_idx; + if (called->IsRuntimeMethod()) { + uint32_t dex_pc = caller->ToDexPc(QuickArgumentVisitor::GetCallingPc(sp)); + const DexFile::CodeItem* code; + { + MethodHelper mh(caller); + dex_file = &mh.GetDexFile(); + code = mh.GetCodeItem(); + } + CHECK_LT(dex_pc, code->insns_size_in_code_units_); + const Instruction* instr = Instruction::At(&code->insns_[dex_pc]); + Instruction::Code instr_code = instr->Opcode(); + bool is_range; + switch (instr_code) { + case Instruction::INVOKE_DIRECT: + invoke_type = kDirect; + is_range = false; + break; + case Instruction::INVOKE_DIRECT_RANGE: + invoke_type = kDirect; + is_range = true; + break; + case Instruction::INVOKE_STATIC: + invoke_type = kStatic; + is_range = false; + break; + case Instruction::INVOKE_STATIC_RANGE: + invoke_type = kStatic; + is_range = true; + break; + case Instruction::INVOKE_SUPER: + invoke_type = kSuper; + is_range = false; + break; + case Instruction::INVOKE_SUPER_RANGE: + invoke_type = kSuper; + is_range = true; + break; + case Instruction::INVOKE_VIRTUAL: + invoke_type = kVirtual; + is_range = false; + break; + case Instruction::INVOKE_VIRTUAL_RANGE: + invoke_type = kVirtual; + is_range = true; + break; + case Instruction::INVOKE_INTERFACE: + invoke_type = kInterface; + is_range = false; + break; + case Instruction::INVOKE_INTERFACE_RANGE: + invoke_type = kInterface; + is_range = true; + break; + default: + LOG(FATAL) << "Unexpected call into trampoline: " << instr->DumpString(NULL); + // Avoid used uninitialized warnings. + invoke_type = kDirect; + is_range = false; + } + dex_method_idx = (is_range) ? instr->VRegB_3rc() : instr->VRegB_35c(); + + } else { + invoke_type = kStatic; + dex_file = &MethodHelper(called).GetDexFile(); + dex_method_idx = called->GetDexMethodIndex(); + } + uint32_t shorty_len; + const char* shorty = + dex_file->GetMethodShorty(dex_file->GetMethodId(dex_method_idx), &shorty_len); + RememberFoGcArgumentVisitor visitor(sp, invoke_type == kStatic, shorty, shorty_len, &soa); + visitor.VisitArguments(); + thread->EndAssertNoThreadSuspension(old_cause); + // Resolve method filling in dex cache. + if (called->IsRuntimeMethod()) { + called = linker->ResolveMethod(dex_method_idx, caller, invoke_type); + } + const void* code = NULL; + if (LIKELY(!thread->IsExceptionPending())) { + // Incompatible class change should have been handled in resolve method. + CHECK(!called->CheckIncompatibleClassChange(invoke_type)); + // Refine called method based on receiver. + if (invoke_type == kVirtual) { + called = receiver->GetClass()->FindVirtualMethodForVirtual(called); + } else if (invoke_type == kInterface) { + called = receiver->GetClass()->FindVirtualMethodForInterface(called); + } + // Ensure that the called method's class is initialized. + mirror::Class* called_class = called->GetDeclaringClass(); + linker->EnsureInitialized(called_class, true, true); + if (LIKELY(called_class->IsInitialized())) { + code = called->GetEntryPointFromCompiledCode(); + } else if (called_class->IsInitializing()) { + if (invoke_type == kStatic) { + // Class is still initializing, go to oat and grab code (trampoline must be left in place + // until class is initialized to stop races between threads). + code = linker->GetOatCodeFor(called); + } else { + // No trampoline for non-static methods. + code = called->GetEntryPointFromCompiledCode(); + } + } else { + DCHECK(called_class->IsErroneous()); + } + } + CHECK_EQ(code == NULL, thread->IsExceptionPending()); +#ifdef MOVING_GARBAGE_COLLECTOR + // TODO: locally saved objects may have moved during a GC during resolution. Need to update the + // registers so that the stale objects aren't passed to the method we've resolved. + UNIMPLEMENTED(WARNING); +#endif + // Place called method in callee-save frame to be placed as first argument to quick method. + *sp = called; + return code; +} + +} // namespace art diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index c0b85f41fd..c3b66b3f79 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -60,7 +60,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { const void* new_code; if (uninstall) { if (forced_interpret_only_ && !method->IsNative() && !method->IsProxyMethod()) { - new_code = GetInterpreterEntryPoint(); + new_code = GetCompiledCodeToInterpreterBridge(); } else if (is_initialized || !method->IsStatic() || method->IsConstructor()) { new_code = class_linker->GetOatCodeFor(method); } else { @@ -68,9 +68,9 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } } else { // !uninstall if (!interpreter_stubs_installed_ || method->IsNative()) { - new_code = GetInstrumentationEntryPoint(); + new_code = GetQuickInstrumentationEntryPoint(); } else { - new_code = GetInterpreterEntryPoint(); + new_code = GetCompiledCodeToInterpreterBridge(); } } method->SetEntryPointFromCompiledCode(new_code); @@ -82,15 +82,15 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { const void* new_code; if (uninstall) { if (forced_interpret_only_ && !method->IsNative() && !method->IsProxyMethod()) { - new_code = GetInterpreterEntryPoint(); + new_code = GetCompiledCodeToInterpreterBridge(); } else { new_code = class_linker->GetOatCodeFor(method); } } else { // !uninstall if (!interpreter_stubs_installed_ || method->IsNative()) { - new_code = GetInstrumentationEntryPoint(); + new_code = GetQuickInstrumentationEntryPoint(); } else { - new_code = GetInterpreterEntryPoint(); + new_code = GetCompiledCodeToInterpreterBridge(); } } method->SetEntryPointFromCompiledCode(new_code); @@ -159,7 +159,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) LOG(INFO) << "Installing exit stubs in " << thread_name; } UniquePtr context(Context::Create()); - uintptr_t instrumentation_exit_pc = GetInstrumentationExitPc(); + uintptr_t instrumentation_exit_pc = GetQuickInstrumentationExitPc(); InstallStackVisitor visitor(thread, context.get(), instrumentation_exit_pc); visitor.WalkStack(true); @@ -251,7 +251,7 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) std::deque* stack = thread->GetInstrumentationStack(); if (stack->size() > 0) { Instrumentation* instrumentation = reinterpret_cast(arg); - uintptr_t instrumentation_exit_pc = GetInstrumentationExitPc(); + uintptr_t instrumentation_exit_pc = GetQuickInstrumentationExitPc(); RestoreStackVisitor visitor(thread, instrumentation_exit_pc, instrumentation); visitor.WalkStack(true); CHECK_EQ(visitor.frames_removed_, stack->size()); @@ -384,9 +384,9 @@ void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const vo method->SetEntryPointFromCompiledCode(code); } else { if (!interpreter_stubs_installed_ || method->IsNative()) { - method->SetEntryPointFromCompiledCode(GetInstrumentationEntryPoint()); + method->SetEntryPointFromCompiledCode(GetQuickInstrumentationEntryPoint()); } else { - method->SetEntryPointFromCompiledCode(GetInterpreterEntryPoint()); + method->SetEntryPointFromCompiledCode(GetCompiledCodeToInterpreterBridge()); } } } @@ -396,8 +396,8 @@ const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* metho if (LIKELY(!instrumentation_stubs_installed_)) { const void* code = method->GetEntryPointFromCompiledCode(); DCHECK(code != NULL); - if (LIKELY(code != GetResolutionTrampoline(runtime->GetClassLinker()) && - code != GetInterpreterEntryPoint())) { + if (LIKELY(code != GetQuickResolutionTrampoline(runtime->GetClassLinker()) && + code != GetQuickToInterpreterBridge())) { return code; } } @@ -548,7 +548,7 @@ uint64_t Instrumentation::PopInstrumentationStackFrame(Thread* self, uintptr_t* << " result is " << std::hex << return_value.GetJ(); } self->SetDeoptimizationReturnValue(return_value); - return static_cast(GetDeoptimizationEntryPoint()) | + return static_cast(GetQuickDeoptimizationEntryPoint()) | (static_cast(*return_pc) << 32); } else { if (kVerboseInstrumentation) { diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index ef4b95c037..6e35d937fb 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -148,7 +148,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, } } else { // Not special, continue with regular interpreter execution. - artInterpreterToInterpreterEntry(self, mh, code_item, shadow_frame, result); + artInterpreterToInterpreterBridge(self, mh, code_item, shadow_frame, result); } } @@ -3039,6 +3039,10 @@ static JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* c static inline JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register) { + DCHECK(shadow_frame.GetMethod() == mh.GetMethod() || + shadow_frame.GetMethod()->GetDeclaringClass()->IsProxyClass()); + DCHECK(!shadow_frame.GetMethod()->IsAbstract()); + DCHECK(!shadow_frame.GetMethod()->IsNative()); if (shadow_frame.GetMethod()->IsPreverified()) { // Enter the "without access check" interpreter. return ExecuteImpl(self, mh, code_item, shadow_frame, result_register); @@ -3150,8 +3154,7 @@ void EnterInterpreterFromDeoptimize(Thread* self, ShadowFrame* shadow_frame, JVa } JValue EnterInterpreterFromStub(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, - ShadowFrame& shadow_frame) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + ShadowFrame& shadow_frame) { DCHECK_EQ(self, Thread::Current()); if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) { ThrowStackOverflowError(self); @@ -3161,10 +3164,9 @@ JValue EnterInterpreterFromStub(Thread* self, MethodHelper& mh, const DexFile::C return Execute(self, mh, code_item, shadow_frame, JValue()); } -void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { +extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result) { if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) { ThrowStackOverflowError(self); return; diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index 17884b9a63..af4a1472ee 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -47,9 +47,9 @@ extern JValue EnterInterpreterFromStub(Thread* self, MethodHelper& mh, ShadowFrame& shadow_frame) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, - ShadowFrame* shadow_frame, JValue* result) +extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, + ShadowFrame* shadow_frame, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); } // namespace interpreter diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index ad66ada329..fcac4811c6 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -144,6 +144,10 @@ struct JNIEnvExt : public JNIEnv { return Offset(OFFSETOF_MEMBER(JNIEnvExt, local_ref_cookie)); } + static Offset SelfOffset() { + return Offset(OFFSETOF_MEMBER(JNIEnvExt, self)); + } + Thread* const self; JavaVMExt* vm; diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/abstract_method-inl.h index d235e3eed8..8fde99be3b 100644 --- a/runtime/mirror/abstract_method-inl.h +++ b/runtime/mirror/abstract_method-inl.h @@ -114,11 +114,11 @@ inline void AbstractMethod::AssertPcIsWithinCode(uintptr_t pc) const { if (IsNative() || IsRuntimeMethod() || IsProxyMethod()) { return; } - if (pc == GetInstrumentationExitPc()) { + if (pc == GetQuickInstrumentationExitPc()) { return; } const void* code = GetEntryPointFromCompiledCode(); - if (code == GetInterpreterEntryPoint() || code == GetInstrumentationEntryPoint()) { + if (code == GetCompiledCodeToInterpreterBridge() || code == GetQuickInstrumentationEntryPoint()) { return; } ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/abstract_method.cc index 4d7f99e076..93065e7f4e 100644 --- a/runtime/mirror/abstract_method.cc +++ b/runtime/mirror/abstract_method.cc @@ -321,6 +321,7 @@ bool AbstractMethod::IsRegistered() const { return native_method != jni_stub; } +extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { DCHECK(Thread::Current() == self); CHECK(IsNative()) << PrettyMethod(this); @@ -332,10 +333,10 @@ void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct // the native method to runtime support and store the target somewhere runtime support will // find it. -#if defined(__arm__) && !defined(ART_USE_PORTABLE_COMPILER) - SetNativeMethod(native_method); -#else +#if defined(__i386__) UNIMPLEMENTED(FATAL); +#else + SetNativeMethod(reinterpret_cast(art_work_around_app_jni_bugs)); #endif SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), reinterpret_cast(native_method), false); diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc index b352d0845e..32ab4f9b8d 100644 --- a/runtime/native/dalvik_system_VMRuntime.cc +++ b/runtime/native/dalvik_system_VMRuntime.cc @@ -144,8 +144,6 @@ static void VMRuntime_setTargetSdkVersion(JNIEnv* env, jobject, jint targetSdkVe if (targetSdkVersion > 0 && targetSdkVersion <= 13 /* honeycomb-mr2 */) { Runtime* runtime = Runtime::Current(); JavaVMExt* vm = runtime->GetJavaVM(); - -#if !defined(ART_USE_PORTABLE_COMPILER) if (vm->check_jni) { LOG(WARNING) << "Turning off CheckJNI so we can turn on JNI app bug workarounds..."; Thread* self = static_cast(env)->self; @@ -158,11 +156,6 @@ static void VMRuntime_setTargetSdkVersion(JNIEnv* env, jobject, jint targetSdkVe << targetSdkVersion << "..."; vm->work_around_app_jni_bugs = true; -#else - UNUSED(env); - LOG(WARNING) << "LLVM does not work-around app jni bugs."; - vm->work_around_app_jni_bugs = false; -#endif } } diff --git a/runtime/oat.cc b/runtime/oat.cc index e606953ed5..c01f77c364 100644 --- a/runtime/oat.cc +++ b/runtime/oat.cc @@ -22,7 +22,7 @@ namespace art { const uint8_t OatHeader::kOatMagic[] = { 'o', 'a', 't', '\n' }; -const uint8_t OatHeader::kOatVersion[] = { '0', '0', '6', '\0' }; +const uint8_t OatHeader::kOatVersion[] = { '0', '0', '7', '\0' }; OatHeader::OatHeader() { memset(this, 0, sizeof(*this)); @@ -57,10 +57,13 @@ OatHeader::OatHeader(InstructionSet instruction_set, UpdateChecksum(image_file_location.data(), image_file_location_size_); executable_offset_ = 0; - interpreter_to_interpreter_entry_offset_ = 0; - interpreter_to_quick_entry_offset_ = 0; + interpreter_to_interpreter_bridge_offset_ = 0; + interpreter_to_compiled_code_bridge_offset_ = 0; + jni_dlsym_lookup_offset_ = 0; portable_resolution_trampoline_offset_ = 0; + portable_to_interpreter_bridge_offset_ = 0; quick_resolution_trampoline_offset_ = 0; + quick_to_interpreter_bridge_offset_ = 0; } bool OatHeader::IsValid() const { @@ -111,42 +114,61 @@ void OatHeader::SetExecutableOffset(uint32_t executable_offset) { UpdateChecksum(&executable_offset_, sizeof(executable_offset)); } -const void* OatHeader::GetInterpreterToInterpreterEntry() const { - return reinterpret_cast(this) + GetInterpreterToInterpreterEntryOffset(); +const void* OatHeader::GetInterpreterToInterpreterBridge() const { + return reinterpret_cast(this) + GetInterpreterToInterpreterBridgeOffset(); } -uint32_t OatHeader::GetInterpreterToInterpreterEntryOffset() const { +uint32_t OatHeader::GetInterpreterToInterpreterBridgeOffset() const { DCHECK(IsValid()); - CHECK_GE(interpreter_to_interpreter_entry_offset_, executable_offset_); - return interpreter_to_interpreter_entry_offset_; + CHECK_GE(interpreter_to_interpreter_bridge_offset_, executable_offset_); + return interpreter_to_interpreter_bridge_offset_; } -void OatHeader::SetInterpreterToInterpreterEntryOffset(uint32_t offset) { +void OatHeader::SetInterpreterToInterpreterBridgeOffset(uint32_t offset) { CHECK(offset == 0 || offset >= executable_offset_); DCHECK(IsValid()); - DCHECK_EQ(interpreter_to_interpreter_entry_offset_, 0U) << offset; + DCHECK_EQ(interpreter_to_interpreter_bridge_offset_, 0U) << offset; - interpreter_to_interpreter_entry_offset_ = offset; - UpdateChecksum(&interpreter_to_interpreter_entry_offset_, sizeof(offset)); + interpreter_to_interpreter_bridge_offset_ = offset; + UpdateChecksum(&interpreter_to_interpreter_bridge_offset_, sizeof(offset)); } -const void* OatHeader::GetInterpreterToQuickEntry() const { - return reinterpret_cast(this) + GetInterpreterToQuickEntryOffset(); +const void* OatHeader::GetInterpreterToCompiledCodeBridge() const { + return reinterpret_cast(this) + GetInterpreterToCompiledCodeBridgeOffset(); } -uint32_t OatHeader::GetInterpreterToQuickEntryOffset() const { +uint32_t OatHeader::GetInterpreterToCompiledCodeBridgeOffset() const { DCHECK(IsValid()); - CHECK_GE(interpreter_to_quick_entry_offset_, interpreter_to_interpreter_entry_offset_); - return interpreter_to_quick_entry_offset_; + CHECK_GE(interpreter_to_compiled_code_bridge_offset_, interpreter_to_interpreter_bridge_offset_); + return interpreter_to_compiled_code_bridge_offset_; } -void OatHeader::SetInterpreterToQuickEntryOffset(uint32_t offset) { - CHECK(offset == 0 || offset >= interpreter_to_interpreter_entry_offset_); +void OatHeader::SetInterpreterToCompiledCodeBridgeOffset(uint32_t offset) { + CHECK(offset == 0 || offset >= interpreter_to_interpreter_bridge_offset_); DCHECK(IsValid()); - DCHECK_EQ(interpreter_to_quick_entry_offset_, 0U) << offset; + DCHECK_EQ(interpreter_to_compiled_code_bridge_offset_, 0U) << offset; - interpreter_to_quick_entry_offset_ = offset; - UpdateChecksum(&interpreter_to_quick_entry_offset_, sizeof(offset)); + interpreter_to_compiled_code_bridge_offset_ = offset; + UpdateChecksum(&interpreter_to_compiled_code_bridge_offset_, sizeof(offset)); +} + +const void* OatHeader::GetJniDlsymLookup() const { + return reinterpret_cast(this) + GetJniDlsymLookupOffset(); +} + +uint32_t OatHeader::GetJniDlsymLookupOffset() const { + DCHECK(IsValid()); + CHECK_GE(jni_dlsym_lookup_offset_, interpreter_to_compiled_code_bridge_offset_); + return jni_dlsym_lookup_offset_; +} + +void OatHeader::SetJniDlsymLookupOffset(uint32_t offset) { + CHECK(offset == 0 || offset >= interpreter_to_compiled_code_bridge_offset_); + DCHECK(IsValid()); + DCHECK_EQ(jni_dlsym_lookup_offset_, 0U) << offset; + + jni_dlsym_lookup_offset_ = offset; + UpdateChecksum(&jni_dlsym_lookup_offset_, sizeof(offset)); } const void* OatHeader::GetPortableResolutionTrampoline() const { @@ -155,12 +177,12 @@ const void* OatHeader::GetPortableResolutionTrampoline() const { uint32_t OatHeader::GetPortableResolutionTrampolineOffset() const { DCHECK(IsValid()); - CHECK_GE(portable_resolution_trampoline_offset_, interpreter_to_quick_entry_offset_); + CHECK_GE(portable_resolution_trampoline_offset_, jni_dlsym_lookup_offset_); return portable_resolution_trampoline_offset_; } void OatHeader::SetPortableResolutionTrampolineOffset(uint32_t offset) { - CHECK(offset == 0 || offset >= interpreter_to_quick_entry_offset_); + CHECK(offset == 0 || offset >= jni_dlsym_lookup_offset_); DCHECK(IsValid()); DCHECK_EQ(portable_resolution_trampoline_offset_, 0U) << offset; @@ -168,18 +190,37 @@ void OatHeader::SetPortableResolutionTrampolineOffset(uint32_t offset) { UpdateChecksum(&portable_resolution_trampoline_offset_, sizeof(offset)); } +const void* OatHeader::GetPortableToInterpreterBridge() const { + return reinterpret_cast(this) + GetPortableToInterpreterBridgeOffset(); +} + +uint32_t OatHeader::GetPortableToInterpreterBridgeOffset() const { + DCHECK(IsValid()); + CHECK_GE(portable_to_interpreter_bridge_offset_, portable_resolution_trampoline_offset_); + return portable_to_interpreter_bridge_offset_; +} + +void OatHeader::SetPortableToInterpreterBridgeOffset(uint32_t offset) { + CHECK(offset == 0 || offset >= portable_resolution_trampoline_offset_); + DCHECK(IsValid()); + DCHECK_EQ(portable_to_interpreter_bridge_offset_, 0U) << offset; + + portable_to_interpreter_bridge_offset_ = offset; + UpdateChecksum(&portable_to_interpreter_bridge_offset_, sizeof(offset)); +} + const void* OatHeader::GetQuickResolutionTrampoline() const { return reinterpret_cast(this) + GetQuickResolutionTrampolineOffset(); } uint32_t OatHeader::GetQuickResolutionTrampolineOffset() const { DCHECK(IsValid()); - CHECK_GE(quick_resolution_trampoline_offset_, portable_resolution_trampoline_offset_); + CHECK_GE(quick_resolution_trampoline_offset_, portable_to_interpreter_bridge_offset_); return quick_resolution_trampoline_offset_; } void OatHeader::SetQuickResolutionTrampolineOffset(uint32_t offset) { - CHECK(offset == 0 || offset >= portable_resolution_trampoline_offset_); + CHECK(offset == 0 || offset >= portable_to_interpreter_bridge_offset_); DCHECK(IsValid()); DCHECK_EQ(quick_resolution_trampoline_offset_, 0U) << offset; @@ -187,6 +228,25 @@ void OatHeader::SetQuickResolutionTrampolineOffset(uint32_t offset) { UpdateChecksum(&quick_resolution_trampoline_offset_, sizeof(offset)); } +const void* OatHeader::GetQuickToInterpreterBridge() const { + return reinterpret_cast(this) + GetQuickToInterpreterBridgeOffset(); +} + +uint32_t OatHeader::GetQuickToInterpreterBridgeOffset() const { + DCHECK(IsValid()); + CHECK_GE(quick_to_interpreter_bridge_offset_, quick_resolution_trampoline_offset_); + return quick_to_interpreter_bridge_offset_; +} + +void OatHeader::SetQuickToInterpreterBridgeOffset(uint32_t offset) { + CHECK(offset == 0 || offset >= quick_resolution_trampoline_offset_); + DCHECK(IsValid()); + DCHECK_EQ(quick_to_interpreter_bridge_offset_, 0U) << offset; + + quick_to_interpreter_bridge_offset_ = offset; + UpdateChecksum(&quick_to_interpreter_bridge_offset_, sizeof(offset)); +} + uint32_t OatHeader::GetImageFileLocationOatChecksum() const { CHECK(IsValid()); return image_file_location_oat_checksum_; diff --git a/runtime/oat.h b/runtime/oat.h index 4bd1871a71..a5c6bed5fc 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -44,18 +44,32 @@ class PACKED(4) OatHeader { } uint32_t GetExecutableOffset() const; void SetExecutableOffset(uint32_t executable_offset); - const void* GetInterpreterToInterpreterEntry() const; - uint32_t GetInterpreterToInterpreterEntryOffset() const; - void SetInterpreterToInterpreterEntryOffset(uint32_t offset); - const void* GetInterpreterToQuickEntry() const; - uint32_t GetInterpreterToQuickEntryOffset() const; - void SetInterpreterToQuickEntryOffset(uint32_t offset); + + const void* GetInterpreterToInterpreterBridge() const; + uint32_t GetInterpreterToInterpreterBridgeOffset() const; + void SetInterpreterToInterpreterBridgeOffset(uint32_t offset); + const void* GetInterpreterToCompiledCodeBridge() const; + uint32_t GetInterpreterToCompiledCodeBridgeOffset() const; + void SetInterpreterToCompiledCodeBridgeOffset(uint32_t offset); + + const void* GetJniDlsymLookup() const; + uint32_t GetJniDlsymLookupOffset() const; + void SetJniDlsymLookupOffset(uint32_t offset); + const void* GetPortableResolutionTrampoline() const; uint32_t GetPortableResolutionTrampolineOffset() const; void SetPortableResolutionTrampolineOffset(uint32_t offset); + const void* GetPortableToInterpreterBridge() const; + uint32_t GetPortableToInterpreterBridgeOffset() const; + void SetPortableToInterpreterBridgeOffset(uint32_t offset); + const void* GetQuickResolutionTrampoline() const; uint32_t GetQuickResolutionTrampolineOffset() const; void SetQuickResolutionTrampolineOffset(uint32_t offset); + const void* GetQuickToInterpreterBridge() const; + uint32_t GetQuickToInterpreterBridgeOffset() const; + void SetQuickToInterpreterBridgeOffset(uint32_t offset); + InstructionSet GetInstructionSet() const; uint32_t GetImageFileLocationOatChecksum() const; uint32_t GetImageFileLocationOatDataBegin() const; @@ -74,10 +88,13 @@ class PACKED(4) OatHeader { InstructionSet instruction_set_; uint32_t dex_file_count_; uint32_t executable_offset_; - uint32_t interpreter_to_interpreter_entry_offset_; - uint32_t interpreter_to_quick_entry_offset_; + uint32_t interpreter_to_interpreter_bridge_offset_; + uint32_t interpreter_to_compiled_code_bridge_offset_; + uint32_t jni_dlsym_lookup_offset_; uint32_t portable_resolution_trampoline_offset_; + uint32_t portable_to_interpreter_bridge_offset_; uint32_t quick_resolution_trampoline_offset_; + uint32_t quick_to_interpreter_bridge_offset_; uint32_t image_file_location_oat_checksum_; uint32_t image_file_location_oat_data_begin_; diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 5d0dca9e4c..68595c896d 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -141,7 +141,7 @@ TEST_F(OatTest, WriteRead) { TEST_F(OatTest, OatHeaderSizeCheck) { // If this test is failing and you have to update these constants, // it is time to update OatHeader::kOatVersion - EXPECT_EQ(52U, sizeof(OatHeader)); + EXPECT_EQ(64U, sizeof(OatHeader)); EXPECT_EQ(28U, sizeof(OatMethodOffsets)); } diff --git a/runtime/object_utils.h b/runtime/object_utils.h index fa7763e11f..3639a80e77 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -411,6 +411,10 @@ class MethodHelper { shorty_ = NULL; } + const mirror::AbstractMethod* GetMethod() const { + return method_; + } + const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); uint32_t dex_method_idx = method_->GetDexMethodIndex(); diff --git a/runtime/stack.cc b/runtime/stack.cc index a74bcdbf0c..7f3f40ce5a 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -308,7 +308,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (UNLIKELY(exit_stubs_installed)) { // While profiling, the return pc is restored from the side stack, except when walking // the stack for an exception where the side stack will be unwound in VisitFrame. - if (GetInstrumentationExitPc() == return_pc) { + if (GetQuickInstrumentationExitPc() == return_pc) { instrumentation::InstrumentationStackFrame instrumentation_frame = GetInstrumentationStackFrame(instrumentation_stack_depth); instrumentation_stack_depth++; diff --git a/runtime/thread.cc b/runtime/thread.cc index 97a1410892..c79caa21f8 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -86,23 +86,25 @@ static void UnimplementedEntryPoint() { } #endif -void InitEntryPoints(QuickEntryPoints* qpoints, PortableEntryPoints* ppoints); +void InitEntryPoints(InterpreterEntryPoints* ipoints, JniEntryPoints* jpoints, + PortableEntryPoints* ppoints, QuickEntryPoints* qpoints); -void Thread::InitFunctionPointers() { +void Thread::InitTlsEntryPoints() { #if !defined(__APPLE__) // The Mac GCC is too old to accept this code. // Insert a placeholder so we can easily tell if we call an unimplemented entry point. - uintptr_t* begin = reinterpret_cast(&quick_entrypoints_); + uintptr_t* begin = reinterpret_cast(&interpreter_entrypoints_); uintptr_t* end = reinterpret_cast(reinterpret_cast(begin) + sizeof(quick_entrypoints_)); for (uintptr_t* it = begin; it != end; ++it) { *it = reinterpret_cast(UnimplementedEntryPoint); } - begin = reinterpret_cast(&portable_entrypoints_); + begin = reinterpret_cast(&interpreter_entrypoints_); end = reinterpret_cast(reinterpret_cast(begin) + sizeof(portable_entrypoints_)); for (uintptr_t* it = begin; it != end; ++it) { *it = reinterpret_cast(UnimplementedEntryPoint); } #endif - InitEntryPoints(&quick_entrypoints_, &portable_entrypoints_); + InitEntryPoints(&interpreter_entrypoints_, &jni_entrypoints_, &portable_entrypoints_, + &quick_entrypoints_); } void Thread::SetDeoptimizationShadowFrame(ShadowFrame* sf) { @@ -292,7 +294,7 @@ void Thread::Init(ThreadList* thread_list, JavaVMExt* java_vm) { CHECK(Thread::Current() == NULL); SetUpAlternateSignalStack(); InitCpu(); - InitFunctionPointers(); + InitTlsEntryPoints(); InitCardTable(); InitTid(); // Set pthread_self_ ahead of pthread_setspecific, that makes Thread::Current function, this @@ -1589,22 +1591,29 @@ struct EntryPointInfo { uint32_t offset; const char* name; }; -#define QUICK_ENTRY_POINT_INFO(x) { QUICK_ENTRYPOINT_OFFSET(x), #x } -#define PORTABLE_ENTRY_POINT_INFO(x) { PORTABLE_ENTRYPOINT_OFFSET(x), #x } +#define INTERPRETER_ENTRY_POINT_INFO(x) { INTERPRETER_ENTRYPOINT_OFFSET(x).Uint32Value(), #x } +#define JNI_ENTRY_POINT_INFO(x) { JNI_ENTRYPOINT_OFFSET(x).Uint32Value(), #x } +#define PORTABLE_ENTRY_POINT_INFO(x) { PORTABLE_ENTRYPOINT_OFFSET(x).Uint32Value(), #x } +#define QUICK_ENTRY_POINT_INFO(x) { QUICK_ENTRYPOINT_OFFSET(x).Uint32Value(), #x } static const EntryPointInfo gThreadEntryPointInfo[] = { - QUICK_ENTRY_POINT_INFO(pAllocArrayFromCode), - QUICK_ENTRY_POINT_INFO(pAllocArrayFromCodeWithAccessCheck), - QUICK_ENTRY_POINT_INFO(pAllocObjectFromCode), - QUICK_ENTRY_POINT_INFO(pAllocObjectFromCodeWithAccessCheck), - QUICK_ENTRY_POINT_INFO(pCheckAndAllocArrayFromCode), - QUICK_ENTRY_POINT_INFO(pCheckAndAllocArrayFromCodeWithAccessCheck), - QUICK_ENTRY_POINT_INFO(pInstanceofNonTrivialFromCode), - QUICK_ENTRY_POINT_INFO(pCanPutArrayElementFromCode), - QUICK_ENTRY_POINT_INFO(pCheckCastFromCode), + INTERPRETER_ENTRY_POINT_INFO(pInterpreterToInterpreterBridge), + INTERPRETER_ENTRY_POINT_INFO(pInterpreterToCompiledCodeBridge), + JNI_ENTRY_POINT_INFO(pDlsymLookup), + PORTABLE_ENTRY_POINT_INFO(pPortableResolutionTrampoline), + PORTABLE_ENTRY_POINT_INFO(pPortableToInterpreterBridge), + QUICK_ENTRY_POINT_INFO(pAllocArray), + QUICK_ENTRY_POINT_INFO(pAllocArrayWithAccessCheck), + QUICK_ENTRY_POINT_INFO(pAllocObject), + QUICK_ENTRY_POINT_INFO(pAllocObjectWithAccessCheck), + QUICK_ENTRY_POINT_INFO(pCheckAndAllocArray), + QUICK_ENTRY_POINT_INFO(pCheckAndAllocArrayWithAccessCheck), + QUICK_ENTRY_POINT_INFO(pInstanceofNonTrivial), + QUICK_ENTRY_POINT_INFO(pCanPutArrayElement), + QUICK_ENTRY_POINT_INFO(pCheckCast), QUICK_ENTRY_POINT_INFO(pInitializeStaticStorage), - QUICK_ENTRY_POINT_INFO(pInitializeTypeAndVerifyAccessFromCode), - QUICK_ENTRY_POINT_INFO(pInitializeTypeFromCode), - QUICK_ENTRY_POINT_INFO(pResolveStringFromCode), + QUICK_ENTRY_POINT_INFO(pInitializeTypeAndVerifyAccess), + QUICK_ENTRY_POINT_INFO(pInitializeType), + QUICK_ENTRY_POINT_INFO(pResolveString), QUICK_ENTRY_POINT_INFO(pSet32Instance), QUICK_ENTRY_POINT_INFO(pSet32Static), QUICK_ENTRY_POINT_INFO(pSet64Instance), @@ -1617,15 +1626,15 @@ static const EntryPointInfo gThreadEntryPointInfo[] = { QUICK_ENTRY_POINT_INFO(pGet64Static), QUICK_ENTRY_POINT_INFO(pGetObjInstance), QUICK_ENTRY_POINT_INFO(pGetObjStatic), - QUICK_ENTRY_POINT_INFO(pHandleFillArrayDataFromCode), + QUICK_ENTRY_POINT_INFO(pHandleFillArrayData), QUICK_ENTRY_POINT_INFO(pJniMethodStart), QUICK_ENTRY_POINT_INFO(pJniMethodStartSynchronized), QUICK_ENTRY_POINT_INFO(pJniMethodEnd), QUICK_ENTRY_POINT_INFO(pJniMethodEndSynchronized), QUICK_ENTRY_POINT_INFO(pJniMethodEndWithReference), QUICK_ENTRY_POINT_INFO(pJniMethodEndWithReferenceSynchronized), - QUICK_ENTRY_POINT_INFO(pLockObjectFromCode), - QUICK_ENTRY_POINT_INFO(pUnlockObjectFromCode), + QUICK_ENTRY_POINT_INFO(pLockObject), + QUICK_ENTRY_POINT_INFO(pUnlockObject), QUICK_ENTRY_POINT_INFO(pCmpgDouble), QUICK_ENTRY_POINT_INFO(pCmpgFloat), QUICK_ENTRY_POINT_INFO(pCmplDouble), @@ -1646,28 +1655,26 @@ static const EntryPointInfo gThreadEntryPointInfo[] = { QUICK_ENTRY_POINT_INFO(pShlLong), QUICK_ENTRY_POINT_INFO(pShrLong), QUICK_ENTRY_POINT_INFO(pUshrLong), - QUICK_ENTRY_POINT_INFO(pInterpreterToInterpreterEntry), - QUICK_ENTRY_POINT_INFO(pInterpreterToQuickEntry), QUICK_ENTRY_POINT_INFO(pIndexOf), QUICK_ENTRY_POINT_INFO(pMemcmp16), QUICK_ENTRY_POINT_INFO(pStringCompareTo), QUICK_ENTRY_POINT_INFO(pMemcpy), - QUICK_ENTRY_POINT_INFO(pQuickResolutionTrampolineFromCode), + QUICK_ENTRY_POINT_INFO(pQuickResolutionTrampoline), + QUICK_ENTRY_POINT_INFO(pQuickToInterpreterBridge), QUICK_ENTRY_POINT_INFO(pInvokeDirectTrampolineWithAccessCheck), QUICK_ENTRY_POINT_INFO(pInvokeInterfaceTrampoline), QUICK_ENTRY_POINT_INFO(pInvokeInterfaceTrampolineWithAccessCheck), QUICK_ENTRY_POINT_INFO(pInvokeStaticTrampolineWithAccessCheck), QUICK_ENTRY_POINT_INFO(pInvokeSuperTrampolineWithAccessCheck), QUICK_ENTRY_POINT_INFO(pInvokeVirtualTrampolineWithAccessCheck), - QUICK_ENTRY_POINT_INFO(pCheckSuspendFromCode), - QUICK_ENTRY_POINT_INFO(pTestSuspendFromCode), + QUICK_ENTRY_POINT_INFO(pCheckSuspend), + QUICK_ENTRY_POINT_INFO(pTestSuspend), QUICK_ENTRY_POINT_INFO(pDeliverException), - QUICK_ENTRY_POINT_INFO(pThrowArrayBoundsFromCode), - QUICK_ENTRY_POINT_INFO(pThrowDivZeroFromCode), - QUICK_ENTRY_POINT_INFO(pThrowNoSuchMethodFromCode), - QUICK_ENTRY_POINT_INFO(pThrowNullPointerFromCode), - QUICK_ENTRY_POINT_INFO(pThrowStackOverflowFromCode), - PORTABLE_ENTRY_POINT_INFO(pPortableResolutionTrampolineFromCode), + QUICK_ENTRY_POINT_INFO(pThrowArrayBounds), + QUICK_ENTRY_POINT_INFO(pThrowDivZero), + QUICK_ENTRY_POINT_INFO(pThrowNoSuchMethod), + QUICK_ENTRY_POINT_INFO(pThrowNullPointer), + QUICK_ENTRY_POINT_INFO(pThrowStackOverflow), }; #undef QUICK_ENTRY_POINT_INFO @@ -1695,8 +1702,9 @@ void Thread::DumpThreadOffset(std::ostream& os, uint32_t offset, size_t size_of_ size_t entry_point_count = arraysize(gThreadEntryPointInfo); CHECK_EQ(entry_point_count * size_of_pointers, - sizeof(QuickEntryPoints) + sizeof(PortableEntryPoints)); - uint32_t expected_offset = OFFSETOF_MEMBER(Thread, quick_entrypoints_); + sizeof(InterpreterEntryPoints) + sizeof(JniEntryPoints) + sizeof(PortableEntryPoints) + + sizeof(QuickEntryPoints)); + uint32_t expected_offset = OFFSETOF_MEMBER(Thread, interpreter_entrypoints_); for (size_t i = 0; i < entry_point_count; ++i) { CHECK_EQ(gThreadEntryPointInfo[i].offset, expected_offset) << gThreadEntryPointInfo[i].name; expected_offset += size_of_pointers; @@ -1739,7 +1747,7 @@ class CatchBlockStackVisitor : public StackVisitor { return false; // End stack walk. } else { if (UNLIKELY(method_tracing_active_ && - GetInstrumentationExitPc() == GetReturnPc())) { + GetQuickInstrumentationExitPc() == GetReturnPc())) { // Keep count of the number of unwinds during instrumentation. instrumentation_frames_to_pop_++; } diff --git a/runtime/thread.h b/runtime/thread.h index ff0fe228c0..8b6771e60c 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -26,6 +26,8 @@ #include #include "base/macros.h" +#include "entrypoints/interpreter/interpreter_entrypoints.h" +#include "entrypoints/jni/jni_entrypoints.h" #include "entrypoints/portable/portable_entrypoints.h" #include "entrypoints/quick/quick_entrypoints.h" #include "globals.h" @@ -43,17 +45,17 @@ namespace art { namespace mirror { -class AbstractMethod; -class Array; -class Class; -class ClassLoader; -class Object; -template class ObjectArray; -template class PrimitiveArray; -typedef PrimitiveArray IntArray; -class StackTraceElement; -class StaticStorageBase; -class Throwable; + class AbstractMethod; + class Array; + class Class; + class ClassLoader; + class Object; + template class ObjectArray; + template class PrimitiveArray; + typedef PrimitiveArray IntArray; + class StackTraceElement; + class StaticStorageBase; + class Throwable; } // namespace mirror class BaseMutex; class ClassLinker; @@ -614,7 +616,7 @@ class PACKED(4) Thread { void Init(ThreadList*, JavaVMExt*) EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_); void InitCardTable(); void InitCpu(); - void InitFunctionPointers(); + void InitTlsEntryPoints(); void InitTid(); void InitPthreadKeySelf(); void InitStackHwm(); @@ -776,8 +778,10 @@ class PACKED(4) Thread { public: // Entrypoint function pointers // TODO: move this near the top, since changing its offset requires all oats to be recompiled! - QuickEntryPoints quick_entrypoints_; + InterpreterEntryPoints interpreter_entrypoints_; + JniEntryPoints jni_entrypoints_; PortableEntryPoints portable_entrypoints_; + QuickEntryPoints quick_entrypoints_; private: // How many times has our pthread key's destructor been called? -- cgit v1.2.3-59-g8ed1b From ea46f950e7a51585db293cd7f047de190a482414 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Tue, 30 Jul 2013 01:26:50 -0700 Subject: Refactor java.lang.reflect implementation Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1. Move to ArtMethod/Field instead of AbstractMethod/Field and have java.lang.reflect APIs delegate to ArtMethod/ArtField. Bug: 10014286. Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7 --- compiler/dex/dex_to_dex_compiler.cc | 4 +- compiler/dex/quick/gen_common.cc | 26 +- compiler/dex/quick/gen_invoke.cc | 10 +- compiler/driver/compiler_driver.cc | 34 +- compiler/driver/compiler_driver.h | 6 +- compiler/driver/compiler_driver_test.cc | 6 +- compiler/elf_writer.cc | 2 +- compiler/elf_writer_mclinker.cc | 6 +- compiler/image_writer.cc | 46 +- compiler/image_writer.h | 2 +- compiler/jni/jni_compiler_test.cc | 4 +- compiler/jni/portable/jni_compiler.cc | 6 +- compiler/jni/portable/jni_compiler.h | 2 +- compiler/jni/quick/jni_compiler.cc | 4 +- compiler/llvm/compiler_llvm.h | 2 +- compiler/llvm/gbc_expander.cc | 20 +- compiler/oat_writer.cc | 4 +- dex2oat/dex2oat.cc | 4 +- oatdump/oatdump.cc | 46 +- runtime/Android.mk | 4 +- runtime/arch/arm/context_arm.cc | 4 +- runtime/arch/arm/entrypoints_init_arm.cc | 8 +- runtime/arch/mips/context_mips.cc | 4 +- runtime/arch/mips/entrypoints_init_mips.cc | 8 +- runtime/arch/x86/context_x86.cc | 4 +- runtime/arch/x86/entrypoints_init_x86.cc | 8 +- runtime/check_jni.cc | 38 +- runtime/class_linker-inl.h | 48 +-- runtime/class_linker.cc | 379 +++++++---------- runtime/class_linker.h | 103 +++-- runtime/class_linker_test.cc | 470 ++++++++++---------- runtime/common_test.h | 10 +- runtime/common_throws.cc | 51 +-- runtime/common_throws.h | 34 +- runtime/debugger.cc | 110 ++--- runtime/debugger.h | 10 +- runtime/dex_file.cc | 9 +- runtime/dex_file.h | 12 +- runtime/entrypoints/entrypoint_utils.cc | 46 +- runtime/entrypoints/entrypoint_utils.h | 52 +-- .../interpreter/interpreter_entrypoints.cc | 4 +- runtime/entrypoints/jni/jni_entrypoints.cc | 6 +- .../portable/portable_alloc_entrypoints.cc | 14 +- .../portable/portable_dexcache_entrypoints.cc | 10 +- .../entrypoints/portable/portable_entrypoints.h | 6 +- .../portable/portable_field_entrypoints.cc | 60 +-- .../portable/portable_fillarray_entrypoints.cc | 4 +- .../portable/portable_invoke_entrypoints.cc | 20 +- .../portable/portable_jni_entrypoints.cc | 2 +- .../portable/portable_thread_entrypoints.cc | 6 +- .../portable/portable_throw_entrypoints.cc | 4 +- .../portable/portable_trampoline_entrypoints.cc | 24 +- runtime/entrypoints/quick/callee_save_frame.h | 4 +- .../entrypoints/quick/quick_alloc_entrypoints.cc | 26 +- .../entrypoints/quick/quick_cast_entrypoints.cc | 4 +- .../quick/quick_deoptimization_entrypoints.cc | 4 +- .../quick/quick_dexcache_entrypoints.cc | 18 +- runtime/entrypoints/quick/quick_entrypoints.h | 10 +- .../entrypoints/quick/quick_field_entrypoints.cc | 112 ++--- .../quick/quick_fillarray_entrypoints.cc | 2 +- .../quick/quick_instrumentation_entrypoints.cc | 10 +- .../entrypoints/quick/quick_invoke_entrypoints.cc | 36 +- runtime/entrypoints/quick/quick_jni_entrypoints.cc | 2 +- .../entrypoints/quick/quick_lock_entrypoints.cc | 4 +- .../entrypoints/quick/quick_thread_entrypoints.cc | 2 +- .../entrypoints/quick/quick_throw_entrypoints.cc | 14 +- .../quick/quick_trampoline_entrypoints.cc | 32 +- runtime/exception_test.cc | 4 +- runtime/gc/accounting/mod_union_table.cc | 2 +- runtime/gc/accounting/space_bitmap.cc | 10 +- runtime/gc/collector/mark_sweep-inl.h | 6 +- runtime/gc/collector/mark_sweep.cc | 10 +- runtime/gc/heap.cc | 8 +- runtime/gc/space/image_space.cc | 10 +- runtime/hprof/hprof.cc | 9 +- runtime/instrumentation.cc | 32 +- runtime/instrumentation.h | 52 +-- runtime/interpreter/interpreter.cc | 70 +-- runtime/interpreter/interpreter.h | 6 +- runtime/invoke_arg_array_builder.h | 2 +- runtime/jdwp/jdwp.h | 2 +- runtime/jdwp/object_registry.h | 2 +- runtime/jni_internal.cc | 120 ++++-- runtime/jni_internal.h | 12 +- runtime/jni_internal_test.cc | 110 +++-- runtime/mirror/abstract_method-inl.h | 203 --------- runtime/mirror/abstract_method.cc | 350 --------------- runtime/mirror/abstract_method.h | 471 --------------------- runtime/mirror/art_field-inl.h | 221 ++++++++++ runtime/mirror/art_field.cc | 56 +++ runtime/mirror/art_field.h | 165 ++++++++ runtime/mirror/art_method-inl.h | 203 +++++++++ runtime/mirror/art_method.cc | 342 +++++++++++++++ runtime/mirror/art_method.h | 457 ++++++++++++++++++++ runtime/mirror/class-inl.h | 87 ++-- runtime/mirror/class.cc | 97 +++-- runtime/mirror/class.h | 102 ++--- runtime/mirror/dex_cache-inl.h | 4 +- runtime/mirror/dex_cache.cc | 12 +- runtime/mirror/dex_cache.h | 30 +- runtime/mirror/field-inl.h | 221 ---------- runtime/mirror/field.cc | 56 --- runtime/mirror/field.h | 168 -------- runtime/mirror/iftable.h | 12 +- runtime/mirror/object-inl.h | 40 +- runtime/mirror/object.cc | 14 +- runtime/mirror/object.h | 16 +- runtime/mirror/object_array-inl.h | 2 +- runtime/mirror/object_test.cc | 40 +- runtime/mirror/throwable.cc | 4 +- runtime/monitor.cc | 10 +- runtime/monitor.h | 8 +- runtime/monitor_android.cc | 2 +- runtime/native/dalvik_system_VMStack.cc | 2 +- runtime/native/java_lang_reflect_Constructor.cc | 10 +- runtime/native/java_lang_reflect_Field.cc | 23 +- runtime/native/java_lang_reflect_Method.cc | 23 +- runtime/native/java_lang_reflect_Proxy.cc | 6 +- runtime/nth_caller_visitor.h | 6 +- runtime/oat_file.cc | 6 +- runtime/oat_file.h | 4 +- runtime/oat_test.cc | 4 +- runtime/object_utils.h | 26 +- runtime/reflection.cc | 17 +- runtime/reflection.h | 12 +- runtime/runtime.cc | 29 +- runtime/runtime.h | 22 +- runtime/scoped_thread_state_change.h | 12 +- runtime/stack.cc | 29 +- runtime/stack.h | 38 +- runtime/thread.cc | 54 +-- runtime/thread.h | 6 +- runtime/throw_location.cc | 2 +- runtime/throw_location.h | 8 +- runtime/trace.cc | 34 +- runtime/trace.h | 18 +- runtime/utils.cc | 13 +- runtime/utils.h | 12 +- runtime/utils_test.cc | 4 +- runtime/verifier/method_verifier.cc | 80 ++-- runtime/verifier/method_verifier.h | 43 +- runtime/well_known_classes.cc | 24 +- runtime/well_known_classes.h | 11 +- test/046-reflect/expected.txt | 9 +- test/046-reflect/src/Main.java | 43 +- test/100-reflect2/expected.txt | 2 +- test/ReferenceMap/stack_walk_refmap_jni.cc | 6 +- test/StackWalk/stack_walk_jni.cc | 6 +- 148 files changed, 3300 insertions(+), 3290 deletions(-) delete mode 100644 runtime/mirror/abstract_method-inl.h delete mode 100644 runtime/mirror/abstract_method.cc delete mode 100644 runtime/mirror/abstract_method.h create mode 100644 runtime/mirror/art_field-inl.h create mode 100644 runtime/mirror/art_field.cc create mode 100644 runtime/mirror/art_field.h create mode 100644 runtime/mirror/art_method-inl.h create mode 100644 runtime/mirror/art_method.cc create mode 100644 runtime/mirror/art_method.h delete mode 100644 runtime/mirror/field-inl.h delete mode 100644 runtime/mirror/field.cc delete mode 100644 runtime/mirror/field.h (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index 60e638c584..a0e2c1e9aa 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -20,10 +20,10 @@ #include "dex_instruction-inl.h" #include "driver/compiler_driver.h" #include "driver/dex_compilation_unit.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/field-inl.h" namespace art { namespace optimizer { diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index 298d3898c8..e5c7fb150e 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -347,7 +347,7 @@ void Mir2Lir::GenSput(uint32_t field_idx, RegLocation rl_src, bool is_long_or_do RegLocation rl_method = LoadCurrMethod(); rBase = AllocTemp(); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), rBase); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), rBase); if (IsTemp(rl_method.low_reg)) { FreeTemp(rl_method.low_reg); } @@ -365,7 +365,7 @@ void Mir2Lir::GenSput(uint32_t field_idx, RegLocation rl_src, bool is_long_or_do rBase = TargetReg(kArg0); LockTemp(rBase); LoadWordDisp(r_method, - mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), + mirror::ArtMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), rBase); LoadWordDisp(rBase, mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + @@ -433,7 +433,7 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, RegLocation rl_method = LoadCurrMethod(); rBase = AllocTemp(); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), rBase); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), rBase); } else { // Medium path, static storage base in a different class which requires checks that the other // class is initialized @@ -448,7 +448,7 @@ void Mir2Lir::GenSget(uint32_t field_idx, RegLocation rl_dest, rBase = TargetReg(kArg0); LockTemp(rBase); LoadWordDisp(r_method, - mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), + mirror::ArtMethod::DexCacheInitializedStaticStorageOffset().Int32Value(), rBase); LoadWordDisp(rBase, mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + sizeof(int32_t*) * ssb_index, rBase); @@ -746,7 +746,7 @@ void Mir2Lir::GenConstClass(uint32_t type_idx, RegLocation rl_dest) { } else { // We're don't need access checks, load type from dex cache int32_t dex_cache_offset = - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(); LoadWordDisp(rl_method.low_reg, dex_cache_offset, res_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) @@ -799,7 +799,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { LockCallTemps(); // Using explicit registers LoadCurrMethodDirect(TargetReg(kArg2)); LoadWordDisp(TargetReg(kArg2), - mirror::AbstractMethod::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0)); + mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), TargetReg(kArg0)); // Might call out to helper, which will return resolved string in kRet0 int r_tgt = CallHelperSetup(QUICK_ENTRYPOINT_OFFSET(pResolveString)); LoadWordDisp(TargetReg(kArg0), offset_of_string, TargetReg(kRet0)); @@ -835,7 +835,7 @@ void Mir2Lir::GenConstString(uint32_t string_idx, RegLocation rl_dest) { int res_reg = AllocTemp(); RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); LoadWordDisp(rl_method.low_reg, - mirror::AbstractMethod::DexCacheStringsOffset().Int32Value(), res_reg); + mirror::ArtMethod::DexCacheStringsOffset().Int32Value(), res_reg); LoadWordDisp(res_reg, offset_of_string, rl_result.low_reg); StoreValue(rl_dest, rl_result); } @@ -884,11 +884,11 @@ void Mir2Lir::GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, Re LoadCurrMethodDirect(check_class); if (use_declaring_class) { - LoadWordDisp(check_class, mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + LoadWordDisp(check_class, mirror::ArtMethod::DeclaringClassOffset().Int32Value(), check_class); LoadWordDisp(object.low_reg, mirror::Object::ClassOffset().Int32Value(), object_class); } else { - LoadWordDisp(check_class, mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), + LoadWordDisp(check_class, mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), check_class); LoadWordDisp(object.low_reg, mirror::Object::ClassOffset().Int32Value(), object_class); int32_t offset_of_type = @@ -940,12 +940,12 @@ void Mir2Lir::GenInstanceofCallingHelper(bool needs_access_check, bool type_know } else if (use_declaring_class) { LoadValueDirectFixed(rl_src, TargetReg(kArg0)); // kArg0 <= ref LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), class_reg); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), class_reg); } else { // Load dex cache entry into class_reg (kArg2) LoadValueDirectFixed(rl_src, TargetReg(kArg0)); // kArg0 <= ref LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) * type_idx); @@ -1078,11 +1078,11 @@ void Mir2Lir::GenCheckCast(uint32_t insn_idx, uint32_t type_idx, RegLocation rl_ OpRegCopy(class_reg, TargetReg(kRet0)); // Align usage with fast path } else if (use_declaring_class) { LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), class_reg); + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), class_reg); } else { // Load dex cache entry into class_reg (kArg2) LoadWordDisp(TargetReg(kArg1), - mirror::AbstractMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); + mirror::ArtMethod::DexCacheResolvedTypesOffset().Int32Value(), class_reg); int32_t offset_of_type = mirror::Array::DataOffset(sizeof(mirror::Class*)).Int32Value() + (sizeof(mirror::Class*) * type_idx); diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 20d683a947..073b550d78 100644 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -365,7 +365,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, break; case 1: // Get method->dex_cache_resolved_methods_ cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); + mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); // Set up direct code if known. if (direct_code != 0) { if (direct_code != static_cast(-1)) { @@ -395,7 +395,7 @@ static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, if (cu->instruction_set != kX86) { if (direct_code == 0) { cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), cg->TargetReg(kInvokeTgt)); } break; @@ -448,7 +448,7 @@ static int NextVCallInsn(CompilationUnit* cu, CallInfo* info, case 4: // Get the compiled code address [uses kArg0, sets kInvokeTgt] if (cu->instruction_set != kX86) { cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), cg->TargetReg(kInvokeTgt)); break; } @@ -514,7 +514,7 @@ static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, break; case 1: // Get method->dex_cache_resolved_methods_ [set/use kArg0] cg->LoadWordDisp(cg->TargetReg(kArg0), - mirror::AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), + mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(), cg->TargetReg(kArg0)); break; case 2: // Grab target method* [set/use kArg0] @@ -1407,7 +1407,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) { } else { if (fast_path && info->type != kInterface) { call_inst = OpMem(kOpBlx, TargetReg(kArg0), - mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); + mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value()); } else { ThreadOffset trampoline(-1); switch (info->type) { diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 144271d581..82f51f200a 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -33,11 +33,11 @@ #include "gc/accounting/card_table-inl.h" #include "gc/accounting/heap_bitmap.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class_loader.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -515,7 +515,7 @@ static DexToDexCompilationLevel GetDexToDexCompilationlevel(mirror::ClassLoader* } } -void CompilerDriver::CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) { +void CompilerDriver::CompileOne(const mirror::ArtMethod* method, base::TimingLogger& timings) { DCHECK(!Runtime::Current()->IsStarted()); Thread* self = Thread::Current(); jobject jclass_loader; @@ -632,12 +632,12 @@ static bool ResolveCatchBlockExceptionsClassVisitor(mirror::Class* c, void* arg) reinterpret_cast >*>(arg); MethodHelper mh; for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { - mirror::AbstractMethod* m = c->GetVirtualMethod(i); + mirror::ArtMethod* m = c->GetVirtualMethod(i); mh.ChangeMethod(m); ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); } for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - mirror::AbstractMethod* m = c->GetDirectMethod(i); + mirror::ArtMethod* m = c->GetDirectMethod(i); mh.ChangeMethod(m); ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); } @@ -895,7 +895,7 @@ static mirror::Class* ComputeCompilingMethodsClass(ScopedObjectAccess& soa, dex_cache, class_loader); } -static mirror::Field* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAccess& soa, +static mirror::ArtField* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAccess& soa, const DexCompilationUnit* mUnit, uint32_t field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -905,7 +905,7 @@ static mirror::Field* ComputeFieldReferencedFromCompilingMethod(ScopedObjectAcce class_loader, false); } -static mirror::AbstractMethod* ComputeMethodReferencedFromCompilingMethod(ScopedObjectAccess& soa, +static mirror::ArtMethod* ComputeMethodReferencedFromCompilingMethod(ScopedObjectAccess& soa, const DexCompilationUnit* mUnit, uint32_t method_idx, InvokeType type) @@ -923,7 +923,7 @@ bool CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, const DexCompi field_offset = -1; is_volatile = true; // Try to resolve field and ignore if an Incompatible Class Change Error (ie is static). - mirror::Field* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); + mirror::ArtField* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); if (resolved_field != NULL && !resolved_field->IsStatic()) { mirror::Class* referrer_class = ComputeCompilingMethodsClass(soa, resolved_field->GetDeclaringClass()->GetDexCache(), @@ -974,7 +974,7 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila is_referrers_class = false; is_volatile = true; // Try to resolve field and ignore if an Incompatible Class Change Error (ie isn't static). - mirror::Field* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); + mirror::ArtField* resolved_field = ComputeFieldReferencedFromCompilingMethod(soa, mUnit, field_idx); if (resolved_field != NULL && resolved_field->IsStatic()) { mirror::Class* referrer_class = ComputeCompilingMethodsClass(soa, resolved_field->GetDeclaringClass()->GetDexCache(), @@ -1051,7 +1051,7 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, mirror::Class* referrer_class, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats) { @@ -1114,7 +1114,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui vtable_idx = -1; direct_code = 0; direct_method = 0; - mirror::AbstractMethod* resolved_method = + mirror::ArtMethod* resolved_method = ComputeMethodReferencedFromCompilingMethod(soa, mUnit, target_method.dex_method_index, invoke_type); if (resolved_method != NULL) { @@ -1179,7 +1179,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui mUnit->GetClassLinker()->FindDexCache(*devirt_map_target->dex_file); mirror::ClassLoader* class_loader = soa.Decode(mUnit->GetClassLoader()); - mirror::AbstractMethod* called_method = + mirror::ArtMethod* called_method = mUnit->GetClassLinker()->ResolveMethod(*devirt_map_target->dex_file, devirt_map_target->dex_method_index, target_dex_cache, class_loader, NULL, @@ -1471,7 +1471,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file); ClassDataItemIterator it(dex_file, class_data); while (it.HasNextStaticField()) { - mirror::Field* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, class_loader, true); if (field == NULL) { CHECK(self->IsExceptionPending()); @@ -1487,7 +1487,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag requires_constructor_barrier = true; } - mirror::Field* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, class_loader, false); if (field == NULL) { CHECK(self->IsExceptionPending()); @@ -1500,7 +1500,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag class_def_index); } while (it.HasNextDirectMethod()) { - mirror::AbstractMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), dex_cache, class_loader, NULL, it.GetMethodInvokeType(class_def)); if (method == NULL) { @@ -1510,7 +1510,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag it.Next(); } while (it.HasNextVirtualMethod()) { - mirror::AbstractMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), dex_cache, class_loader, NULL, it.GetMethodInvokeType(class_def)); if (method == NULL) { @@ -2073,7 +2073,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl LOG(INFO) << "Initializing: " << descriptor; if (StringPiece(descriptor) == "Ljava/lang/Void;") { // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. - mirror::ObjectArray* fields = klass->GetSFields(); + mirror::ObjectArray* fields = klass->GetSFields(); CHECK_EQ(fields->GetLength(), 1); fields->Get(0)->SetObj(klass, manager->GetClassLinker()->FindPrimitiveClass('V')); klass->SetStatus(mirror::Class::kStatusInitialized); diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index b5222c99b8..21a44eaf12 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -99,7 +99,7 @@ class CompilerDriver { LOCKS_EXCLUDED(Locks::mutator_lock_); // Compile a single Method - void CompileOne(const mirror::AbstractMethod* method, base::TimingLogger& timings) + void CompileOne(const mirror::ArtMethod* method, base::TimingLogger& timings) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); InstructionSet GetInstructionSet() const { @@ -301,7 +301,7 @@ class CompilerDriver { // Compute constant code and method pointers when possible void GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, mirror::Class* referrer_class, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -425,7 +425,7 @@ class CompilerDriver { CompilerEnableAutoElfLoadingFn compiler_enable_auto_elf_loading_; typedef const void* (*CompilerGetMethodCodeAddrFn) - (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::AbstractMethod* method); + (const CompilerDriver& driver, const CompiledMethod* cm, const mirror::ArtMethod* method); CompilerGetMethodCodeAddrFn compiler_get_method_code_addr_; bool support_boot_image_fixup_; diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 8ee9cf6442..c6687bb4aa 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -24,10 +24,10 @@ #include "common_test.h" #include "dex_file.h" #include "gc/heap.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -115,7 +115,7 @@ TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) { } EXPECT_EQ(dex->NumMethodIds(), dex_cache->NumResolvedMethods()); for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { - mirror::AbstractMethod* method = dex_cache->GetResolvedMethod(i); + mirror::ArtMethod* method = dex_cache->GetResolvedMethod(i); EXPECT_TRUE(method != NULL) << "method_idx=" << i << " " << dex->GetMethodDeclaringClassDescriptor(dex->GetMethodId(i)) << " " << dex->GetMethodName(dex->GetMethodId(i)); @@ -126,7 +126,7 @@ TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) { } EXPECT_EQ(dex->NumFieldIds(), dex_cache->NumResolvedFields()); for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { - mirror::Field* field = dex_cache->GetResolvedField(i); + mirror::ArtField* field = dex_cache->GetResolvedField(i); EXPECT_TRUE(field != NULL) << "field_idx=" << i << " " << dex->GetFieldDeclaringClassDescriptor(dex->GetFieldId(i)) << " " << dex->GetFieldName(dex->GetFieldId(i)); diff --git a/compiler/elf_writer.cc b/compiler/elf_writer.cc index 70d17de102..d3c13dd791 100644 --- a/compiler/elf_writer.cc +++ b/compiler/elf_writer.cc @@ -24,7 +24,7 @@ #include "elf_file.h" #include "invoke_type.h" #include "llvm/utils_llvm.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "oat.h" #include "scoped_thread_state_change.h" diff --git a/compiler/elf_writer_mclinker.cc b/compiler/elf_writer_mclinker.cc index 2a9bc35559..e496ace27a 100644 --- a/compiler/elf_writer_mclinker.cc +++ b/compiler/elf_writer_mclinker.cc @@ -33,8 +33,8 @@ #include "driver/compiler_driver.h" #include "elf_file.h" #include "globals.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "oat_writer.h" #include "scoped_thread_state_change.h" @@ -353,7 +353,7 @@ void ElfWriterMclinker::FixupOatMethodOffsets(const std::vector& const DexFile& dex_file = it.GetDexFile(); uint32_t method_idx = it.GetMemberIndex(); InvokeType invoke_type = it.GetInvokeType(); - mirror::AbstractMethod* method = NULL; + mirror::ArtMethod* method = NULL; if (compiler_driver_->IsImage()) { ClassLinker* linker = Runtime::Current()->GetClassLinker(); mirror::DexCache* dex_cache = linker->FindDexCache(dex_file); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 3432c8cbee..a40e3fc149 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -35,12 +35,12 @@ #include "globals.h" #include "image.h" #include "intern_table.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "oat.h" @@ -52,11 +52,11 @@ #include "UniquePtr.h" #include "utils.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Class; using ::art::mirror::DexCache; using ::art::mirror::EntryPointFromInterpreter; -using ::art::mirror::Field; using ::art::mirror::Object; using ::art::mirror::ObjectArray; using ::art::mirror::String; @@ -257,7 +257,7 @@ void ImageWriter::PruneNonImageClasses() { } // Clear references to removed classes from the DexCaches. - AbstractMethod* resolution_method = runtime->GetResolutionMethod(); + ArtMethod* resolution_method = runtime->GetResolutionMethod(); typedef Set::const_iterator CacheIt; // TODO: C++0x auto for (CacheIt it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it) { DexCache* dex_cache = *it; @@ -269,13 +269,13 @@ void ImageWriter::PruneNonImageClasses() { } } for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) { - AbstractMethod* method = dex_cache->GetResolvedMethod(i); + ArtMethod* method = dex_cache->GetResolvedMethod(i); if (method != NULL && !IsImageClass(method->GetDeclaringClass())) { dex_cache->SetResolvedMethod(i, resolution_method); } } for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) { - Field* field = dex_cache->GetResolvedField(i); + ArtField* field = dex_cache->GetResolvedField(i); if (field != NULL && !IsImageClass(field->GetDeclaringClass())) { dex_cache->SetResolvedField(i, NULL); } @@ -487,8 +487,8 @@ void ImageWriter::FixupObject(const Object* orig, Object* copy) { FixupClass(orig->AsClass(), down_cast(copy)); } else if (orig->IsObjectArray()) { FixupObjectArray(orig->AsObjectArray(), down_cast*>(copy)); - } else if (orig->IsMethod()) { - FixupMethod(orig->AsMethod(), down_cast(copy)); + } else if (orig->IsArtMethod()) { + FixupMethod(orig->AsArtMethod(), down_cast(copy)); } else { FixupInstanceFields(orig, copy); } @@ -499,7 +499,7 @@ void ImageWriter::FixupClass(const Class* orig, Class* copy) { FixupStaticFields(orig, copy); } -void ImageWriter::FixupMethod(const AbstractMethod* orig, AbstractMethod* copy) { +void ImageWriter::FixupMethod(const ArtMethod* orig, ArtMethod* copy) { FixupInstanceFields(orig, copy); // OatWriter replaces the code_ with an offset value. Here we re-adjust to a pointer relative to @@ -614,9 +614,9 @@ void ImageWriter::FixupFields(const Object* orig, ? klass->NumReferenceStaticFields() : klass->NumReferenceInstanceFields()); for (size_t i = 0; i < num_reference_fields; ++i) { - Field* field = (is_static - ? klass->GetStaticField(i) - : klass->GetInstanceField(i)); + ArtField* field = (is_static + ? klass->GetStaticField(i) + : klass->GetInstanceField(i)); MemberOffset field_offset = field->GetOffset(); const Object* ref = orig->GetFieldObject(field_offset, false); // Use SetFieldPtr to avoid card marking since we are writing to the image. @@ -626,7 +626,7 @@ void ImageWriter::FixupFields(const Object* orig, } if (!is_static && orig->IsReferenceInstance()) { // Fix-up referent, that isn't marked as an object field, for References. - Field* field = orig->GetClass()->FindInstanceField("referent", "Ljava/lang/Object;"); + ArtField* field = orig->GetClass()->FindInstanceField("referent", "Ljava/lang/Object;"); MemberOffset field_offset = field->GetOffset(); const Object* ref = orig->GetFieldObject(field_offset, false); // Use SetFieldPtr to avoid card marking since we are writing to the image. @@ -634,16 +634,16 @@ void ImageWriter::FixupFields(const Object* orig, } } -static AbstractMethod* GetTargetMethod(const CompilerDriver::PatchInformation* patch) +static ArtMethod* GetTargetMethod(const CompilerDriver::PatchInformation* patch) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); DexCache* dex_cache = class_linker->FindDexCache(patch->GetDexFile()); - AbstractMethod* method = class_linker->ResolveMethod(patch->GetDexFile(), - patch->GetTargetMethodIdx(), - dex_cache, - NULL, - NULL, - patch->GetTargetInvokeType()); + ArtMethod* method = class_linker->ResolveMethod(patch->GetDexFile(), + patch->GetTargetMethodIdx(), + dex_cache, + NULL, + NULL, + patch->GetTargetInvokeType()); CHECK(method != NULL) << patch->GetDexFile().GetLocation() << " " << patch->GetTargetMethodIdx(); CHECK(!method->IsRuntimeMethod()) @@ -664,7 +664,7 @@ void ImageWriter::PatchOatCodeAndMethods() { const Patches& code_to_patch = compiler_driver_.GetCodeToPatch(); for (size_t i = 0; i < code_to_patch.size(); i++) { const CompilerDriver::PatchInformation* patch = code_to_patch[i]; - AbstractMethod* target = GetTargetMethod(patch); + ArtMethod* target = GetTargetMethod(patch); uint32_t code = reinterpret_cast(class_linker->GetOatCodeFor(target)); uint32_t code_base = reinterpret_cast(&oat_file_->GetOatHeader()); uint32_t code_offset = code - code_base; @@ -674,7 +674,7 @@ void ImageWriter::PatchOatCodeAndMethods() { const Patches& methods_to_patch = compiler_driver_.GetMethodsToPatch(); for (size_t i = 0; i < methods_to_patch.size(); i++) { const CompilerDriver::PatchInformation* patch = methods_to_patch[i]; - AbstractMethod* target = GetTargetMethod(patch); + ArtMethod* target = GetTargetMethod(patch); SetPatchLocation(patch, reinterpret_cast(GetImageAddress(target))); } diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 545534fff7..750109d1d9 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -152,7 +152,7 @@ class ImageWriter { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupClass(const mirror::Class* orig, mirror::Class* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void FixupMethod(const mirror::AbstractMethod* orig, mirror::AbstractMethod* copy) + void FixupMethod(const mirror::ArtMethod* orig, mirror::ArtMethod* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupObject(const mirror::Object* orig, mirror::Object* copy) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc index 4b6967faa0..a653ab42a9 100644 --- a/compiler/jni/jni_compiler_test.cc +++ b/compiler/jni/jni_compiler_test.cc @@ -21,9 +21,9 @@ #include "indirect_reference_table.h" #include "jni_internal.h" #include "mem_map.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "mirror/stack_trace_element.h" @@ -51,7 +51,7 @@ class JniCompilerTest : public CommonTest { // Compile the native method before starting the runtime mirror::Class* c = class_linker_->FindClass("LMyClassNatives;", soa.Decode(class_loader)); - mirror::AbstractMethod* method; + mirror::ArtMethod* method; if (direct) { method = c->FindDirectMethod(method_name, method_sig); } else { diff --git a/compiler/jni/portable/jni_compiler.cc b/compiler/jni/portable/jni_compiler.cc index e05f291a73..58ee1c1602 100644 --- a/compiler/jni/portable/jni_compiler.cc +++ b/compiler/jni/portable/jni_compiler.cc @@ -27,7 +27,7 @@ #include "llvm/llvm_compilation_unit.h" #include "llvm/runtime_support_llvm_func.h" #include "llvm/utils_llvm.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "runtime.h" #include "stack.h" #include "thread.h" @@ -91,7 +91,7 @@ CompiledMethod* JniCompiler::Compile() { // Load class object this_object_or_class_object = irb_.LoadFromObjectOffset(method_object_addr, - mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } @@ -135,7 +135,7 @@ CompiledMethod* JniCompiler::Compile() { // Get callee code_addr ::llvm::Value* code_addr = irb_.LoadFromObjectOffset(method_object_addr, - mirror::AbstractMethod::NativeMethodOffset().Int32Value(), + mirror::ArtMethod::NativeMethodOffset().Int32Value(), GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(), is_static, true)->getPointerTo(), kTBAARuntimeInfo); diff --git a/compiler/jni/portable/jni_compiler.h b/compiler/jni/portable/jni_compiler.h index 9bdf35ef10..49cc9f4abf 100644 --- a/compiler/jni/portable/jni_compiler.h +++ b/compiler/jni/portable/jni_compiler.h @@ -28,7 +28,7 @@ namespace art { class DexFile; class DexCompilationUnit; namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; class DexCache; } // namespace mirror diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index 9713fe9da9..069def60f9 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -119,7 +119,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, // Check sirt offset is within frame CHECK_LT(sirt_offset.Uint32Value(), frame_size); __ LoadRef(main_jni_conv->InterproceduralScratchRegister(), - mr_conv->MethodRegister(), mirror::AbstractMethod::DeclaringClassOffset()); + mr_conv->MethodRegister(), mirror::ArtMethod::DeclaringClassOffset()); __ VerifyObject(main_jni_conv->InterproceduralScratchRegister(), false); __ StoreRef(sirt_offset, main_jni_conv->InterproceduralScratchRegister()); main_jni_conv->Next(); // in SIRT so move to next argument @@ -270,7 +270,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, } // 9. Plant call to native code associated with method. - __ Call(main_jni_conv->MethodStackOffset(), mirror::AbstractMethod::NativeMethodOffset(), + __ Call(main_jni_conv->MethodStackOffset(), mirror::ArtMethod::NativeMethodOffset(), mr_conv->InterproceduralScratchRegister()); // 10. Fix differences in result widths. diff --git a/compiler/llvm/compiler_llvm.h b/compiler/llvm/compiler_llvm.h index 20934ab209..65bc16bcd8 100644 --- a/compiler/llvm/compiler_llvm.h +++ b/compiler/llvm/compiler_llvm.h @@ -34,7 +34,7 @@ namespace art { class CompilerDriver; class DexCompilationUnit; namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; } // namespace mirror } // namespace art diff --git a/compiler/llvm/gbc_expander.cc b/compiler/llvm/gbc_expander.cc index a727d06cb2..4f6fa0a2df 100644 --- a/compiler/llvm/gbc_expander.cc +++ b/compiler/llvm/gbc_expander.cc @@ -20,7 +20,7 @@ #include "intrinsic_helper.h" #include "ir_builder.h" #include "method_reference.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/string.h" #include "thread.h" @@ -722,7 +722,7 @@ llvm::Value* GBCExpanderPass::EmitLoadDexCacheAddr(art::MemberOffset offset) { llvm::Value* GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) { llvm::Value* static_storage_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheInitializedStaticStorageOffset()); llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); @@ -732,7 +732,7 @@ GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) { llvm::Value* GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) { llvm::Value* resolved_type_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedTypesOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheResolvedTypesOffset()); llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx); @@ -742,7 +742,7 @@ GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) { llvm::Value* GBCExpanderPass:: EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) { llvm::Value* resolved_method_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedMethodsOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheResolvedMethodsOffset()); llvm::Value* method_idx_value = irb_.getPtrEquivInt(method_idx); @@ -752,7 +752,7 @@ EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) { llvm::Value* GBCExpanderPass:: EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) { llvm::Value* string_dex_cache_addr = - EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheStringsOffset()); + EmitLoadDexCacheAddr(art::mirror::ArtMethod::DexCacheStringsOffset()); llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx); @@ -911,7 +911,7 @@ llvm::Value* GBCExpanderPass::EmitInvoke(llvm::CallInst& call_inst) { } else { code_addr = irb_.LoadFromObjectOffset(callee_method_object_addr, - art::mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + art::mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), func_type->getPointerTo(), kTBAARuntimeInfo); } @@ -1207,7 +1207,7 @@ void GBCExpanderPass::Expand_SPutFast(llvm::Value* static_storage_addr, llvm::Value* GBCExpanderPass::Expand_LoadDeclaringClassSSB(llvm::Value* method_object_addr) { return irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } @@ -1259,7 +1259,7 @@ llvm::Value* GBCExpanderPass::Expand_Invoke(llvm::CallInst& call_inst) { llvm::Value* code_addr = irb_.LoadFromObjectOffset(callee_method_object_addr, - art::mirror::AbstractMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), + art::mirror::ArtMethod::GetEntryPointFromCompiledCodeOffset().Int32Value(), callee_method_type->getPointerTo(), kTBAARuntimeInfo); @@ -1938,7 +1938,7 @@ llvm::Value* GBCExpanderPass::Expand_HLSget(llvm::CallInst& call_inst, static_storage_addr = irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } else { @@ -2023,7 +2023,7 @@ void GBCExpanderPass::Expand_HLSput(llvm::CallInst& call_inst, static_storage_addr = irb_.LoadFromObjectOffset(method_object_addr, - art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(), + art::mirror::ArtMethod::DeclaringClassOffset().Int32Value(), irb_.getJObjectTy(), kTBAAConstJObject); } else { diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index ce88cf6dd6..f813843bd3 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -23,7 +23,7 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "gc/space/space.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" @@ -400,7 +400,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, mirror::DexCache* dex_cache = linker->FindDexCache(*dex_file); // Unchecked as we hold mutator_lock_ on entry. ScopedObjectAccessUnchecked soa(Thread::Current()); - mirror::AbstractMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, NULL, NULL, invoke_type); CHECK(method != NULL); method->SetFrameSizeInBytes(frame_size_in_bytes); diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index b85378d9ec..c372d000df 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -37,7 +37,7 @@ #include "gc/space/space-inl.h" #include "image_writer.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" @@ -862,7 +862,7 @@ static int dex2oat(int argc, char** argv) { // give it away now and then switch to a more managable ScopedObjectAccess. Thread::Current()->TransitionFromRunnableToSuspended(kNative); // Whilst we're in native take the opportunity to initialize well known classes. - WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); + WellKnownClasses::Init(Thread::Current()->GetJniEnv()); ScopedObjectAccess soa(Thread::Current()); // If --image-classes was specified, calculate the full list of classes to include in the image diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index a6f295f46d..67398afd5f 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -36,10 +36,10 @@ #include "image.h" #include "indenter.h" #include "mapping_table.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "oat.h" @@ -169,7 +169,7 @@ class OatDumper { return oat_file_.GetOatHeader().GetInstructionSet(); } - const void* GetOatCode(mirror::AbstractMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const void* GetOatCode(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); for (size_t i = 0; i < oat_dex_files_.size(); i++) { const OatFile::OatDexFile* oat_dex_file = oat_dex_files_[i]; @@ -804,18 +804,18 @@ class ImageDumper { } else if (type->IsClassClass()) { mirror::Class* klass = value->AsClass(); os << StringPrintf("%p Class: %s\n", klass, PrettyDescriptor(klass).c_str()); - } else if (type->IsFieldClass()) { - mirror::Field* field = value->AsField(); + } else if (type->IsArtFieldClass()) { + mirror::ArtField* field = value->AsArtField(); os << StringPrintf("%p Field: %s\n", field, PrettyField(field).c_str()); - } else if (type->IsMethodClass()) { - mirror::AbstractMethod* method = value->AsMethod(); + } else if (type->IsArtMethodClass()) { + mirror::ArtMethod* method = value->AsArtMethod(); os << StringPrintf("%p Method: %s\n", method, PrettyMethod(method).c_str()); } else { os << StringPrintf("%p %s\n", value, PrettyDescriptor(type).c_str()); } } - static void PrintField(std::ostream& os, mirror::Field* field, mirror::Object* obj) + static void PrintField(std::ostream& os, mirror::ArtField* field, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FieldHelper fh(field); const char* descriptor = fh.GetTypeDescriptor(); @@ -856,10 +856,10 @@ class ImageDumper { if (super != NULL) { DumpFields(os, obj, super); } - mirror::ObjectArray* fields = klass->GetIFields(); + mirror::ObjectArray* fields = klass->GetIFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); PrintField(os, field, obj); } } @@ -869,7 +869,7 @@ class ImageDumper { return image_space_.Contains(object); } - const void* GetOatCodeBegin(mirror::AbstractMethod* m) + const void* GetOatCodeBegin(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const void* code = m->GetEntryPointFromCompiledCode(); if (code == GetResolutionTrampoline(Runtime::Current()->GetClassLinker())) { @@ -881,7 +881,7 @@ class ImageDumper { return code; } - uint32_t GetOatCodeSize(mirror::AbstractMethod* m) + uint32_t GetOatCodeSize(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const uint32_t* oat_code_begin = reinterpret_cast(GetOatCodeBegin(m)); if (oat_code_begin == NULL) { @@ -890,7 +890,7 @@ class ImageDumper { return oat_code_begin[-1]; } - const void* GetOatCodeEnd(mirror::AbstractMethod* m) + const void* GetOatCodeEnd(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const uint8_t* oat_code_begin = reinterpret_cast(GetOatCodeBegin(m)); if (oat_code_begin == NULL) { @@ -922,12 +922,12 @@ class ImageDumper { mirror::Class* klass = obj->AsClass(); os << StringPrintf("%p: java.lang.Class \"%s\" (", obj, PrettyDescriptor(klass).c_str()) << klass->GetStatus() << ")\n"; - } else if (obj->IsField()) { + } else if (obj->IsArtField()) { os << StringPrintf("%p: java.lang.reflect.Field %s\n", obj, - PrettyField(obj->AsField()).c_str()); - } else if (obj->IsMethod()) { + PrettyField(obj->AsArtField()).c_str()); + } else if (obj->IsArtMethod()) { os << StringPrintf("%p: java.lang.reflect.Method %s\n", obj, - PrettyMethod(obj->AsMethod()).c_str()); + PrettyMethod(obj->AsArtMethod()).c_str()); } else if (obj_class->IsStringClass()) { os << StringPrintf("%p: java.lang.String %s\n", obj, PrintableString(obj->AsString()->ToModifiedUtf8()).c_str()); @@ -960,18 +960,18 @@ class ImageDumper { PrettyObjectValue(indent_os, value_class, value); } } else if (obj->IsClass()) { - mirror::ObjectArray* sfields = obj->AsClass()->GetSFields(); + mirror::ObjectArray* sfields = obj->AsClass()->GetSFields(); if (sfields != NULL) { indent_os << "STATICS:\n"; Indenter indent2_filter(indent_os.rdbuf(), kIndentChar, kIndentBy1Count); std::ostream indent2_os(&indent2_filter); for (int32_t i = 0; i < sfields->GetLength(); i++) { - mirror::Field* field = sfields->Get(i); + mirror::ArtField* field = sfields->Get(i); PrintField(indent2_os, field, field->GetDeclaringClass()); } } - } else if (obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); + } else if (obj->IsArtMethod()) { + mirror::ArtMethod* method = obj->AsArtMethod(); if (method->IsNative()) { DCHECK(method->GetNativeGcMap() == NULL) << PrettyMethod(method); DCHECK(method->GetMappingTable() == NULL) << PrettyMethod(method); @@ -1085,7 +1085,7 @@ class ImageDumper { size_t dex_instruction_bytes; - std::vector method_outlier; + std::vector method_outlier; std::vector method_outlier_size; std::vector method_outlier_expansion; std::vector > oat_dex_file_sizes; @@ -1138,7 +1138,7 @@ class ImageDumper { return (static_cast(size) / static_cast(object_bytes)) * 100; } - void ComputeOutliers(size_t total_size, double expansion, mirror::AbstractMethod* method) { + void ComputeOutliers(size_t total_size, double expansion, mirror::ArtMethod* method) { method_outlier_size.push_back(total_size); method_outlier_expansion.push_back(expansion); method_outlier.push_back(method); diff --git a/runtime/Android.mk b/runtime/Android.mk index 69e13e58f5..b34abe4282 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -78,11 +78,11 @@ LIBART_COMMON_SRC_FILES := \ locks.cc \ mem_map.cc \ memory_region.cc \ - mirror/abstract_method.cc \ + mirror/art_field.cc \ + mirror/art_method.cc \ mirror/array.cc \ mirror/class.cc \ mirror/dex_cache.cc \ - mirror/field.cc \ mirror/object.cc \ mirror/stack_trace_element.cc \ mirror/string.cc \ diff --git a/runtime/arch/arm/context_arm.cc b/runtime/arch/arm/context_arm.cc index 6b9538e801..102e1269b5 100644 --- a/runtime/arch/arm/context_arm.cc +++ b/runtime/arch/arm/context_arm.cc @@ -16,7 +16,7 @@ #include "context_arm.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" #include "thread.h" @@ -41,7 +41,7 @@ void ArmContext::Reset() { } void ArmContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/arm/entrypoints_init_arm.cc b/runtime/arch/arm/entrypoints_init_arm.cc index 810a6832b6..9e6902de3f 100644 --- a/runtime/arch/arm/entrypoints_init_arm.cc +++ b/runtime/arch/arm/entrypoints_init_arm.cc @@ -31,8 +31,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -112,8 +112,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/mips/context_mips.cc b/runtime/arch/mips/context_mips.cc index a78e5ee80d..b957708769 100644 --- a/runtime/arch/mips/context_mips.cc +++ b/runtime/arch/mips/context_mips.cc @@ -16,7 +16,7 @@ #include "context_mips.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -40,7 +40,7 @@ void MipsContext::Reset() { } void MipsContext::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); uint32_t fp_core_spills = method->GetFpSpillMask(); size_t spill_count = __builtin_popcount(core_spills); diff --git a/runtime/arch/mips/entrypoints_init_mips.cc b/runtime/arch/mips/entrypoints_init_mips.cc index a0d3995bce..40d7cd913c 100644 --- a/runtime/arch/mips/entrypoints_init_mips.cc +++ b/runtime/arch/mips/entrypoints_init_mips.cc @@ -30,8 +30,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -113,8 +113,8 @@ extern "C" int32_t art_quick_indexof(void*, uint32_t, uint32_t, uint32_t); extern "C" int32_t art_quick_string_compareto(void*, void*); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/arch/x86/context_x86.cc b/runtime/arch/x86/context_x86.cc index c728ae97ec..66a51f7492 100644 --- a/runtime/arch/x86/context_x86.cc +++ b/runtime/arch/x86/context_x86.cc @@ -16,7 +16,7 @@ #include "context_x86.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "stack.h" @@ -36,7 +36,7 @@ void X86Context::Reset() { } void X86Context::FillCalleeSaves(const StackVisitor& fr) { - mirror::AbstractMethod* method = fr.GetMethod(); + mirror::ArtMethod* method = fr.GetMethod(); uint32_t core_spills = method->GetCoreSpillMask(); size_t spill_count = __builtin_popcount(core_spills); DCHECK_EQ(method->GetFpSpillMask(), 0u); diff --git a/runtime/arch/x86/entrypoints_init_x86.cc b/runtime/arch/x86/entrypoints_init_x86.cc index 9b54d55bfc..abc2990cc0 100644 --- a/runtime/arch/x86/entrypoints_init_x86.cc +++ b/runtime/arch/x86/entrypoints_init_x86.cc @@ -29,8 +29,8 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m ShadowFrame* shadow_frame, JValue* result); // Portable entrypoints. -extern "C" void art_portable_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); // Alloc entrypoints. extern "C" void* art_quick_alloc_array(uint32_t, void*, int32_t); @@ -95,8 +95,8 @@ extern "C" int32_t art_quick_string_compareto(void*, void*); extern "C" void* art_quick_memcpy(void*, const void*, size_t); // Invoke entrypoints. -extern "C" void art_quick_resolution_trampoline(mirror::AbstractMethod*); -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_resolution_trampoline(mirror::ArtMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); extern "C" void art_quick_invoke_direct_trampoline_with_access_check(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline(uint32_t, void*); extern "C" void art_quick_invoke_interface_trampoline_with_access_check(uint32_t, void*); diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc index 073d67b823..6a7ceeed0b 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -24,9 +24,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -44,7 +44,7 @@ namespace art { static void JniAbort(const char* jni_function_name, const char* msg) { Thread* self = Thread::Current(); ScopedObjectAccess soa(self); - mirror::AbstractMethod* current_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = self->GetCurrentMethod(NULL); std::ostringstream os; os << "JNI DETECTED ERROR IN APPLICATION: " << msg; @@ -131,7 +131,7 @@ static const char* gBuiltInPrefixes[] = { NULL }; -static bool ShouldTrace(JavaVMExt* vm, const mirror::AbstractMethod* method) +static bool ShouldTrace(JavaVMExt* vm, const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // If both "-Xcheck:jni" and "-Xjnitrace:" are enabled, we print trace messages // when a native method that matches the -Xjnitrace argument calls a JNI function @@ -204,7 +204,7 @@ class ScopedCheck { */ void CheckFieldType(jobject java_object, jfieldID fid, char prim, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -259,7 +259,7 @@ class ScopedCheck { return; } - mirror::Field* f = CheckFieldID(fid); + mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -286,7 +286,7 @@ class ScopedCheck { */ void CheckSig(jmethodID mid, const char* expectedType, bool isStatic) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = CheckMethodID(mid); + mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -313,7 +313,7 @@ class ScopedCheck { void CheckStaticFieldID(jclass java_class, jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::Class* c = soa_.Decode(java_class); - const mirror::Field* f = CheckFieldID(fid); + const mirror::ArtField* f = CheckFieldID(fid); if (f == NULL) { return; } @@ -334,7 +334,7 @@ class ScopedCheck { */ void CheckStaticMethod(jclass java_class, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -354,7 +354,7 @@ class ScopedCheck { */ void CheckVirtualMethod(jobject java_object, jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::AbstractMethod* m = CheckMethodID(mid); + const mirror::ArtMethod* m = CheckMethodID(mid); if (m == NULL) { return; } @@ -404,7 +404,7 @@ class ScopedCheck { void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { va_list ap; - const mirror::AbstractMethod* traceMethod = NULL; + const mirror::ArtMethod* traceMethod = NULL; if (has_method_ && (!soa_.Vm()->trace.empty() || VLOG_IS_ON(third_party_jni))) { // We need to guard some of the invocation interface's calls: a bad caller might // use DetachCurrentThread or GetEnv on a thread that's not yet attached. @@ -477,7 +477,7 @@ class ScopedCheck { } } else if (ch == 'f') { // jfieldID jfieldID fid = va_arg(ap, jfieldID); - mirror::Field* f = reinterpret_cast(fid); + mirror::ArtField* f = reinterpret_cast(fid); msg += PrettyField(f); if (!entry) { StringAppendF(&msg, " (%p)", fid); @@ -490,7 +490,7 @@ class ScopedCheck { StringAppendF(&msg, "%d", i); } else if (ch == 'm') { // jmethodID jmethodID mid = va_arg(ap, jmethodID); - mirror::AbstractMethod* m = reinterpret_cast(mid); + mirror::ArtMethod* m = reinterpret_cast(mid); msg += PrettyMethod(m); if (!entry) { StringAppendF(&msg, " (%p)", mid); @@ -700,13 +700,13 @@ class ScopedCheck { } } - mirror::Field* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtField* CheckFieldID(jfieldID fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (fid == NULL) { JniAbortF(function_name_, "jfieldID was NULL"); return NULL; } - mirror::Field* f = soa_.DecodeField(fid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsField()) { + mirror::ArtField* f = soa_.DecodeField(fid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(f) || !f->IsArtField()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jfieldID: %p", fid); return NULL; @@ -714,13 +714,13 @@ class ScopedCheck { return f; } - mirror::AbstractMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + mirror::ArtMethod* CheckMethodID(jmethodID mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (mid == NULL) { JniAbortF(function_name_, "jmethodID was NULL"); return NULL; } - mirror::AbstractMethod* m = soa_.DecodeMethod(mid); - if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsMethod()) { + mirror::ArtMethod* m = soa_.DecodeMethod(mid); + if (!Runtime::Current()->GetHeap()->IsHeapAddress(m) || !m->IsArtMethod()) { Runtime::Current()->GetHeap()->DumpSpaces(); JniAbortF(function_name_, "invalid jmethodID: %p", mid); return NULL; diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 4d01b66f0a..ad568b1cdb 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -19,15 +19,15 @@ #include "class_linker.h" +#include "mirror/art_field.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/object_array.h" namespace art { inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::String* resolved_string = referrer->GetDexCacheStrings()->Get(string_idx); if (UNLIKELY(resolved_string == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -39,7 +39,7 @@ inline mirror::String* ClassLinker::ResolveString(uint32_t string_idx, } inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { mirror::Class* resolved_type = referrer->GetDexCacheResolvedTypes()->Get(type_idx); if (UNLIKELY(resolved_type == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -51,7 +51,7 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, return resolved_type; } -inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::Field* referrer) { +inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); mirror::Class* resolved_type = dex_cache->GetResolvedType(type_idx); @@ -63,10 +63,10 @@ inline mirror::Class* ClassLinker::ResolveType(uint16_t type_idx, const mirror:: return resolved_type; } -inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, - const mirror::AbstractMethod* referrer, - InvokeType type) { - mirror::AbstractMethod* resolved_method = +inline mirror::ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx, + const mirror::ArtMethod* referrer, + InvokeType type) { + mirror::ArtMethod* resolved_method = referrer->GetDexCacheResolvedMethods()->Get(method_idx); if (UNLIKELY(resolved_method == NULL || resolved_method->IsRuntimeMethod())) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -78,10 +78,10 @@ inline mirror::AbstractMethod* ClassLinker::ResolveMethod(uint32_t method_idx, return resolved_method; } -inline mirror::Field* ClassLinker::ResolveField(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - bool is_static) { - mirror::Field* resolved_field = +inline mirror::ArtField* ClassLinker::ResolveField(uint32_t field_idx, + const mirror::ArtMethod* referrer, + bool is_static) { + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); @@ -109,16 +109,10 @@ inline mirror::ObjectArray* ClassLinker::AllocStringArray(Thread length); } -inline mirror::ObjectArray* ClassLinker::AllocAbstractMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectAbstractMethodArrayClass), length); -} - -inline mirror::ObjectArray* ClassLinker::AllocMethodArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectMethodArrayClass), length); +inline mirror::ObjectArray* ClassLinker::AllocArtMethodArray(Thread* self, + size_t length) { + return mirror::ObjectArray::Alloc(self, + GetClassRoot(kJavaLangReflectArtMethodArrayClass), length); } inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) { @@ -126,11 +120,11 @@ inline mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) mirror::IfTable::Alloc(self, GetClassRoot(kObjectArrayClass), ifcount * mirror::IfTable::kMax)); } -inline mirror::ObjectArray* ClassLinker::AllocFieldArray(Thread* self, - size_t length) { - return mirror::ObjectArray::Alloc(self, - GetClassRoot(kJavaLangReflectFieldArrayClass), - length); +inline mirror::ObjectArray* ClassLinker::AllocArtFieldArray(Thread* self, + size_t length) { + return mirror::ObjectArray::Alloc(self, + GetClassRoot(kJavaLangReflectArtFieldArrayClass), + length); } inline mirror::Class* ClassLinker::GetClassRoot(ClassRoot class_root) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c7a8f7e3d4..1e21736d66 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -43,14 +43,13 @@ #include "leb128.h" #include "oat.h" #include "oat_file.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/iftable-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -145,15 +144,12 @@ const char* ClassLinker::class_roots_descriptors_[] = { "Ljava/lang/String;", "Ljava/lang/DexCache;", "Ljava/lang/ref/Reference;", - "Ljava/lang/reflect/Constructor;", - "Ljava/lang/reflect/Field;", - "Ljava/lang/reflect/AbstractMethod;", - "Ljava/lang/reflect/Method;", + "Ljava/lang/reflect/ArtField;", + "Ljava/lang/reflect/ArtMethod;", "Ljava/lang/reflect/Proxy;", "[Ljava/lang/String;", - "[Ljava/lang/reflect/AbstractMethod;", - "[Ljava/lang/reflect/Field;", - "[Ljava/lang/reflect/Method;", + "[Ljava/lang/reflect/ArtField;", + "[Ljava/lang/reflect/ArtMethod;", "Ljava/lang/ClassLoader;", "Ljava/lang/Throwable;", "Ljava/lang/ClassNotFoundException;", @@ -292,56 +288,38 @@ void ClassLinker::InitFromCompiler(const std::vector& boot_class java_lang_DexCache->SetStatus(mirror::Class::kStatusResolved); // Constructor, Field, Method, and AbstractMethod are necessary so that FindClass can link members. - SirtRef java_lang_reflect_Field(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::FieldClass))); - CHECK(java_lang_reflect_Field.get() != NULL); - java_lang_reflect_Field->SetObjectSize(sizeof(mirror::Field)); - SetClassRoot(kJavaLangReflectField, java_lang_reflect_Field.get()); - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusResolved); - mirror::Field::SetClass(java_lang_reflect_Field.get()); - - SirtRef java_lang_reflect_AbstractMethod(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_AbstractMethod.get() != NULL); - java_lang_reflect_AbstractMethod->SetObjectSize(sizeof(mirror::AbstractMethod)); - SetClassRoot(kJavaLangReflectAbstractMethod, java_lang_reflect_AbstractMethod.get()); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusResolved); - - SirtRef java_lang_reflect_Constructor(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Constructor.get() != NULL); - java_lang_reflect_Constructor->SetObjectSize(sizeof(mirror::Constructor)); - java_lang_reflect_Constructor->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectConstructor, java_lang_reflect_Constructor.get()); - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusResolved); - - SirtRef java_lang_reflect_Method(self, AllocClass(self, java_lang_Class.get(), - sizeof(mirror::AbstractMethodClass))); - CHECK(java_lang_reflect_Method.get() != NULL); - java_lang_reflect_Method->SetObjectSize(sizeof(mirror::Method)); - java_lang_reflect_Method->SetSuperClass(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectMethod, java_lang_reflect_Method.get()); - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusResolved); - - mirror::AbstractMethod::SetClasses(java_lang_reflect_Constructor.get(), - java_lang_reflect_Method.get()); + SirtRef java_lang_reflect_ArtField(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtFieldClass))); + CHECK(java_lang_reflect_ArtField.get() != NULL); + java_lang_reflect_ArtField->SetObjectSize(sizeof(mirror::ArtField)); + SetClassRoot(kJavaLangReflectArtField, java_lang_reflect_ArtField.get()); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusResolved); + mirror::ArtField::SetClass(java_lang_reflect_ArtField.get()); + + SirtRef java_lang_reflect_ArtMethod(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::ArtMethodClass))); + CHECK(java_lang_reflect_ArtMethod.get() != NULL); + java_lang_reflect_ArtMethod->SetObjectSize(sizeof(mirror::ArtMethod)); + SetClassRoot(kJavaLangReflectArtMethod, java_lang_reflect_ArtMethod.get()); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusResolved); + + mirror::ArtMethod::SetClass(java_lang_reflect_ArtMethod.get()); // Set up array classes for string, field, method - SirtRef object_array_string(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); + SirtRef object_array_string(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); object_array_string->SetComponentType(java_lang_String.get()); SetClassRoot(kJavaLangStringArrayClass, object_array_string.get()); - SirtRef object_array_abstract_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_abstract_method->SetComponentType(java_lang_reflect_AbstractMethod.get()); - SetClassRoot(kJavaLangReflectAbstractMethodArrayClass, object_array_abstract_method.get()); + SirtRef object_array_art_method(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_method->SetComponentType(java_lang_reflect_ArtMethod.get()); + SetClassRoot(kJavaLangReflectArtMethodArrayClass, object_array_art_method.get()); - SirtRef object_array_field(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_field->SetComponentType(java_lang_reflect_Field.get()); - SetClassRoot(kJavaLangReflectFieldArrayClass, object_array_field.get()); - - SirtRef object_array_method(self, AllocClass(self, java_lang_Class.get(), sizeof(mirror::Class))); - object_array_method->SetComponentType(java_lang_reflect_Method.get()); - SetClassRoot(kJavaLangReflectMethodArrayClass, object_array_method.get()); + SirtRef object_array_art_field(self, AllocClass(self, java_lang_Class.get(), + sizeof(mirror::Class))); + object_array_art_field->SetComponentType(java_lang_reflect_ArtField.get()); + SetClassRoot(kJavaLangReflectArtFieldArrayClass, object_array_art_field.get()); // Setup boot_class_path_ and register class_path now that we can use AllocObjectArray to create // DexCache instances. Needs to be after String, Field, Method arrays since AllocDexCache uses @@ -422,42 +400,29 @@ void ClassLinker::InitFromCompiler(const std::vector& boot_class kh.ChangeClass(object_array_class.get()); CHECK_EQ(java_lang_Cloneable, kh.GetDirectInterface(0)); CHECK_EQ(java_io_Serializable, kh.GetDirectInterface(1)); - // Run Class, Constructor, Field, and Method through FindSystemClass. This initializes their + // Run Class, ArtField, and ArtMethod through FindSystemClass. This initializes their // dex_cache_ fields and register them in classes_. mirror::Class* Class_class = FindSystemClass("Ljava/lang/Class;"); CHECK_EQ(java_lang_Class.get(), Class_class); - java_lang_reflect_AbstractMethod->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Abstract_method_class = FindSystemClass("Ljava/lang/reflect/AbstractMethod;"); - CHECK_EQ(java_lang_reflect_AbstractMethod.get(), Abstract_method_class); - - // Method extends AbstractMethod so must reset after. - java_lang_reflect_Method->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Method_class = FindSystemClass("Ljava/lang/reflect/Method;"); - CHECK_EQ(java_lang_reflect_Method.get(), Method_class); + java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_method_class = FindSystemClass("Ljava/lang/reflect/ArtMethod;"); + CHECK_EQ(java_lang_reflect_ArtMethod.get(), Art_method_class); - // Constructor extends AbstractMethod so must reset after. - java_lang_reflect_Constructor->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Constructor_class = FindSystemClass("Ljava/lang/reflect/Constructor;"); - CHECK_EQ(java_lang_reflect_Constructor.get(), Constructor_class); - - java_lang_reflect_Field->SetStatus(mirror::Class::kStatusNotReady); - mirror::Class* Field_class = FindSystemClass("Ljava/lang/reflect/Field;"); - CHECK_EQ(java_lang_reflect_Field.get(), Field_class); + java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusNotReady); + mirror::Class* Art_field_class = FindSystemClass("Ljava/lang/reflect/ArtField;"); + CHECK_EQ(java_lang_reflect_ArtField.get(), Art_field_class); mirror::Class* String_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangStringArrayClass]); CHECK_EQ(object_array_string.get(), String_array_class); - mirror::Class* Abstract_method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]); - CHECK_EQ(object_array_abstract_method.get(), Abstract_method_array_class); - - mirror::Class* Field_array_class = FindSystemClass(class_roots_descriptors_[kJavaLangReflectFieldArrayClass]); - CHECK_EQ(object_array_field.get(), Field_array_class); + mirror::Class* Art_method_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]); + CHECK_EQ(object_array_art_method.get(), Art_method_array_class); - mirror::Class* Method_array_class = - FindSystemClass(class_roots_descriptors_[kJavaLangReflectMethodArrayClass]); - CHECK_EQ(object_array_method.get(), Method_array_class); + mirror::Class* Art_field_array_class = + FindSystemClass(class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]); + CHECK_EQ(object_array_art_field.get(), Art_field_array_class); // End of special init trickery, subsequent classes may be loaded via FindSystemClass. @@ -516,31 +481,31 @@ void ClassLinker::FinishInit() { const DexFile& java_lang_dex = *java_lang_ref_Reference->GetDexCache()->GetDexFile(); - mirror::Field* pendingNext = java_lang_ref_Reference->GetInstanceField(0); + mirror::ArtField* pendingNext = java_lang_ref_Reference->GetInstanceField(0); FieldHelper fh(pendingNext, this); CHECK_STREQ(fh.GetName(), "pendingNext"); CHECK_EQ(java_lang_dex.GetFieldId(pendingNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* queue = java_lang_ref_Reference->GetInstanceField(1); + mirror::ArtField* queue = java_lang_ref_Reference->GetInstanceField(1); fh.ChangeField(queue); CHECK_STREQ(fh.GetName(), "queue"); CHECK_EQ(java_lang_dex.GetFieldId(queue->GetDexFieldIndex()).type_idx_, java_lang_ref_ReferenceQueue->GetDexTypeIndex()); - mirror::Field* queueNext = java_lang_ref_Reference->GetInstanceField(2); + mirror::ArtField* queueNext = java_lang_ref_Reference->GetInstanceField(2); fh.ChangeField(queueNext); CHECK_STREQ(fh.GetName(), "queueNext"); CHECK_EQ(java_lang_dex.GetFieldId(queueNext->GetDexFieldIndex()).type_idx_, java_lang_ref_Reference->GetDexTypeIndex()); - mirror::Field* referent = java_lang_ref_Reference->GetInstanceField(3); + mirror::ArtField* referent = java_lang_ref_Reference->GetInstanceField(3); fh.ChangeField(referent); CHECK_STREQ(fh.GetName(), "referent"); CHECK_EQ(java_lang_dex.GetFieldId(referent->GetDexFieldIndex()).type_idx_, GetClassRoot(kJavaLangObject)->GetDexTypeIndex()); - mirror::Field* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); + mirror::ArtField* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); fh.ChangeField(zombie); CHECK_STREQ(fh.GetName(), "zombie"); CHECK_EQ(java_lang_dex.GetFieldId(zombie->GetDexFieldIndex()).type_idx_, @@ -958,8 +923,8 @@ static void InitFromImageCallbackCommon(mirror::Object* obj, ClassLinker* class_ ClassHelper kh(klass, class_linker); mirror::Class* existing = class_linker->InsertClass(kh.GetDescriptor(), klass, true); DCHECK(existing == NULL) << kh.GetDescriptor(); - } else if (interpret_only_mode && obj->IsMethod()) { - mirror::AbstractMethod* method = obj->AsMethod(); + } else if (interpret_only_mode && obj->IsArtMethod()) { + mirror::ArtMethod* method = obj->AsArtMethod(); if (!method->IsNative()) { method->SetEntryPointFromInterpreter(interpreter::artInterpreterToInterpreterBridge); if (method != Runtime::Current()->GetResolutionMethod()) { @@ -1027,8 +992,7 @@ void ClassLinker::InitFromImage() { // Set classes on AbstractMethod early so that IsMethod tests can be performed during the live // bitmap walk. - mirror::AbstractMethod::SetClasses(GetClassRoot(kJavaLangReflectConstructor), - GetClassRoot(kJavaLangReflectMethod)); + mirror::ArtMethod::SetClass(GetClassRoot(kJavaLangReflectArtMethod)); // reinit clases_ table { @@ -1049,7 +1013,7 @@ void ClassLinker::InitFromImage() { array_iftable_ = GetClassRoot(kObjectArrayClass)->GetIfTable(); DCHECK(array_iftable_ == GetClassRoot(kBooleanArrayClass)->GetIfTable()); // String class root was set above - mirror::Field::SetClass(GetClassRoot(kJavaLangReflectField)); + mirror::ArtField::SetClass(GetClassRoot(kJavaLangReflectArtField)); mirror::BooleanArray::SetArrayClass(GetClassRoot(kBooleanArrayClass)); mirror::ByteArray::SetArrayClass(GetClassRoot(kByteArrayClass)); mirror::CharArray::SetArrayClass(GetClassRoot(kCharArrayClass)); @@ -1132,8 +1096,8 @@ void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* ar ClassLinker::~ClassLinker() { mirror::Class::ResetClass(); mirror::String::ResetClass(); - mirror::Field::ResetClass(); - mirror::AbstractMethod::ResetClasses(); + mirror::ArtField::ResetClass(); + mirror::ArtMethod::ResetClass(); mirror::BooleanArray::ResetArrayClass(); mirror::ByteArray::ResetArrayClass(); mirror::CharArray::ResetArrayClass(); @@ -1172,13 +1136,13 @@ mirror::DexCache* ClassLinker::AllocDexCache(Thread* self, const DexFile& dex_fi if (types.get() == NULL) { return NULL; } - SirtRef > - methods(self, AllocAbstractMethodArray(self, dex_file.NumMethodIds())); + SirtRef > + methods(self, AllocArtMethodArray(self, dex_file.NumMethodIds())); if (methods.get() == NULL) { return NULL; } - SirtRef > - fields(self, AllocFieldArray(self, dex_file.NumFieldIds())); + SirtRef > + fields(self, AllocArtFieldArray(self, dex_file.NumFieldIds())); if (fields.get() == NULL) { return NULL; } @@ -1214,16 +1178,12 @@ mirror::Class* ClassLinker::AllocClass(Thread* self, size_t class_size) { return AllocClass(self, GetClassRoot(kJavaLangClass), class_size); } -mirror::Field* ClassLinker::AllocField(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectField)->AllocObject(self)); +mirror::ArtField* ClassLinker::AllocArtField(Thread* self) { + return down_cast(GetClassRoot(kJavaLangReflectArtField)->AllocObject(self)); } -mirror::Method* ClassLinker::AllocMethod(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectMethod)->AllocObject(self)); -} - -mirror::Constructor* ClassLinker::AllocConstructor(Thread* self) { - return down_cast(GetClassRoot(kJavaLangReflectConstructor)->AllocObject(self)); +mirror::ArtMethod* ClassLinker::AllocArtMethod(Thread* self) { + return down_cast(GetClassRoot(kJavaLangReflectArtMethod)->AllocObject(self)); } mirror::ObjectArray* ClassLinker::AllocStackTraceElementArray(Thread* self, @@ -1364,14 +1324,10 @@ mirror::Class* ClassLinker::DefineClass(const StringPiece& descriptor, klass.reset(GetClassRoot(kJavaLangString)); } else if (descriptor == "Ljava/lang/DexCache;") { klass.reset(GetClassRoot(kJavaLangDexCache)); - } else if (descriptor == "Ljava/lang/reflect/Field;") { - klass.reset(GetClassRoot(kJavaLangReflectField)); - } else if (descriptor == "Ljava/lang/reflect/AbstractMethod;") { - klass.reset(GetClassRoot(kJavaLangReflectAbstractMethod)); - } else if (descriptor == "Ljava/lang/reflect/Constructor;") { - klass.reset(GetClassRoot(kJavaLangReflectConstructor)); - } else if (descriptor == "Ljava/lang/reflect/Method;") { - klass.reset(GetClassRoot(kJavaLangReflectMethod)); + } else if (descriptor == "Ljava/lang/reflect/ArtField;") { + klass.reset(GetClassRoot(kJavaLangReflectArtField)); + } else if (descriptor == "Ljava/lang/reflect/ArtMethod;") { + klass.reset(GetClassRoot(kJavaLangReflectArtMethod)); } else { klass.reset(AllocClass(self, SizeOfClass(dex_file, dex_class_def))); } @@ -1519,7 +1475,7 @@ static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file, uint32 return 0; } -const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMethod* method) { +const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::ArtMethod* method) { // Although we overwrite the trampoline of non-static methods, we may get here via the resolution // method for direct methods (or virtual methods made direct). mirror::Class* declaring_class = method->GetDeclaringClass(); @@ -1553,7 +1509,7 @@ const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::AbstractMeth } // Special case to get oat code without overwriting a trampoline. -const void* ClassLinker::GetOatCodeFor(const mirror::AbstractMethod* method) { +const void* ClassLinker::GetOatCodeFor(const mirror::ArtMethod* method) { CHECK(!method->IsAbstract()) << PrettyMethod(method); if (method->IsProxyMethod()) { #if !defined(ART_USE_PORTABLE_COMPILER) @@ -1580,7 +1536,7 @@ const void* ClassLinker::GetOatCodeFor(const DexFile& dex_file, uint32_t method_ } // Returns true if the method must run with interpreter, false otherwise. -static bool NeedsInterpreter(const mirror::AbstractMethod* method, const void* code) { +static bool NeedsInterpreter(const mirror::ArtMethod* method, const void* code) { if (code == NULL) { // No code: need interpreter. return true; @@ -1617,7 +1573,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { } // Link the code of methods skipped by LinkCode for (size_t method_index = 0; it.HasNextDirectMethod(); ++method_index, it.Next()) { - mirror::AbstractMethod* method = klass->GetDirectMethod(method_index); + mirror::ArtMethod* method = klass->GetDirectMethod(method_index); if (!method->IsStatic()) { // Only update static methods. continue; @@ -1633,7 +1589,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { // Ignore virtual methods on the iterator. } -static void LinkCode(SirtRef& method, const OatFile::OatClass* oat_class, +static void LinkCode(SirtRef& method, const OatFile::OatClass* oat_class, uint32_t method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Method shouldn't have already been linked. @@ -1707,18 +1663,18 @@ void ClassLinker::LoadClass(const DexFile& dex_file, ClassDataItemIterator it(dex_file, class_data); Thread* self = Thread::Current(); if (it.NumStaticFields() != 0) { - klass->SetSFields(AllocFieldArray(self, it.NumStaticFields())); + klass->SetSFields(AllocArtFieldArray(self, it.NumStaticFields())); } if (it.NumInstanceFields() != 0) { - klass->SetIFields(AllocFieldArray(self, it.NumInstanceFields())); + klass->SetIFields(AllocArtFieldArray(self, it.NumInstanceFields())); } for (size_t i = 0; it.HasNextStaticField(); i++, it.Next()) { - SirtRef sfield(self, AllocField(self)); + SirtRef sfield(self, AllocArtField(self)); klass->SetStaticField(i, sfield.get()); LoadField(dex_file, it, klass, sfield); } for (size_t i = 0; it.HasNextInstanceField(); i++, it.Next()) { - SirtRef ifield(self, AllocField(self)); + SirtRef ifield(self, AllocArtField(self)); klass->SetInstanceField(i, ifield.get()); LoadField(dex_file, it, klass, ifield); } @@ -1731,15 +1687,15 @@ void ClassLinker::LoadClass(const DexFile& dex_file, // Load methods. if (it.NumDirectMethods() != 0) { // TODO: append direct methods to class object - klass->SetDirectMethods(AllocAbstractMethodArray(self, it.NumDirectMethods())); + klass->SetDirectMethods(AllocArtMethodArray(self, it.NumDirectMethods())); } if (it.NumVirtualMethods() != 0) { // TODO: append direct methods to class object - klass->SetVirtualMethods(AllocMethodArray(self, it.NumVirtualMethods())); + klass->SetVirtualMethods(AllocArtMethodArray(self, it.NumVirtualMethods())); } size_t class_def_method_index = 0; for (size_t i = 0; it.HasNextDirectMethod(); i++, it.Next()) { - SirtRef method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef method(self, LoadMethod(self, dex_file, it, klass)); klass->SetDirectMethod(i, method.get()); if (oat_class.get() != NULL) { LinkCode(method, oat_class.get(), class_def_method_index); @@ -1748,7 +1704,7 @@ void ClassLinker::LoadClass(const DexFile& dex_file, class_def_method_index++; } for (size_t i = 0; it.HasNextVirtualMethod(); i++, it.Next()) { - SirtRef method(self, LoadMethod(self, dex_file, it, klass)); + SirtRef method(self, LoadMethod(self, dex_file, it, klass)); klass->SetVirtualMethod(i, method.get()); DCHECK_EQ(class_def_method_index, it.NumDirectMethods() + i); if (oat_class.get() != NULL) { @@ -1760,27 +1716,22 @@ void ClassLinker::LoadClass(const DexFile& dex_file, } void ClassLinker::LoadField(const DexFile& /*dex_file*/, const ClassDataItemIterator& it, - SirtRef& klass, SirtRef& dst) { + SirtRef& klass, SirtRef& dst) { uint32_t field_idx = it.GetMemberIndex(); dst->SetDexFieldIndex(field_idx); dst->SetDeclaringClass(klass.get()); dst->SetAccessFlags(it.GetMemberAccessFlags()); } -mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it, SirtRef& klass) { uint32_t dex_method_idx = it.GetMemberIndex(); const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); StringPiece method_name(dex_file.GetMethodName(method_id)); - mirror::AbstractMethod* dst = NULL; - if (method_name == "") { - dst = AllocConstructor(self); - } else { - dst = AllocMethod(self); - } - DCHECK(dst->IsMethod()) << PrettyDescriptor(dst->GetClass()); + mirror::ArtMethod* dst = AllocArtMethod(self); + DCHECK(dst->IsArtMethod()) << PrettyDescriptor(dst->GetClass()); const char* old_cause = self->StartAssertNoThreadSuspension("LoadMethod"); dst->SetDexMethodIndex(dex_method_idx); @@ -1824,7 +1775,7 @@ mirror::AbstractMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes()); dst->SetDexCacheInitializedStaticStorage(klass->GetDexCache()->GetInitializedStaticStorage()); - CHECK(dst->IsMethod()); + CHECK(dst->IsArtMethod()); self->EndAssertNoThreadSuspension(old_cause); return dst; @@ -1918,7 +1869,7 @@ mirror::DexCache* ClassLinker::FindDexCache(const DexFile& dex_file) const { return NULL; } -void ClassLinker::FixupDexCaches(mirror::AbstractMethod* resolution_method) const { +void ClassLinker::FixupDexCaches(mirror::ArtMethod* resolution_method) const { ReaderMutexLock mu(Thread::Current(), dex_lock_); for (size_t i = 0; i != dex_caches_.size(); ++i) { dex_caches_[i]->Fixup(resolution_method); @@ -2007,12 +1958,10 @@ mirror::Class* ClassLinker::CreateArrayClass(const std::string& descriptor, new_class.reset(GetClassRoot(kObjectArrayClass)); } else if (descriptor == class_roots_descriptors_[kJavaLangStringArrayClass]) { new_class.reset(GetClassRoot(kJavaLangStringArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectAbstractMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectAbstractMethodArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectFieldArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectFieldArrayClass)); - } else if (descriptor == class_roots_descriptors_[kJavaLangReflectMethodArrayClass]) { - new_class.reset(GetClassRoot(kJavaLangReflectMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtMethodArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtMethodArrayClass)); + } else if (descriptor == class_roots_descriptors_[kJavaLangReflectArtFieldArrayClass]) { + new_class.reset(GetClassRoot(kJavaLangReflectArtFieldArrayClass)); } else if (descriptor == "[C") { new_class.reset(GetClassRoot(kCharArrayClass)); } else if (descriptor == "[I") { @@ -2428,7 +2377,7 @@ void ClassLinker::ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mir } void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, - mirror::AbstractMethod* method) { + mirror::ArtMethod* method) { // similar to DexVerifier::ScanTryCatchBlocks and dex2oat's ResolveExceptionsForMethod. const DexFile::CodeItem* code_item = dex_file.GetCodeItem(method->GetCodeItemOffset()); if (code_item == NULL) { @@ -2457,14 +2406,14 @@ void ClassLinker::ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, } } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor); -static void CheckProxyMethod(mirror::AbstractMethod* method, - SirtRef& prototype); +static void CheckProxyConstructor(mirror::ArtMethod* constructor); +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef& prototype); mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, mirror::ObjectArray* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray* methods, + mirror::ObjectArray* methods, mirror::ObjectArray >* throws) { Thread* self = Thread::Current(); SirtRef klass(self, AllocClass(self, GetClassRoot(kJavaLangClass), @@ -2484,30 +2433,30 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, klass->SetDexTypeIndex(DexFile::kDexNoIndex16); // Instance fields are inherited, but we add a couple of static fields... - klass->SetSFields(AllocFieldArray(self, 2)); + klass->SetSFields(AllocArtFieldArray(self, 2)); // 1. Create a static field 'interfaces' that holds the _declared_ interfaces implemented by // our proxy, so Class.getInterfaces doesn't return the flattened set. - SirtRef interfaces_sfield(self, AllocField(self)); + SirtRef interfaces_sfield(self, AllocArtField(self)); klass->SetStaticField(0, interfaces_sfield.get()); interfaces_sfield->SetDexFieldIndex(0); interfaces_sfield->SetDeclaringClass(klass.get()); interfaces_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // 2. Create a static field 'throws' that holds exceptions thrown by our methods. - SirtRef throws_sfield(self, AllocField(self)); + SirtRef throws_sfield(self, AllocArtField(self)); klass->SetStaticField(1, throws_sfield.get()); throws_sfield->SetDexFieldIndex(1); throws_sfield->SetDeclaringClass(klass.get()); throws_sfield->SetAccessFlags(kAccStatic | kAccPublic | kAccFinal); // Proxies have 1 direct method, the constructor - klass->SetDirectMethods(AllocAbstractMethodArray(self, 1)); + klass->SetDirectMethods(AllocArtMethodArray(self, 1)); klass->SetDirectMethod(0, CreateProxyConstructor(self, klass, proxy_class)); // Create virtual method using specified prototypes size_t num_virtual_methods = methods->GetLength(); - klass->SetVirtualMethods(AllocMethodArray(self, num_virtual_methods)); + klass->SetVirtualMethods(AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef prototype(self, methods->Get(i)); + SirtRef prototype(self, methods->Get(i)); klass->SetVirtualMethod(i, CreateProxyMethod(self, klass, prototype)); } @@ -2532,7 +2481,7 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, CHECK(klass->GetIFields() == NULL); CheckProxyConstructor(klass->GetDirectMethod(0)); for (size_t i = 0; i < num_virtual_methods; ++i) { - SirtRef prototype(self, methods->Get(i)); + SirtRef prototype(self, methods->Get(i)); CheckProxyMethod(klass->GetVirtualMethod(i), prototype); } @@ -2559,8 +2508,8 @@ std::string ClassLinker::GetDescriptorForProxy(const mirror::Class* proxy_class) return DotToDescriptor(name->ToModifiedUtf8().c_str()); } -mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) { +mirror::ArtMethod* ClassLinker::FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) { DCHECK(proxy_class->IsProxyClass()); DCHECK(proxy_method->IsProxyMethod()); // Locate the dex cache of the original interface/Object @@ -2577,31 +2526,31 @@ mirror::AbstractMethod* ClassLinker::FindMethodForProxy(const mirror::Class* pro } CHECK(dex_cache != NULL); uint32_t method_idx = proxy_method->GetDexMethodIndex(); - mirror::AbstractMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved_method = dex_cache->GetResolvedMethod(method_idx); CHECK(resolved_method != NULL); return resolved_method; } -mirror::AbstractMethod* ClassLinker::CreateProxyConstructor(Thread* self, - SirtRef& klass, - mirror::Class* proxy_class) { +mirror::ArtMethod* ClassLinker::CreateProxyConstructor(Thread* self, + SirtRef& klass, + mirror::Class* proxy_class) { // Create constructor for Proxy that must initialize h - mirror::ObjectArray* proxy_direct_methods = + mirror::ObjectArray* proxy_direct_methods = proxy_class->GetDirectMethods(); - CHECK_EQ(proxy_direct_methods->GetLength(), 15); - mirror::AbstractMethod* proxy_constructor = proxy_direct_methods->Get(2); + CHECK_EQ(proxy_direct_methods->GetLength(), 16); + mirror::ArtMethod* proxy_constructor = proxy_direct_methods->Get(2); // Clone the existing constructor of Proxy (our constructor would just invoke it so steal its // code_ too) - mirror::AbstractMethod* constructor = - down_cast(proxy_constructor->Clone(self)); + mirror::ArtMethod* constructor = + down_cast(proxy_constructor->Clone(self)); // Make this constructor public and fix the class to be our Proxy version constructor->SetAccessFlags((constructor->GetAccessFlags() & ~kAccProtected) | kAccPublic); constructor->SetDeclaringClass(klass.get()); return constructor; } -static void CheckProxyConstructor(mirror::AbstractMethod* constructor) +static void CheckProxyConstructor(mirror::ArtMethod* constructor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(constructor->IsConstructor()); MethodHelper mh(constructor); @@ -2610,15 +2559,15 @@ static void CheckProxyConstructor(mirror::AbstractMethod* constructor) DCHECK(constructor->IsPublic()); } -mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& klass, - SirtRef& prototype) { +mirror::ArtMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& klass, + SirtRef& prototype) { // Ensure prototype is in dex cache so that we can use the dex cache to look up the overridden // prototype method prototype->GetDeclaringClass()->GetDexCache()->SetResolvedMethod(prototype->GetDexMethodIndex(), prototype.get()); // We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize // as necessary - mirror::AbstractMethod* method = down_cast(prototype->Clone(self)); + mirror::ArtMethod* method = down_cast(prototype->Clone(self)); // Set class to be the concrete proxy class and clear the abstract flag, modify exceptions to // the intersection of throw exceptions as defined in Proxy @@ -2627,7 +2576,7 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRefGetCalleeSaveMethod(Runtime::kRefsAndArgs); method->SetCoreSpillMask(refs_and_args->GetCoreSpillMask()); method->SetFpSpillMask(refs_and_args->GetFpSpillMask()); @@ -2638,8 +2587,8 @@ mirror::AbstractMethod* ClassLinker::CreateProxyMethod(Thread* self, SirtRef& prototype) +static void CheckProxyMethod(mirror::ArtMethod* method, + SirtRef& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Basic sanity CHECK(!prototype->IsFinal()); @@ -2669,7 +2618,7 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo Thread* self = Thread::Current(); - mirror::AbstractMethod* clinit = NULL; + mirror::ArtMethod* clinit = NULL; { // see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol ObjectLock lock(self, klass); @@ -2842,7 +2791,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { klass->GetClassLoader() != klass->GetSuperClass()->GetClassLoader()) { const mirror::Class* super = klass->GetSuperClass(); for (int i = super->GetVTable()->GetLength() - 1; i >= 0; --i) { - const mirror::AbstractMethod* method = klass->GetVTable()->Get(i); + const mirror::ArtMethod* method = klass->GetVTable()->Get(i); if (method != super->GetVTable()->Get(i) && !IsSameMethodSignatureInDifferentClassContexts(method, super, klass)) { ThrowLinkageError(klass, "Class %s method %s resolves differently in superclass %s", @@ -2857,7 +2806,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { mirror::Class* interface = iftable->GetInterface(i); if (klass->GetClassLoader() != interface->GetClassLoader()) { for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - const mirror::AbstractMethod* method = iftable->GetMethodArray(i)->Get(j); + const mirror::ArtMethod* method = iftable->GetMethodArray(i)->Get(j); if (!IsSameMethodSignatureInDifferentClassContexts(method, interface, method->GetDeclaringClass())) { ThrowLinkageError(klass, "Class %s method %s resolves differently in interface %s", @@ -2874,7 +2823,7 @@ bool ClassLinker::ValidateSuperClassDescriptors(const mirror::Class* klass) { // Returns true if classes referenced by the signature of the method are the // same classes in klass1 as they are in klass2. -bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, +bool ClassLinker::IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) { if (klass1 == klass2) { @@ -2969,7 +2918,7 @@ bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool } void ClassLinker::ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap& field_map) { + mirror::Class* c, SafeMap& field_map) { mirror::ClassLoader* cl = c->GetClassLoader(); const byte* class_data = dex_file.GetClassData(dex_class_def); ClassDataItemIterator it(dex_file, class_data); @@ -2997,7 +2946,7 @@ bool ClassLinker::InitializeStaticFields(mirror::Class* klass) { if (it.HasNext()) { // We reordered the fields, so we need to be able to map the field indexes to the right fields. - SafeMap field_map; + SafeMap field_map; ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); for (size_t i = 0; it.HasNext(); i++, it.Next()) { it.ReadValueToField(field_map.Get(i)); @@ -3161,17 +3110,17 @@ bool ClassLinker::LinkVirtualMethods(SirtRef& klass) { size_t actual_count = klass->GetSuperClass()->GetVTable()->GetLength(); CHECK_LE(actual_count, max_count); // TODO: do not assign to the vtable field until it is fully constructed. - SirtRef > + SirtRef > vtable(self, klass->GetSuperClass()->GetVTable()->CopyOf(self, max_count)); // See if any of our virtual methods override the superclass. MethodHelper local_mh(NULL, this); MethodHelper super_mh(NULL, this); for (size_t i = 0; i < klass->NumVirtualMethods(); ++i) { - mirror::AbstractMethod* local_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* local_method = klass->GetVirtualMethodDuringLinking(i); local_mh.ChangeMethod(local_method); size_t j = 0; for (; j < actual_count; ++j) { - mirror::AbstractMethod* super_method = vtable->Get(j); + mirror::ArtMethod* super_method = vtable->Get(j); super_mh.ChangeMethod(super_method); if (local_mh.HasSameNameAndSignature(&super_mh)) { if (klass->CanAccessMember(super_method->GetDeclaringClass(), super_method->GetAccessFlags())) { @@ -3215,10 +3164,10 @@ bool ClassLinker::LinkVirtualMethods(SirtRef& klass) { ThrowClassFormatError(klass.get(), "Too many methods: %d", num_virtual_methods); return false; } - SirtRef > - vtable(self, AllocMethodArray(self, num_virtual_methods)); + SirtRef > + vtable(self, AllocArtMethodArray(self, num_virtual_methods)); for (size_t i = 0; i < num_virtual_methods; ++i) { - mirror::AbstractMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); + mirror::ArtMethod* virtual_method = klass->GetVirtualMethodDuringLinking(i); vtable->Set(i, virtual_method); virtual_method->SetMethodIndex(i & 0xFFFF); } @@ -3328,19 +3277,19 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, if (klass->IsInterface()) { return true; } - std::vector miranda_list; + std::vector miranda_list; MethodHelper vtable_mh(NULL, this); MethodHelper interface_mh(NULL, this); for (size_t i = 0; i < ifcount; ++i) { mirror::Class* interface = iftable->GetInterface(i); size_t num_methods = interface->NumVirtualMethods(); if (num_methods > 0) { - mirror::ObjectArray* method_array = - AllocMethodArray(self, num_methods); + mirror::ObjectArray* method_array = + AllocArtMethodArray(self, num_methods); iftable->SetMethodArray(i, method_array); - mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); for (size_t j = 0; j < num_methods; ++j) { - mirror::AbstractMethod* interface_method = interface->GetVirtualMethod(j); + mirror::ArtMethod* interface_method = interface->GetVirtualMethod(j); interface_mh.ChangeMethod(interface_method); int32_t k; // For each method listed in the interface's method list, find the @@ -3352,7 +3301,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, // those don't end up in the virtual method table, so it shouldn't // matter which direction we go. We walk it backward anyway.) for (k = vtable->GetLength() - 1; k >= 0; --k) { - mirror::AbstractMethod* vtable_method = vtable->Get(k); + mirror::ArtMethod* vtable_method = vtable->Get(k); vtable_mh.ChangeMethod(vtable_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { if (!vtable_method->IsAbstract() && !vtable_method->IsPublic()) { @@ -3367,9 +3316,9 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, } } if (k < 0) { - SirtRef miranda_method(self, NULL); + SirtRef miranda_method(self, NULL); for (size_t mir = 0; mir < miranda_list.size(); mir++) { - mirror::AbstractMethod* mir_method = miranda_list[mir]; + mirror::ArtMethod* mir_method = miranda_list[mir]; vtable_mh.ChangeMethod(mir_method); if (interface_mh.HasSameNameAndSignature(&vtable_mh)) { miranda_method.reset(miranda_list[mir]); @@ -3378,7 +3327,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, } if (miranda_method.get() == NULL) { // point the interface table at a phantom slot - miranda_method.reset(down_cast(interface_method->Clone(self))); + miranda_method.reset(down_cast(interface_method->Clone(self))); miranda_list.push_back(miranda_method.get()); } method_array->Set(j, miranda_method.get()); @@ -3390,17 +3339,17 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, int old_method_count = klass->NumVirtualMethods(); int new_method_count = old_method_count + miranda_list.size(); klass->SetVirtualMethods((old_method_count == 0) - ? AllocMethodArray(self, new_method_count) + ? AllocArtMethodArray(self, new_method_count) : klass->GetVirtualMethods()->CopyOf(self, new_method_count)); - SirtRef > + SirtRef > vtable(self, klass->GetVTableDuringLinking()); CHECK(vtable.get() != NULL); int old_vtable_count = vtable->GetLength(); int new_vtable_count = old_vtable_count + miranda_list.size(); vtable.reset(vtable->CopyOf(self, new_vtable_count)); for (size_t i = 0; i < miranda_list.size(); ++i) { - mirror::AbstractMethod* method = miranda_list[i]; + mirror::ArtMethod* method = miranda_list[i]; // Leave the declaring class alone as type indices are relative to it method->SetAccessFlags(method->GetAccessFlags() | kAccMiranda); method->SetMethodIndex(0xFFFF & (old_vtable_count + i)); @@ -3411,7 +3360,7 @@ bool ClassLinker::LinkInterfaceMethods(SirtRef& klass, klass->SetVTable(vtable.get()); } - mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); + mirror::ObjectArray* vtable = klass->GetVTableDuringLinking(); for (int i = 0; i < vtable->GetLength(); ++i) { CHECK(vtable->Get(i) != NULL); } @@ -3439,7 +3388,7 @@ struct LinkFieldsComparator { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : fh_(fh) {} // No thread safety analysis as will be called from STL. Checked lock held in constructor. - bool operator()(const mirror::Field* field1, const mirror::Field* field2) + bool operator()(const mirror::ArtField* field1, const mirror::ArtField* field2) NO_THREAD_SAFETY_ANALYSIS { // First come reference fields, then 64-bit, and finally 32-bit fh_->ChangeField(field1); @@ -3471,7 +3420,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { size_t num_fields = is_static ? klass->NumStaticFields() : klass->NumInstanceFields(); - mirror::ObjectArray* fields = + mirror::ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // Initialize size and field_offset @@ -3493,7 +3442,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // we want a relatively stable order so that adding new fields // minimizes disruption of C++ version such as Class and Method. - std::deque grouped_and_sorted_fields; + std::deque grouped_and_sorted_fields; for (size_t i = 0; i < num_fields; i++) { grouped_and_sorted_fields.push_back(fields->Get(i)); } @@ -3506,7 +3455,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { size_t current_field = 0; size_t num_reference_fields = 0; for (; current_field < num_fields; current_field++) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); bool isPrimitive = type != Primitive::kPrimNot; @@ -3525,7 +3474,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // into place. If we can't find one, we'll have to pad it. if (current_field != num_fields && !IsAligned<8>(field_offset.Uint32Value())) { for (size_t i = 0; i < grouped_and_sorted_fields.size(); i++) { - mirror::Field* field = grouped_and_sorted_fields[i]; + mirror::ArtField* field = grouped_and_sorted_fields[i]; fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); CHECK(type != Primitive::kPrimNot); // should only be working on primitive types @@ -3546,7 +3495,7 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // finish assigning field offsets to all fields. DCHECK(current_field == num_fields || IsAligned<8>(field_offset.Uint32Value())); while (!grouped_and_sorted_fields.empty()) { - mirror::Field* field = grouped_and_sorted_fields.front(); + mirror::ArtField* field = grouped_and_sorted_fields.front(); grouped_and_sorted_fields.pop_front(); fh.ChangeField(field); Primitive::Type type = fh.GetTypeAsPrimitiveType(); @@ -3576,12 +3525,12 @@ bool ClassLinker::LinkFields(SirtRef& klass, bool is_static) { // non-reference fields, and all double-wide fields are aligned. bool seen_non_ref = false; for (size_t i = 0; i < num_fields; i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); if (false) { // enable to debug field layout LOG(INFO) << "LinkFields: " << (is_static ? "static" : "instance") << " class=" << PrettyClass(klass.get()) << " field=" << PrettyField(field) - << " offset=" << field->GetField32(MemberOffset(mirror::Field::OffsetOffset()), + << " offset=" << field->GetField32(MemberOffset(mirror::ArtField::OffsetOffset()), false); } fh.ChangeField(field); @@ -3644,14 +3593,14 @@ void ClassLinker::CreateReferenceOffsets(SirtRef& klass, bool is_ size_t num_reference_fields = is_static ? klass->NumReferenceStaticFieldsDuringLinking() : klass->NumReferenceInstanceFieldsDuringLinking(); - const mirror::ObjectArray* fields = + const mirror::ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); // All of the fields that contain object references are guaranteed // to be at the beginning of the fields list. for (size_t i = 0; i < num_reference_fields; ++i) { // Note that byte_offset is the offset from the beginning of // object, not the offset into instance data - const mirror::Field* field = fields->Get(i); + const mirror::ArtField* field = fields->Get(i); MemberOffset byte_offset = field->GetOffsetDuringLinking(); CHECK_EQ(byte_offset.Uint32Value() & (CLASS_OFFSET_ALIGNMENT - 1), 0U); if (CLASS_CAN_ENCODE_OFFSET(byte_offset.Uint32Value())) { @@ -3716,15 +3665,15 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, return resolved; } -mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, +mirror::ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, uint32_t method_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, InvokeType type) { DCHECK(dex_cache != NULL); // Check for hit in the dex cache. - mirror::AbstractMethod* resolved = dex_cache->GetResolvedMethod(method_idx); + mirror::ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx); if (resolved != NULL) { return resolved; } @@ -3863,13 +3812,13 @@ mirror::AbstractMethod* ClassLinker::ResolveMethod(const DexFile& dex_file, } } -mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveField(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, bool is_static) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3903,12 +3852,12 @@ mirror::Field* ClassLinker::ResolveField(const DexFile& dex_file, return resolved; } -mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, +mirror::ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader) { DCHECK(dex_cache != NULL); - mirror::Field* resolved = dex_cache->GetResolvedField(field_idx); + mirror::ArtField* resolved = dex_cache->GetResolvedField(field_idx); if (resolved != NULL) { return resolved; } @@ -3930,7 +3879,7 @@ mirror::Field* ClassLinker::ResolveFieldJLS(const DexFile& dex_file, return resolved; } -const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, +const char* ClassLinker::MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) { mirror::Class* declaring_class = referrer->GetDeclaringClass(); mirror::DexCache* dex_cache = declaring_class->GetDexCache(); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 67be2ff028..d0cc562ca5 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -106,7 +106,7 @@ class ClassLinker { // Resolve a String with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::String* ResolveString(uint32_t string_idx, const mirror::AbstractMethod* referrer) + mirror::String* ResolveString(uint32_t string_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a String with the given index from the DexFile, storing the @@ -130,10 +130,10 @@ class ClassLinker { // Resolve a Type with the given index from the DexFile, storing the // result in the DexCache. The referrer is used to identify the // target DexCache and ClassLoader to use for resolution. - mirror::Class* ResolveType(uint16_t type_idx, const mirror::AbstractMethod* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Class* ResolveType(uint16_t type_idx, const mirror::Field* referrer) + mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a type with the given ID from the DexFile, storing the @@ -151,20 +151,20 @@ class ClassLinker { // in ResolveType. What is unique is the method type argument which // is used to determine if this method is a direct, static, or // virtual method. - mirror::AbstractMethod* ResolveMethod(const DexFile& dex_file, - uint32_t method_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(const DexFile& dex_file, + uint32_t method_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* ResolveMethod(uint32_t method_idx, const mirror::AbstractMethod* referrer, - InvokeType type) + mirror::ArtMethod* ResolveMethod(uint32_t method_idx, const mirror::ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* ResolveField(uint32_t field_idx, const mirror::AbstractMethod* referrer, - bool is_static) + mirror::ArtField* ResolveField(uint32_t field_idx, const mirror::ArtMethod* referrer, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the @@ -172,25 +172,25 @@ class ClassLinker { // in ResolveType. What is unique is the is_static argument which is // used to determine if we are resolving a static or non-static // field. - mirror::Field* ResolveField(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, - bool is_static) + mirror::ArtField* ResolveField(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader, + bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the // result in DexCache. The ClassLinker and ClassLoader are used as // in ResolveType. No is_static argument is provided so that Java // field resolution semantics are followed. - mirror::Field* ResolveFieldJLS(const DexFile& dex_file, - uint32_t field_idx, - mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader) + mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, + uint32_t field_idx, + mirror::DexCache* dex_cache, + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get shorty from method index without resolution. Used to do handlerization. - const char* MethodShorty(uint32_t method_idx, mirror::AbstractMethod* referrer, uint32_t* length) + const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns true on success, false if there's an exception pending. @@ -232,7 +232,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsDexFileRegistered(const DexFile& dex_file) const LOCKS_EXCLUDED(dex_lock_); - void FixupDexCaches(mirror::AbstractMethod* resolution_method) const + void FixupDexCaches(mirror::ArtMethod* resolution_method) const LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -283,16 +283,13 @@ class ClassLinker { mirror::ObjectArray* AllocStringArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray* AllocAbstractMethodArray(Thread* self, size_t length) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - mirror::ObjectArray* AllocMethodArray(Thread* self, size_t length) + mirror::ObjectArray* AllocArtMethodArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray* AllocFieldArray(Thread* self, size_t length) + mirror::ObjectArray* AllocArtFieldArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::ObjectArray* AllocStackTraceElementArray(Thread* self, @@ -305,23 +302,23 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::AbstractMethod* klass) + void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreateProxyClass(mirror::String* name, mirror::ObjectArray* interfaces, mirror::ClassLoader* loader, - mirror::ObjectArray* methods, + mirror::ObjectArray* methods, mirror::ObjectArray >* throws) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string GetDescriptorForProxy(const mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindMethodForProxy(const mirror::Class* proxy_class, - const mirror::AbstractMethod* proxy_method) + mirror::ArtMethod* FindMethodForProxy(const mirror::Class* proxy_class, + const mirror::ArtMethod* proxy_method) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method when its class isn't yet initialized - const void* GetOatCodeFor(const mirror::AbstractMethod* method) + const void* GetOatCodeFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method from a method index. @@ -361,7 +358,7 @@ class ClassLinker { private: explicit ClassLinker(InternTable*); - const OatFile::OatMethod GetOatMethodFor(const mirror::AbstractMethod* method) + const OatFile::OatMethod GetOatMethodFor(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Initialize class linker by bootstraping from dex files @@ -386,9 +383,8 @@ class ClassLinker { mirror::Class* AllocClass(Thread* self, size_t class_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* AllocField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Method* AllocMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Constructor* AllocConstructor(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* AllocArtField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -405,7 +401,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, - mirror::Class* c, SafeMap& field_map) + mirror::Class* c, SafeMap& field_map) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t SizeOfClass(const DexFile& dex_file, @@ -418,12 +414,12 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it, - SirtRef& klass, SirtRef& dst) + SirtRef& klass, SirtRef& dst) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* LoadMethod(Thread* self, const DexFile& dex_file, - const ClassDataItemIterator& dex_method, - SirtRef& klass) + mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file, + const ClassDataItemIterator& dex_method, + SirtRef& klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -455,7 +451,7 @@ class ClassLinker { const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsSameMethodSignatureInDifferentClassContexts(const mirror::AbstractMethod* method, + bool IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, const mirror::Class* klass1, const mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -519,11 +515,11 @@ class ClassLinker { EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyConstructor(Thread* self, SirtRef& klass, - mirror::Class* proxy_class) + mirror::ArtMethod* CreateProxyConstructor(Thread* self, SirtRef& klass, + mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateProxyMethod(Thread* self, SirtRef& klass, - SirtRef& prototype) + mirror::ArtMethod* CreateProxyMethod(Thread* self, SirtRef& klass, + SirtRef& prototype) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::vector boot_class_path_; @@ -554,15 +550,12 @@ class ClassLinker { kJavaLangString, kJavaLangDexCache, kJavaLangRefReference, - kJavaLangReflectConstructor, - kJavaLangReflectField, - kJavaLangReflectAbstractMethod, - kJavaLangReflectMethod, + kJavaLangReflectArtField, + kJavaLangReflectArtMethod, kJavaLangReflectProxy, kJavaLangStringArrayClass, - kJavaLangReflectAbstractMethodArrayClass, - kJavaLangReflectFieldArrayClass, - kJavaLangReflectMethodArrayClass, + kJavaLangReflectArtFieldArrayClass, + kJavaLangReflectArtMethodArrayClass, kJavaLangClassLoader, kJavaLangThrowable, kJavaLangClassNotFoundException, diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 4659fd1982..6442f5ad63 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -24,42 +24,17 @@ #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" #include "gc/heap.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "mirror/stack_trace_element.h" #include "sirt_ref.h" -using ::art::mirror::AbstractMethod; -using ::art::mirror::AbstractMethodClass; -using ::art::mirror::CharArray; -using ::art::mirror::Class; -using ::art::mirror::ClassClass; -using ::art::mirror::ClassLoader; -using ::art::mirror::Constructor; -using ::art::mirror::DexCache; -using ::art::mirror::DoubleArray; -using ::art::mirror::Field; -using ::art::mirror::FieldClass; -using ::art::mirror::IfTable; -using ::art::mirror::IntArray; -using ::art::mirror::LongArray; -using ::art::mirror::Method; -using ::art::mirror::Object; -using ::art::mirror::ObjectArray; -using ::art::mirror::Proxy; -using ::art::mirror::ShortArray; -using ::art::mirror::StackTraceElement; -using ::art::mirror::StaticStorageBase; -using ::art::mirror::String; -using ::art::mirror::StringClass; -using ::art::mirror::Throwable; - namespace art { class ClassLinkerTest : public CommonTest { @@ -69,9 +44,9 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(class_linker_->FindSystemClass(descriptor.c_str()) == NULL); Thread* self = Thread::Current(); EXPECT_TRUE(self->IsExceptionPending()); - Object* exception = self->GetException(NULL); + mirror::Object* exception = self->GetException(NULL); self->ClearException(); - Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); + mirror::Class* exception_class = class_linker_->FindSystemClass("Ljava/lang/NoClassDefFoundError;"); EXPECT_TRUE(exception->InstanceOf(exception_class)); } @@ -80,7 +55,7 @@ class ClassLinkerTest : public CommonTest { AssertPrimitiveClass(descriptor, class_linker_->FindSystemClass(descriptor.c_str())); } - void AssertPrimitiveClass(const std::string& descriptor, const Class* primitive) + void AssertPrimitiveClass(const std::string& descriptor, const mirror::Class* primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper primitive_ch(primitive); ASSERT_TRUE(primitive != NULL); @@ -91,7 +66,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(primitive->GetSuperClass() == NULL); EXPECT_FALSE(primitive->HasSuperClass()); EXPECT_TRUE(primitive->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusInitialized, primitive->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, primitive->GetStatus()); EXPECT_FALSE(primitive->IsErroneous()); EXPECT_TRUE(primitive->IsLoaded()); EXPECT_TRUE(primitive->IsResolved()); @@ -118,9 +93,9 @@ class ClassLinkerTest : public CommonTest { void AssertArrayClass(const std::string& array_descriptor, const std::string& component_type, - ClassLoader* class_loader) + mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); + mirror::Class* array = class_linker_->FindClass(array_descriptor.c_str(), class_loader); ClassHelper array_component_ch(array->GetComponentType()); EXPECT_STREQ(component_type.c_str(), array_component_ch.GetDescriptor()); EXPECT_EQ(class_loader, array->GetClassLoader()); @@ -128,7 +103,7 @@ class ClassLinkerTest : public CommonTest { AssertArrayClass(array_descriptor, array); } - void AssertArrayClass(const std::string& array_descriptor, Class* array) + void AssertArrayClass(const std::string& array_descriptor, mirror::Class* array) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(array); ASSERT_TRUE(array != NULL); @@ -142,7 +117,7 @@ class ClassLinkerTest : public CommonTest { ASSERT_TRUE(array->GetComponentType() != NULL); kh.ChangeClass(array->GetComponentType()); ASSERT_TRUE(kh.GetDescriptor() != NULL); - EXPECT_EQ(Class::kStatusInitialized, array->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, array->GetStatus()); EXPECT_FALSE(array->IsErroneous()); EXPECT_TRUE(array->IsLoaded()); EXPECT_TRUE(array->IsResolved()); @@ -163,7 +138,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_EQ(2U, kh.NumDirectInterfaces()); EXPECT_TRUE(array->GetVTable() != NULL); EXPECT_EQ(2, array->GetIfTableCount()); - IfTable* iftable = array->GetIfTable(); + mirror::IfTable* iftable = array->GetIfTable(); ASSERT_TRUE(iftable != NULL); kh.ChangeClass(kh.GetDirectInterface(0)); EXPECT_STREQ(kh.GetDescriptor(), "Ljava/lang/Cloneable;"); @@ -172,7 +147,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_STREQ(kh.GetDescriptor(), "Ljava/io/Serializable;"); } - void AssertMethod(AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void AssertMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(method); EXPECT_TRUE(method != NULL); EXPECT_TRUE(method->GetClass() != NULL); @@ -193,7 +168,7 @@ class ClassLinkerTest : public CommonTest { method->GetDexCacheInitializedStaticStorage()); } - void AssertField(Class* klass, Field* field) + void AssertField(mirror::Class* klass, mirror::ArtField* field) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FieldHelper fh(field); EXPECT_TRUE(field != NULL); @@ -203,7 +178,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(fh.GetType() != NULL); } - void AssertClass(const std::string& descriptor, Class* klass) + void AssertClass(const std::string& descriptor, mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassHelper kh(klass); EXPECT_STREQ(descriptor.c_str(), kh.GetDescriptor()); @@ -222,7 +197,7 @@ class ClassLinkerTest : public CommonTest { EXPECT_FALSE(klass->IsArrayClass()); EXPECT_TRUE(klass->GetComponentType() == NULL); EXPECT_TRUE(klass->IsInSamePackage(klass)); - EXPECT_TRUE(Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); + EXPECT_TRUE(mirror::Class::IsInSamePackage(kh.GetDescriptor(), kh.GetDescriptor())); if (klass->IsInterface()) { EXPECT_TRUE(klass->IsAbstract()); if (klass->NumDirectMethods() == 1) { @@ -238,9 +213,9 @@ class ClassLinkerTest : public CommonTest { } } EXPECT_EQ(klass->IsInterface(), klass->GetVTable() == NULL); - const IfTable* iftable = klass->GetIfTable(); + const mirror::IfTable* iftable = klass->GetIfTable(); for (int i = 0; i < klass->GetIfTableCount(); i++) { - Class* interface = iftable->GetInterface(i); + mirror::Class* interface = iftable->GetInterface(i); ASSERT_TRUE(interface != NULL); if (klass->IsInterface()) { EXPECT_EQ(0U, iftable->GetMethodArrayCount(i)); @@ -266,27 +241,27 @@ class ClassLinkerTest : public CommonTest { EXPECT_TRUE(klass->CanAccess(klass)); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); AssertMethod(method); EXPECT_TRUE(method->IsDirect()); EXPECT_EQ(klass, method->GetDeclaringClass()); } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); AssertMethod(method); EXPECT_FALSE(method->IsDirect()); EXPECT_TRUE(method->GetDeclaringClass()->IsAssignableFrom(klass)); } for (size_t i = 0; i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); AssertField(klass, field); EXPECT_FALSE(field->IsStatic()); } for (size_t i = 0; i < klass->NumStaticFields(); i++) { - Field* field = klass->GetStaticField(i); + mirror::ArtField* field = klass->GetStaticField(i); AssertField(klass, field); EXPECT_TRUE(field->IsStatic()); } @@ -295,17 +270,17 @@ class ClassLinkerTest : public CommonTest { EXPECT_GE(klass->NumInstanceFields(), klass->NumReferenceInstanceFields()); FieldHelper fh; for (size_t i = 0; i < klass->NumReferenceInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); ASSERT_TRUE(!fh.IsPrimitiveType()); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); ASSERT_TRUE(!field_type->IsPrimitive()); } for (size_t i = klass->NumReferenceInstanceFields(); i < klass->NumInstanceFields(); i++) { - Field* field = klass->GetInstanceField(i); + mirror::ArtField* field = klass->GetInstanceField(i); fh.ChangeField(field); - Class* field_type = fh.GetType(); + mirror::Class* field_type = fh.GetType(); ASSERT_TRUE(field_type != NULL); if (!fh.IsPrimitiveType() || !field_type->IsPrimitive()) { // While Reference.referent is not primitive, the ClassLinker @@ -315,7 +290,7 @@ class ClassLinkerTest : public CommonTest { } size_t total_num_reference_instance_fields = 0; - Class* k = klass; + mirror::Class* k = klass; while (k != NULL) { total_num_reference_instance_fields += k->NumReferenceInstanceFields(); k = k->GetSuperClass(); @@ -324,10 +299,10 @@ class ClassLinkerTest : public CommonTest { total_num_reference_instance_fields == 0); } - void AssertDexFileClass(ClassLoader* class_loader, const std::string& descriptor) + void AssertDexFileClass(mirror::ClassLoader* class_loader, const std::string& descriptor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(descriptor != NULL); - Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); + mirror::Class* klass = class_linker_->FindSystemClass(descriptor.c_str()); ASSERT_TRUE(klass != NULL); EXPECT_STREQ(descriptor.c_str(), ClassHelper(klass).GetDescriptor()); EXPECT_EQ(class_loader, klass->GetClassLoader()); @@ -340,7 +315,7 @@ class ClassLinkerTest : public CommonTest { } } - void AssertDexFile(const DexFile* dex, ClassLoader* class_loader) + void AssertDexFile(const DexFile* dex, mirror::ClassLoader* class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ASSERT_TRUE(dex != NULL); @@ -358,14 +333,14 @@ class ClassLinkerTest : public CommonTest { } class_linker_->VisitRoots(TestRootVisitor, NULL, false); // Verify the dex cache has resolution methods in all resolved method slots - DexCache* dex_cache = class_linker_->FindDexCache(*dex); - ObjectArray* resolved_methods = dex_cache->GetResolvedMethods(); + mirror::DexCache* dex_cache = class_linker_->FindDexCache(*dex); + mirror::ObjectArray* resolved_methods = dex_cache->GetResolvedMethods(); for (size_t i = 0; i < static_cast(resolved_methods->GetLength()); i++) { EXPECT_TRUE(resolved_methods->Get(i) != NULL); } } - static void TestRootVisitor(const Object* root, void*) { + static void TestRootVisitor(const mirror::Object* root, void*) { EXPECT_TRUE(root != NULL); } }; @@ -385,7 +360,7 @@ struct CheckOffsets { std::vector offsets; bool Check() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); + mirror::Class* klass = Runtime::Current()->GetClassLinker()->FindSystemClass(class_descriptor.c_str()); CHECK(klass != NULL) << class_descriptor; bool error = false; @@ -412,7 +387,7 @@ struct CheckOffsets { FieldHelper fh; for (size_t i = 0; i < offsets.size(); i++) { - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -422,7 +397,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); fh.ChangeField(field); StringPiece field_name(fh.GetName()); if (field_name != offsets[i].java_name) { @@ -437,7 +412,7 @@ struct CheckOffsets { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { error = true; } @@ -445,7 +420,7 @@ struct CheckOffsets { if (error) { for (size_t i = 0; i < offsets.size(); i++) { CheckOffset& offset = offsets[i]; - Field* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); + mirror::ArtField* field = is_static ? klass->GetStaticField(i) : klass->GetInstanceField(i); if (field->GetOffset().Uint32Value() != offset.cpp_offset) { LOG(ERROR) << "OFFSET MISMATCH NEXT LINE:"; } @@ -464,195 +439,179 @@ struct CheckOffsets { // Note that ClassLinkerTest.ValidateFieldOrderOfJavaCppUnionClasses // is first since if it is failing, others are unlikely to succeed. -struct ObjectOffsets : public CheckOffsets { - ObjectOffsets() : CheckOffsets(false, "Ljava/lang/Object;") { +struct ObjectOffsets : public CheckOffsets { + ObjectOffsets() : CheckOffsets(false, "Ljava/lang/Object;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, klass_), "shadow$_klass_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, klass_), "shadow$_klass_")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Object, monitor_), "shadow$_monitor_")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Object, monitor_), "shadow$_monitor_")); }; }; -struct FieldOffsets : public CheckOffsets { - FieldOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Field;") { +struct ArtFieldOffsets : public CheckOffsets { + ArtFieldOffsets() : CheckOffsets(false, "Ljava/lang/reflect/ArtField;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, declaring_class_), "declaringClass")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, field_dex_idx_), "fieldDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Field, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, field_dex_idx_), "fieldDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtField, offset_), "offset")); }; }; -struct AbstractMethodOffsets : public CheckOffsets { - AbstractMethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/AbstractMethod;") { +struct ArtMethodOffsets : public CheckOffsets { + ArtMethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/ArtMethod;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, dex_cache_strings_), "dexCacheStrings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_methods_), "dexCacheResolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_resolved_types_), "dexCacheResolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, dex_cache_strings_), "dexCacheStrings")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, code_item_offset_), "codeItemOffset")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, core_spill_mask_), "coreSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, fp_spill_mask_), "fpSpillMask")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, frame_size_in_bytes_), "frameSizeInBytes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, gc_map_), "gcMap")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, mapping_table_), "mappingTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_dex_index_), "methodDexIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, method_index_), "methodIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, native_method_), "nativeMethod")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethod, vmap_table_), "vmapTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, code_item_offset_), "codeItemOffset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, core_spill_mask_), "coreSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_compiled_code_), "entryPointFromCompiledCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, entry_point_from_interpreter_), "entryPointFromInterpreter")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, fp_spill_mask_), "fpSpillMask")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, frame_size_in_bytes_), "frameSizeInBytes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, gc_map_), "gcMap")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, mapping_table_), "mappingTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_dex_index_), "methodDexIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, method_index_), "methodIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, native_method_), "nativeMethod")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ArtMethod, vmap_table_), "vmapTable")); }; }; -struct ConstructorOffsets : public CheckOffsets { - // java.lang.reflect.Constructor is a subclass of java.lang.reflect.AbstractMethod - ConstructorOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Constructor;") { - } -}; - -struct MethodOffsets : public CheckOffsets { - // java.lang.reflect.Method is a subclass of java.lang.reflect.AbstractMethod - MethodOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Method;") { - } -}; - -struct ClassOffsets : public CheckOffsets { - ClassOffsets() : CheckOffsets(false, "Ljava/lang/Class;") { +struct ClassOffsets : public CheckOffsets { + ClassOffsets() : CheckOffsets(false, "Ljava/lang/Class;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_loader_), "classLoader")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, component_type_), "componentType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_cache_), "dexCache")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, direct_methods_), "directMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, ifields_), "iFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, iftable_), "ifTable")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, name_), "name")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, sfields_), "sFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, super_class_), "superClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, verify_error_class_), "verifyErrorClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, virtual_methods_), "virtualMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, vtable_), "vtable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_loader_), "classLoader")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, component_type_), "componentType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_cache_), "dexCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, direct_methods_), "directMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, ifields_), "iFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, iftable_), "ifTable")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, name_), "name")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, sfields_), "sFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, super_class_), "superClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, verify_error_class_), "verifyErrorClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, virtual_methods_), "virtualMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, vtable_), "vtable")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, access_flags_), "accessFlags")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, class_size_), "classSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, clinit_thread_id_), "clinitThreadId")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, dex_type_idx_), "dexTypeIndex")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_instance_fields_), "numReferenceInstanceFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, num_reference_static_fields_), "numReferenceStaticFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, object_size_), "objectSize")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, primitive_type_), "primitiveType")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_instance_offsets_), "referenceInstanceOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, reference_static_offsets_), "referenceStaticOffsets")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Class, status_), "status")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, access_flags_), "accessFlags")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_size_), "classSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, clinit_thread_id_), "clinitThreadId")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_type_idx_), "dexTypeIndex")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_instance_fields_), "numReferenceInstanceFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_static_fields_), "numReferenceStaticFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, object_size_), "objectSize")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, primitive_type_), "primitiveType")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_instance_offsets_), "referenceInstanceOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, reference_static_offsets_), "referenceStaticOffsets")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, status_), "status")); }; }; -struct StringOffsets : public CheckOffsets { - StringOffsets() : CheckOffsets(false, "Ljava/lang/String;") { +struct StringOffsets : public CheckOffsets { + StringOffsets() : CheckOffsets(false, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, array_), "value")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, array_), "value")); // alphabetical 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, count_), "count")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, hash_code_), "hashCode")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(String, offset_), "offset")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, count_), "count")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, hash_code_), "hashCode")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::String, offset_), "offset")); }; }; -struct ThrowableOffsets : public CheckOffsets { - ThrowableOffsets() : CheckOffsets(false, "Ljava/lang/Throwable;") { +struct ThrowableOffsets : public CheckOffsets { + ThrowableOffsets() : CheckOffsets(false, "Ljava/lang/Throwable;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, cause_), "cause")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, detail_message_), "detailMessage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_state_), "stackState")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, stack_trace_), "stackTrace")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Throwable, suppressed_exceptions_), "suppressedExceptions")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, cause_), "cause")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, detail_message_), "detailMessage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_state_), "stackState")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, stack_trace_), "stackTrace")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Throwable, suppressed_exceptions_), "suppressedExceptions")); }; }; -struct StackTraceElementOffsets : public CheckOffsets { - StackTraceElementOffsets() : CheckOffsets(false, "Ljava/lang/StackTraceElement;") { +struct StackTraceElementOffsets : public CheckOffsets { + StackTraceElementOffsets() : CheckOffsets(false, "Ljava/lang/StackTraceElement;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, declaring_class_), "declaringClass")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, file_name_), "fileName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, method_name_), "methodName")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StackTraceElement, line_number_), "lineNumber")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, declaring_class_), "declaringClass")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, file_name_), "fileName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, method_name_), "methodName")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StackTraceElement, line_number_), "lineNumber")); }; }; -struct ClassLoaderOffsets : public CheckOffsets { - ClassLoaderOffsets() : CheckOffsets(false, "Ljava/lang/ClassLoader;") { +struct ClassLoaderOffsets : public CheckOffsets { + ClassLoaderOffsets() : CheckOffsets(false, "Ljava/lang/ClassLoader;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, packages_), "packages")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, parent_), "parent")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassLoader, proxyCache_), "proxyCache")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, packages_), "packages")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, parent_), "parent")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassLoader, proxyCache_), "proxyCache")); }; }; -struct ProxyOffsets : public CheckOffsets { - ProxyOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Proxy;") { +struct ProxyOffsets : public CheckOffsets { + ProxyOffsets() : CheckOffsets(false, "Ljava/lang/reflect/Proxy;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Proxy, h_), "h")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Proxy, h_), "h")); }; }; -struct ClassClassOffsets : public CheckOffsets { - ClassClassOffsets() : CheckOffsets(true, "Ljava/lang/Class;") { +struct ClassClassOffsets : public CheckOffsets { + ClassClassOffsets() : CheckOffsets(true, "Ljava/lang/Class;") { // padding 32-bit - CHECK_EQ(OFFSETOF_MEMBER(ClassClass, padding_) + 4, - OFFSETOF_MEMBER(ClassClass, serialVersionUID_)); + CHECK_EQ(OFFSETOF_MEMBER(mirror::ClassClass, padding_) + 4, + OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_)); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(ClassClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_), "serialVersionUID")); }; }; -struct StringClassOffsets : public CheckOffsets { - StringClassOffsets() : CheckOffsets(true, "Ljava/lang/String;") { +struct StringClassOffsets : public CheckOffsets { + StringClassOffsets() : CheckOffsets(true, "Ljava/lang/String;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, ASCII_), "ASCII")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, ASCII_), "ASCII")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); // padding 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); // alphabetical 64-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(StringClass, serialVersionUID_), "serialVersionUID")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, serialVersionUID_), "serialVersionUID")); }; }; -struct FieldClassOffsets : public CheckOffsets { - FieldClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/Field;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(FieldClass, ORDER_BY_NAME_AND_DECLARING_CLASS_), "ORDER_BY_NAME_AND_DECLARING_CLASS")); +struct ArtFieldClassOffsets : public CheckOffsets { + ArtFieldClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/ArtField;") { }; }; -struct MethodClassOffsets : public CheckOffsets { - MethodClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/Method;") { - // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(AbstractMethodClass, ORDER_BY_SIGNATURE_), "ORDER_BY_SIGNATURE")); +struct ArtMethodClassOffsets : public CheckOffsets { + ArtMethodClassOffsets() : CheckOffsets(true, "Ljava/lang/reflect/ArtMethod;") { }; }; -struct DexCacheOffsets : public CheckOffsets { - DexCacheOffsets() : CheckOffsets(false, "Ljava/lang/DexCache;") { +struct DexCacheOffsets : public CheckOffsets { + DexCacheOffsets() : CheckOffsets(false, "Ljava/lang/DexCache;") { // alphabetical references - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, initialized_static_storage_), "initializedStaticStorage")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, location_), "location")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_fields_), "resolvedFields")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_methods_), "resolvedMethods")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, resolved_types_), "resolvedTypes")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, strings_), "strings")); - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(DexCache, dex_file_), "dexFile")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, initialized_static_storage_), "initializedStaticStorage")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, location_), "location")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_fields_), "resolvedFields")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_methods_), "resolvedMethods")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_types_), "resolvedTypes")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, strings_), "strings")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_file_), "dexFile")); }; }; @@ -662,10 +621,8 @@ struct DexCacheOffsets : public CheckOffsets { TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { ScopedObjectAccess soa(Thread::Current()); EXPECT_TRUE(ObjectOffsets().Check()); - EXPECT_TRUE(ConstructorOffsets().Check()); - EXPECT_TRUE(MethodOffsets().Check()); - EXPECT_TRUE(FieldOffsets().Check()); - EXPECT_TRUE(AbstractMethodOffsets().Check()); + EXPECT_TRUE(ArtFieldOffsets().Check()); + EXPECT_TRUE(ArtMethodOffsets().Check()); EXPECT_TRUE(ClassOffsets().Check()); EXPECT_TRUE(StringOffsets().Check()); EXPECT_TRUE(ThrowableOffsets().Check()); @@ -676,8 +633,8 @@ TEST_F(ClassLinkerTest, ValidateFieldOrderOfJavaCppUnionClasses) { EXPECT_TRUE(ClassClassOffsets().Check()); EXPECT_TRUE(StringClassOffsets().Check()); - EXPECT_TRUE(FieldClassOffsets().Check()); - EXPECT_TRUE(MethodClassOffsets().Check()); + EXPECT_TRUE(ArtFieldClassOffsets().Check()); + EXPECT_TRUE(ArtMethodClassOffsets().Check()); } TEST_F(ClassLinkerTest, FindClassNonexistent) { @@ -688,14 +645,14 @@ TEST_F(ClassLinkerTest, FindClassNonexistent) { TEST_F(ClassLinkerTest, FindClassNested) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Nested"))); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Nested"))); - Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); + mirror::Class* outer = class_linker_->FindClass("LNested;", class_loader.get()); ASSERT_TRUE(outer != NULL); EXPECT_EQ(0U, outer->NumVirtualMethods()); EXPECT_EQ(1U, outer->NumDirectMethods()); - Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); + mirror::Class* inner = class_linker_->FindClass("LNested$Inner;", class_loader.get()); ASSERT_TRUE(inner != NULL); EXPECT_EQ(0U, inner->NumVirtualMethods()); EXPECT_EQ(1U, inner->NumDirectMethods()); @@ -717,7 +674,7 @@ TEST_F(ClassLinkerTest, FindClass_Primitives) { TEST_F(ClassLinkerTest, FindClass) { ScopedObjectAccess soa(Thread::Current()); - Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); + mirror::Class* JavaLangObject = class_linker_->FindSystemClass("Ljava/lang/Object;"); ClassHelper kh(JavaLangObject); ASSERT_TRUE(JavaLangObject != NULL); ASSERT_TRUE(JavaLangObject->GetClass() != NULL); @@ -727,12 +684,12 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(JavaLangObject->GetSuperClass() == NULL); EXPECT_FALSE(JavaLangObject->HasSuperClass()); EXPECT_TRUE(JavaLangObject->GetClassLoader() == NULL); - EXPECT_EQ(Class::kStatusResolved, JavaLangObject->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusInitialized, JavaLangObject->GetStatus()); EXPECT_FALSE(JavaLangObject->IsErroneous()); EXPECT_TRUE(JavaLangObject->IsLoaded()); EXPECT_TRUE(JavaLangObject->IsResolved()); - EXPECT_FALSE(JavaLangObject->IsVerified()); - EXPECT_FALSE(JavaLangObject->IsInitialized()); + EXPECT_TRUE(JavaLangObject->IsVerified()); + EXPECT_TRUE(JavaLangObject->IsInitialized()); EXPECT_FALSE(JavaLangObject->IsArrayInstance()); EXPECT_FALSE(JavaLangObject->IsArrayClass()); EXPECT_TRUE(JavaLangObject->GetComponentType() == NULL); @@ -752,9 +709,9 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_EQ(0U, JavaLangObject->NumStaticFields()); EXPECT_EQ(0U, kh.NumDirectInterfaces()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("MyClass"))); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("MyClass"))); AssertNonExistentClass("LMyClass;"); - Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); + mirror::Class* MyClass = class_linker_->FindClass("LMyClass;", class_loader.get()); kh.ChangeClass(MyClass); ASSERT_TRUE(MyClass != NULL); ASSERT_TRUE(MyClass->GetClass() != NULL); @@ -764,7 +721,7 @@ TEST_F(ClassLinkerTest, FindClass) { EXPECT_TRUE(MyClass->GetSuperClass() == JavaLangObject); EXPECT_TRUE(MyClass->HasSuperClass()); EXPECT_EQ(class_loader.get(), MyClass->GetClassLoader()); - EXPECT_EQ(Class::kStatusResolved, MyClass->GetStatus()); + EXPECT_EQ(mirror::Class::kStatusResolved, MyClass->GetStatus()); EXPECT_FALSE(MyClass->IsErroneous()); EXPECT_TRUE(MyClass->IsLoaded()); EXPECT_TRUE(MyClass->IsResolved()); @@ -805,12 +762,13 @@ TEST_F(ClassLinkerTest, LibCore) { // start of the object TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); - ObjectArray* array = ObjectArray::Alloc(soa.Self(), array_class, 0); + mirror::Class* array_class = class_linker_->FindSystemClass("[Ljava/lang/String;"); + mirror::ObjectArray* array = + mirror::ObjectArray::Alloc(soa.Self(), array_class, 0); uint32_t array_offset = reinterpret_cast(array); uint32_t data_offset = - array_offset + ObjectArray::DataOffset(sizeof(String*)).Uint32Value(); - if (sizeof(String*) == sizeof(int32_t)) { + array_offset + mirror::ObjectArray::DataOffset(sizeof(mirror::String*)).Uint32Value(); + if (sizeof(mirror::String*) == sizeof(int32_t)) { EXPECT_TRUE(IsAligned<4>(data_offset)); // Check 4 byte alignment. } else { EXPECT_TRUE(IsAligned<8>(data_offset)); // Check 8 byte alignment. @@ -819,27 +777,27 @@ TEST_F(ClassLinkerTest, ValidateObjectArrayElementsOffset) { TEST_F(ClassLinkerTest, ValidatePrimitiveArrayElementsOffset) { ScopedObjectAccess soa(Thread::Current()); - SirtRef long_array(soa.Self(), LongArray::Alloc(soa.Self(), 0)); + SirtRef long_array(soa.Self(), mirror::LongArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[J"), long_array->GetClass()); uintptr_t data_offset = reinterpret_cast(long_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Longs require 8 byte alignment - SirtRef double_array(soa.Self(), DoubleArray::Alloc(soa.Self(), 0)); + SirtRef double_array(soa.Self(), mirror::DoubleArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[D"), double_array->GetClass()); data_offset = reinterpret_cast(double_array->GetData()); EXPECT_TRUE(IsAligned<8>(data_offset)); // Doubles require 8 byte alignment - SirtRef int_array(soa.Self(), IntArray::Alloc(soa.Self(), 0)); + SirtRef int_array(soa.Self(), mirror::IntArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[I"), int_array->GetClass()); data_offset = reinterpret_cast(int_array->GetData()); EXPECT_TRUE(IsAligned<4>(data_offset)); // Ints require 4 byte alignment - SirtRef char_array(soa.Self(), CharArray::Alloc(soa.Self(), 0)); + SirtRef char_array(soa.Self(), mirror::CharArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[C"), char_array->GetClass()); data_offset = reinterpret_cast(char_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Chars require 2 byte alignment - SirtRef short_array(soa.Self(), ShortArray::Alloc(soa.Self(), 0)); + SirtRef short_array(soa.Self(), mirror::ShortArray::Alloc(soa.Self(), 0)); EXPECT_EQ(class_linker_->FindSystemClass("[S"), short_array->GetClass()); data_offset = reinterpret_cast(short_array->GetData()); EXPECT_TRUE(IsAligned<2>(data_offset)); // Shorts require 2 byte alignment @@ -851,7 +809,7 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { // Validate that the "value" field is always the 0th field in each of java.lang's box classes. // This lets UnboxPrimitive avoid searching for the field by name at runtime. ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; c = class_linker_->FindClass("Ljava/lang/Boolean;", NULL); FieldHelper fh(c->GetIFields()->Get(0)); EXPECT_STREQ("value", fh.GetName()); @@ -880,10 +838,10 @@ TEST_F(ClassLinkerTest, ValidateBoxedTypes) { TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader_1(soa.Self(), soa.Decode(LoadDex("MyClass"))); - SirtRef class_loader_2(soa.Self(), soa.Decode(LoadDex("MyClass"))); - Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); - Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); + SirtRef class_loader_1(soa.Self(), soa.Decode(LoadDex("MyClass"))); + SirtRef class_loader_2(soa.Self(), soa.Decode(LoadDex("MyClass"))); + mirror::Class* MyClass_1 = class_linker_->FindClass("LMyClass;", class_loader_1.get()); + mirror::Class* MyClass_2 = class_linker_->FindClass("LMyClass;", class_loader_2.get()); EXPECT_TRUE(MyClass_1 != NULL); EXPECT_TRUE(MyClass_2 != NULL); EXPECT_NE(MyClass_1, MyClass_2); @@ -891,72 +849,72 @@ TEST_F(ClassLinkerTest, TwoClassLoadersOneClass) { TEST_F(ClassLinkerTest, StaticFields) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Statics"))); - Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Statics"))); + mirror::Class* statics = class_linker_->FindClass("LStatics;", class_loader.get()); class_linker_->EnsureInitialized(statics, true, true); // Static final primitives that are initialized by a compile-time constant // expression resolve to a copy of a constant value from the constant pool. // So should be null. - AbstractMethod* clinit = statics->FindDirectMethod("", "()V"); + mirror::ArtMethod* clinit = statics->FindDirectMethod("", "()V"); EXPECT_TRUE(clinit == NULL); EXPECT_EQ(9U, statics->NumStaticFields()); - Field* s0 = statics->FindStaticField("s0", "Z"); + mirror::ArtField* s0 = statics->FindStaticField("s0", "Z"); FieldHelper fh(s0); - EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/Field;"); + EXPECT_STREQ(ClassHelper(s0->GetClass()).GetDescriptor(), "Ljava/lang/reflect/ArtField;"); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimBoolean); EXPECT_EQ(true, s0->GetBoolean(statics)); s0->SetBoolean(statics, false); - Field* s1 = statics->FindStaticField("s1", "B"); + mirror::ArtField* s1 = statics->FindStaticField("s1", "B"); fh.ChangeField(s1); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimByte); EXPECT_EQ(5, s1->GetByte(statics)); s1->SetByte(statics, 6); - Field* s2 = statics->FindStaticField("s2", "C"); + mirror::ArtField* s2 = statics->FindStaticField("s2", "C"); fh.ChangeField(s2); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimChar); EXPECT_EQ('a', s2->GetChar(statics)); s2->SetChar(statics, 'b'); - Field* s3 = statics->FindStaticField("s3", "S"); + mirror::ArtField* s3 = statics->FindStaticField("s3", "S"); fh.ChangeField(s3); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimShort); EXPECT_EQ(-536, s3->GetShort(statics)); s3->SetShort(statics, -535); - Field* s4 = statics->FindStaticField("s4", "I"); + mirror::ArtField* s4 = statics->FindStaticField("s4", "I"); fh.ChangeField(s4); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimInt); EXPECT_EQ(2000000000, s4->GetInt(statics)); s4->SetInt(statics, 2000000001); - Field* s5 = statics->FindStaticField("s5", "J"); + mirror::ArtField* s5 = statics->FindStaticField("s5", "J"); fh.ChangeField(s5); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimLong); EXPECT_EQ(0x1234567890abcdefLL, s5->GetLong(statics)); s5->SetLong(statics, 0x34567890abcdef12LL); - Field* s6 = statics->FindStaticField("s6", "F"); + mirror::ArtField* s6 = statics->FindStaticField("s6", "F"); fh.ChangeField(s6); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimFloat); EXPECT_EQ(0.5, s6->GetFloat(statics)); s6->SetFloat(statics, 0.75); - Field* s7 = statics->FindStaticField("s7", "D"); + mirror::ArtField* s7 = statics->FindStaticField("s7", "D"); fh.ChangeField(s7); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimDouble); EXPECT_EQ(16777217, s7->GetDouble(statics)); s7->SetDouble(statics, 16777219); - Field* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); + mirror::ArtField* s8 = statics->FindStaticField("s8", "Ljava/lang/String;"); fh.ChangeField(s8); EXPECT_TRUE(fh.GetTypeAsPrimitiveType() == Primitive::kPrimNot); EXPECT_TRUE(s8->GetObject(statics)->AsString()->Equals("android")); - s8->SetObject(s8->GetDeclaringClass(), String::AllocFromModifiedUtf8(soa.Self(), "robot")); + s8->SetObject(s8->GetDeclaringClass(), mirror::String::AllocFromModifiedUtf8(soa.Self(), "robot")); // TODO: Remove EXPECT_FALSE when GCC can handle EXPECT_EQ // http://code.google.com/p/googletest/issues/detail?id=322 @@ -973,27 +931,27 @@ TEST_F(ClassLinkerTest, StaticFields) { TEST_F(ClassLinkerTest, Interfaces) { ScopedObjectAccess soa(Thread::Current()); - SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Interfaces"))); - Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); - Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); - Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); - Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); - Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); + SirtRef class_loader(soa.Self(), soa.Decode(LoadDex("Interfaces"))); + mirror::Class* I = class_linker_->FindClass("LInterfaces$I;", class_loader.get()); + mirror::Class* J = class_linker_->FindClass("LInterfaces$J;", class_loader.get()); + mirror::Class* K = class_linker_->FindClass("LInterfaces$K;", class_loader.get()); + mirror::Class* A = class_linker_->FindClass("LInterfaces$A;", class_loader.get()); + mirror::Class* B = class_linker_->FindClass("LInterfaces$B;", class_loader.get()); EXPECT_TRUE(I->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(A)); EXPECT_TRUE(J->IsAssignableFrom(K)); EXPECT_TRUE(K->IsAssignableFrom(B)); EXPECT_TRUE(J->IsAssignableFrom(B)); - AbstractMethod* Ii = I->FindVirtualMethod("i", "()V"); - AbstractMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); - AbstractMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); - AbstractMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); - AbstractMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); - AbstractMethod* Kk = K->FindInterfaceMethod("k", "()V"); - AbstractMethod* Ai = A->FindVirtualMethod("i", "()V"); - AbstractMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); - AbstractMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Ii = I->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Jj1 = J->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Jj2 = J->FindVirtualMethod("j2", "()V"); + mirror::ArtMethod* Kj1 = K->FindInterfaceMethod("j1", "()V"); + mirror::ArtMethod* Kj2 = K->FindInterfaceMethod("j2", "()V"); + mirror::ArtMethod* Kk = K->FindInterfaceMethod("k", "()V"); + mirror::ArtMethod* Ai = A->FindVirtualMethod("i", "()V"); + mirror::ArtMethod* Aj1 = A->FindVirtualMethod("j1", "()V"); + mirror::ArtMethod* Aj2 = A->FindVirtualMethod("j2", "()V"); ASSERT_TRUE(Ii != NULL); ASSERT_TRUE(Jj1 != NULL); ASSERT_TRUE(Jj2 != NULL); @@ -1015,10 +973,10 @@ TEST_F(ClassLinkerTest, Interfaces) { EXPECT_EQ(Aj1, A->FindVirtualMethodForVirtualOrInterface(Jj1)); EXPECT_EQ(Aj2, A->FindVirtualMethodForVirtualOrInterface(Jj2)); - Field* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); - Field* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); - Field* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); - Field* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Afoo = A->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Bfoo = B->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Jfoo = J->FindStaticField("foo", "Ljava/lang/String;"); + mirror::ArtField* Kfoo = K->FindStaticField("foo", "Ljava/lang/String;"); ASSERT_TRUE(Afoo != NULL); EXPECT_EQ(Afoo, Bfoo); EXPECT_EQ(Afoo, Jfoo); @@ -1033,30 +991,30 @@ TEST_F(ClassLinkerTest, ResolveVerifyAndClinit) { ScopedObjectAccess soa(Thread::Current()); jobject jclass_loader = LoadDex("StaticsFromCode"); - SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); + SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); const DexFile* dex_file = Runtime::Current()->GetCompileTimeClassPath(jclass_loader)[0]; CHECK(dex_file != NULL); - Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); - AbstractMethod* clinit = klass->FindDirectMethod("", "()V"); - AbstractMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); + mirror::Class* klass = class_linker_->FindClass("LStaticsFromCode;", class_loader.get()); + mirror::ArtMethod* clinit = klass->FindDirectMethod("", "()V"); + mirror::ArtMethod* getS0 = klass->FindDirectMethod("getS0", "()Ljava/lang/Object;"); const DexFile::StringId* string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id)); ASSERT_TRUE(type_id != NULL); uint32_t type_idx = dex_file->GetIndexForTypeId(*type_id); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); + mirror::StaticStorageBase* uninit = ResolveVerifyAndClinit(type_idx, clinit, Thread::Current(), true, false); EXPECT_TRUE(uninit != NULL); EXPECT_TRUE(clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx) == NULL); - StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); + mirror::StaticStorageBase* init = ResolveVerifyAndClinit(type_idx, getS0, Thread::Current(), true, false); EXPECT_TRUE(init != NULL); EXPECT_EQ(init, clinit->GetDexCacheInitializedStaticStorage()->Get(type_idx)); } TEST_F(ClassLinkerTest, FinalizableBit) { ScopedObjectAccess soa(Thread::Current()); - Class* c; + mirror::Class* c; // Object has a finalize method, but we know it's empty. c = class_linker_->FindSystemClass("Ljava/lang/Object;"); @@ -1092,7 +1050,7 @@ TEST_F(ClassLinkerTest, ClassRootDescriptors) { ScopedObjectAccess soa(Thread::Current()); ClassHelper kh; for (int i = 0; i < ClassLinker::kClassRootsMax; i++) { - Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); + mirror::Class* klass = class_linker_->GetClassRoot(ClassLinker::ClassRoot(i)); kh.ChangeClass(klass); EXPECT_TRUE(kh.GetDescriptor() != NULL); EXPECT_STREQ(kh.GetDescriptor(), diff --git a/runtime/common_test.h b/runtime/common_test.h index 7110e117f3..ced2af9670 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -181,7 +181,7 @@ class CommonTest : public testing::Test { reinterpret_cast(gc_map)); } - void MakeExecutable(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void MakeExecutable(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); LOG(INFO) << "MakeExecutable " << PrettyMethod(method); @@ -348,7 +348,7 @@ class CommonTest : public testing::Test { compiler_driver_->SetSupportBootImageFixup(false); // We're back in native, take the opportunity to initialize well known classes. - WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); + WellKnownClasses::Init(Thread::Current()->GetJniEnv()); // Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread // pool is created by the runtime. runtime_->GetHeap()->CreateThreadPool(); @@ -464,7 +464,7 @@ class CommonTest : public testing::Test { } } - void CompileMethod(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void CompileMethod(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { CHECK(method != NULL); base::TimingLogger timings("CommonTest::CompileMethod", false, false); timings.StartSplit("CompileOne"); @@ -480,7 +480,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindDirectMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindDirectMethod(method_name, signature); CHECK(method != NULL) << "Direct method not found: " << class_name << "." << method_name << signature; CompileMethod(method); @@ -494,7 +494,7 @@ class CommonTest : public testing::Test { std::string class_descriptor(DotToDescriptor(class_name)); mirror::Class* klass = class_linker_->FindClass(class_descriptor.c_str(), class_loader); CHECK(klass != NULL) << "Class not found " << class_name; - mirror::AbstractMethod* method = klass->FindVirtualMethod(method_name, signature); + mirror::ArtMethod* method = klass->FindVirtualMethod(method_name, signature); CHECK(method != NULL) << "Virtual method not found: " << class_name << "." << method_name << signature; CompileMethod(method); diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc index 2a55e3138b..26ce5be1ec 100644 --- a/runtime/common_throws.cc +++ b/runtime/common_throws.cc @@ -21,7 +21,7 @@ #include "dex_file-inl.h" #include "dex_instruction-inl.h" #include "invoke_type.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -68,7 +68,7 @@ static void ThrowException(const ThrowLocation* throw_location, const char* exce // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) { +void ThrowAbstractMethodError(const mirror::ArtMethod* method) { ThrowException(NULL, "Ljava/lang/AbstractMethodError;", NULL, StringPrintf("abstract method \"%s\"", PrettyMethod(method).c_str()).c_str()); @@ -136,8 +136,8 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access } void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) { std::ostringstream msg; msg << "Illegal class access ('" << PrettyDescriptor(referrer) << "' attempting to access '" @@ -146,26 +146,27 @@ void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirr ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) { +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) { std::ostringstream msg; msg << "Method '" << PrettyMethod(accessed) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) { +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) { std::ostringstream msg; msg << "Field '" << PrettyField(accessed, false) << "' is inaccessible to class '" << PrettyDescriptor(referrer) << "'"; ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer, msg.str().c_str()); } -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) { +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) { std::ostringstream msg; msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '" << PrettyMethod(referrer) << "'"; - ThrowException(NULL, "Ljava/lang/IllegalAccessError;", referrer != NULL ? referrer->GetClass() : NULL, + ThrowException(NULL, "Ljava/lang/IllegalAccessError;", + referrer != NULL ? referrer->GetClass() : NULL, msg.str().c_str()); } @@ -186,8 +187,8 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) { + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "The method '" << PrettyMethod(method) << "' was expected to be of type " << expected_type << " but instead was found to be of type " << found_type; @@ -196,9 +197,9 @@ void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType foun msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) { + const mirror::ArtMethod* referrer) { // Referrer is calling interface_method on this_object, however, the interface_method isn't // implemented by this_object. CHECK(this_object != NULL); @@ -212,8 +213,8 @@ void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::Ab msg.str().c_str()); } -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) { +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) { std::ostringstream msg; msg << "Expected '" << PrettyField(resolved_field) << "' to be a " << (is_static ? "static" : "instance") << " field" << " rather than a " @@ -241,7 +242,8 @@ void ThrowLinkageError(const mirror::Class* referrer, const char* fmt, ...) { // NegativeArraySizeException void ThrowNegativeArraySizeException(int size) { - ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, StringPrintf("%d", size).c_str()); + ThrowException(NULL, "Ljava/lang/NegativeArraySizeException;", NULL, + StringPrintf("%d", size).c_str()); } void ThrowNegativeArraySizeException(const char* msg) { @@ -285,7 +287,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) { // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, bool is_read) { + mirror::ArtField* field, bool is_read) { std::ostringstream msg; msg << "Attempt to " << (is_read ? "read from" : "write to") << " field '" << PrettyField(field, true) << "' on a null object reference"; @@ -303,7 +305,8 @@ static void ThrowNullPointerExceptionForMethodAccessImpl(const ThrowLocation& th ThrowException(&throw_location, "Ljava/lang/NullPointerException;", NULL, msg.str().c_str()); } -void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, uint32_t method_idx, +void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, + uint32_t method_idx, InvokeType type) { mirror::DexCache* dex_cache = throw_location.GetMethod()->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -312,7 +315,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio } void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) { mirror::DexCache* dex_cache = method->GetDeclaringClass()->GetDexCache(); const DexFile& dex_file = *dex_cache->GetDexFile(); @@ -348,7 +351,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { // Since we replaced the method index, we ask the verifier to tell us which // method is invoked at this location. - mirror::AbstractMethod* method = + mirror::ArtMethod* method = verifier::MethodVerifier::FindInvokedMethodAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (method != NULL) { @@ -368,7 +371,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_BYTE: case Instruction::IGET_CHAR: case Instruction::IGET_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, true /* read */); @@ -379,7 +382,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IGET_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { @@ -399,7 +402,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_BYTE: case Instruction::IPUT_CHAR: case Instruction::IPUT_SHORT: { - mirror::Field* field = + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(instr->VRegC_22c(), throw_location.GetMethod(), false); ThrowNullPointerExceptionForFieldAccess(throw_location, field, false /* write */); @@ -410,7 +413,7 @@ void ThrowNullPointerExceptionFromDexPC(const ThrowLocation& throw_location) { case Instruction::IPUT_OBJECT_QUICK: { // Since we replaced the field index, we ask the verifier to tell us which // field is accessed at this location. - mirror::Field* field = + mirror::ArtField* field = verifier::MethodVerifier::FindAccessedFieldAtDexPc(throw_location.GetMethod(), throw_location.GetDexPc()); if (field != NULL) { diff --git a/runtime/common_throws.h b/runtime/common_throws.h index b7f2754df1..99c6343cdd 100644 --- a/runtime/common_throws.h +++ b/runtime/common_throws.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Class; -class Field; class Object; } // namespace mirror class StringPiece; @@ -32,7 +32,7 @@ class ThrowLocation; // AbstractMethodError -void ThrowAbstractMethodError(const mirror::AbstractMethod* method) +void ThrowAbstractMethodError(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // ArithmeticException @@ -74,19 +74,19 @@ void ThrowIllegalAccessErrorClass(mirror::Class* referrer, mirror::Class* access SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessErrorClassForMethodDispatch(mirror::Class* referrer, mirror::Class* accessed, - const mirror::AbstractMethod* caller, - const mirror::AbstractMethod* called, + const mirror::ArtMethod* caller, + const mirror::ArtMethod* called, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::AbstractMethod* accessed) +void ThrowIllegalAccessErrorMethod(mirror::Class* referrer, mirror::ArtMethod* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::Field* accessed) +void ThrowIllegalAccessErrorField(mirror::Class* referrer, mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIllegalAccessErrorFinalField(const mirror::AbstractMethod* referrer, - mirror::Field* accessed) +void ThrowIllegalAccessErrorFinalField(const mirror::ArtMethod* referrer, + mirror::ArtField* accessed) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIllegalAccessError(mirror::Class* referrer, const char* fmt, ...) @@ -101,17 +101,17 @@ void ThrowIllegalArgumentException(const ThrowLocation* throw_location, const ch // IncompatibleClassChangeError void ThrowIncompatibleClassChangeError(InvokeType expected_type, InvokeType found_type, - mirror::AbstractMethod* method, - const mirror::AbstractMethod* referrer) + mirror::ArtMethod* method, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::AbstractMethod* interface_method, +void ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(const mirror::ArtMethod* interface_method, mirror::Object* this_object, - const mirror::AbstractMethod* referrer) + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void ThrowIncompatibleClassChangeErrorField(const mirror::Field* resolved_field, bool is_static, - const mirror::AbstractMethod* referrer) +void ThrowIncompatibleClassChangeErrorField(const mirror::ArtField* resolved_field, bool is_static, + const mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowIncompatibleClassChangeError(const mirror::Class* referrer, const char* fmt, ...) @@ -149,7 +149,7 @@ void ThrowNoSuchMethodError(uint32_t method_idx) // NullPointerException void ThrowNullPointerExceptionForFieldAccess(const ThrowLocation& throw_location, - mirror::Field* field, + mirror::ArtField* field, bool is_read) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -159,7 +159,7 @@ void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_locatio SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ThrowNullPointerExceptionForMethodAccess(const ThrowLocation& throw_location, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 3591a5097b..569a370b3f 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -30,11 +30,11 @@ #include "gc/space/space-inl.h" #include "invoke_arg_array_builder.h" #include "jdwp/object_registry.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -60,7 +60,7 @@ static const size_t kMaxAllocRecordStackDepth = 16; // Max 255. static const size_t kDefaultNumAllocRecords = 64*1024; // Must be a power of 2. struct AllocRecordStackTraceElement { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; int32_t LineNumber() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -84,9 +84,9 @@ struct AllocRecord { }; struct Breakpoint { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; uint32_t dex_pc; - Breakpoint(mirror::AbstractMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} + Breakpoint(mirror::ArtMethod* method, uint32_t dex_pc) : method(method), dex_pc(dex_pc) {} }; static std::ostream& operator<<(std::ostream& os, const Breakpoint& rhs) @@ -103,7 +103,7 @@ struct SingleStepControl { JDWP::JdwpStepSize step_size; JDWP::JdwpStepDepth step_depth; - const mirror::AbstractMethod* method; + const mirror::ArtMethod* method; int32_t line_number; // Or -1 for native methods. std::set dex_pcs; int stack_depth; @@ -115,7 +115,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList virtual ~DebugInstrumentationListener() {} virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method->IsNative()) { // TODO: post location events is a suspension point and native method entry stubs aren't. @@ -125,7 +125,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { UNUSED(return_value); @@ -136,7 +136,7 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList Dbg::PostLocationEvent(method, dex_pc, this_object, Dbg::kMethodExit); } - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected method unwind event in debugger " << PrettyMethod(method) @@ -144,13 +144,13 @@ class DebugInstrumentationListener : public instrumentation::InstrumentationList } virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::UpdateDebugger(thread, this_object, method, new_dex_pc); } virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Dbg::PostException(thread, throw_location, catch_method, catch_dex_pc, exception_object); @@ -194,7 +194,7 @@ static size_t gAllocRecordCount GUARDED_BY(gAllocTrackerLock) = 0; static std::vector gBreakpoints GUARDED_BY(Locks::breakpoint_lock_); static SingleStepControl gSingleStepControl GUARDED_BY(Locks::breakpoint_lock_); -static bool IsBreakpoint(const mirror::AbstractMethod* m, uint32_t dex_pc) +static bool IsBreakpoint(const mirror::ArtMethod* m, uint32_t dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); @@ -1131,7 +1131,7 @@ bool Dbg::MatchType(JDWP::RefTypeId instance_class_id, JDWP::RefTypeId class_id) return c1->IsAssignableFrom(c2); } -static JDWP::FieldId ToFieldId(const mirror::Field* f) +static JDWP::FieldId ToFieldId(const mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1140,7 +1140,7 @@ static JDWP::FieldId ToFieldId(const mirror::Field* f) #endif } -static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) +static JDWP::MethodId ToMethodId(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); @@ -1149,25 +1149,25 @@ static JDWP::MethodId ToMethodId(const mirror::AbstractMethod* m) #endif } -static mirror::Field* FromFieldId(JDWP::FieldId fid) +static mirror::ArtField* FromFieldId(JDWP::FieldId fid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast(static_cast(fid)); + return reinterpret_cast(static_cast(fid)); #endif } -static mirror::AbstractMethod* FromMethodId(JDWP::MethodId mid) +static mirror::ArtMethod* FromMethodId(JDWP::MethodId mid) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { #ifdef MOVING_GARBAGE_COLLECTOR UNIMPLEMENTED(FATAL); #else - return reinterpret_cast(static_cast(mid)); + return reinterpret_cast(static_cast(mid)); #endif } -static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, uint32_t dex_pc) +static void SetLocation(JDWP::JdwpLocation& location, mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m == NULL) { memset(&location, 0, sizeof(location)); @@ -1182,13 +1182,13 @@ static void SetLocation(JDWP::JdwpLocation& location, mirror::AbstractMethod* m, std::string Dbg::GetMethodName(JDWP::MethodId method_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); return MethodHelper(m).GetName(); } std::string Dbg::GetFieldName(JDWP::FieldId field_id) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); return FieldHelper(f).GetName(); } @@ -1230,7 +1230,7 @@ static uint16_t MangleSlot(uint16_t slot, const char* name) { return newSlot; } -static uint16_t DemangleSlot(uint16_t slot, mirror::AbstractMethod* m) +static uint16_t DemangleSlot(uint16_t slot, mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (slot == kEclipseWorkaroundSlot) { return 0; @@ -1255,7 +1255,7 @@ JDWP::JdwpError Dbg::OutputDeclaredFields(JDWP::RefTypeId class_id, bool with_ge expandBufAdd4BE(pReply, instance_field_count + static_field_count); for (size_t i = 0; i < instance_field_count + static_field_count; ++i) { - mirror::Field* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); + mirror::ArtField* f = (i < instance_field_count) ? c->GetInstanceField(i) : c->GetStaticField(i - instance_field_count); FieldHelper fh(f); expandBufAddFieldId(pReply, ToFieldId(f)); expandBufAddUtf8String(pReply, fh.GetName()); @@ -1283,7 +1283,7 @@ JDWP::JdwpError Dbg::OutputDeclaredMethods(JDWP::RefTypeId class_id, bool with_g expandBufAdd4BE(pReply, direct_method_count + virtual_method_count); for (size_t i = 0; i < direct_method_count + virtual_method_count; ++i) { - mirror::AbstractMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); + mirror::ArtMethod* m = (i < direct_method_count) ? c->GetDirectMethod(i) : c->GetVirtualMethod(i - direct_method_count); MethodHelper mh(m); expandBufAddMethodId(pReply, ToMethodId(m)); expandBufAddUtf8String(pReply, mh.GetName()); @@ -1327,7 +1327,7 @@ void Dbg::OutputLineTable(JDWP::RefTypeId, JDWP::MethodId method_id, JDWP::Expan return true; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); uint64_t start, end; if (m->IsNative()) { @@ -1381,14 +1381,14 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi ++pContext->variable_count; } }; - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); // arg_count considers doubles and longs to take 2 units. // variable_count considers everything to take 1 unit. std::string shorty(mh.GetShorty()); - expandBufAdd4BE(pReply, mirror::AbstractMethod::NumArgRegisters(shorty)); + expandBufAdd4BE(pReply, mirror::ArtMethod::NumArgRegisters(shorty)); // We don't know the total number of variables yet, so leave a blank and update it later. size_t variable_count_offset = expandBufGetLength(pReply); @@ -1408,7 +1408,7 @@ void Dbg::OutputVariableTable(JDWP::RefTypeId, JDWP::MethodId method_id, bool wi JDWP::JdwpError Dbg::GetBytecodes(JDWP::RefTypeId, JDWP::MethodId method_id, std::vector& bytecodes) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m == NULL) { return JDWP::ERR_INVALID_METHODID; } @@ -1445,7 +1445,7 @@ static JDWP::JdwpError GetFieldValueImpl(JDWP::RefTypeId ref_type_id, JDWP::Obje if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); mirror::Class* receiver_class = c; if (receiver_class == NULL && o != NULL) { @@ -1511,7 +1511,7 @@ static JDWP::JdwpError SetFieldValueImpl(JDWP::ObjectId object_id, JDWP::FieldId if ((!is_static && o == NULL) || o == ObjectRegistry::kInvalidObject) { return JDWP::ERR_INVALID_OBJECT; } - mirror::Field* f = FromFieldId(field_id); + mirror::ArtField* f = FromFieldId(field_id); // The RI only enforces the static/non-static mismatch in one direction. // TODO: should we change the tests and check both? @@ -1580,7 +1580,7 @@ JDWP::JdwpError Dbg::GetThreadName(JDWP::ObjectId thread_id, std::string& name) // We still need to report the zombie threads' names, so we can't just call Thread::GetThreadName. mirror::Object* thread_object = gRegistry->Get(thread_id); - mirror::Field* java_lang_Thread_name_field = + mirror::ArtField* java_lang_Thread_name_field = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); mirror::String* s = reinterpret_cast(java_lang_Thread_name_field->GetObject(thread_object)); @@ -1612,7 +1612,7 @@ JDWP::JdwpError Dbg::GetThreadGroup(JDWP::ObjectId thread_id, JDWP::ExpandBuf* p mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/Thread;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("group", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* group = f->GetObject(thread_object); CHECK(group != NULL); @@ -1629,7 +1629,7 @@ std::string Dbg::GetThreadGroupName(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("name", "Ljava/lang/String;"); + mirror::ArtField* f = c->FindInstanceField("name", "Ljava/lang/String;"); CHECK(f != NULL); mirror::String* s = reinterpret_cast(f->GetObject(thread_group)); return s->ToModifiedUtf8(); @@ -1641,7 +1641,7 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { mirror::Class* c = Runtime::Current()->GetClassLinker()->FindSystemClass("Ljava/lang/ThreadGroup;"); CHECK(c != NULL); - mirror::Field* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); + mirror::ArtField* f = c->FindInstanceField("parent", "Ljava/lang/ThreadGroup;"); CHECK(f != NULL); mirror::Object* parent = f->GetObject(thread_group); return gRegistry->Add(parent); @@ -1649,14 +1649,14 @@ JDWP::ObjectId Dbg::GetThreadGroupParent(JDWP::ObjectId thread_group_id) { JDWP::ObjectId Dbg::GetSystemThreadGroupId() { ScopedObjectAccessUnchecked soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } JDWP::ObjectId Dbg::GetMainThreadGroupId() { ScopedObjectAccess soa(Thread::Current()); - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup); mirror::Object* group = f->GetObject(f->GetDeclaringClass()); return gRegistry->Add(group); } @@ -1793,12 +1793,12 @@ void Dbg::GetChildThreadGroups(JDWP::ObjectId thread_group_id, std::vectorGet(thread_group_id); // Get the ArrayList "groups" out of this thread group... - mirror::Field* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); + mirror::ArtField* groups_field = thread_group->GetClass()->FindInstanceField("groups", "Ljava/util/List;"); mirror::Object* groups_array_list = groups_field->GetObject(thread_group); // Get the array and size out of the ArrayList... - mirror::Field* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); - mirror::Field* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); + mirror::ArtField* array_field = groups_array_list->GetClass()->FindInstanceField("array", "[Ljava/lang/Object;"); + mirror::ArtField* size_field = groups_array_list->GetClass()->FindInstanceField("size", "I"); mirror::ObjectArray* groups_array = array_field->GetObject(groups_array_list)->AsObjectArray(); const int32_t size = size_field->GetInt(groups_array_list); @@ -2017,7 +2017,7 @@ void Dbg::GetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2156,7 +2156,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl return true; // Not our frame, carry on. } // TODO: check that the tag is compatible with the actual type of the slot! - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); uint16_t reg = DemangleSlot(slot_, m); switch (tag_) { @@ -2226,7 +2226,7 @@ void Dbg::SetLocalValue(JDWP::ObjectId thread_id, JDWP::FrameId frame_id, int sl visitor.WalkStack(); } -void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, +void Dbg::PostLocationEvent(const mirror::ArtMethod* m, int dex_pc, mirror::Object* this_object, int event_flags) { mirror::Class* c = m->GetDeclaringClass(); @@ -2246,7 +2246,7 @@ void Dbg::PostLocationEvent(const mirror::AbstractMethod* m, int dex_pc, } void Dbg::PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (!IsDebuggerActive()) { return; @@ -2280,7 +2280,7 @@ void Dbg::PostClassPrepare(mirror::Class* c) { } void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* m, uint32_t dex_pc) { + const mirror::ArtMethod* m, uint32_t dex_pc) { if (!IsDebuggerActive() || dex_pc == static_cast(-2) /* fake method exit */) { return; } @@ -2361,14 +2361,14 @@ void Dbg::UpdateDebugger(Thread* thread, mirror::Object* this_object, void Dbg::WatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); gBreakpoints.push_back(Breakpoint(m, location->dex_pc)); VLOG(jdwp) << "Set breakpoint #" << (gBreakpoints.size() - 1) << ": " << gBreakpoints[gBreakpoints.size() - 1]; } void Dbg::UnwatchLocation(const JDWP::JdwpLocation* location) { MutexLock mu(Thread::Current(), *Locks::breakpoint_lock_); - mirror::AbstractMethod* m = FromMethodId(location->method_id); + mirror::ArtMethod* m = FromMethodId(location->method_id); for (size_t i = 0; i < gBreakpoints.size(); ++i) { if (gBreakpoints[i].method == m && gBreakpoints[i].dex_pc == location->dex_pc) { VLOG(jdwp) << "Removed breakpoint #" << i << ": " << gBreakpoints[i]; @@ -2468,7 +2468,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize // annotalysis. bool VisitFrame() NO_THREAD_SAFETY_ANALYSIS { Locks::breakpoint_lock_->AssertHeld(Thread::Current()); - const mirror::AbstractMethod* m = GetMethod(); + const mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { ++gSingleStepControl.stack_depth; if (gSingleStepControl.method == NULL) { @@ -2538,7 +2538,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId thread_id, JDWP::JdwpStepSize uint32_t last_pc; }; gSingleStepControl.dex_pcs.clear(); - const mirror::AbstractMethod* m = gSingleStepControl.method; + const mirror::ArtMethod* m = gSingleStepControl.method; if (m->IsNative()) { gSingleStepControl.line_number = -1; } else { @@ -2675,7 +2675,7 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec return status; } - mirror::AbstractMethod* m = FromMethodId(method_id); + mirror::ArtMethod* m = FromMethodId(method_id); if (m->IsStatic() != (receiver == NULL)) { return JDWP::ERR_INVALID_METHODID; } @@ -2798,7 +2798,7 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { // We can be called while an exception is pending. We need // to preserve that across the method invocation. SirtRef old_throw_this_object(soa.Self(), NULL); - SirtRef old_throw_method(soa.Self(), NULL); + SirtRef old_throw_method(soa.Self(), NULL); SirtRef old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { @@ -2812,9 +2812,9 @@ void Dbg::ExecuteMethod(DebugInvokeReq* pReq) { } // Translate the method through the vtable, unless the debugger wants to suppress it. - mirror::AbstractMethod* m = pReq->method_; + mirror::ArtMethod* m = pReq->method_; if ((pReq->options_ & JDWP::INVOKE_NONVIRTUAL) == 0 && pReq->receiver_ != NULL) { - mirror::AbstractMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); + mirror::ArtMethod* actual_method = pReq->class_->FindVirtualMethodForVirtualOrInterface(pReq->method_); if (actual_method != m) { VLOG(jdwp) << "ExecuteMethod translated " << PrettyMethod(m) << " to " << PrettyMethod(actual_method); m = actual_method; @@ -3491,7 +3491,7 @@ struct AllocRecordStackVisitor : public StackVisitor { if (depth >= kMaxAllocRecordStackDepth) { return false; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (!m->IsRuntimeMethod()) { record->stack[depth].method = m; record->stack[depth].dex_pc = GetDexPc(); @@ -3574,7 +3574,7 @@ void Dbg::DumpRecentAllocations() { << PrettyClass(record->type); for (size_t stack_frame = 0; stack_frame < kMaxAllocRecordStackDepth; ++stack_frame) { - const mirror::AbstractMethod* m = record->stack[stack_frame].method; + const mirror::ArtMethod* m = record->stack[stack_frame].method; if (m == NULL) { break; } @@ -3695,7 +3695,7 @@ jbyteArray Dbg::GetRecentAllocations() { MethodHelper mh; for (size_t i = 0; i < kMaxAllocRecordStackDepth; i++) { - mirror::AbstractMethod* m = record->stack[i].method; + mirror::ArtMethod* m = record->stack[i].method; if (m != NULL) { mh.ChangeMethod(m); class_names.Add(mh.GetDeclaringClassDescriptor()); diff --git a/runtime/debugger.h b/runtime/debugger.h index 6b7e2ba6e8..2282305ac2 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -32,7 +32,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Class; class Object; class Throwable; @@ -64,7 +64,7 @@ struct DebugInvokeReq { mirror::Object* receiver_; /* not used for ClassType.InvokeMethod */ mirror::Object* thread_; mirror::Class* class_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t arg_count_; uint64_t* arg_values_; /* will be NULL if arg_count_ == 0 */ uint32_t options_; @@ -324,11 +324,11 @@ class Dbg { kMethodEntry = 0x04, kMethodExit = 0x08, }; - static void PostLocationEvent(const mirror::AbstractMethod* method, int pcOffset, + static void PostLocationEvent(const mirror::ArtMethod* method, int pcOffset, mirror::Object* thisPtr, int eventFlags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostException(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void PostThreadStart(Thread* t) @@ -339,7 +339,7 @@ class Dbg { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void UpdateDebugger(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) LOCKS_EXCLUDED(Locks::breakpoint_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index aaff0fc6da..45b34270f9 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -31,9 +31,8 @@ #include "dex_file_verifier.h" #include "globals.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/string.h" #include "os.h" #include "safe_map.h" @@ -624,7 +623,7 @@ std::string DexFile::CreateMethodSignature(uint32_t proto_idx, int32_t* unicode_ return descriptor; } -int32_t DexFile::GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const { +int32_t DexFile::GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const { // For native method, lineno should be -2 to indicate it is native. Note that // "line number == -2" is how libcore tells from StackTraceElement. if (method->GetCodeItemOffset() == 0) { @@ -1024,7 +1023,7 @@ void EncodedStaticFieldValueIterator::Next() { ptr_ += width; } -void EncodedStaticFieldValueIterator::ReadValueToField(mirror::Field* field) const { +void EncodedStaticFieldValueIterator::ReadValueToField(mirror::ArtField* field) const { switch (type_) { case kBoolean: field->SetBoolean(field->GetDeclaringClass(), jval_.z); break; case kByte: field->SetByte(field->GetDeclaringClass(), jval_.b); break; diff --git a/runtime/dex_file.h b/runtime/dex_file.h index a60a1398d8..006b692c85 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -34,10 +34,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class DexCache; -class Field; + class ArtField; + class ArtMethod; + class ClassLoader; + class DexCache; } // namespace mirror class ClassLinker; class ZipArchive; @@ -786,7 +786,7 @@ class DexFile { // Returns -2 for native methods (as expected in exception traces). // // This is used by runtime; therefore use art::Method not art::DexFile::Method. - int32_t GetLineNumFromPC(const mirror::AbstractMethod* method, uint32_t rel_pc) const + int32_t GetLineNumFromPC(const mirror::ArtMethod* method, uint32_t rel_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DecodeDebugInfo(const CodeItem* code_item, bool is_static, uint32_t method_idx, @@ -1135,7 +1135,7 @@ class EncodedStaticFieldValueIterator { ClassLinker* linker, const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ReadValueToField(mirror::Field* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void ReadValueToField(mirror::ArtField* field) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool HasNext() { return pos_ < array_size_; } diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index c29784151c..6b8c41ed41 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -19,9 +19,9 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" @@ -33,7 +33,7 @@ namespace art { // Helper function to allocate array for FILLED_NEW_ARRAY. -mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* referrer, +mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* referrer, int32_t component_count, Thread* self, bool access_check) { if (UNLIKELY(component_count < 0)) { @@ -73,7 +73,7 @@ mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMet } } -mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, +mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, Thread* self, FindFieldType type, size_t expected_size, bool access_check) { bool is_primitive; @@ -91,7 +91,7 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho default: is_primitive = true; is_set = true; is_static = true; break; } ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); + mirror::ArtField* resolved_field = class_linker->ResolveField(field_idx, referrer, is_static); if (UNLIKELY(resolved_field == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -158,12 +158,12 @@ mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMetho } // Slow path method resolution -mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, +mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, Thread* self, bool access_check, InvokeType type) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); bool is_direct = type == kStatic || type == kDirect; - mirror::AbstractMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); + mirror::ArtMethod* resolved_method = class_linker->ResolveMethod(method_idx, referrer, type); if (UNLIKELY(resolved_method == NULL)) { DCHECK(self->IsExceptionPending()); // Throw exception and unwind. return NULL; // Failure. @@ -179,7 +179,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -189,7 +189,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray* vtable; + mirror::ObjectArray* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { vtable = referrer->GetDeclaringClass()->GetSuperClass()->GetVTable(); @@ -231,7 +231,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* if (is_direct) { return resolved_method; } else if (type == kInterface) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = this_object->GetClass()->FindVirtualMethodForInterface(resolved_method); if (UNLIKELY(interface_method == NULL)) { ThrowIncompatibleClassChangeErrorClassForInterfaceDispatch(resolved_method, this_object, @@ -241,7 +241,7 @@ mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* return interface_method; } } else { - mirror::ObjectArray* vtable; + mirror::ObjectArray* vtable; uint16_t vtable_index = resolved_method->GetMethodIndex(); if (type == kSuper) { mirror::Class* super_class = referring_class->GetSuperClass(); @@ -326,17 +326,15 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } } - // Call InvocationHandler.invoke(Object proxy, Method method, Object[] args). - jobject inv_hand = soa.Env()->GetObjectField(rcvr_jobj, - WellKnownClasses::java_lang_reflect_Proxy_h); + // Call Proxy.invoke(Proxy proxy, ArtMethod method, Object[] args). jvalue invocation_args[3]; invocation_args[0].l = rcvr_jobj; invocation_args[1].l = interface_method_jobj; invocation_args[2].l = args_jobj; jobject result = - soa.Env()->CallObjectMethodA(inv_hand, - WellKnownClasses::java_lang_reflect_InvocationHandler_invoke, - invocation_args); + soa.Env()->CallStaticObjectMethodA(WellKnownClasses::java_lang_reflect_Proxy, + WellKnownClasses::java_lang_reflect_Proxy_invoke, + invocation_args); // Unbox result and handle error conditions. if (LIKELY(!soa.Self()->IsExceptionPending())) { @@ -346,10 +344,10 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char } else { mirror::Object* result_ref = soa.Decode(result); mirror::Object* rcvr = soa.Decode(rcvr_jobj); - mirror::AbstractMethod* interface_method = - soa.Decode(interface_method_jobj); + mirror::ArtMethod* interface_method = + soa.Decode(interface_method_jobj); mirror::Class* result_type = MethodHelper(interface_method).GetReturnType(); - mirror::AbstractMethod* proxy_method; + mirror::ArtMethod* proxy_method; if (interface_method->GetDeclaringClass()->IsInterface()) { proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); } else { @@ -373,9 +371,9 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char mirror::Object* rcvr = soa.Decode(rcvr_jobj); mirror::SynthesizedProxyClass* proxy_class = down_cast(rcvr->GetClass()); - mirror::AbstractMethod* interface_method = - soa.Decode(interface_method_jobj); - mirror::AbstractMethod* proxy_method = + mirror::ArtMethod* interface_method = + soa.Decode(interface_method_jobj); + mirror::ArtMethod* proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(interface_method); int throws_index = -1; size_t num_virt_methods = proxy_class->NumVirtualMethods(); diff --git a/runtime/entrypoints/entrypoint_utils.h b/runtime/entrypoints/entrypoint_utils.h index b6781c02b9..2b73af437e 100644 --- a/runtime/entrypoints/entrypoint_utils.h +++ b/runtime/entrypoints/entrypoint_utils.h @@ -23,7 +23,7 @@ #include "indirect_reference_table.h" #include "invoke_type.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/throwable.h" @@ -34,7 +34,7 @@ namespace art { namespace mirror { class Class; - class Field; + class ArtField; class Object; } // namespace mirror @@ -42,7 +42,7 @@ namespace mirror { // cannot be resolved, throw an error. If it can, use it to create an instance. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -80,7 +80,7 @@ static inline mirror::Object* AllocObjectFromCode(uint32_t type_idx, mirror::Abs // it cannot be resolved, throw an error. If it can, use it to create an array. // When verification/compiler hasn't been able to verify access, optionally perform an access // check. -static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -107,7 +107,7 @@ static inline mirror::Array* AllocArrayFromCode(uint32_t type_idx, mirror::Abstr return mirror::Array::Alloc(self, klass, component_count); } -extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -125,17 +125,17 @@ enum FindFieldType { }; // Slow field find that can initialize classes and may throw exceptions. -extern mirror::Field* FindFieldFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - Thread* self, FindFieldType type, size_t expected_size, - bool access_check) +extern mirror::ArtField* FindFieldFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + Thread* self, FindFieldType type, size_t expected_size, + bool access_check) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Fast path field resolution that can't initialize classes or throw exceptions. -static inline mirror::Field* FindFieldFast(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - FindFieldType type, size_t expected_size) +static inline mirror::ArtField* FindFieldFast(uint32_t field_idx, + const mirror::ArtMethod* referrer, + FindFieldType type, size_t expected_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* resolved_field = + mirror::ArtField* resolved_field = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx); if (UNLIKELY(resolved_field == NULL)) { return NULL; @@ -186,16 +186,16 @@ static inline mirror::Field* FindFieldFast(uint32_t field_idx, } // Fast path method resolution that can't throw exceptions. -static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, - mirror::Object* this_object, - const mirror::AbstractMethod* referrer, - bool access_check, InvokeType type) +static inline mirror::ArtMethod* FindMethodFast(uint32_t method_idx, + mirror::Object* this_object, + const mirror::ArtMethod* referrer, + bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool is_direct = type == kStatic || type == kDirect; if (UNLIKELY(this_object == NULL && !is_direct)) { return NULL; } - mirror::AbstractMethod* resolved_method = + mirror::ArtMethod* resolved_method = referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx); if (UNLIKELY(resolved_method == NULL)) { return NULL; @@ -228,13 +228,13 @@ static inline mirror::AbstractMethod* FindMethodFast(uint32_t method_idx, } } -extern mirror::AbstractMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, - Thread* self, bool access_check, InvokeType type) +extern mirror::ArtMethod* FindMethodFromCode(uint32_t method_idx, mirror::Object* this_object, + mirror::ArtMethod* referrer, + Thread* self, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, bool can_run_clinit, bool verify_access) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -271,7 +271,7 @@ static inline mirror::Class* ResolveVerifyAndClinit(uint32_t type_idx, extern void ThrowStackOverflowError(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -static inline mirror::String* ResolveStringFromCode(const mirror::AbstractMethod* referrer, +static inline mirror::String* ResolveStringFromCode(const mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -307,7 +307,7 @@ static inline void CheckReferenceResult(mirror::Object* o, Thread* self) if (o == NULL) { return; } - mirror::AbstractMethod* m = self->GetCurrentMethod(NULL); + mirror::ArtMethod* m = self->GetCurrentMethod(NULL); if (o == kInvalidIndirectRefObject) { JniAbortF(NULL, "invalid reference returned from %s", PrettyMethod(m).c_str()); } @@ -334,7 +334,7 @@ static inline void CheckSuspend(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mut } JValue InvokeProxyInvocationHandler(ScopedObjectAccessUnchecked& soa, const char* shorty, - jobject rcvr_jobj, jobject interface_method_jobj, + jobject rcvr_jobj, jobject interface_art_method_jobj, std::vector& args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -356,12 +356,12 @@ static inline uintptr_t GetQuickInstrumentationExitPc() { return reinterpret_cast(art_quick_instrumentation_exit); } -extern "C" void art_portable_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_portable_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetPortableToInterpreterBridge() { return reinterpret_cast(art_portable_to_interpreter_bridge); } -extern "C" void art_quick_to_interpreter_bridge(mirror::AbstractMethod*); +extern "C" void art_quick_to_interpreter_bridge(mirror::ArtMethod*); static inline const void* GetQuickToInterpreterBridge() { return reinterpret_cast(art_quick_to_interpreter_bridge); } diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc index 67f6d98493..f319a0084b 100644 --- a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc +++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc @@ -17,7 +17,7 @@ #include "class_linker.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "runtime.h" @@ -29,7 +29,7 @@ extern "C" void artInterpreterToCompiledCodeBridge(Thread* self, MethodHelper& m const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = shadow_frame->GetMethod(); + mirror::ArtMethod* method = shadow_frame->GetMethod(); // Ensure static methods are initialized. if (method->IsStatic()) { Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true); diff --git a/runtime/entrypoints/jni/jni_entrypoints.cc b/runtime/entrypoints/jni/jni_entrypoints.cc index 88b4936255..83d3a584c5 100644 --- a/runtime/entrypoints/jni/jni_entrypoints.cc +++ b/runtime/entrypoints/jni/jni_entrypoints.cc @@ -16,7 +16,7 @@ #include "base/logging.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -30,7 +30,7 @@ extern "C" void* artFindNativeMethod() { Locks::mutator_lock_->AssertNotHeld(self); // We come here as Native. ScopedObjectAccess soa(self); - mirror::AbstractMethod* method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* method = self->GetCurrentMethod(NULL); DCHECK(method != NULL); // Lookup symbol address for method, on failure we'll return NULL with an exception set, @@ -69,7 +69,7 @@ extern "C" const void* artWorkAroundAppJniBugs(Thread* self, intptr_t* sp) // | unused | // | unused | // | unused | <- sp - mirror::AbstractMethod* jni_method = self->GetCurrentMethod(NULL); + mirror::ArtMethod* jni_method = self->GetCurrentMethod(NULL); DCHECK(jni_method->IsNative()) << PrettyMethod(jni_method); intptr_t* arg_ptr = sp + 4; // pointer to r1 on stack // Fix up this/jclass argument diff --git a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc index 286926909c..91b7353bab 100644 --- a/runtime/entrypoints/portable/portable_alloc_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_alloc_entrypoints.cc @@ -15,27 +15,27 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_alloc_object_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, false); } extern "C" mirror::Object* art_portable_alloc_object_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return AllocObjectFromCode(type_idx, referrer, thread, true); } extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -43,7 +43,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx, } extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -51,7 +51,7 @@ extern "C" mirror::Object* art_portable_alloc_array_from_code_with_access_check( } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -59,7 +59,7 @@ extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t } extern "C" mirror::Object* art_portable_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, uint32_t length, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc index bdab587797..b37ebcf785 100644 --- a/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_dexcache_entrypoints.cc @@ -16,27 +16,27 @@ #include "entrypoints/entrypoint_utils.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Object* art_portable_initialize_static_storage_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, true, false); } extern "C" mirror::Object* art_portable_initialize_type_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveVerifyAndClinit(type_idx, referrer, thread, false, false); } extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_code(uint32_t type_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be @@ -44,7 +44,7 @@ extern "C" mirror::Object* art_portable_initialize_type_and_verify_access_from_c return ResolveVerifyAndClinit(type_idx, referrer, thread, false, true); } -extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::AbstractMethod* referrer, +extern "C" mirror::Object* art_portable_resolve_string_from_code(mirror::ArtMethod* referrer, uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/portable/portable_entrypoints.h b/runtime/entrypoints/portable/portable_entrypoints.h index ec9e4f8a7d..d4564471ac 100644 --- a/runtime/entrypoints/portable/portable_entrypoints.h +++ b/runtime/entrypoints/portable/portable_entrypoints.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Object; } // namespace mirror class Thread; @@ -35,8 +35,8 @@ class Thread; // compiler ABI. struct PACKED(4) PortableEntryPoints { // Invocation - void (*pPortableResolutionTrampoline)(mirror::AbstractMethod*); - void (*pPortableToInterpreterBridge)(mirror::AbstractMethod*); + void (*pPortableResolutionTrampoline)(mirror::ArtMethod*); + void (*pPortableToInterpreterBridge)(mirror::ArtMethod*); }; } // namespace art diff --git a/runtime/entrypoints/portable/portable_field_entrypoints.cc b/runtime/entrypoints/portable/portable_field_entrypoints.cc index aa0f03ce8b..bd6f79584b 100644 --- a/runtime/entrypoints/portable/portable_field_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_field_entrypoints.cc @@ -15,17 +15,17 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" -#include "mirror/field-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint32_t)); @@ -47,10 +47,10 @@ extern "C" int32_t art_portable_set32_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; @@ -69,11 +69,11 @@ extern "C" int32_t art_portable_set64_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(field->GetDeclaringClass(), new_value); return 0; @@ -88,9 +88,9 @@ extern "C" int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -103,9 +103,9 @@ extern "C" int32_t art_portable_get32_static_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -118,10 +118,10 @@ extern "C" int64_t art_portable_get64_static_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer) + mirror::ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -134,10 +134,10 @@ extern "C" mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_ } extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, uint32_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t)); if (LIKELY(field != NULL)) { field->Set32(obj, new_value); return 0; @@ -152,10 +152,10 @@ extern "C" int32_t art_portable_set32_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, int64_t new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t)); if (LIKELY(field != NULL)) { field->Set64(obj, new_value); return 0; @@ -170,12 +170,12 @@ extern "C" int32_t art_portable_set64_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj, mirror::Object* new_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { field->SetObj(obj, new_value); return 0; @@ -190,10 +190,10 @@ extern "C" int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, } extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t)); if (LIKELY(field != NULL)) { return field->Get32(obj); } @@ -206,10 +206,10 @@ extern "C" int32_t art_portable_get32_instance_from_code(uint32_t field_idx, } extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t)); if (LIKELY(field != NULL)) { return field->Get64(obj); } @@ -222,11 +222,11 @@ extern "C" int64_t art_portable_get64_instance_from_code(uint32_t field_idx, } extern "C" mirror::Object* art_portable_get_obj_instance_from_code(uint32_t field_idx, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(obj); } diff --git a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc index 771608b604..8cf4eed88f 100644 --- a/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_fillarray_entrypoints.cc @@ -16,12 +16,12 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" void art_portable_fill_array_data_from_code(mirror::AbstractMethod* method, +extern "C" void art_portable_fill_array_data_from_code(mirror::ArtMethod* method, uint32_t dex_pc, mirror::Array* array, uint32_t payload_offset) diff --git a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc index 5911ba3d8b..14cbd84186 100644 --- a/runtime/entrypoints/portable/portable_invoke_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_invoke_entrypoints.cc @@ -15,20 +15,20 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" namespace art { -static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, +static mirror::ArtMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, bool access_check, InvokeType type, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, @@ -55,7 +55,7 @@ static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kStatic, thread); @@ -63,7 +63,7 @@ extern "C" mirror::Object* art_portable_find_static_method_from_code_with_access extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kDirect, thread); @@ -71,7 +71,7 @@ extern "C" mirror::Object* art_portable_find_direct_method_from_code_with_access extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kVirtual, thread); @@ -79,7 +79,7 @@ extern "C" mirror::Object* art_portable_find_virtual_method_from_code_with_acces extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kSuper, thread); @@ -87,7 +87,7 @@ extern "C" mirror::Object* art_portable_find_super_method_from_code_with_access_ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_access_check(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, true, kInterface, thread); @@ -95,7 +95,7 @@ extern "C" mirror::Object* art_portable_find_interface_method_from_code_with_acc extern "C" mirror::Object* art_portable_find_interface_method_from_code(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* referrer, + mirror::ArtMethod* referrer, Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return FindMethodHelper(method_idx, this_object, referrer, false, kInterface, thread); diff --git a/runtime/entrypoints/portable/portable_jni_entrypoints.cc b/runtime/entrypoints/portable/portable_jni_entrypoints.cc index 8df16ae931..de1e32ef17 100644 --- a/runtime/entrypoints/portable/portable_jni_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_jni_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "thread-inl.h" diff --git a/runtime/entrypoints/portable/portable_thread_entrypoints.cc b/runtime/entrypoints/portable/portable_thread_entrypoints.cc index dac73885a5..8a2c8998aa 100644 --- a/runtime/entrypoints/portable/portable_thread_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_thread_entrypoints.cc @@ -15,7 +15,7 @@ */ #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object-inl.h" #include "verifier/dex_gc_map.h" #include "stack.h" @@ -31,7 +31,7 @@ class ShadowFrameCopyVisitor : public StackVisitor { if (IsShadowFrame()) { ShadowFrame* cur_frame = GetCurrentShadowFrame(); size_t num_regs = cur_frame->NumberOfVRegs(); - mirror::AbstractMethod* method = cur_frame->GetMethod(); + mirror::ArtMethod* method = cur_frame->GetMethod(); uint32_t dex_pc = cur_frame->GetDexPC(); ShadowFrame* new_frame = ShadowFrame::Create(num_regs, NULL, method, dex_pc); @@ -88,7 +88,7 @@ extern "C" void art_portable_test_suspend_from_code(Thread* self) extern "C" ShadowFrame* art_portable_push_shadow_frame_from_code(Thread* thread, ShadowFrame* new_shadow_frame, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t num_vregs) { ShadowFrame* old_frame = thread->PushShadowFrame(new_shadow_frame); new_shadow_frame->SetMethod(method); diff --git a/runtime/entrypoints/portable/portable_throw_entrypoints.cc b/runtime/entrypoints/portable/portable_throw_entrypoints.cc index 64a67ebb4c..2a0df9b896 100644 --- a/runtime/entrypoints/portable/portable_throw_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_throw_entrypoints.cc @@ -16,7 +16,7 @@ #include "dex_instruction.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" namespace art { @@ -68,7 +68,7 @@ extern "C" void* art_portable_get_and_clear_exception(Thread* self) return exception; } -extern "C" int32_t art_portable_find_catch_block_from_code(mirror::AbstractMethod* current_method, +extern "C" int32_t art_portable_find_catch_block_from_code(mirror::ArtMethod* current_method, uint32_t ti_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Thread* self = Thread::Current(); // TODO: make an argument. diff --git a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc index c02ace88c1..e1ce11a825 100644 --- a/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc +++ b/runtime/entrypoints/portable/portable_trampoline_entrypoints.cc @@ -20,7 +20,7 @@ #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "scoped_thread_state_change.h" @@ -52,7 +52,7 @@ class PortableArgumentVisitor { #define PORTABLE_STACK_ARG_SKIP 0 #endif - PortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp) + PortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : caller_mh_(caller_mh), args_in_regs_(ComputeArgsInRegs(caller_mh)), @@ -140,7 +140,7 @@ class PortableArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { public: - BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableShadowFrameVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ShadowFrame& sf, size_t first_arg_reg) : PortableArgumentVisitor(caller_mh, sp), sf_(sf), cur_reg_(first_arg_reg) { } virtual void Visit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -176,8 +176,8 @@ class BuildPortableShadowFrameVisitor : public PortableArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildPortableShadowFrameVisitor); }; -extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artPortableToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -225,7 +225,7 @@ extern "C" uint64_t artPortableToInterpreterBridge(mirror::AbstractMethod* metho // to jobjects. class BuildPortableArgumentVisitor : public PortableArgumentVisitor { public: - BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::AbstractMethod** sp, + BuildPortableArgumentVisitor(MethodHelper& caller_mh, mirror::ArtMethod** sp, ScopedObjectAccessUnchecked& soa, std::vector& args) : PortableArgumentVisitor(caller_mh, sp), soa_(soa), args_(args) {} @@ -269,9 +269,9 @@ class BuildPortableArgumentVisitor : public PortableArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artPortableProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -292,7 +292,7 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference(interface_method); @@ -306,13 +306,13 @@ extern "C" uint64_t artPortableProxyInvokeHandler(mirror::AbstractMethod* proxy_ } // Lazily resolve a method for portable. Called by stub code. -extern "C" const void* artPortableResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artPortableResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, Thread* thread, - mirror::AbstractMethod** called_addr) + mirror::ArtMethod** called_addr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc; - mirror::AbstractMethod* caller = thread->GetCurrentMethod(&dex_pc); + mirror::ArtMethod* caller = thread->GetCurrentMethod(&dex_pc); ClassLinker* linker = Runtime::Current()->GetClassLinker(); InvokeType invoke_type; diff --git a/runtime/entrypoints/quick/callee_save_frame.h b/runtime/entrypoints/quick/callee_save_frame.h index 0cb578ddd0..8f7004920d 100644 --- a/runtime/entrypoints/quick/callee_save_frame.h +++ b/runtime/entrypoints/quick/callee_save_frame.h @@ -22,11 +22,11 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; } // namespace mirror // Place a special frame at the TOS that will save the callee saves for the given type. -static void FinishCalleeSaveFrameSetup(Thread* self, mirror::AbstractMethod** sp, +static void FinishCalleeSaveFrameSetup(Thread* self, mirror::ArtMethod** sp, Runtime::CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Be aware the store below may well stomp on an incoming argument. diff --git a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc index 9ed802a2bb..420e63a1bb 100644 --- a/runtime/entrypoints/quick/quick_alloc_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_alloc_entrypoints.cc @@ -16,61 +16,61 @@ #include "callee_save_frame.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { -extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::AbstractMethod* method, - Thread* self, mirror::AbstractMethod** sp) +extern "C" mirror::Object* artAllocObjectFromCode(uint32_t type_idx, mirror::ArtMethod* method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, false); } extern "C" mirror::Object* artAllocObjectFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocObjectFromCode(type_idx, method, self, true); } -extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::AbstractMethod* method, +extern "C" mirror::Array* artAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return AllocArrayFromCode(type_idx, method, component_count, self, true); } extern "C" mirror::Array* artCheckAndAllocArrayFromCode(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, false); } extern "C" mirror::Array* artCheckAndAllocArrayFromCodeWithAccessCheck(uint32_t type_idx, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, int32_t component_count, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return CheckAndAllocArrayFromCode(type_idx, method, component_count, self, true); diff --git a/runtime/entrypoints/quick/quick_cast_entrypoints.cc b/runtime/entrypoints/quick/quick_cast_entrypoints.cc index b810bb70a6..9ffa736614 100644 --- a/runtime/entrypoints/quick/quick_cast_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_cast_entrypoints.cc @@ -33,7 +33,7 @@ extern "C" uint32_t artIsAssignableFromCode(const mirror::Class* klass, // Check whether it is safe to cast one class to the other, throw exception and return -1 on failure extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest_type, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(src_type->IsClass()) << PrettyClass(src_type); DCHECK(dest_type->IsClass()) << PrettyClass(dest_type); @@ -50,7 +50,7 @@ extern "C" int artCheckCastFromCode(mirror::Class* src_type, mirror::Class* dest // Returns 0 on success and -1 if an exception is pending. extern "C" int artCanPutArrayElementFromCode(const mirror::Object* element, const mirror::Class* array_class, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(array_class != NULL); // element can't be NULL as we catch this is screened in runtime_support diff --git a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc index 43fc9d2a2d..51c647adf1 100644 --- a/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_deoptimization_entrypoints.cc @@ -17,7 +17,7 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "interpreter/interpreter.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { -extern "C" void artDeoptimize(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artDeoptimize(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); self->SetException(ThrowLocation(), reinterpret_cast(-1)); diff --git a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc index 6400161b3e..003047a5f8 100644 --- a/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_dexcache_entrypoints.cc @@ -19,16 +19,16 @@ #include "class_linker-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" namespace art { extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called to ensure static storage base is initialized for direct static field reads and writes. // A class may be accessing another class' fields when it doesn't have access, as access has been @@ -38,8 +38,8 @@ extern "C" mirror::Class* artInitializeStaticStorageFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when method->dex_cache_resolved_types_[] misses. FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); @@ -47,9 +47,9 @@ extern "C" mirror::Class* artInitializeTypeFromCode(uint32_t type_idx, } extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type_idx, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when caller isn't guaranteed to have access to a type and the dex cache may be // unpopulated. @@ -57,9 +57,9 @@ extern "C" mirror::Class* artInitializeTypeAndVerifyAccessFromCode(uint32_t type return ResolveVerifyAndClinit(type_idx, referrer, self, false, true); } -extern "C" mirror::String* artResolveStringFromCode(mirror::AbstractMethod* referrer, +extern "C" mirror::String* artResolveStringFromCode(mirror::ArtMethod* referrer, int32_t string_idx, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); return ResolveStringFromCode(referrer, string_idx); diff --git a/runtime/entrypoints/quick/quick_entrypoints.h b/runtime/entrypoints/quick/quick_entrypoints.h index e76679b91f..9d3b8ef27c 100644 --- a/runtime/entrypoints/quick/quick_entrypoints.h +++ b/runtime/entrypoints/quick/quick_entrypoints.h @@ -29,9 +29,9 @@ namespace art { namespace mirror { - class AbstractMethod; - class Class; - class Object; +class ArtMethod; +class Class; +class Object; } // namespace mirror class Thread; @@ -116,8 +116,8 @@ struct PACKED(4) QuickEntryPoints { void* (*pMemcpy)(void*, const void*, size_t); // Invocation - void (*pQuickResolutionTrampoline)(mirror::AbstractMethod*); - void (*pQuickToInterpreterBridge)(mirror::AbstractMethod*); + void (*pQuickResolutionTrampoline)(mirror::ArtMethod*); + void (*pQuickToInterpreterBridge)(mirror::ArtMethod*); void (*pInvokeDirectTrampolineWithAccessCheck)(uint32_t, void*); void (*pInvokeInterfaceTrampoline)(uint32_t, void*); void (*pInvokeInterfaceTrampolineWithAccessCheck)(uint32_t, void*); diff --git a/runtime/entrypoints/quick/quick_field_entrypoints.cc b/runtime/entrypoints/quick/quick_field_entrypoints.cc index a4e9dc9b27..0ec1eb7920 100644 --- a/runtime/entrypoints/quick/quick_field_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_field_entrypoints.cc @@ -17,19 +17,20 @@ #include "callee_save_frame.h" #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include namespace art { extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL)) { return field->Get32(field->GetDeclaringClass()); } @@ -42,10 +43,11 @@ extern "C" uint32_t artGet32StaticFromCode(uint32_t field_idx, } extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL)) { return field->Get64(field->GetDeclaringClass()); } @@ -58,16 +60,17 @@ extern "C" uint64_t artGet64StaticFromCode(uint32_t field_idx, } extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, - const mirror::AbstractMethod* referrer, - Thread* self, mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectRead, sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, StaticObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { return field->GetObj(field->GetDeclaringClass()); } @@ -75,15 +78,17 @@ extern "C" mirror::Object* artGetObjStaticFromCode(uint32_t field_idx, } extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get32(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -96,15 +101,17 @@ extern "C" uint32_t artGet32InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { return field->Get64(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveRead, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -117,16 +124,18 @@ extern "C" uint64_t artGet64InstanceFromCode(uint32_t field_idx, mirror::Object* } extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, - const mirror::AbstractMethod* referrer, + const mirror::ArtMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { return field->GetObj(obj); } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), true); + field = FindFieldFromCode(field_idx, referrer, self, InstanceObjectRead, sizeof(mirror::Object*), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -139,10 +148,11 @@ extern "C" mirror::Object* artGetObjInstanceFromCode(uint32_t field_idx, mirror: } extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL)) { field->Set32(field->GetDeclaringClass(), new_value); return 0; // success @@ -156,10 +166,11 @@ extern "C" int artSet32StaticFromCode(uint32_t field_idx, uint32_t new_value, return -1; // failure } -extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::AbstractMethod* referrer, - uint64_t new_value, Thread* self, mirror::AbstractMethod** sp) +extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::ArtMethod* referrer, + uint64_t new_value, Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(int64_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL)) { field->Set64(field->GetDeclaringClass(), new_value); return 0; // success @@ -174,11 +185,11 @@ extern "C" int artSet64StaticFromCode(uint32_t field_idx, const mirror::Abstract } extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL)) { if (LIKELY(!FieldHelper(field).IsPrimitiveType())) { field->SetObj(field->GetDeclaringClass(), new_value); @@ -195,16 +206,18 @@ extern "C" int artSetObjStaticFromCode(uint32_t field_idx, mirror::Object* new_v } extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint32_t new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(int32_t)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int32_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set32(obj, new_value); return 0; // success } FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int32_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -218,20 +231,21 @@ extern "C" int artSet32InstanceFromCode(uint32_t field_idx, mirror::Object* obj, } extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, uint64_t new_value, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); - mirror::AbstractMethod* referrer = - sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::AbstractMethod*)]; - mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, - sizeof(int64_t)); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* referrer = + sp[callee_save->GetFrameSizeInBytes() / sizeof(mirror::ArtMethod*)]; + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, + sizeof(int64_t)); if (LIKELY(field != NULL && obj != NULL)) { field->Set64(obj, new_value); return 0; // success } *sp = callee_save; self->SetTopOfStack(sp, 0); - field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), true); + field = FindFieldFromCode(field_idx, referrer, self, InstancePrimitiveWrite, sizeof(int64_t), + true); if (LIKELY(field != NULL)) { if (UNLIKELY(obj == NULL)) { ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -246,11 +260,11 @@ extern "C" int artSet64InstanceFromCode(uint32_t field_idx, mirror::Object* obj, extern "C" int artSetObjInstanceFromCode(uint32_t field_idx, mirror::Object* obj, mirror::Object* new_value, - const mirror::AbstractMethod* referrer, Thread* self, - mirror::AbstractMethod** sp) + const mirror::ArtMethod* referrer, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, - sizeof(mirror::Object*)); + mirror::ArtField* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, + sizeof(mirror::Object*)); if (LIKELY(field != NULL && obj != NULL)) { field->SetObj(obj, new_value); return 0; // success diff --git a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc index b81ad12b7b..ca0c92e6d5 100644 --- a/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_fillarray_entrypoints.cc @@ -39,7 +39,7 @@ namespace art { */ extern "C" int artHandleFillArrayDataFromCode(mirror::Array* array, const Instruction::ArrayDataPayload* payload, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK_EQ(payload->ident, static_cast(Instruction::kArrayDataSignature)); diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc index 0e61942209..633f580bd6 100644 --- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc @@ -16,17 +16,17 @@ #include "callee_save_frame.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/object-inl.h" #include "runtime.h" #include "thread-inl.h" namespace art { -extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMethod* method, +extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::ArtMethod* method, mirror::Object* this_object, Thread* self, - mirror::AbstractMethod** sp, + mirror::ArtMethod** sp, uintptr_t lr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -39,7 +39,7 @@ extern "C" const void* artInstrumentationMethodEntryFromCode(mirror::AbstractMet return result; } -extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::AbstractMethod** sp, +extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::ArtMethod** sp, uint64_t gpr_result, uint64_t fpr_result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: use FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly) not the hand inlined below. @@ -47,7 +47,7 @@ extern "C" uint64_t artInstrumentationMethodExitFromCode(Thread* self, mirror::A // stack. // Be aware the store below may well stomp on an incoming argument. Locks::mutator_lock_->AssertSharedHeld(self); - mirror::AbstractMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); + mirror::ArtMethod* callee_save = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsOnly); *sp = callee_save; uintptr_t* return_pc = reinterpret_cast(reinterpret_cast(sp) + callee_save->GetReturnPcOffsetInBytes()); diff --git a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc index 53b3628e2f..1d8022f803 100644 --- a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc @@ -17,21 +17,21 @@ #include "callee_save_frame.h" #include "dex_instruction-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" namespace art { // Determine target of interface dispatch. This object is known non-null. -extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interface_method, +extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::ArtMethod* interface_method, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp) + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex16)) { method = this_object->GetClass()->FindVirtualMethodForInterface(interface_method); if (UNLIKELY(method == NULL)) { @@ -144,11 +144,11 @@ extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::AbstractMethod* interfa static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, - Thread* self, mirror::AbstractMethod** sp, bool access_check, + mirror::ArtMethod* caller_method, + Thread* self, mirror::ArtMethod** sp, bool access_check, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = FindMethodFast(method_idx, this_object, caller_method, + mirror::ArtMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, type); if (UNLIKELY(method == NULL)) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); @@ -179,9 +179,9 @@ static uint64_t artInvokeCommon(uint32_t method_idx, mirror::Object* this_object // See comments in runtime_support_asm.S extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kInterface); } @@ -189,36 +189,36 @@ extern "C" uint64_t artInvokeInterfaceTrampolineWithAccessCheck(uint32_t method_ extern "C" uint64_t artInvokeDirectTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kDirect); } extern "C" uint64_t artInvokeStaticTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kStatic); } extern "C" uint64_t artInvokeSuperTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kSuper); } extern "C" uint64_t artInvokeVirtualTrampolineWithAccessCheck(uint32_t method_idx, mirror::Object* this_object, - mirror::AbstractMethod* caller_method, + mirror::ArtMethod* caller_method, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return artInvokeCommon(method_idx, this_object, caller_method, self, sp, true, kVirtual); } diff --git a/runtime/entrypoints/quick/quick_jni_entrypoints.cc b/runtime/entrypoints/quick/quick_jni_entrypoints.cc index 9907c043ee..27ae59b9b0 100644 --- a/runtime/entrypoints/quick/quick_jni_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_jni_entrypoints.cc @@ -16,8 +16,8 @@ #include "dex_file-inl.h" #include "entrypoints/entrypoint_utils.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" diff --git a/runtime/entrypoints/quick/quick_lock_entrypoints.cc b/runtime/entrypoints/quick/quick_lock_entrypoints.cc index 79bb7a69f1..36ca6044a2 100644 --- a/runtime/entrypoints/quick/quick_lock_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_lock_entrypoints.cc @@ -20,7 +20,7 @@ namespace art { extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) UNLOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry @@ -29,7 +29,7 @@ extern "C" int artUnlockObjectFromCode(mirror::Object* obj, Thread* self, } extern "C" void artLockObjectFromCode(mirror::Object* obj, Thread* thread, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); DCHECK(obj != NULL); // Assumed to have been checked before entry diff --git a/runtime/entrypoints/quick/quick_thread_entrypoints.cc b/runtime/entrypoints/quick/quick_thread_entrypoints.cc index b4d6c0ba8d..53e725edba 100644 --- a/runtime/entrypoints/quick/quick_thread_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_thread_entrypoints.cc @@ -28,7 +28,7 @@ void CheckSuspendFromCode(Thread* thread) CheckSuspend(thread); } -extern "C" void artTestSuspendFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artTestSuspendFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Called when suspend count check value is 0 and thread->suspend_count_ != 0 FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsOnly); diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc index 3bfa2f2611..f67b2fc4ab 100644 --- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc @@ -24,7 +24,7 @@ namespace art { // Deliver an exception that's pending on thread helping set up a callee save frame on the way. -extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::AbstractMethod** sp) +extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kSaveAll); thread->QuickDeliverException(); @@ -32,7 +32,7 @@ extern "C" void artDeliverPendingExceptionFromCode(Thread* thread, mirror::Abstr // Called by generated call to throw an exception. extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { /* * exception may be NULL, in which case this routine should @@ -54,7 +54,7 @@ extern "C" void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread // Called by generated call to throw a NPE exception. extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowLocation throw_location = self->GetCurrentLocationForThrow(); @@ -64,7 +64,7 @@ extern "C" void artThrowNullPointerExceptionFromCode(Thread* self, // Called by generated call to throw an arithmetic divide by zero exception. extern "C" void artThrowDivZeroFromCode(Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArithmeticExceptionDivideByZero(); @@ -73,14 +73,14 @@ extern "C" void artThrowDivZeroFromCode(Thread* self, // Called by generated call to throw an array index out of bounds exception. extern "C" void artThrowArrayBoundsFromCode(int index, int length, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowArrayIndexOutOfBoundsException(index, length); self->QuickDeliverException(); } -extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMethod** sp) +extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowStackOverflowError(self); @@ -88,7 +88,7 @@ extern "C" void artThrowStackOverflowFromCode(Thread* self, mirror::AbstractMeth } extern "C" void artThrowNoSuchMethodFromCode(int32_t method_idx, Thread* self, - mirror::AbstractMethod** sp) + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kSaveAll); ThrowNoSuchMethodError(method_idx); diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 9bf02e8c8e..392bcc5257 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -19,7 +19,7 @@ #include "dex_instruction-inl.h" #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -100,18 +100,18 @@ class QuickArgumentVisitor { #define QUICK_STACK_ARG_SKIP 0 #endif - static mirror::AbstractMethod* GetCallingMethod(mirror::AbstractMethod** sp) { + static mirror::ArtMethod* GetCallingMethod(mirror::ArtMethod** sp) { byte* previous_sp = reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__FRAME_SIZE; - return *reinterpret_cast(previous_sp); + return *reinterpret_cast(previous_sp); } - static uintptr_t GetCallingPc(mirror::AbstractMethod** sp) { + static uintptr_t GetCallingPc(mirror::ArtMethod** sp) { byte* lr = reinterpret_cast(sp) + QUICK_CALLEE_SAVE_FRAME__REF_AND_ARGS__LR_OFFSET; return *reinterpret_cast(lr); } - QuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, + QuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : is_static_(is_static), shorty_(shorty), shorty_len_(shorty_len), @@ -220,7 +220,7 @@ class QuickArgumentVisitor { // Visits arguments on the stack placing them into the shadow frame. class BuildShadowFrameVisitor : public QuickArgumentVisitor { public: - BuildShadowFrameVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildShadowFrameVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ShadowFrame& sf, size_t first_arg_reg) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), sf_(sf), cur_reg_(first_arg_reg) {} @@ -261,8 +261,8 @@ class BuildShadowFrameVisitor : public QuickArgumentVisitor { DISALLOW_COPY_AND_ASSIGN(BuildShadowFrameVisitor); }; -extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, Thread* self, - mirror::AbstractMethod** sp) +extern "C" uint64_t artQuickToInterpreterBridge(mirror::ArtMethod* method, Thread* self, + mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in the shadow // frame. @@ -311,7 +311,7 @@ extern "C" uint64_t artQuickToInterpreterBridge(mirror::AbstractMethod* method, // to jobjects. class BuildQuickArgumentVisitor : public QuickArgumentVisitor { public: - BuildQuickArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + BuildQuickArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa, std::vector* args) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa), args_(args) {} @@ -360,9 +360,9 @@ class BuildQuickArgumentVisitor : public QuickArgumentVisitor { // which is responsible for recording callee save registers. We explicitly place into jobjects the // incoming reference arguments (so they survive GC). We invoke the invocation handler, which is a // field within the proxy object, which will box the primitive arguments and deal with error cases. -extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_method, +extern "C" uint64_t artQuickProxyInvokeHandler(mirror::ArtMethod* proxy_method, mirror::Object* receiver, - Thread* self, mirror::AbstractMethod** sp) + Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // Ensure we don't get thread suspension until the object arguments are safely in jobjects. const char* old_cause = @@ -389,7 +389,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met args.erase(args.begin()); // Convert proxy method into expected interface method. - mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod(); + mirror::ArtMethod* interface_method = proxy_method->FindOverriddenMethod(); DCHECK(interface_method != NULL); DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method); jobject interface_method_jobj = soa.AddLocalReference(interface_method); @@ -406,7 +406,7 @@ extern "C" uint64_t artQuickProxyInvokeHandler(mirror::AbstractMethod* proxy_met // so they don't get garbage collected. class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { public: - RememberFoGcArgumentVisitor(mirror::AbstractMethod** sp, bool is_static, const char* shorty, + RememberFoGcArgumentVisitor(mirror::ArtMethod** sp, bool is_static, const char* shorty, uint32_t shorty_len, ScopedObjectAccessUnchecked* soa) : QuickArgumentVisitor(sp, is_static, shorty, shorty_len), soa_(soa) {} @@ -423,9 +423,9 @@ class RememberFoGcArgumentVisitor : public QuickArgumentVisitor { }; // Lazily resolve a method for quick. Called by stub code. -extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* called, +extern "C" const void* artQuickResolutionTrampoline(mirror::ArtMethod* called, mirror::Object* receiver, - Thread* thread, mirror::AbstractMethod** sp) + Thread* thread, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { FinishCalleeSaveFrameSetup(thread, sp, Runtime::kRefsAndArgs); // Start new JNI local reference state @@ -436,7 +436,7 @@ extern "C" const void* artQuickResolutionTrampoline(mirror::AbstractMethod* call // Compute details about the called method (avoid GCs) ClassLinker* linker = Runtime::Current()->GetClassLinker(); - mirror::AbstractMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); + mirror::ArtMethod* caller = QuickArgumentVisitor::GetCallingMethod(sp); InvokeType invoke_type; const DexFile* dex_file; uint32_t dex_method_idx; diff --git a/runtime/exception_test.cc b/runtime/exception_test.cc index 933b74ace1..e48208d771 100644 --- a/runtime/exception_test.cc +++ b/runtime/exception_test.cc @@ -95,8 +95,8 @@ class ExceptionTest : public CommonTest { UnsignedLeb128EncodingVector fake_vmap_table_data_; std::vector fake_gc_map_; - mirror::AbstractMethod* method_f_; - mirror::AbstractMethod* method_g_; + mirror::ArtMethod* method_f_; + mirror::ArtMethod* method_g_; private: mirror::Class* my_klass_; diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc index 0363acb477..3bbc3810a0 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -22,9 +22,9 @@ #include "gc/collector/mark_sweep-inl.h" #include "gc/heap.h" #include "gc/space/space.h" +#include "mirror/art_field-inl.h" #include "mirror/object-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "space_bitmap-inl.h" #include "thread.h" diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc index 6edc067cc7..702e162262 100644 --- a/runtime/gc/accounting/space_bitmap.cc +++ b/runtime/gc/accounting/space_bitmap.cc @@ -17,8 +17,8 @@ #include "base/logging.h" #include "dex_file-inl.h" #include "heap_bitmap.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -182,10 +182,10 @@ static void WalkInstanceFields(SpaceBitmap* visited, SpaceBitmap::Callback* call WalkInstanceFields(visited, callback, obj, super, arg); } // Walk instance fields - mirror::ObjectArray* fields = klass->GetIFields(); + mirror::ObjectArray* fields = klass->GetIFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(obj); @@ -212,10 +212,10 @@ static void WalkFieldsInOrder(SpaceBitmap* visited, SpaceBitmap::Callback* callb WalkInstanceFields(visited, callback, obj, klass, arg); // Walk static fields of a Class if (obj->IsClass()) { - mirror::ObjectArray* fields = klass->GetSFields(); + mirror::ObjectArray* fields = klass->GetSFields(); if (fields != NULL) { for (int32_t i = 0; i < fields->GetLength(); i++) { - mirror::Field* field = fields->Get(i); + mirror::ArtField* field = fields->Get(i); FieldHelper fh(field); if (!fh.IsPrimitiveType()) { mirror::Object* value = field->GetObj(NULL); diff --git a/runtime/gc/collector/mark_sweep-inl.h b/runtime/gc/collector/mark_sweep-inl.h index 6b1b617eb4..e158952119 100644 --- a/runtime/gc/collector/mark_sweep-inl.h +++ b/runtime/gc/collector/mark_sweep-inl.h @@ -20,8 +20,8 @@ #include "gc/collector/mark_sweep.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "mirror/object_array.h" namespace art { @@ -136,8 +136,8 @@ inline void MarkSweep::VisitFieldsReferences(const mirror::Object* obj, uint32_t ? klass->NumReferenceStaticFields() : klass->NumReferenceInstanceFields()); for (size_t i = 0; i < num_reference_fields; ++i) { - mirror::Field* field = (is_static ? klass->GetStaticField(i) - : klass->GetInstanceField(i)); + mirror::ArtField* field = (is_static ? klass->GetStaticField(i) + : klass->GetInstanceField(i)); MemberOffset field_offset = field->GetOffset(); const mirror::Object* ref = obj->GetFieldObject(field_offset, false); visitor(obj, ref, field_offset, is_static); diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 7b78720392..61570ae393 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -37,11 +37,11 @@ #include "jni_internal.h" #include "monitor.h" #include "mark_sweep-inl.h" +#include "mirror/art_field.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" @@ -50,8 +50,8 @@ #include "thread_list.h" #include "verifier/method_verifier.h" +using ::art::mirror::ArtField; using ::art::mirror::Class; -using ::art::mirror::Field; using ::art::mirror::Object; using ::art::mirror::ObjectArray; @@ -1072,11 +1072,11 @@ void MarkSweep::CheckReference(const Object* obj, const Object* ref, MemberOffse const Class* klass = is_static ? obj->AsClass() : obj->GetClass(); DCHECK(klass != NULL); - const ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); + const ObjectArray* fields = is_static ? klass->GetSFields() : klass->GetIFields(); DCHECK(fields != NULL); bool found = false; for (int32_t i = 0; i < fields->GetLength(); ++i) { - const Field* cur = fields->Get(i); + const ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(WARNING) << "Field referencing the alloc space was " << PrettyField(cur); found = true; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index df1f3fe92e..a2453b8405 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -41,8 +41,8 @@ #include "gc/space/space-inl.h" #include "image.h" #include "invoke_arg_array_builder.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -1512,11 +1512,11 @@ class VerifyReferenceCardVisitor { if (!obj->IsObjectArray()) { const mirror::Class* klass = is_static ? obj->AsClass() : obj->GetClass(); CHECK(klass != NULL); - const mirror::ObjectArray* fields = is_static ? klass->GetSFields() - : klass->GetIFields(); + const mirror::ObjectArray* fields = is_static ? klass->GetSFields() + : klass->GetIFields(); CHECK(fields != NULL); for (int32_t i = 0; i < fields->GetLength(); ++i) { - const mirror::Field* cur = fields->Get(i); + const mirror::ArtField* cur = fields->Get(i); if (cur->GetOffset().Int32Value() == offset.Int32Value()) { LOG(ERROR) << (is_static ? "Static " : "") << "field in the live stack is " << PrettyField(cur); diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 8ff7025c34..22562df512 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -22,7 +22,7 @@ #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/art_method.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "oat_file.h" @@ -187,14 +187,14 @@ ImageSpace* ImageSpace::Init(const std::string& image_file_name, bool validate_o Runtime* runtime = Runtime::Current(); mirror::Object* resolution_method = image_header.GetImageRoot(ImageHeader::kResolutionMethod); - runtime->SetResolutionMethod(down_cast(resolution_method)); + runtime->SetResolutionMethod(down_cast(resolution_method)); mirror::Object* callee_save_method = image_header.GetImageRoot(ImageHeader::kCalleeSaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kSaveAll); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kSaveAll); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsOnlySaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsOnly); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsOnly); callee_save_method = image_header.GetImageRoot(ImageHeader::kRefsAndArgsSaveMethod); - runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsAndArgs); + runtime->SetCalleeSaveMethod(down_cast(callee_save_method), Runtime::kRefsAndArgs); UniquePtr space(new ImageSpace(image_file_name, map.release())); diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index d3bb2e8f5f..0b2e741527 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -48,10 +48,9 @@ #include "gc/heap.h" #include "gc/space/space.h" #include "globals.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "os.h" @@ -922,7 +921,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { rec->AddId(CLASS_STATICS_ID(obj)); for (size_t i = 0; i < sFieldCount; ++i) { - mirror::Field* f = thisClass->GetStaticField(i); + mirror::ArtField* f = thisClass->GetStaticField(i); fh.ChangeField(f); size_t size; @@ -947,7 +946,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { int iFieldCount = thisClass->IsObjectClass() ? 0 : thisClass->NumInstanceFields(); rec->AddU2((uint16_t)iFieldCount); for (int i = 0; i < iFieldCount; ++i) { - mirror::Field* f = thisClass->GetInstanceField(i); + mirror::ArtField* f = thisClass->GetInstanceField(i); fh.ChangeField(f); HprofBasicType t = SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), NULL); rec->AddId(LookupStringId(fh.GetName())); @@ -1010,7 +1009,7 @@ int Hprof::DumpHeapObject(mirror::Object* obj) { while (!sclass->IsObjectClass()) { int ifieldCount = sclass->NumInstanceFields(); for (int i = 0; i < ifieldCount; ++i) { - mirror::Field* f = sclass->GetInstanceField(i); + mirror::ArtField* f = sclass->GetInstanceField(i); fh.ChangeField(f); size_t size; SignatureToBasicTypeAndSize(fh.GetTypeDescriptor(), &size); diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index c3b66b3f79..ae3a165a70 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -23,9 +23,9 @@ #include "class_linker.h" #include "debugger.h" #include "dex_file-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" #include "nth_caller_visitor.h" @@ -55,7 +55,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } bool is_initialized = klass->IsInitialized(); for (size_t i = 0; i < klass->NumDirectMethods(); i++) { - mirror::AbstractMethod* method = klass->GetDirectMethod(i); + mirror::ArtMethod* method = klass->GetDirectMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -77,7 +77,7 @@ bool Instrumentation::InstallStubsForClass(mirror::Class* klass) { } } for (size_t i = 0; i < klass->NumVirtualMethods(); i++) { - mirror::AbstractMethod* method = klass->GetVirtualMethod(i); + mirror::ArtMethod* method = klass->GetVirtualMethod(i); if (!method->IsAbstract()) { const void* new_code; if (uninstall) { @@ -109,7 +109,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) instrumentation_exit_pc_(instrumentation_exit_pc), last_return_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() @@ -169,7 +169,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) for (It it = thread->GetInstrumentationStack()->rbegin(), end = thread->GetInstrumentationStack()->rend(); it != end; ++it) { mirror::Object* this_object = (*it).this_object_; - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; uint32_t dex_pc = visitor.dex_pcs_.back(); visitor.dex_pcs_.pop_back(); instrumentation->MethodEnterEvent(thread, this_object, method, dex_pc); @@ -193,7 +193,7 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) if (instrumentation_stack_->size() == 0) { return false; // Stop. } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (GetCurrentQuickFrame() == NULL) { if (kVerboseInstrumentation) { LOG(INFO) << " Ignoring a shadow frame. Frame " << GetFrameId() << " Method=" << PrettyMethod(m); @@ -379,7 +379,7 @@ void Instrumentation::ConfigureStubs(bool require_entry_exit_stubs, bool require } } -void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const { +void Instrumentation::UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const { if (LIKELY(!instrumentation_stubs_installed_)) { method->SetEntryPointFromCompiledCode(code); } else { @@ -391,7 +391,7 @@ void Instrumentation::UpdateMethodsCode(mirror::AbstractMethod* method, const vo } } -const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* method) const { +const void* Instrumentation::GetQuickCodeFor(const mirror::ArtMethod* method) const { Runtime* runtime = Runtime::Current(); if (LIKELY(!instrumentation_stubs_installed_)) { const void* code = method->GetEntryPointFromCompiledCode(); @@ -405,7 +405,7 @@ const void* Instrumentation::GetQuickCodeFor(const mirror::AbstractMethod* metho } void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { typedef std::list::const_iterator It; // TODO: C++0x auto It it = method_entry_listeners_.begin(); @@ -420,7 +420,7 @@ void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_ } void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const { typedef std::list::const_iterator It; // TODO: C++0x auto It it = method_exit_listeners_.begin(); @@ -435,7 +435,7 @@ void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { if (have_method_unwind_listeners_) { typedef std::list::const_iterator It; // TODO: C++0x auto @@ -447,7 +447,7 @@ void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_obj } void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) const { // TODO: STL copy-on-write collection? The copy below is due to the debug listener having an // action where it can remove itself as a listener and break the iterator. The copy only works @@ -461,7 +461,7 @@ void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_o } void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) { if (have_exception_caught_listeners_) { @@ -489,7 +489,7 @@ static void CheckStackDepth(Thread* self, const InstrumentationStackFrame& instr } void Instrumentation::PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) { // We have a callee-save frame meaning this value is guaranteed to never be 0. size_t frame_id = StackVisitor::ComputeNumFrames(self); @@ -516,7 +516,7 @@ uint64_t Instrumentation::PopInstrumentationStackFrame(Thread* self, uintptr_t* *return_pc = instrumentation_frame.return_pc_; CheckStackDepth(self, instrumentation_frame, 0); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; char return_shorty = MethodHelper(method).GetShorty()[0]; JValue return_value; if (return_shorty == 'V') { @@ -567,7 +567,7 @@ void Instrumentation::PopMethodForUnwind(Thread* self, bool is_deoptimization) c // TODO: bring back CheckStackDepth(self, instrumentation_frame, 2); stack->pop_front(); - mirror::AbstractMethod* method = instrumentation_frame.method_; + mirror::ArtMethod* method = instrumentation_frame.method_; if (is_deoptimization) { if (kVerboseInstrumentation) { LOG(INFO) << "Popping for deoptimization " << PrettyMethod(method); diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 798b7ab56d..6c80b41b64 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -25,10 +25,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Object; -class Throwable; + class ArtMethod; + class Class; + class Object; + class Throwable; } // namespace mirror union JValue; class Thread; @@ -47,30 +47,30 @@ struct InstrumentationListener { // Call-back for when a method is entered. virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is exited. // TODO: its likely passing the return value would be useful, however, we may need to get and // parse the shorty to determine what kind of register holds the result. virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when a method is popped due to an exception throw. A method will either cause a // MethodExited call-back or a MethodUnwind call-back when its activation is removed. - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back for when the dex pc moves in a method. virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; // Call-back when an exception is caught. virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; }; @@ -111,12 +111,12 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); // Update the code of a method respecting any installed stubs. - void UpdateMethodsCode(mirror::AbstractMethod* method, const void* code) const; + void UpdateMethodsCode(mirror::ArtMethod* method, const void* code) const; // Get the quick code for the given method. More efficient than asking the class linker as it // will short-cut to GetCode if instrumentation and static method resolution stubs aren't // installed. - const void* GetQuickCodeFor(const mirror::AbstractMethod* method) const + const void* GetQuickCodeFor(const mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void ForceInterpretOnly() { @@ -124,7 +124,7 @@ class Instrumentation { forced_interpret_only_ = true; } - // Called by AbstractMethod::Invoke to determine dispatch mechanism. + // Called by ArtMethod::Invoke to determine dispatch mechanism. bool InterpretOnly() const { return interpret_only_; } @@ -152,7 +152,7 @@ class Instrumentation { // Inform listeners that a method has been entered. A dex PC is provided as we may install // listeners into executing code and get method enter events for methods already on the stack. void MethodEnterEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodEntryListeners())) { MethodEnterEventImpl(thread, this_object, method, dex_pc); @@ -161,7 +161,7 @@ class Instrumentation { // Inform listeners that a method has been exited. void MethodExitEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasMethodExitListeners())) { @@ -171,12 +171,12 @@ class Instrumentation { // Inform listeners that a method has been exited due to an exception. void MethodUnwindEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Inform listeners that the dex pc has moved (only supported by the interpreter). void DexPcMovedEvent(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (UNLIKELY(HasDexPcListeners())) { DexPcMovedEventImpl(thread, this_object, method, dex_pc); @@ -185,14 +185,14 @@ class Instrumentation { // Inform listeners that an exception was caught. void ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Called when an instrumented method is entered. The intended link register (lr) is saved so // that returning causes a branch to the method exit stub. Generates method enter events. void PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, - mirror::AbstractMethod* method, uintptr_t lr, + mirror::ArtMethod* method, uintptr_t lr, bool interpreter_entry) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -216,23 +216,23 @@ class Instrumentation { LOCKS_EXCLUDED(Locks::thread_list_lock_, Locks::classlinker_classes_lock_); void MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void MethodExitEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) const + const mirror::ArtMethod* method, uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Have we hijacked AbstractMethod::code_ so that it calls instrumentation/interpreter code? + // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code? bool instrumentation_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter/exit stubs? + // Have we hijacked ArtMethod::code_ to reference the enter/exit stubs? bool entry_exit_stubs_installed_; - // Have we hijacked AbstractMethod::code_ to reference the enter interpreter stub? + // Have we hijacked ArtMethod::code_ to reference the enter interpreter stub? bool interpreter_stubs_installed_; // Do we need the fidelity of events that we only get from running within the interpreter? @@ -272,7 +272,7 @@ class Instrumentation { // An element in the instrumentation side stack maintained in art::Thread. struct InstrumentationStackFrame { - InstrumentationStackFrame(mirror::Object* this_object, mirror::AbstractMethod* method, + InstrumentationStackFrame(mirror::Object* this_object, mirror::ArtMethod* method, uintptr_t return_pc, size_t frame_id, bool interpreter_entry) : this_object_(this_object), method_(method), return_pc_(return_pc), frame_id_(frame_id), interpreter_entry_(interpreter_entry) { @@ -281,7 +281,7 @@ struct InstrumentationStackFrame { std::string Dump() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; const uintptr_t return_pc_; const size_t frame_id_; const bool interpreter_entry_; diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 6e35d937fb..59f0ac2e38 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -28,26 +28,27 @@ #include "gc/accounting/card_table-inl.h" #include "invoke_arg_array_builder.h" #include "nth_caller_visitor.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" #include "ScopedLocalRef.h" #include "scoped_thread_state_change.h" #include "thread.h" +#include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; -using ::art::mirror::Field; using ::art::mirror::IntArray; using ::art::mirror::LongArray; using ::art::mirror::Object; @@ -82,22 +83,22 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, result->SetL(found); } else if (name == "java.lang.Object java.lang.Class.newInstance()") { Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); - AbstractMethod* c = klass->FindDeclaredDirectMethod("", "()V"); + ArtMethod* c = klass->FindDeclaredDirectMethod("", "()V"); CHECK(c != NULL); - Object* obj = klass->AllocObject(self); - CHECK(obj != NULL); - EnterInterpreterFromInvoke(self, c, obj, NULL, NULL); - result->SetL(obj); + SirtRef obj(self, klass->AllocObject(self)); + CHECK(obj.get() != NULL); + EnterInterpreterFromInvoke(self, c, obj.get(), NULL, NULL); + result->SetL(obj.get()); } else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") { // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail // going the reflective Dex way. Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); String* name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); - Field* found = NULL; + ArtField* found = NULL; FieldHelper fh; - ObjectArray* fields = klass->GetIFields(); + ObjectArray* fields = klass->GetIFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -106,7 +107,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, if (found == NULL) { fields = klass->GetSFields(); for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { - Field* f = fields->Get(i); + ArtField* f = fields->Get(i); fh.ChangeField(f); if (name->Equals(fh.GetName())) { found = f; @@ -118,7 +119,14 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); // TODO: getDeclaredField calls GetType once the field is found to ensure a // NoClassDefFoundError is thrown if the field's type cannot be resolved. - result->SetL(found); + Class* jlr_Field = self->DecodeJObject(WellKnownClasses::java_lang_reflect_Field)->AsClass(); + SirtRef field(self, jlr_Field->AllocObject(self)); + CHECK(field.get() != NULL); + ArtMethod* c = jlr_Field->FindDeclaredDirectMethod("", "(Ljava/lang/reflect/ArtField;)V"); + uint32_t args[1]; + args[0] = reinterpret_cast(found); + EnterInterpreterFromInvoke(self, c, field.get(), args, NULL); + result->SetL(field.get()); } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)") { // Special case array copying without initializing System. Class* ctype = shadow_frame->GetVRegReference(arg_offset)->GetClass()->GetComponentType(); @@ -153,7 +161,7 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, } // Hand select a number of methods to be run in a not yet started runtime without using JNI. -static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, +static void UnstartedRuntimeJni(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string name(PrettyMethod(method)); @@ -215,7 +223,7 @@ static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, } } -static void InterpreterJni(Thread* self, AbstractMethod* method, StringPiece shorty, +static void InterpreterJni(Thread* self, ArtMethod* method, StringPiece shorty, Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { // TODO: The following enters JNI code using a typedef-ed function rather than the JNI compiler, @@ -417,8 +425,8 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); Object* receiver = (type == kStatic) ? NULL : shadow_frame.GetVRegReference(vregC); - AbstractMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, - do_access_check, type); + ArtMethod* method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, + do_access_check, type); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -438,7 +446,7 @@ static bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -510,7 +518,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, } uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); // TODO: use ObjectArray::GetWithoutChecks ? - AbstractMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); + ArtMethod* method = receiver->GetClass()->GetVTable()->Get(vtable_idx); if (UNLIKELY(method == NULL)) { CHECK(self->IsExceptionPending()); result->SetJ(0); @@ -530,7 +538,7 @@ static bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, num_ins = code_item->ins_size_; } else { DCHECK(method->IsNative() || method->IsProxyMethod()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -601,9 +609,9 @@ static inline bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -695,9 +703,9 @@ static inline bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst) { bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, - find_type, Primitive::FieldSize(field_type), - do_access_check); + ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, + find_type, Primitive::FieldSize(field_type), + do_access_check); if (UNLIKELY(f == NULL)) { CHECK(self->IsExceptionPending()); return false; @@ -3052,7 +3060,7 @@ static inline JValue Execute(Thread* self, MethodHelper& mh, const DexFile::Code } } -void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* receiver, +void EnterInterpreterFromInvoke(Thread* self, ArtMethod* method, Object* receiver, uint32_t* args, JValue* result) { DCHECK_EQ(self, Thread::Current()); if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) { @@ -3072,7 +3080,7 @@ void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* re return; } else { DCHECK(method->IsNative()); - num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); + num_regs = num_ins = ArtMethod::NumArgRegisters(mh.GetShorty()); if (!method->IsStatic()) { num_regs++; num_ins++; @@ -3172,7 +3180,7 @@ extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh return; } - AbstractMethod* method = shadow_frame->GetMethod(); + ArtMethod* method = shadow_frame->GetMethod(); if (method->IsStatic() && !method->GetDeclaringClass()->IsInitializing()) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), true, true)) { diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index af4a1472ee..49e8de08ec 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -22,7 +22,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // namespace mirror @@ -33,8 +33,8 @@ class Thread; namespace interpreter { -// Called by AbstractMethod::Invoke, shadow frames arguments are taken from the args array. -extern void EnterInterpreterFromInvoke(Thread* self, mirror::AbstractMethod* method, +// Called by ArtMethod::Invoke, shadow frames arguments are taken from the args array. +extern void EnterInterpreterFromInvoke(Thread* self, mirror::ArtMethod* method, mirror::Object* receiver, uint32_t* args, JValue* result) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); diff --git a/runtime/invoke_arg_array_builder.h b/runtime/invoke_arg_array_builder.h index 084d005e96..f615e8ebac 100644 --- a/runtime/invoke_arg_array_builder.h +++ b/runtime/invoke_arg_array_builder.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ #define ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "mirror/object.h" #include "scoped_thread_state_change.h" diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index 010a2079b4..a1657d098b 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -32,7 +32,7 @@ struct iovec; namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h index 345f0ad73a..7f162ca80b 100644 --- a/runtime/jdwp/object_registry.h +++ b/runtime/jdwp/object_registry.h @@ -22,9 +22,9 @@ #include #include "jdwp/jdwp.h" +#include "mirror/art_field-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "safe_map.h" diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index d1de6e6f5a..852dd00a77 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -32,10 +32,10 @@ #include "interpreter/interpreter.h" #include "invoke_arg_array_builder.h" #include "jni.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/throwable.h" @@ -49,7 +49,8 @@ #include "UniquePtr.h" #include "well_known_classes.h" -using ::art::mirror::AbstractMethod; +using ::art::mirror::ArtField; +using ::art::mirror::ArtMethod; using ::art::mirror::Array; using ::art::mirror::BooleanArray; using ::art::mirror::ByteArray; @@ -57,7 +58,6 @@ using ::art::mirror::CharArray; using ::art::mirror::Class; using ::art::mirror::ClassLoader; using ::art::mirror::DoubleArray; -using ::art::mirror::Field; using ::art::mirror::FloatArray; using ::art::mirror::IntArray; using ::art::mirror::LongArray; @@ -101,7 +101,7 @@ static bool IsBadJniVersion(int version) { return version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4 && version != JNI_VERSION_1_6; } -static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) +static void CheckMethodArguments(ArtMethod* m, uint32_t* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::TypeList* params = mh.GetParameterTypeList(); @@ -144,7 +144,7 @@ static void CheckMethodArguments(AbstractMethod* m, uint32_t* args) } } -void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, ArtMethod* method, ArgArray* arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t* args = arg_array->GetArray(); @@ -157,7 +157,7 @@ void InvokeWithArgArray(const ScopedObjectAccess& soa, AbstractMethod* method, static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode(obj); MethodHelper mh(method); JValue result; @@ -167,7 +167,7 @@ static JValue InvokeWithVarArgs(const ScopedObjectAccess& soa, jobject obj, return result; } -static AbstractMethod* FindVirtualMethod(Object* receiver, AbstractMethod* method) +static ArtMethod* FindVirtualMethod(Object* receiver, ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(method); } @@ -176,7 +176,7 @@ static JValue InvokeVirtualOrInterfaceWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -189,7 +189,7 @@ static JValue InvokeVirtualOrInterfaceWithVarArgs(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, va_list args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Object* receiver = soa.Decode(obj); - AbstractMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); + ArtMethod* method = FindVirtualMethod(receiver, soa.DecodeMethod(mid)); MethodHelper mh(method); JValue result; ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); @@ -239,7 +239,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, return NULL; } - AbstractMethod* method = NULL; + ArtMethod* method = NULL; if (is_static) { method = c->FindDirectMethod(name, sig); } else { @@ -261,7 +261,7 @@ static jmethodID FindMethodID(ScopedObjectAccess& soa, jclass jni_class, static ClassLoader* GetClassLoader(const ScopedObjectAccess& soa) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = soa.Self()->GetCurrentMethod(NULL); + ArtMethod* method = soa.Self()->GetCurrentMethod(NULL); if (method == NULL || method == soa.DecodeMethod(WellKnownClasses::java_lang_Runtime_nativeLoad)) { return soa.Self()->GetClassLoaderOverride(); @@ -277,7 +277,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con return NULL; } - Field* field = NULL; + ArtField* field = NULL; Class* field_type; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); if (sig[1] != '\0') { @@ -290,7 +290,7 @@ static jfieldID FindFieldID(const ScopedObjectAccess& soa, jclass jni_class, con // Failed to find type from the signature of the field. DCHECK(soa.Self()->IsExceptionPending()); ThrowLocation throw_location; - SirtRef cause(soa.Self(), soa.Self()->GetException(&throw_location)); + SirtRef cause(soa.Self(), soa.Self()->GetException(&throw_location)); soa.Self()->ClearException(); soa.Self()->ThrowNewExceptionF(throw_location, "Ljava/lang/NoSuchFieldError;", "no type \"%s\" found and so no field \"%s\" could be found in class " @@ -561,7 +561,7 @@ class Libraries { } // See section 11.3 "Linking Native Methods" of the JNI spec. - void* FindNativeMethod(const AbstractMethod* m, std::string& detail) + void* FindNativeMethod(const ArtMethod* m, std::string& detail) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string jni_short_name(JniShortName(m)); std::string jni_long_name(JniLongName(m)); @@ -598,7 +598,7 @@ class Libraries { JValue InvokeWithJValues(const ScopedObjectAccess& soa, jobject obj, jmethodID mid, jvalue* args) { - AbstractMethod* method = soa.DecodeMethod(mid); + ArtMethod* method = soa.DecodeMethod(mid); Object* receiver = method->IsStatic() ? NULL : soa.Decode(obj); MethodHelper mh(method); JValue result; @@ -620,10 +620,10 @@ class JNI { } static jclass FindClass(JNIEnv* env, const char* name) { - ScopedObjectAccess soa(env); Runtime* runtime = Runtime::Current(); ClassLinker* class_linker = runtime->GetClassLinker(); std::string descriptor(NormalizeJniClassDescriptor(name)); + ScopedObjectAccess soa(env); Class* c = NULL; if (runtime->IsStarted()) { ClassLoader* cl = GetClassLoader(soa); @@ -636,26 +636,50 @@ class JNI { static jmethodID FromReflectedMethod(JNIEnv* env, jobject java_method) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.Decode(java_method); + jobject art_method = env->GetObjectField(java_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + ArtMethod* method = soa.Decode(art_method); + DCHECK(method != NULL); return soa.EncodeMethod(method); } static jfieldID FromReflectedField(JNIEnv* env, jobject java_field) { ScopedObjectAccess soa(env); - Field* field = soa.Decode(java_field); + jobject art_field = env->GetObjectField(java_field, + WellKnownClasses::java_lang_reflect_Field_artField); + ArtField* field = soa.Decode(art_field); + DCHECK(field != NULL); return soa.EncodeField(field); } static jobject ToReflectedMethod(JNIEnv* env, jclass, jmethodID mid, jboolean) { ScopedObjectAccess soa(env); - AbstractMethod* method = soa.DecodeMethod(mid); - return soa.AddLocalReference(method); + ArtMethod* m = soa.DecodeMethod(mid); + jobject art_method = soa.AddLocalReference(m); + jobject reflect_method = env->AllocObject(WellKnownClasses::java_lang_reflect_Method); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_method, + WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod, + art_method); + return reflect_method; } static jobject ToReflectedField(JNIEnv* env, jclass, jfieldID fid, jboolean) { ScopedObjectAccess soa(env); - Field* field = soa.DecodeField(fid); - return soa.AddLocalReference(field); + ArtField* f = soa.DecodeField(fid); + jobject art_field = soa.AddLocalReference(f); + jobject reflect_field = env->AllocObject(WellKnownClasses::java_lang_reflect_Field); + if (env->ExceptionCheck()) { + return NULL; + } + SetObjectField(env, + reflect_field, + WellKnownClasses::java_lang_reflect_Field_artField, + art_field); + return reflect_field; } static jclass GetObjectClass(JNIEnv* env, jobject java_object) { @@ -678,7 +702,6 @@ class JNI { } static jboolean IsInstanceOf(JNIEnv* env, jobject jobj, jclass java_class) { - ScopedObjectAccess soa(env); if (java_class == NULL) { JniAbortF("IsInstanceOf", "null class (second argument)"); } @@ -686,6 +709,7 @@ class JNI { // Note: JNI is different from regular Java instanceof in this respect return JNI_TRUE; } else { + ScopedObjectAccess soa(env); Object* obj = soa.Decode(jobj); Class* c = soa.Decode(java_class); return obj->InstanceOf(c) ? JNI_TRUE : JNI_FALSE; @@ -718,13 +742,13 @@ class JNI { static void ExceptionDescribe(JNIEnv* env) { ScopedObjectAccess soa(env); - SirtRef old_throw_this_object(soa.Self(), NULL); - SirtRef old_throw_method(soa.Self(), NULL); - SirtRef old_exception(soa.Self(), NULL); + SirtRef old_throw_this_object(soa.Self(), NULL); + SirtRef old_throw_method(soa.Self(), NULL); + SirtRef old_exception(soa.Self(), NULL); uint32_t old_throw_dex_pc; { ThrowLocation old_throw_location; - mirror::Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); + Throwable* old_exception_obj = soa.Self()->GetException(&old_throw_location); old_throw_this_object.reset(old_throw_location.GetThis()); old_throw_method.reset(old_throw_location.GetMethod()); old_exception.reset(old_exception_obj); @@ -855,8 +879,12 @@ class JNI { } static jboolean IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) { - ScopedObjectAccess soa(env); - return (soa.Decode(obj1) == soa.Decode(obj2)) ? JNI_TRUE : JNI_FALSE; + if (obj1 == obj2) { + return JNI_TRUE; + } else { + ScopedObjectAccess soa(env); + return (soa.Decode(obj1) == soa.Decode(obj2)) ? JNI_TRUE : JNI_FALSE; + } } static jobject AllocObject(JNIEnv* env, jclass java_class) { @@ -1316,8 +1344,8 @@ class JNI { va_end(ap); } - static void CallNonvirtualVoidMethodV(JNIEnv* env, - jobject obj, jclass, jmethodID mid, va_list args) { + static void CallNonvirtualVoidMethodV(JNIEnv* env, jobject obj, jclass, jmethodID mid, + va_list args) { ScopedObjectAccess soa(env); InvokeWithVarArgs(soa, obj, mid, args); } @@ -1342,13 +1370,13 @@ class JNI { static jobject GetObjectField(JNIEnv* env, jobject obj, jfieldID fid) { ScopedObjectAccess soa(env); Object* o = soa.Decode(obj); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference(f->GetObject(o)); } static jobject GetStaticObjectField(JNIEnv* env, jclass, jfieldID fid) { ScopedObjectAccess soa(env); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); return soa.AddLocalReference(f->GetObject(f->GetDeclaringClass())); } @@ -1356,37 +1384,37 @@ class JNI { ScopedObjectAccess soa(env); Object* o = soa.Decode(java_object); Object* v = soa.Decode(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(o, v); } static void SetStaticObjectField(JNIEnv* env, jclass, jfieldID fid, jobject java_value) { ScopedObjectAccess soa(env); Object* v = soa.Decode(java_value); - Field* f = soa.DecodeField(fid); + ArtField* f = soa.DecodeField(fid); f->SetObject(f->GetDeclaringClass(), v); } #define GET_PRIMITIVE_FIELD(fn, instance) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(o) #define GET_STATIC_PRIMITIVE_FIELD(fn) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ return f->fn(f->GetDeclaringClass()) #define SET_PRIMITIVE_FIELD(fn, instance, value) \ ScopedObjectAccess soa(env); \ Object* o = soa.Decode(instance); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(o, value) #define SET_STATIC_PRIMITIVE_FIELD(fn, value) \ ScopedObjectAccess soa(env); \ - Field* f = soa.DecodeField(fid); \ + ArtField* f = soa.DecodeField(fid); \ f->fn(f->GetDeclaringClass(), value) static jboolean GetBooleanField(JNIEnv* env, jobject obj, jfieldID fid) { @@ -1806,7 +1834,7 @@ class JNI { static jsize GetArrayLength(JNIEnv* env, jarray java_array) { ScopedObjectAccess soa(env); Object* obj = soa.Decode(java_array); - if (!obj->IsArrayInstance()) { + if (UNLIKELY(!obj->IsArrayInstance())) { JniAbortF("GetArrayLength", "not an array: %s", PrettyTypeOf(obj).c_str()); } Array* array = obj->AsArray(); @@ -1863,12 +1891,12 @@ class JNI { } static jobjectArray NewObjectArray(JNIEnv* env, jsize length, jclass element_jclass, jobject initial_element) { - ScopedObjectAccess soa(env); if (length < 0) { JniAbortF("NewObjectArray", "negative array length: %d", length); } // Compute the array class corresponding to the given element class. + ScopedObjectAccess soa(env); Class* element_class = soa.Decode(element_jclass); std::string descriptor; descriptor += "["; @@ -2080,7 +2108,7 @@ class JNI { ++sig; } - AbstractMethod* m = c->FindDirectMethod(name, sig); + ArtMethod* m = c->FindDirectMethod(name, sig); if (m == NULL) { m = c->FindVirtualMethod(name, sig); } @@ -2111,13 +2139,13 @@ class JNI { VLOG(jni) << "[Unregistering JNI native methods for " << PrettyClass(c) << "]"; for (size_t i = 0; i < c->NumDirectMethods(); ++i) { - AbstractMethod* m = c->GetDirectMethod(i); + ArtMethod* m = c->GetDirectMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } } for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { - AbstractMethod* m = c->GetVirtualMethod(i); + ArtMethod* m = c->GetVirtualMethod(i); if (m->IsNative()) { m->UnregisterNative(soa.Self()); } @@ -2899,7 +2927,7 @@ bool JavaVMExt::LoadNativeLibrary(const std::string& path, ClassLoader* class_lo return was_successful; } -void* JavaVMExt::FindCodeForNativeMethod(AbstractMethod* m) { +void* JavaVMExt::FindCodeForNativeMethod(ArtMethod* m) { CHECK(m->IsNative()); Class* c = m->GetDeclaringClass(); diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index fcac4811c6..e3ffc8421b 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -38,10 +38,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class ClassLoader; -class Field; -} + class ArtField; + class ArtMethod; + class ClassLoader; +} // namespace mirror class ArgArray; union JValue; class Libraries; @@ -55,7 +55,7 @@ void RegisterNativeMethods(JNIEnv* env, const char* jni_class_name, const JNINat JValue InvokeWithJValues(const ScopedObjectAccess&, jobject obj, jmethodID mid, jvalue* args) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); -void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::AbstractMethod* method, +void InvokeWithArgArray(const ScopedObjectAccess& soa, mirror::ArtMethod* method, ArgArray *arg_array, JValue* result, char result_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -79,7 +79,7 @@ struct JavaVMExt : public JavaVM { * Returns a pointer to the code for the native method 'm', found * using dlsym(3) on every native library that's been loaded so far. */ - void* FindCodeForNativeMethod(mirror::AbstractMethod* m) + void* FindCodeForNativeMethod(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpForSigQuit(std::ostream& os); diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc index c8b9eb95e3..234e40ac46 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -22,7 +22,7 @@ #include "common_test.h" #include "invoke_arg_array_builder.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -43,7 +43,8 @@ class JniInternalTest : public CommonTest { vm_->AttachCurrentThread(&env_, NULL); - ScopedLocalRef aioobe(env_, env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); + ScopedLocalRef aioobe(env_, + env_->FindClass("java/lang/ArrayIndexOutOfBoundsException")); CHECK(aioobe.get() != NULL); aioobe_ = reinterpret_cast(env_->NewGlobalRef(aioobe.get())); @@ -51,7 +52,8 @@ class JniInternalTest : public CommonTest { CHECK(ase.get() != NULL); ase_ = reinterpret_cast(env_->NewGlobalRef(ase.get())); - ScopedLocalRef sioobe(env_, env_->FindClass("java/lang/StringIndexOutOfBoundsException")); + ScopedLocalRef sioobe(env_, + env_->FindClass("java/lang/StringIndexOutOfBoundsException")); CHECK(sioobe.get() != NULL); sioobe_ = reinterpret_cast(env_->NewGlobalRef(sioobe.get())); } @@ -76,7 +78,7 @@ class JniInternalTest : public CommonTest { CommonTest::TearDown(); } - void DoCompile(mirror::AbstractMethod*& method, + void DoCompile(mirror::ArtMethod*& method, mirror::Object*& receiver, bool is_static, const char* method_name, const char* method_signature) @@ -95,7 +97,8 @@ class JniInternalTest : public CommonTest { CompileVirtualMethod(class_loader.get(), class_name, method_name, method_signature); } - mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), class_loader.get()); + mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), + class_loader.get()); CHECK(c != NULL); method = is_static ? c->FindDirectMethod(method_name, method_signature) @@ -111,7 +114,7 @@ class JniInternalTest : public CommonTest { } void InvokeNopMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "nop", "()V"); @@ -127,7 +130,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityByteMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -163,7 +166,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(I)I"); @@ -199,7 +202,7 @@ class JniInternalTest : public CommonTest { void InvokeIdentityDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "identity", "(D)D"); @@ -243,7 +246,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(II)I"); @@ -289,7 +292,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(III)I"); @@ -340,7 +343,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIII)I"); @@ -396,7 +399,7 @@ class JniInternalTest : public CommonTest { void InvokeSumIntIntIntIntIntMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(IIIII)I"); @@ -457,7 +460,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DD)D"); @@ -523,7 +526,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDD)D"); @@ -578,7 +581,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDD)D"); @@ -642,7 +645,7 @@ class JniInternalTest : public CommonTest { void InvokeSumDoubleDoubleDoubleDoubleDoubleMethod(bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method; + mirror::ArtMethod* method; mirror::Object* receiver; DoCompile(method, receiver, is_static, "sum", "(DDDDD)D"); @@ -891,6 +894,11 @@ TEST_F(JniInternalTest, GetMethodID) { method = env_->GetMethodID(jlstring, "valueOf", "(I)Ljava/lang/String;"); EXPECT_EQ(static_cast(NULL), method); EXPECT_EXCEPTION(jlnsme); + + // Check that GetMethodID for java.lang.NoSuchMethodError.(String) finds the constructor + method = env_->GetMethodID(jlnsme, "", "(Ljava/lang/String;)V"); + EXPECT_NE(static_cast(NULL), method); + EXPECT_FALSE(env_->ExceptionCheck()); } TEST_F(JniInternalTest, GetStaticMethodID) { @@ -933,6 +941,9 @@ TEST_F(JniInternalTest, FromReflectedField_ToReflectedField) { // ...and back again. jfieldID fid2 = env_->FromReflectedField(field); ASSERT_TRUE(fid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + ASSERT_EQ(4, env_->GetIntField(s, fid2)); } TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { @@ -948,6 +959,13 @@ TEST_F(JniInternalTest, FromReflectedMethod_ToReflectedMethod) { // ...and back again. jmethodID mid2 = env_->FromReflectedMethod(method); ASSERT_TRUE(mid2 != NULL); + // Make sure we can actually use it. + jstring s = env_->NewStringUTF("poop"); + // TODO: this should return 4, but the runtime skips the method + // invoke because the runtime isn't started. In the future it would + // be nice to use interpretter for things like this. This still does + // validate that we have a sane jmethodID value. + ASSERT_EQ(0, env_->CallIntMethod(s, mid2)); } void BogusMethod() { @@ -986,7 +1004,13 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->UnregisterNatives(jlobject); } -#define EXPECT_PRIMITIVE_ARRAY(new_fn, get_region_fn, set_region_fn, get_elements_fn, release_elements_fn, scalar_type, expected_class_descriptor) \ +#define EXPECT_PRIMITIVE_ARRAY(new_fn, \ + get_region_fn, \ + set_region_fn, \ + get_elements_fn, \ + release_elements_fn, \ + scalar_type, \ + expected_class_descriptor) \ jsize size = 4; \ /* Allocate an array and check it has the right type and length. */ \ scalar_type ## Array a = env_->new_fn(size); \ @@ -1017,47 +1041,60 @@ TEST_F(JniInternalTest, RegisterNatives) { env_->set_region_fn(a, 0, size, &src_buf[0]); \ /* Copy back only part. */ \ env_->get_region_fn(a, 1, size - 2, &dst_buf[1]); \ - EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "short copy equal"; \ + EXPECT_NE(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "short copy equal"; \ /* Copy the missing pieces. */ \ env_->get_region_fn(a, 0, 1, &dst_buf[0]); \ env_->get_region_fn(a, size - 1, 1, &dst_buf[size - 1]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "fixed copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "fixed copy not equal"; \ /* Copy back the whole array. */ \ env_->get_region_fn(a, 0, size, &dst_buf[0]); \ - EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) << "full copy not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], &dst_buf[0], size * sizeof(scalar_type)), 0) \ + << "full copy not equal"; \ /* GetPrimitiveArrayCritical */ \ void* v = env_->GetPrimitiveArrayCritical(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) << "GetPrimitiveArrayCritical not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], v, size * sizeof(scalar_type)), 0) \ + << "GetPrimitiveArrayCritical not equal"; \ env_->ReleasePrimitiveArrayCritical(a, v, 0); \ /* GetXArrayElements */ \ scalar_type* xs = env_->get_elements_fn(a, NULL); \ - EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) << # get_elements_fn " not equal"; \ + EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) \ + << # get_elements_fn " not equal"; \ env_->release_elements_fn(a, xs, 0); \ EXPECT_EQ(reinterpret_cast(v), reinterpret_cast(xs)) TEST_F(JniInternalTest, BooleanArrays) { - EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); + EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, + GetBooleanArrayElements, ReleaseBooleanArrayElements, jboolean, "[Z"); } TEST_F(JniInternalTest, ByteArrays) { - EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); + EXPECT_PRIMITIVE_ARRAY(NewByteArray, GetByteArrayRegion, SetByteArrayRegion, + GetByteArrayElements, ReleaseByteArrayElements, jbyte, "[B"); } TEST_F(JniInternalTest, CharArrays) { - EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); + EXPECT_PRIMITIVE_ARRAY(NewCharArray, GetCharArrayRegion, SetCharArrayRegion, + GetCharArrayElements, ReleaseCharArrayElements, jchar, "[C"); } TEST_F(JniInternalTest, DoubleArrays) { - EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); + EXPECT_PRIMITIVE_ARRAY(NewDoubleArray, GetDoubleArrayRegion, SetDoubleArrayRegion, + GetDoubleArrayElements, ReleaseDoubleArrayElements, jdouble, "[D"); } TEST_F(JniInternalTest, FloatArrays) { - EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); + EXPECT_PRIMITIVE_ARRAY(NewFloatArray, GetFloatArrayRegion, SetFloatArrayRegion, + GetFloatArrayElements, ReleaseFloatArrayElements, jfloat, "[F"); } TEST_F(JniInternalTest, IntArrays) { - EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); + EXPECT_PRIMITIVE_ARRAY(NewIntArray, GetIntArrayRegion, SetIntArrayRegion, + GetIntArrayElements, ReleaseIntArrayElements, jint, "[I"); } TEST_F(JniInternalTest, LongArrays) { - EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); + EXPECT_PRIMITIVE_ARRAY(NewLongArray, GetLongArrayRegion, SetLongArrayRegion, + GetLongArrayElements, ReleaseLongArrayElements, jlong, "[J"); } TEST_F(JniInternalTest, ShortArrays) { - EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); + EXPECT_PRIMITIVE_ARRAY(NewShortArray, GetShortArrayRegion, SetShortArrayRegion, + GetShortArrayElements, ReleaseShortArrayElements, jshort, "[S"); } TEST_F(JniInternalTest, NewObjectArray) { @@ -1437,7 +1474,8 @@ TEST_F(JniInternalTest, DeleteLocalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteLocalRef(s); - std::string expected(StringPrintf("native code passing in reference to invalid local reference: %p", s)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid local reference: %p", s)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1520,7 +1558,8 @@ TEST_F(JniInternalTest, DeleteGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1564,7 +1603,8 @@ TEST_F(JniInternalTest, DeleteWeakGlobalRef) { CheckJniAbortCatcher check_jni_abort_catcher; env_->DeleteWeakGlobalRef(o); - std::string expected(StringPrintf("native code passing in reference to invalid weak global reference: %p", o)); + std::string expected(StringPrintf("native code passing in reference to " + "invalid weak global reference: %p", o)); check_jni_abort_catcher.Check(expected.c_str()); } @@ -1588,7 +1628,7 @@ TEST_F(JniInternalTest, StaticMainMethod) { mirror::Class* klass = class_linker_->FindClass("LMain;", class_loader.get()); ASSERT_TRUE(klass != NULL); - mirror::AbstractMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); + mirror::ArtMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); ASSERT_TRUE(method != NULL); ArgArray arg_array(NULL, 0); diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/abstract_method-inl.h deleted file mode 100644 index d47b3ebccc..0000000000 --- a/runtime/mirror/abstract_method-inl.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ - -#include "abstract_method.h" - -#include "dex_file.h" -#include "entrypoints/entrypoint_utils.h" -#include "object_array.h" -#include "runtime.h" - -namespace art { -namespace mirror { - -inline Class* AbstractMethod::GetDeclaringClass() const { - Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), false); - DCHECK(result != NULL) << this; - DCHECK(result->IsIdxLoaded() || result->IsErroneous()) << this; - return result; -} - -inline void AbstractMethod::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, declaring_class_), new_declaring_class, false); -} - -inline uint32_t AbstractMethod::GetAccessFlags() const { - DCHECK(GetDeclaringClass()->IsIdxLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), false); -} - -inline uint16_t AbstractMethod::GetMethodIndex() const { - DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), false); -} - -inline uint32_t AbstractMethod::GetDexMethodIndex() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheStrings() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheResolvedMethods() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheResolvedTypes() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), false); -} - -inline ObjectArray* AbstractMethod::GetDexCacheInitializedStaticStorage() const { - return GetFieldObject*>( - OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), - false); -} - -inline uint32_t AbstractMethod::GetCodeSize() const { - DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); - uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); - if (code == 0) { - return 0; - } - // TODO: make this Thumb2 specific - code &= ~0x1; - return reinterpret_cast(code)[-1]; -} - -inline bool AbstractMethod::CheckIncompatibleClassChange(InvokeType type) { - switch (type) { - case kStatic: - return !IsStatic(); - case kDirect: - return !IsDirect() || IsStatic(); - case kVirtual: { - Class* methods_class = GetDeclaringClass(); - return IsDirect() || (methods_class->IsInterface() && !IsMiranda()); - } - case kSuper: - return false; // TODO: appropriate checks for call to super class. - case kInterface: { - Class* methods_class = GetDeclaringClass(); - return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); - } - default: - LOG(FATAL) << "Unreachable - invocation type: " << type; - return true; - } -} - -inline void AbstractMethod::AssertPcIsWithinCode(uintptr_t pc) const { - if (!kIsDebugBuild) { - return; - } - if (IsNative() || IsRuntimeMethod() || IsProxyMethod()) { - return; - } - if (pc == GetQuickInstrumentationExitPc()) { - return; - } - const void* code = GetEntryPointFromCompiledCode(); - if (code == GetCompiledCodeToInterpreterBridge() || code == GetQuickInstrumentationEntryPoint()) { - return; - } - ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - if (code == GetResolutionTrampoline(class_linker)) { - return; - } - DCHECK(IsWithinCode(pc)) - << PrettyMethod(this) - << " pc=" << std::hex << pc - << " code=" << code - << " size=" << GetCodeSize(); -} - -inline uint32_t AbstractMethod::GetOatCodeOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetEntryPointFromCompiledCode()); -} - -inline void AbstractMethod::SetOatCodeOffset(uint32_t code_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetEntryPointFromCompiledCode(reinterpret_cast(code_offset)); -} - -inline uint32_t AbstractMethod::GetOatMappingTableOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetMappingTable()); -} - -inline void AbstractMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetMappingTable(reinterpret_cast(mapping_table_offset)); -} - -inline uint32_t AbstractMethod::GetOatVmapTableOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetVmapTable()); -} - -inline void AbstractMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetVmapTable(reinterpret_cast(vmap_table_offset)); -} - -inline void AbstractMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { - DCHECK(!Runtime::Current()->IsStarted()); - SetNativeGcMap(reinterpret_cast(gc_map_offset)); -} - -inline uint32_t AbstractMethod::GetOatNativeGcMapOffset() const { - DCHECK(!Runtime::Current()->IsStarted()); - return reinterpret_cast(GetNativeGcMap()); -} - -inline bool AbstractMethod::IsRuntimeMethod() const { - return GetDexMethodIndex() == DexFile::kDexNoIndex16; -} - -inline bool AbstractMethod::IsCalleeSaveMethod() const { - if (!IsRuntimeMethod()) { - return false; - } - Runtime* runtime = Runtime::Current(); - bool result = false; - for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { - if (this == runtime->GetCalleeSaveMethod(Runtime::CalleeSaveType(i))) { - result = true; - break; - } - } - return result; -} - -inline bool AbstractMethod::IsResolutionMethod() const { - bool result = this == Runtime::Current()->GetResolutionMethod(); - // Check that if we do think it is phony it looks like the resolution method. - DCHECK(!result || IsRuntimeMethod()); - return result; -} -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ diff --git a/runtime/mirror/abstract_method.cc b/runtime/mirror/abstract_method.cc deleted file mode 100644 index b3db5c2721..0000000000 --- a/runtime/mirror/abstract_method.cc +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2011 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 "abstract_method.h" - -#include "abstract_method-inl.h" -#include "base/stringpiece.h" -#include "class-inl.h" -#include "dex_file-inl.h" -#include "dex_instruction.h" -#include "gc/accounting/card_table-inl.h" -#include "interpreter/interpreter.h" -#include "jni_internal.h" -#include "mapping_table.h" -#include "object-inl.h" -#include "object_array.h" -#include "object_array-inl.h" -#include "string.h" -#include "object_utils.h" - -namespace art { -namespace mirror { - -extern "C" void art_portable_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); -extern "C" void art_quick_invoke_stub(AbstractMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); - -// TODO: get global references for these -Class* AbstractMethod::java_lang_reflect_Constructor_ = NULL; -Class* AbstractMethod::java_lang_reflect_Method_ = NULL; - -InvokeType AbstractMethod::GetInvokeType() const { - // TODO: kSuper? - if (GetDeclaringClass()->IsInterface()) { - return kInterface; - } else if (IsStatic()) { - return kStatic; - } else if (IsDirect()) { - return kDirect; - } else { - return kVirtual; - } -} - -void AbstractMethod::SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method) { - CHECK(java_lang_reflect_Constructor_ == NULL); - CHECK(java_lang_reflect_Constructor != NULL); - java_lang_reflect_Constructor_ = java_lang_reflect_Constructor; - - CHECK(java_lang_reflect_Method_ == NULL); - CHECK(java_lang_reflect_Method != NULL); - java_lang_reflect_Method_ = java_lang_reflect_Method; -} - -void AbstractMethod::ResetClasses() { - CHECK(java_lang_reflect_Constructor_ != NULL); - java_lang_reflect_Constructor_ = NULL; - - CHECK(java_lang_reflect_Method_ != NULL); - java_lang_reflect_Method_ = NULL; -} - -void AbstractMethod::SetDexCacheStrings(ObjectArray* new_dex_cache_strings) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_), - new_dex_cache_strings, false); -} - -void AbstractMethod::SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_), - new_dex_cache_methods, false); -} - -void AbstractMethod::SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_classes) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_), - new_dex_cache_classes, false); -} - -void AbstractMethod::SetDexCacheInitializedStaticStorage(ObjectArray* new_value) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_initialized_static_storage_), - new_value, false); -} - -size_t AbstractMethod::NumArgRegisters(const StringPiece& shorty) { - CHECK_LE(1, shorty.length()); - uint32_t num_registers = 0; - for (int i = 1; i < shorty.length(); ++i) { - char ch = shorty[i]; - if (ch == 'D' || ch == 'J') { - num_registers += 2; - } else { - num_registers += 1; - } - } - return num_registers; -} - -bool AbstractMethod::IsProxyMethod() const { - return GetDeclaringClass()->IsProxyClass(); -} - -AbstractMethod* AbstractMethod::FindOverriddenMethod() const { - if (IsStatic()) { - return NULL; - } - Class* declaring_class = GetDeclaringClass(); - Class* super_class = declaring_class->GetSuperClass(); - uint16_t method_index = GetMethodIndex(); - ObjectArray* super_class_vtable = super_class->GetVTable(); - AbstractMethod* result = NULL; - // Did this method override a super class method? If so load the result from the super class' - // vtable - if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) { - result = super_class_vtable->Get(method_index); - } else { - // Method didn't override superclass method so search interfaces - if (IsProxyMethod()) { - result = GetDexCacheResolvedMethods()->Get(GetDexMethodIndex()); - CHECK_EQ(result, - Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this)); - } else { - MethodHelper mh(this); - MethodHelper interface_mh; - IfTable* iftable = GetDeclaringClass()->GetIfTable(); - for (size_t i = 0; i < iftable->Count() && result == NULL; i++) { - Class* interface = iftable->GetInterface(i); - for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { - AbstractMethod* interface_method = interface->GetVirtualMethod(j); - interface_mh.ChangeMethod(interface_method); - if (mh.HasSameNameAndSignature(&interface_mh)) { - result = interface_method; - break; - } - } - } - } - } -#ifndef NDEBUG - MethodHelper result_mh(result); - DCHECK(result == NULL || MethodHelper(this).HasSameNameAndSignature(&result_mh)); -#endif - return result; -} - -uintptr_t AbstractMethod::NativePcOffset(const uintptr_t pc) const { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return pc - reinterpret_cast(code); -} - -uint32_t AbstractMethod::ToDexPc(const uintptr_t pc) const { -#if !defined(ART_USE_PORTABLE_COMPILER) - MappingTable table(GetMappingTable()); - if (table.TotalSize() == 0) { - DCHECK(IsNative() || IsCalleeSaveMethod() || IsProxyMethod()) << PrettyMethod(this); - return DexFile::kDexNoIndex; // Special no mapping case - } - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - uint32_t sought_offset = pc - reinterpret_cast(code); - // Assume the caller wants a pc-to-dex mapping so check here first. - typedef MappingTable::PcToDexIterator It; - for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { - if (cur.NativePcOffset() == sought_offset) { - return cur.DexPc(); - } - } - // Now check dex-to-pc mappings. - typedef MappingTable::DexToPcIterator It2; - for (It2 cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { - if (cur.NativePcOffset() == sought_offset) { - return cur.DexPc(); - } - } - LOG(FATAL) << "Failed to find Dex offset for PC offset " << reinterpret_cast(sought_offset) - << "(PC " << reinterpret_cast(pc) << ", code=" << code - << ") in " << PrettyMethod(this); - return DexFile::kDexNoIndex; -#else - // Compiler LLVM doesn't use the machine pc, we just use dex pc instead. - return static_cast(pc); -#endif -} - -uintptr_t AbstractMethod::ToNativePc(const uint32_t dex_pc) const { - MappingTable table(GetMappingTable()); - if (table.TotalSize() == 0) { - DCHECK_EQ(dex_pc, 0U); - return 0; // Special no mapping/pc == 0 case - } - // Assume the caller wants a dex-to-pc mapping so check here first. - typedef MappingTable::DexToPcIterator It; - for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { - if (cur.DexPc() == dex_pc) { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return reinterpret_cast(code) + cur.NativePcOffset(); - } - } - // Now check pc-to-dex mappings. - typedef MappingTable::PcToDexIterator It2; - for (It2 cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { - if (cur.DexPc() == dex_pc) { - const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); - return reinterpret_cast(code) + cur.NativePcOffset(); - } - } - LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc - << " in " << PrettyMethod(this); - return 0; -} - -uint32_t AbstractMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, - bool* has_no_move_exception) const { - MethodHelper mh(this); - const DexFile::CodeItem* code_item = mh.GetCodeItem(); - // Default to handler not found. - uint32_t found_dex_pc = DexFile::kDexNoIndex; - // Iterate over the catch handlers associated with dex_pc. - for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) { - uint16_t iter_type_idx = it.GetHandlerTypeIndex(); - // Catch all case - if (iter_type_idx == DexFile::kDexNoIndex16) { - found_dex_pc = it.GetHandlerAddress(); - break; - } - // Does this catch exception type apply? - Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx); - if (iter_exception_type == NULL) { - // The verifier should take care of resolving all exception classes early - LOG(WARNING) << "Unresolved exception class when finding catch block: " - << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx); - } else if (iter_exception_type->IsAssignableFrom(exception_type)) { - found_dex_pc = it.GetHandlerAddress(); - break; - } - } - if (found_dex_pc != DexFile::kDexNoIndex) { - const Instruction* first_catch_instr = - Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]); - *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION); - } - return found_dex_pc; -} - -void AbstractMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, - char result_type) { - if (kIsDebugBuild) { - self->AssertThreadSuspensionIsAllowable(); - CHECK_EQ(kRunnable, self->GetState()); - } - - // Push a transition back into managed code onto the linked list in thread. - ManagedStack fragment; - self->PushManagedStackFragment(&fragment); - - Runtime* runtime = Runtime::Current(); - // Call the invoke stub, passing everything as arguments. - if (UNLIKELY(!runtime->IsStarted())) { - LOG(INFO) << "Not invoking " << PrettyMethod(this) << " for a runtime that isn't started"; - if (result != NULL) { - result->SetJ(0); - } - } else { - const bool kLogInvocationStartAndReturn = false; - if (GetEntryPointFromCompiledCode() != NULL) { - if (kLogInvocationStartAndReturn) { - LOG(INFO) << StringPrintf("Invoking '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); - } -#ifdef ART_USE_PORTABLE_COMPILER - (*art_portable_invoke_stub)(this, args, args_size, self, result, result_type); -#else - (*art_quick_invoke_stub)(this, args, args_size, self, result, result_type); -#endif - if (UNLIKELY(reinterpret_cast(self->GetException(NULL)) == -1)) { - // Unusual case where we were running LLVM generated code and an - // exception was thrown to force the activations to be removed from the - // stack. Continue execution in the interpreter. - self->ClearException(); - ShadowFrame* shadow_frame = self->GetAndClearDeoptimizationShadowFrame(result); - self->SetTopOfStack(NULL, 0); - self->SetTopOfShadowStack(shadow_frame); - interpreter::EnterInterpreterFromDeoptimize(self, shadow_frame, result); - } - if (kLogInvocationStartAndReturn) { - LOG(INFO) << StringPrintf("Returned '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); - } - } else { - LOG(INFO) << "Not invoking '" << PrettyMethod(this) - << "' code=" << reinterpret_cast(GetEntryPointFromCompiledCode()); - if (result != NULL) { - result->SetJ(0); - } - } - } - - // Pop transition. - self->PopManagedStackFragment(fragment); -} - -bool AbstractMethod::IsRegistered() const { - void* native_method = GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), false); - CHECK(native_method != NULL); - void* jni_stub = GetJniDlsymLookupStub(); - return native_method != jni_stub; -} - -extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); -void AbstractMethod::RegisterNative(Thread* self, const void* native_method) { - DCHECK(Thread::Current() == self); - CHECK(IsNative()) << PrettyMethod(this); - CHECK(native_method != NULL) << PrettyMethod(this); - if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) { - SetNativeMethod(native_method); - } else { - // We've been asked to associate this method with the given native method but are working - // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct - // the native method to runtime support and store the target somewhere runtime support will - // find it. -#if defined(__i386__) - UNIMPLEMENTED(FATAL); -#else - SetNativeMethod(reinterpret_cast(art_work_around_app_jni_bugs)); -#endif - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), - reinterpret_cast(native_method), false); - } -} - -void AbstractMethod::UnregisterNative(Thread* self) { - CHECK(IsNative()) << PrettyMethod(this); - // restore stub to lookup native pointer via dlsym - RegisterNative(self, GetJniDlsymLookupStub()); -} - -void AbstractMethod::SetNativeMethod(const void* native_method) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_), - native_method, false); -} - -} // namespace mirror -} // namespace art diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h deleted file mode 100644 index 5b8c61cd06..0000000000 --- a/runtime/mirror/abstract_method.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ -#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ - -#include "class.h" -#include "dex_file.h" -#include "invoke_type.h" -#include "locks.h" -#include "modifiers.h" -#include "object.h" - -namespace art { - -struct AbstractMethodOffsets; -struct ConstructorMethodOffsets; -union JValue; -struct MethodClassOffsets; -class MethodHelper; -struct MethodOffsets; -class StringPiece; -class ShadowFrame; - -namespace mirror { - -class StaticStorageBase; - -typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, - const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); - -// C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor -class MANAGED AbstractMethod : public Object { - public: - Class* GetDeclaringClass() const; - - void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset DeclaringClassOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, declaring_class_)); - } - - static MemberOffset EntryPointFromCompiledCodeOffset() { - return MemberOffset(OFFSETOF_MEMBER(AbstractMethod, entry_point_from_compiled_code_)); - } - - uint32_t GetAccessFlags() const; - - void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, access_flags_), new_access_flags, false); - } - - // Approximate what kind of method call would be used for this method. - InvokeType GetInvokeType() const; - - // Returns true if the method is declared public. - bool IsPublic() const { - return (GetAccessFlags() & kAccPublic) != 0; - } - - // Returns true if the method is declared private. - bool IsPrivate() const { - return (GetAccessFlags() & kAccPrivate) != 0; - } - - // Returns true if the method is declared static. - bool IsStatic() const { - return (GetAccessFlags() & kAccStatic) != 0; - } - - // Returns true if the method is a constructor. - bool IsConstructor() const { - return (GetAccessFlags() & kAccConstructor) != 0; - } - - // Returns true if the method is static, private, or a constructor. - bool IsDirect() const { - return IsDirect(GetAccessFlags()); - } - - static bool IsDirect(uint32_t access_flags) { - return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; - } - - // Returns true if the method is declared synchronized. - bool IsSynchronized() const { - uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; - return (GetAccessFlags() & synchonized) != 0; - } - - bool IsFinal() const { - return (GetAccessFlags() & kAccFinal) != 0; - } - - bool IsMiranda() const { - return (GetAccessFlags() & kAccMiranda) != 0; - } - - bool IsNative() const { - return (GetAccessFlags() & kAccNative) != 0; - } - - bool IsAbstract() const { - return (GetAccessFlags() & kAccAbstract) != 0; - } - - bool IsSynthetic() const { - return (GetAccessFlags() & kAccSynthetic) != 0; - } - - bool IsProxyMethod() const; - - bool IsPreverified() const { - return (GetAccessFlags() & kAccPreverified) != 0; - } - - void SetPreverified() { - SetAccessFlags(GetAccessFlags() | kAccPreverified); - } - - bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint16_t GetMethodIndex() const; - - size_t GetVtableIndex() const { - return GetMethodIndex(); - } - - void SetMethodIndex(uint16_t new_method_index) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_), new_method_index, false); - } - - static MemberOffset MethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); - } - - uint32_t GetCodeItemOffset() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), false); - } - - void SetCodeItemOffset(uint32_t new_code_off) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, code_item_offset_), new_code_off, false); - } - - // Number of 32bit registers that would be required to hold all the arguments - static size_t NumArgRegisters(const StringPiece& shorty); - - uint32_t GetDexMethodIndex() const; - - void SetDexMethodIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_dex_index_), new_idx, false); - } - - ObjectArray* GetDexCacheStrings() const; - void SetDexCacheStrings(ObjectArray* new_dex_cache_strings) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset DexCacheStringsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_strings_); - } - - static MemberOffset DexCacheResolvedMethodsOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_methods_); - } - - static MemberOffset DexCacheResolvedTypesOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, dex_cache_resolved_types_); - } - - static MemberOffset DexCacheInitializedStaticStorageOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, - dex_cache_initialized_static_storage_); - } - - ObjectArray* GetDexCacheResolvedMethods() const; - void SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - ObjectArray* GetDexCacheResolvedTypes() const; - void SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_types) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - ObjectArray* GetDexCacheInitializedStaticStorage() const; - void SetDexCacheInitializedStaticStorage(ObjectArray* new_value) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Find the method that this method overrides - AbstractMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - EntryPointFromInterpreter* GetEntryPointFromInterpreter() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), false); - } - - void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); - } - - const void* GetEntryPointFromCompiledCode() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), false); - } - - void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); - } - - uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - bool IsWithinCode(uintptr_t pc) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); - if (code == 0) { - return pc == 0; - } - /* - * During a stack walk, a return PC may point to the end of the code + 1 - * (in the case that the last instruction is a call that isn't expected to - * return. Thus, we check <= code + GetCodeSize(). - */ - return (code <= pc && pc <= code + GetCodeSize()); - } - - void AssertPcIsWithinCode(uintptr_t pc) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint32_t GetOatCodeOffset() const; - - void SetOatCodeOffset(uint32_t code_offset); - - static MemberOffset GetEntryPointFromCompiledCodeOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, entry_point_from_compiled_code_); - } - - // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. - const uint8_t* GetMappingTable() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), false); - } - - void SetMappingTable(const uint8_t* mapping_table) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, mapping_table_), - mapping_table, false); - } - - uint32_t GetOatMappingTableOffset() const; - - void SetOatMappingTableOffset(uint32_t mapping_table_offset); - - // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. - const uint8_t* GetVmapTable() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), false); - } - - void SetVmapTable(const uint8_t* vmap_table) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, vmap_table_), vmap_table, false); - } - - uint32_t GetOatVmapTableOffset() const; - - void SetOatVmapTableOffset(uint32_t vmap_table_offset); - - const uint8_t* GetNativeGcMap() const { - return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), false); - } - void SetNativeGcMap(const uint8_t* data) { - SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, gc_map_), data, false); - } - - // When building the oat need a convenient place to stuff the offset of the native GC map. - void SetOatNativeGcMapOffset(uint32_t gc_map_offset); - uint32_t GetOatNativeGcMapOffset() const; - - size_t GetFrameSizeInBytes() const { - DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), false); - DCHECK_LE(static_cast(kStackAlignment), result); - return result; - } - - void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) { - DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, frame_size_in_bytes_), - new_frame_size_in_bytes, false); - } - - size_t GetReturnPcOffsetInBytes() const { - return GetFrameSizeInBytes() - kPointerSize; - } - - size_t GetSirtOffsetInBytes() const { - CHECK(IsNative()); - return kPointerSize; - } - - bool IsRegistered() const; - - void RegisterNative(Thread* self, const void* native_method) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static MemberOffset NativeMethodOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, native_method_); - } - - const void* GetNativeMethod() const { - return reinterpret_cast(GetField32(NativeMethodOffset(), false)); - } - - void SetNativeMethod(const void*); - - static MemberOffset GetMethodIndexOffset() { - return OFFSET_OF_OBJECT_MEMBER(AbstractMethod, method_index_); - } - - uint32_t GetCoreSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), false); - } - - void SetCoreSpillMask(uint32_t core_spill_mask) { - // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, core_spill_mask_), core_spill_mask, false); - } - - uint32_t GetFpSpillMask() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), false); - } - - void SetFpSpillMask(uint32_t fp_spill_mask) { - // Computed during compilation - SetField32(OFFSET_OF_OBJECT_MEMBER(AbstractMethod, fp_spill_mask_), fp_spill_mask, false); - } - - // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal - // conventions for a method of managed code. Returns false for Proxy methods. - bool IsRuntimeMethod() const; - - // Is this a hand crafted method used for something like describing callee saves? - bool IsCalleeSaveMethod() const; - - bool IsResolutionMethod() const; - - uintptr_t NativePcOffset(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Converts a native PC to a dex PC. - uint32_t ToDexPc(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Converts a dex PC to a native PC. - uintptr_t ToNativePc(const uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // Find the catch block for the given exception type and dex_pc. When a catch block is found, - // indicates whether the found catch block is responsible for clearing the exception or whether - // a move-exception instruction is present. - uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static void SetClasses(Class* java_lang_reflect_Constructor, Class* java_lang_reflect_Method); - - static Class* GetConstructorClass() { - return java_lang_reflect_Constructor_; - } - - static Class* GetMethodClass() { - return java_lang_reflect_Method_; - } - - static void ResetClasses(); - - protected: - // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". - // The class we are a part of - Class* declaring_class_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_initialized_static_storage_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_resolved_methods_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_resolved_types_; - - // short cuts to declaring_class_->dex_cache_ member for fast compiled code access - ObjectArray* dex_cache_strings_; - - // Access flags; low 16 bits are defined by spec. - uint32_t access_flags_; - - // Offset to the CodeItem. - uint32_t code_item_offset_; - - // Architecture-dependent register spill mask - uint32_t core_spill_mask_; - - // Compiled code associated with this method for callers from managed code. - // May be compiled managed code or a bridge for invoking a native method. - // TODO: Break apart this into portable and quick. - const void* entry_point_from_compiled_code_; - - // Called by the interpreter to execute this method. - EntryPointFromInterpreter* entry_point_from_interpreter_; - - // Architecture-dependent register spill mask - uint32_t fp_spill_mask_; - - // Total size in bytes of the frame - size_t frame_size_in_bytes_; - - // Garbage collection map of native PC offsets (quick) or dex PCs (portable) to reference bitmaps. - const uint8_t* gc_map_; - - // Mapping from native pc to dex pc - const uint32_t* mapping_table_; - - // Index into method_ids of the dex file associated with this method - uint32_t method_dex_index_; - - // For concrete virtual methods, this is the offset of the method in Class::vtable_. - // - // For abstract methods in an interface class, this is the offset of the method in - // "iftable_->Get(n)->GetMethodArray()". - // - // For static and direct methods this is the index in the direct methods table. - uint32_t method_index_; - - // The target native method registered with this method - const void* native_method_; - - // When a register is promoted into a register, the spill mask holds which registers hold dex - // registers. The first promoted register's corresponding dex register is vmap_table_[1], the Nth - // is vmap_table_[N]. vmap_table_[0] holds the length of the table. - const uint16_t* vmap_table_; - - static Class* java_lang_reflect_Constructor_; - static Class* java_lang_reflect_Method_; - - friend struct art::AbstractMethodOffsets; // for verifying offset information - friend struct art::ConstructorMethodOffsets; // for verifying offset information - friend struct art::MethodOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethod); -}; - -class MANAGED Method : public AbstractMethod {}; - -class MANAGED Constructor : public AbstractMethod {}; - -class MANAGED AbstractMethodClass : public Class { - private: - Object* ORDER_BY_SIGNATURE_; - friend struct art::MethodClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(AbstractMethodClass); -}; - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ diff --git a/runtime/mirror/art_field-inl.h b/runtime/mirror/art_field-inl.h new file mode 100644 index 0000000000..d8c278c9ac --- /dev/null +++ b/runtime/mirror/art_field-inl.h @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ + +#include "art_field.h" + +#include "base/logging.h" +#include "gc/accounting/card_table-inl.h" +#include "jvalue.h" +#include "object-inl.h" +#include "object_utils.h" +#include "primitive.h" + +namespace art { +namespace mirror { + +inline Class* ArtField::GetDeclaringClass() const { + Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), false); + DCHECK(result != NULL); + DCHECK(result->IsLoaded() || result->IsErroneous()); + return result; +} + +inline void ArtField::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtField, declaring_class_), new_declaring_class, false); +} + +inline uint32_t ArtField::GetAccessFlags() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), false); +} + +inline MemberOffset ArtField::GetOffset() const { + DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); +} + +inline MemberOffset ArtField::GetOffsetDuringLinking() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), false)); +} + +inline uint32_t ArtField::Get32(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetField32(GetOffset(), IsVolatile()); +} + +inline void ArtField::Set32(Object* object, uint32_t new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetField32(GetOffset(), new_value, IsVolatile()); +} + +inline uint64_t ArtField::Get64(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetField64(GetOffset(), IsVolatile()); +} + +inline void ArtField::Set64(Object* object, uint64_t new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetField64(GetOffset(), new_value, IsVolatile()); +} + +inline Object* ArtField::GetObj(const Object* object) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + return object->GetFieldObject(GetOffset(), IsVolatile()); +} + +inline void ArtField::SetObj(Object* object, const Object* new_value) const { + DCHECK(object != NULL) << PrettyField(this); + DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); + object->SetFieldObject(GetOffset(), new_value, IsVolatile()); +} + +inline bool ArtField::GetBoolean(const Object* object) const { + DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetBoolean(Object* object, bool z) const { + DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, z); +} + +inline int8_t ArtField::GetByte(const Object* object) const { + DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetByte(Object* object, int8_t b) const { + DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, b); +} + +inline uint16_t ArtField::GetChar(const Object* object) const { + DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetChar(Object* object, uint16_t c) const { + DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, c); +} + +inline int16_t ArtField::GetShort(const Object* object) const { + DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return Get32(object); +} + +inline void ArtField::SetShort(Object* object, int16_t s) const { + DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + Set32(object, s); +} + +inline int32_t ArtField::GetInt(const Object* object) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); +#endif + return Get32(object); +} + +inline void ArtField::SetInt(Object* object, int32_t i) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); +#endif + Set32(object, i); +} + +inline int64_t ArtField::GetLong(const Object* object) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); +#endif + return Get64(object); +} + +inline void ArtField::SetLong(Object* object, int64_t j) const { +#ifndef NDEBUG + Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); + CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); +#endif + Set64(object, j); +} + +inline float ArtField::GetFloat(const Object* object) const { + DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetI(Get32(object)); + return bits.GetF(); +} + +inline void ArtField::SetFloat(Object* object, float f) const { + DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetF(f); + Set32(object, bits.GetI()); +} + +inline double ArtField::GetDouble(const Object* object) const { + DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetJ(Get64(object)); + return bits.GetD(); +} + +inline void ArtField::SetDouble(Object* object, double d) const { + DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + JValue bits; + bits.SetD(d); + Set64(object, bits.GetJ()); +} + +inline Object* ArtField::GetObject(const Object* object) const { + DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + return GetObj(object); +} + +inline void ArtField::SetObject(Object* object, const Object* l) const { + DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) + << PrettyField(this); + SetObj(object, l); +} + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_FIELD_INL_H_ diff --git a/runtime/mirror/art_field.cc b/runtime/mirror/art_field.cc new file mode 100644 index 0000000000..a8bbe4bc6a --- /dev/null +++ b/runtime/mirror/art_field.cc @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 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 "art_field.h" + +#include "art_field-inl.h" +#include "gc/accounting/card_table-inl.h" +#include "object-inl.h" +#include "object_utils.h" +#include "runtime.h" +#include "utils.h" + +namespace art { +namespace mirror { + +// TODO: get global references for these +Class* ArtField::java_lang_reflect_ArtField_ = NULL; + +void ArtField::SetClass(Class* java_lang_reflect_ArtField) { + CHECK(java_lang_reflect_ArtField_ == NULL); + CHECK(java_lang_reflect_ArtField != NULL); + java_lang_reflect_ArtField_ = java_lang_reflect_ArtField; +} + +void ArtField::ResetClass() { + CHECK(java_lang_reflect_ArtField_ != NULL); + java_lang_reflect_ArtField_ = NULL; +} + +void ArtField::SetOffset(MemberOffset num_bytes) { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); +#if 0 // TODO enable later in boot and under !NDEBUG + FieldHelper fh(this); + Primitive::Type type = fh.GetTypeAsPrimitiveType(); + if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) { + DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); + } +#endif + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, offset_), num_bytes.Uint32Value(), false); +} + +} // namespace mirror +} // namespace art diff --git a/runtime/mirror/art_field.h b/runtime/mirror/art_field.h new file mode 100644 index 0000000000..ae34cb1f84 --- /dev/null +++ b/runtime/mirror/art_field.h @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_RUNTIME_MIRROR_ART_FIELD_H_ +#define ART_RUNTIME_MIRROR_ART_FIELD_H_ + +#include "class.h" +#include "modifiers.h" +#include "object.h" + +namespace art { + +struct ArtFieldOffsets; + +namespace mirror { + +// C++ mirror of java.lang.reflect.ArtField +class MANAGED ArtField : public Object { + public: + Class* GetDeclaringClass() const; + + void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint32_t GetAccessFlags() const; + + void SetAccessFlags(uint32_t new_access_flags) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, access_flags_), new_access_flags, false); + } + + bool IsPublic() const { + return (GetAccessFlags() & kAccPublic) != 0; + } + + bool IsStatic() const { + return (GetAccessFlags() & kAccStatic) != 0; + } + + bool IsFinal() const { + return (GetAccessFlags() & kAccFinal) != 0; + } + + uint32_t GetDexFieldIndex() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), false); + } + + void SetDexFieldIndex(uint32_t new_idx) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtField, field_dex_idx_), new_idx, false); + } + + // Offset to field within an Object + MemberOffset GetOffset() const; + + static MemberOffset OffsetOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtField, offset_)); + } + + MemberOffset GetOffsetDuringLinking() const; + + void SetOffset(MemberOffset num_bytes); + + // field access, null object for static fields + bool GetBoolean(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetBoolean(Object* object, bool z) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int8_t GetByte(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetByte(Object* object, int8_t b) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint16_t GetChar(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetChar(Object* object, uint16_t c) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int16_t GetShort(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetShort(Object* object, int16_t s) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int32_t GetInt(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetInt(Object* object, int32_t i) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + int64_t GetLong(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetLong(Object* object, int64_t j) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + float GetFloat(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetFloat(Object* object, float f) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + double GetDouble(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetDouble(Object* object, double d) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + Object* GetObject(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetObject(Object* object, const Object* l) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // raw field accesses + uint32_t Get32(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Set32(Object* object, uint32_t new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + uint64_t Get64(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Set64(Object* object, uint64_t new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + Object* GetObj(const Object* object) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetObj(Object* object, const Object* new_value) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static Class* GetJavaLangReflectArtField() { + DCHECK(java_lang_reflect_ArtField_ != NULL); + return java_lang_reflect_ArtField_; + } + + static void SetClass(Class* java_lang_reflect_ArtField); + static void ResetClass(); + + bool IsVolatile() const { + return (GetAccessFlags() & kAccVolatile) != 0; + } + + private: + // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". + // The class we are a part of + Class* declaring_class_; + + uint32_t access_flags_; + + // Dex cache index of field id + uint32_t field_dex_idx_; + + // Offset of field within an instance or in the Class' static fields + uint32_t offset_; + + static Class* java_lang_reflect_ArtField_; + + friend struct art::ArtFieldOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtField); +}; + +class MANAGED ArtFieldClass : public Class { + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtFieldClass); +}; + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_FIELD_H_ diff --git a/runtime/mirror/art_method-inl.h b/runtime/mirror/art_method-inl.h new file mode 100644 index 0000000000..4d8aa6f741 --- /dev/null +++ b/runtime/mirror/art_method-inl.h @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ + +#include "art_method.h" + +#include "dex_file.h" +#include "entrypoints/entrypoint_utils.h" +#include "object_array.h" +#include "runtime.h" + +namespace art { +namespace mirror { + +inline Class* ArtMethod::GetDeclaringClass() const { + Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), false); + DCHECK(result != NULL) << this; + DCHECK(result->IsIdxLoaded() || result->IsErroneous()) << this; + return result; +} + +inline void ArtMethod::SetDeclaringClass(Class *new_declaring_class) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, declaring_class_), new_declaring_class, false); +} + +inline uint32_t ArtMethod::GetAccessFlags() const { + DCHECK(GetDeclaringClass()->IsIdxLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), false); +} + +inline uint16_t ArtMethod::GetMethodIndex() const { + DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), false); +} + +inline uint32_t ArtMethod::GetDexMethodIndex() const { + DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheStrings() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheResolvedMethods() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheResolvedTypes() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), false); +} + +inline ObjectArray* ArtMethod::GetDexCacheInitializedStaticStorage() const { + return GetFieldObject*>( + OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), + false); +} + +inline uint32_t ArtMethod::GetCodeSize() const { + DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); + uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); + if (code == 0) { + return 0; + } + // TODO: make this Thumb2 specific + code &= ~0x1; + return reinterpret_cast(code)[-1]; +} + +inline bool ArtMethod::CheckIncompatibleClassChange(InvokeType type) { + switch (type) { + case kStatic: + return !IsStatic(); + case kDirect: + return !IsDirect() || IsStatic(); + case kVirtual: { + Class* methods_class = GetDeclaringClass(); + return IsDirect() || (methods_class->IsInterface() && !IsMiranda()); + } + case kSuper: + return false; // TODO: appropriate checks for call to super class. + case kInterface: { + Class* methods_class = GetDeclaringClass(); + return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); + } + default: + LOG(FATAL) << "Unreachable - invocation type: " << type; + return true; + } +} + +inline void ArtMethod::AssertPcIsWithinCode(uintptr_t pc) const { + if (!kIsDebugBuild) { + return; + } + if (IsNative() || IsRuntimeMethod() || IsProxyMethod()) { + return; + } + if (pc == GetQuickInstrumentationExitPc()) { + return; + } + const void* code = GetEntryPointFromCompiledCode(); + if (code == GetCompiledCodeToInterpreterBridge() || code == GetQuickInstrumentationEntryPoint()) { + return; + } + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + if (code == GetResolutionTrampoline(class_linker)) { + return; + } + DCHECK(IsWithinCode(pc)) + << PrettyMethod(this) + << " pc=" << std::hex << pc + << " code=" << code + << " size=" << GetCodeSize(); +} + +inline uint32_t ArtMethod::GetOatCodeOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetEntryPointFromCompiledCode()); +} + +inline void ArtMethod::SetOatCodeOffset(uint32_t code_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetEntryPointFromCompiledCode(reinterpret_cast(code_offset)); +} + +inline uint32_t ArtMethod::GetOatMappingTableOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetMappingTable()); +} + +inline void ArtMethod::SetOatMappingTableOffset(uint32_t mapping_table_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetMappingTable(reinterpret_cast(mapping_table_offset)); +} + +inline uint32_t ArtMethod::GetOatVmapTableOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetVmapTable()); +} + +inline void ArtMethod::SetOatVmapTableOffset(uint32_t vmap_table_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetVmapTable(reinterpret_cast(vmap_table_offset)); +} + +inline void ArtMethod::SetOatNativeGcMapOffset(uint32_t gc_map_offset) { + DCHECK(!Runtime::Current()->IsStarted()); + SetNativeGcMap(reinterpret_cast(gc_map_offset)); +} + +inline uint32_t ArtMethod::GetOatNativeGcMapOffset() const { + DCHECK(!Runtime::Current()->IsStarted()); + return reinterpret_cast(GetNativeGcMap()); +} + +inline bool ArtMethod::IsRuntimeMethod() const { + return GetDexMethodIndex() == DexFile::kDexNoIndex16; +} + +inline bool ArtMethod::IsCalleeSaveMethod() const { + if (!IsRuntimeMethod()) { + return false; + } + Runtime* runtime = Runtime::Current(); + bool result = false; + for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { + if (this == runtime->GetCalleeSaveMethod(Runtime::CalleeSaveType(i))) { + result = true; + break; + } + } + return result; +} + +inline bool ArtMethod::IsResolutionMethod() const { + bool result = this == Runtime::Current()->GetResolutionMethod(); + // Check that if we do think it is phony it looks like the resolution method. + DCHECK(!result || IsRuntimeMethod()); + return result; +} +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_METHOD_INL_H_ diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc new file mode 100644 index 0000000000..cd05f41cc2 --- /dev/null +++ b/runtime/mirror/art_method.cc @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2011 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 "art_method.h" + +#include "art_method-inl.h" +#include "base/stringpiece.h" +#include "class-inl.h" +#include "dex_file-inl.h" +#include "dex_instruction.h" +#include "gc/accounting/card_table-inl.h" +#include "interpreter/interpreter.h" +#include "jni_internal.h" +#include "mapping_table.h" +#include "object-inl.h" +#include "object_array.h" +#include "object_array-inl.h" +#include "string.h" +#include "object_utils.h" + +namespace art { +namespace mirror { + +extern "C" void art_portable_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); +extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char); + +// TODO: get global references for these +Class* ArtMethod::java_lang_reflect_ArtMethod_ = NULL; + +InvokeType ArtMethod::GetInvokeType() const { + // TODO: kSuper? + if (GetDeclaringClass()->IsInterface()) { + return kInterface; + } else if (IsStatic()) { + return kStatic; + } else if (IsDirect()) { + return kDirect; + } else { + return kVirtual; + } +} + +void ArtMethod::SetClass(Class* java_lang_reflect_ArtMethod) { + CHECK(java_lang_reflect_ArtMethod_ == NULL); + CHECK(java_lang_reflect_ArtMethod != NULL); + java_lang_reflect_ArtMethod_ = java_lang_reflect_ArtMethod; +} + +void ArtMethod::ResetClass() { + CHECK(java_lang_reflect_ArtMethod_ != NULL); + java_lang_reflect_ArtMethod_ = NULL; +} + +void ArtMethod::SetDexCacheStrings(ObjectArray* new_dex_cache_strings) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_), + new_dex_cache_strings, false); +} + +void ArtMethod::SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_), + new_dex_cache_methods, false); +} + +void ArtMethod::SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_classes) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_), + new_dex_cache_classes, false); +} + +void ArtMethod::SetDexCacheInitializedStaticStorage(ObjectArray* new_value) { + SetFieldObject(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_initialized_static_storage_), + new_value, false); +} + +size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) { + CHECK_LE(1, shorty.length()); + uint32_t num_registers = 0; + for (int i = 1; i < shorty.length(); ++i) { + char ch = shorty[i]; + if (ch == 'D' || ch == 'J') { + num_registers += 2; + } else { + num_registers += 1; + } + } + return num_registers; +} + +bool ArtMethod::IsProxyMethod() const { + return GetDeclaringClass()->IsProxyClass(); +} + +ArtMethod* ArtMethod::FindOverriddenMethod() const { + if (IsStatic()) { + return NULL; + } + Class* declaring_class = GetDeclaringClass(); + Class* super_class = declaring_class->GetSuperClass(); + uint16_t method_index = GetMethodIndex(); + ObjectArray* super_class_vtable = super_class->GetVTable(); + ArtMethod* result = NULL; + // Did this method override a super class method? If so load the result from the super class' + // vtable + if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) { + result = super_class_vtable->Get(method_index); + } else { + // Method didn't override superclass method so search interfaces + if (IsProxyMethod()) { + result = GetDexCacheResolvedMethods()->Get(GetDexMethodIndex()); + CHECK_EQ(result, + Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this)); + } else { + MethodHelper mh(this); + MethodHelper interface_mh; + IfTable* iftable = GetDeclaringClass()->GetIfTable(); + for (size_t i = 0; i < iftable->Count() && result == NULL; i++) { + Class* interface = iftable->GetInterface(i); + for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) { + ArtMethod* interface_method = interface->GetVirtualMethod(j); + interface_mh.ChangeMethod(interface_method); + if (mh.HasSameNameAndSignature(&interface_mh)) { + result = interface_method; + break; + } + } + } + } + } +#ifndef NDEBUG + MethodHelper result_mh(result); + DCHECK(result == NULL || MethodHelper(this).HasSameNameAndSignature(&result_mh)); +#endif + return result; +} + +uintptr_t ArtMethod::NativePcOffset(const uintptr_t pc) const { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return pc - reinterpret_cast(code); +} + +uint32_t ArtMethod::ToDexPc(const uintptr_t pc) const { +#if !defined(ART_USE_PORTABLE_COMPILER) + MappingTable table(GetMappingTable()); + if (table.TotalSize() == 0) { + DCHECK(IsNative() || IsCalleeSaveMethod() || IsProxyMethod()) << PrettyMethod(this); + return DexFile::kDexNoIndex; // Special no mapping case + } + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + uint32_t sought_offset = pc - reinterpret_cast(code); + // Assume the caller wants a pc-to-dex mapping so check here first. + typedef MappingTable::PcToDexIterator It; + for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { + if (cur.NativePcOffset() == sought_offset) { + return cur.DexPc(); + } + } + // Now check dex-to-pc mappings. + typedef MappingTable::DexToPcIterator It2; + for (It2 cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { + if (cur.NativePcOffset() == sought_offset) { + return cur.DexPc(); + } + } + LOG(FATAL) << "Failed to find Dex offset for PC offset " << reinterpret_cast(sought_offset) + << "(PC " << reinterpret_cast(pc) << ", code=" << code + << ") in " << PrettyMethod(this); + return DexFile::kDexNoIndex; +#else + // Compiler LLVM doesn't use the machine pc, we just use dex pc instead. + return static_cast(pc); +#endif +} + +uintptr_t ArtMethod::ToNativePc(const uint32_t dex_pc) const { + MappingTable table(GetMappingTable()); + if (table.TotalSize() == 0) { + DCHECK_EQ(dex_pc, 0U); + return 0; // Special no mapping/pc == 0 case + } + // Assume the caller wants a dex-to-pc mapping so check here first. + typedef MappingTable::DexToPcIterator It; + for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) { + if (cur.DexPc() == dex_pc) { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return reinterpret_cast(code) + cur.NativePcOffset(); + } + } + // Now check pc-to-dex mappings. + typedef MappingTable::PcToDexIterator It2; + for (It2 cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) { + if (cur.DexPc() == dex_pc) { + const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this); + return reinterpret_cast(code) + cur.NativePcOffset(); + } + } + LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc + << " in " << PrettyMethod(this); + return 0; +} + +uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, + bool* has_no_move_exception) const { + MethodHelper mh(this); + const DexFile::CodeItem* code_item = mh.GetCodeItem(); + // Default to handler not found. + uint32_t found_dex_pc = DexFile::kDexNoIndex; + // Iterate over the catch handlers associated with dex_pc. + for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) { + uint16_t iter_type_idx = it.GetHandlerTypeIndex(); + // Catch all case + if (iter_type_idx == DexFile::kDexNoIndex16) { + found_dex_pc = it.GetHandlerAddress(); + break; + } + // Does this catch exception type apply? + Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx); + if (iter_exception_type == NULL) { + // The verifier should take care of resolving all exception classes early + LOG(WARNING) << "Unresolved exception class when finding catch block: " + << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx); + } else if (iter_exception_type->IsAssignableFrom(exception_type)) { + found_dex_pc = it.GetHandlerAddress(); + break; + } + } + if (found_dex_pc != DexFile::kDexNoIndex) { + const Instruction* first_catch_instr = + Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]); + *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION); + } + return found_dex_pc; +} + +void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, + char result_type) { + if (kIsDebugBuild) { + self->AssertThreadSuspensionIsAllowable(); + CHECK_EQ(kRunnable, self->GetState()); + } + + // Push a transition back into managed code onto the linked list in thread. + ManagedStack fragment; + self->PushManagedStackFragment(&fragment); + + Runtime* runtime = Runtime::Current(); + // Call the invoke stub, passing everything as arguments. + if (UNLIKELY(!runtime->IsStarted())) { + LOG(INFO) << "Not invoking " << PrettyMethod(this) << " for a runtime that isn't started"; + if (result != NULL) { + result->SetJ(0); + } + } else { + const bool kLogInvocationStartAndReturn = false; + if (GetEntryPointFromCompiledCode() != NULL) { + if (kLogInvocationStartAndReturn) { + LOG(INFO) << StringPrintf("Invoking '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); + } +#ifdef ART_USE_PORTABLE_COMPILER + (*art_portable_invoke_stub)(this, args, args_size, self, result, result_type); +#else + (*art_quick_invoke_stub)(this, args, args_size, self, result, result_type); +#endif + if (UNLIKELY(reinterpret_cast(self->GetException(NULL)) == -1)) { + // Unusual case where we were running LLVM generated code and an + // exception was thrown to force the activations to be removed from the + // stack. Continue execution in the interpreter. + self->ClearException(); + ShadowFrame* shadow_frame = self->GetAndClearDeoptimizationShadowFrame(result); + self->SetTopOfStack(NULL, 0); + self->SetTopOfShadowStack(shadow_frame); + interpreter::EnterInterpreterFromDeoptimize(self, shadow_frame, result); + } + if (kLogInvocationStartAndReturn) { + LOG(INFO) << StringPrintf("Returned '%s' code=%p", PrettyMethod(this).c_str(), GetEntryPointFromCompiledCode()); + } + } else { + LOG(INFO) << "Not invoking '" << PrettyMethod(this) + << "' code=" << reinterpret_cast(GetEntryPointFromCompiledCode()); + if (result != NULL) { + result->SetJ(0); + } + } + } + + // Pop transition. + self->PopManagedStackFragment(fragment); +} + +bool ArtMethod::IsRegistered() const { + void* native_method = GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), false); + CHECK(native_method != NULL); + void* jni_stub = GetJniDlsymLookupStub(); + return native_method != jni_stub; +} + +extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject); +void ArtMethod::RegisterNative(Thread* self, const void* native_method) { + DCHECK(Thread::Current() == self); + CHECK(IsNative()) << PrettyMethod(this); + CHECK(native_method != NULL) << PrettyMethod(this); + if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) { + SetNativeMethod(native_method); + } else { + // We've been asked to associate this method with the given native method but are working + // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct + // the native method to runtime support and store the target somewhere runtime support will + // find it. +#if defined(__i386__) + UNIMPLEMENTED(FATAL); +#else + SetNativeMethod(reinterpret_cast(art_work_around_app_jni_bugs)); +#endif + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), + reinterpret_cast(native_method), false); + } +} + +void ArtMethod::UnregisterNative(Thread* self) { + CHECK(IsNative()) << PrettyMethod(this); + // restore stub to lookup native pointer via dlsym + RegisterNative(self, GetJniDlsymLookupStub()); +} + +void ArtMethod::SetNativeMethod(const void* native_method) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_), + native_method, false); +} + +} // namespace mirror +} // namespace art diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h new file mode 100644 index 0000000000..7301f23747 --- /dev/null +++ b/runtime/mirror/art_method.h @@ -0,0 +1,457 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_RUNTIME_MIRROR_ART_METHOD_H_ +#define ART_RUNTIME_MIRROR_ART_METHOD_H_ + +#include "class.h" +#include "dex_file.h" +#include "invoke_type.h" +#include "locks.h" +#include "modifiers.h" +#include "object.h" + +namespace art { + +struct ArtMethodOffsets; +struct ConstructorMethodOffsets; +union JValue; +struct MethodClassOffsets; +class MethodHelper; +class StringPiece; +class ShadowFrame; + +namespace mirror { + +class StaticStorageBase; + +typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, + const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); + +// C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor +class MANAGED ArtMethod : public Object { + public: + Class* GetDeclaringClass() const; + + void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset DeclaringClassOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); + } + + static MemberOffset EntryPointFromCompiledCodeOffset() { + return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_compiled_code_)); + } + + uint32_t GetAccessFlags() const; + + void SetAccessFlags(uint32_t new_access_flags) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags, false); + } + + // Approximate what kind of method call would be used for this method. + InvokeType GetInvokeType() const; + + // Returns true if the method is declared public. + bool IsPublic() const { + return (GetAccessFlags() & kAccPublic) != 0; + } + + // Returns true if the method is declared private. + bool IsPrivate() const { + return (GetAccessFlags() & kAccPrivate) != 0; + } + + // Returns true if the method is declared static. + bool IsStatic() const { + return (GetAccessFlags() & kAccStatic) != 0; + } + + // Returns true if the method is a constructor. + bool IsConstructor() const { + return (GetAccessFlags() & kAccConstructor) != 0; + } + + // Returns true if the method is static, private, or a constructor. + bool IsDirect() const { + return IsDirect(GetAccessFlags()); + } + + static bool IsDirect(uint32_t access_flags) { + return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; + } + + // Returns true if the method is declared synchronized. + bool IsSynchronized() const { + uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; + return (GetAccessFlags() & synchonized) != 0; + } + + bool IsFinal() const { + return (GetAccessFlags() & kAccFinal) != 0; + } + + bool IsMiranda() const { + return (GetAccessFlags() & kAccMiranda) != 0; + } + + bool IsNative() const { + return (GetAccessFlags() & kAccNative) != 0; + } + + bool IsAbstract() const { + return (GetAccessFlags() & kAccAbstract) != 0; + } + + bool IsSynthetic() const { + return (GetAccessFlags() & kAccSynthetic) != 0; + } + + bool IsProxyMethod() const; + + bool IsPreverified() const { + return (GetAccessFlags() & kAccPreverified) != 0; + } + + void SetPreverified() { + SetAccessFlags(GetAccessFlags() | kAccPreverified); + } + + bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint16_t GetMethodIndex() const; + + size_t GetVtableIndex() const { + return GetMethodIndex(); + } + + void SetMethodIndex(uint16_t new_method_index) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index, false); + } + + static MemberOffset MethodIndexOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); + } + + uint32_t GetCodeItemOffset() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), false); + } + + void SetCodeItemOffset(uint32_t new_code_off) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), new_code_off, false); + } + + // Number of 32bit registers that would be required to hold all the arguments + static size_t NumArgRegisters(const StringPiece& shorty); + + uint32_t GetDexMethodIndex() const; + + void SetDexMethodIndex(uint32_t new_idx) { + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), new_idx, false); + } + + ObjectArray* GetDexCacheStrings() const; + void SetDexCacheStrings(ObjectArray* new_dex_cache_strings) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset DexCacheStringsOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_); + } + + static MemberOffset DexCacheResolvedMethodsOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); + } + + static MemberOffset DexCacheResolvedTypesOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_); + } + + static MemberOffset DexCacheInitializedStaticStorageOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, + dex_cache_initialized_static_storage_); + } + + ObjectArray* GetDexCacheResolvedMethods() const; + void SetDexCacheResolvedMethods(ObjectArray* new_dex_cache_methods) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + ObjectArray* GetDexCacheResolvedTypes() const; + void SetDexCacheResolvedTypes(ObjectArray* new_dex_cache_types) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + ObjectArray* GetDexCacheInitializedStaticStorage() const; + void SetDexCacheInitializedStaticStorage(ObjectArray* new_value) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Find the method that this method overrides + ArtMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + EntryPointFromInterpreter* GetEntryPointFromInterpreter() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), false); + } + + void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false); + } + + const void* GetEntryPointFromCompiledCode() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), false); + } + + void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false); + } + + uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool IsWithinCode(uintptr_t pc) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + uintptr_t code = reinterpret_cast(GetEntryPointFromCompiledCode()); + if (code == 0) { + return pc == 0; + } + /* + * During a stack walk, a return PC may point to the end of the code + 1 + * (in the case that the last instruction is a call that isn't expected to + * return. Thus, we check <= code + GetCodeSize(). + */ + return (code <= pc && pc <= code + GetCodeSize()); + } + + void AssertPcIsWithinCode(uintptr_t pc) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + uint32_t GetOatCodeOffset() const; + + void SetOatCodeOffset(uint32_t code_offset); + + static MemberOffset GetEntryPointFromCompiledCodeOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_); + } + + // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. + const uint8_t* GetMappingTable() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), false); + } + + void SetMappingTable(const uint8_t* mapping_table) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), + mapping_table, false); + } + + uint32_t GetOatMappingTableOffset() const; + + void SetOatMappingTableOffset(uint32_t mapping_table_offset); + + // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. + const uint8_t* GetVmapTable() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), false); + } + + void SetVmapTable(const uint8_t* vmap_table) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), vmap_table, false); + } + + uint32_t GetOatVmapTableOffset() const; + + void SetOatVmapTableOffset(uint32_t vmap_table_offset); + + const uint8_t* GetNativeGcMap() const { + return GetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), false); + } + void SetNativeGcMap(const uint8_t* data) { + SetFieldPtr(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data, false); + } + + // When building the oat need a convenient place to stuff the offset of the native GC map. + void SetOatNativeGcMapOffset(uint32_t gc_map_offset); + uint32_t GetOatNativeGcMapOffset() const; + + size_t GetFrameSizeInBytes() const { + DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); + size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), false); + DCHECK_LE(static_cast(kStackAlignment), result); + return result; + } + + void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) { + DCHECK_EQ(sizeof(size_t), sizeof(uint32_t)); + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), + new_frame_size_in_bytes, false); + } + + size_t GetReturnPcOffsetInBytes() const { + return GetFrameSizeInBytes() - kPointerSize; + } + + size_t GetSirtOffsetInBytes() const { + CHECK(IsNative()); + return kPointerSize; + } + + bool IsRegistered() const; + + void RegisterNative(Thread* self, const void* native_method) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static MemberOffset NativeMethodOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_); + } + + const void* GetNativeMethod() const { + return reinterpret_cast(GetField32(NativeMethodOffset(), false)); + } + + void SetNativeMethod(const void*); + + static MemberOffset GetMethodIndexOffset() { + return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); + } + + uint32_t GetCoreSpillMask() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), false); + } + + void SetCoreSpillMask(uint32_t core_spill_mask) { + // Computed during compilation + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), core_spill_mask, false); + } + + uint32_t GetFpSpillMask() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), false); + } + + void SetFpSpillMask(uint32_t fp_spill_mask) { + // Computed during compilation + SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), fp_spill_mask, false); + } + + // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal + // conventions for a method of managed code. Returns false for Proxy methods. + bool IsRuntimeMethod() const; + + // Is this a hand crafted method used for something like describing callee saves? + bool IsCalleeSaveMethod() const; + + bool IsResolutionMethod() const; + + uintptr_t NativePcOffset(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Converts a native PC to a dex PC. + uint32_t ToDexPc(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Converts a dex PC to a native PC. + uintptr_t ToNativePc(const uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + // Find the catch block for the given exception type and dex_pc. When a catch block is found, + // indicates whether the found catch block is responsible for clearing the exception or whether + // a move-exception instruction is present. + uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + static void SetClass(Class* java_lang_reflect_ArtMethod); + + static Class* GetJavaLangReflectArtMethod() { + return java_lang_reflect_ArtMethod_; + } + + static void ResetClass(); + + protected: + // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". + // The class we are a part of + Class* declaring_class_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_initialized_static_storage_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_resolved_methods_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_resolved_types_; + + // short cuts to declaring_class_->dex_cache_ member for fast compiled code access + ObjectArray* dex_cache_strings_; + + // Access flags; low 16 bits are defined by spec. + uint32_t access_flags_; + + // Offset to the CodeItem. + uint32_t code_item_offset_; + + // Architecture-dependent register spill mask + uint32_t core_spill_mask_; + + // Compiled code associated with this method for callers from managed code. + // May be compiled managed code or a bridge for invoking a native method. + // TODO: Break apart this into portable and quick. + const void* entry_point_from_compiled_code_; + + // Called by the interpreter to execute this method. + EntryPointFromInterpreter* entry_point_from_interpreter_; + + // Architecture-dependent register spill mask + uint32_t fp_spill_mask_; + + // Total size in bytes of the frame + size_t frame_size_in_bytes_; + + // Garbage collection map of native PC offsets (quick) or dex PCs (portable) to reference bitmaps. + const uint8_t* gc_map_; + + // Mapping from native pc to dex pc + const uint32_t* mapping_table_; + + // Index into method_ids of the dex file associated with this method + uint32_t method_dex_index_; + + // For concrete virtual methods, this is the offset of the method in Class::vtable_. + // + // For abstract methods in an interface class, this is the offset of the method in + // "iftable_->Get(n)->GetMethodArray()". + // + // For static and direct methods this is the index in the direct methods table. + uint32_t method_index_; + + // The target native method registered with this method + const void* native_method_; + + // When a register is promoted into a register, the spill mask holds which registers hold dex + // registers. The first promoted register's corresponding dex register is vmap_table_[1], the Nth + // is vmap_table_[N]. vmap_table_[0] holds the length of the table. + const uint16_t* vmap_table_; + + static Class* java_lang_reflect_ArtMethod_; + + friend struct art::ArtMethodOffsets; // for verifying offset information + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); +}; + +class MANAGED ArtMethodClass : public Class { + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethodClass); +}; + +} // namespace mirror +} // namespace art + +#endif // ART_RUNTIME_MIRROR_ART_METHOD_H_ diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 52906a2650..1e1138745d 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -19,10 +19,10 @@ #include "class.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "class_loader.h" #include "dex_cache.h" -#include "field.h" #include "iftable.h" #include "object_array-inl.h" #include "runtime.h" @@ -54,30 +54,30 @@ inline DexCache* Class::GetDexCache() const { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, dex_cache_), false); } -inline ObjectArray* Class::GetDirectMethods() const { +inline ObjectArray* Class::GetDirectMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>( + return GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); } -inline void Class::SetDirectMethods(ObjectArray* new_direct_methods) +inline void Class::SetDirectMethods(ObjectArray* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false)); DCHECK_NE(0, new_direct_methods->GetLength()); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), new_direct_methods, false); } -inline AbstractMethod* Class::GetDirectMethod(int32_t i) const +inline ArtMethod* Class::GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetDirectMethods()->Get(i); } -inline void Class::SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* direct_methods = - GetFieldObject*>( + ObjectArray* direct_methods = + GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, direct_methods_), false); direct_methods->Set(i, f); } @@ -87,13 +87,13 @@ inline size_t Class::NumDirectMethods() const { return (GetDirectMethods() != NULL) ? GetDirectMethods()->GetLength() : 0; } -inline ObjectArray* Class::GetVirtualMethods() const { +inline ObjectArray* Class::GetVirtualMethods() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>( + return GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); } -inline void Class::SetVirtualMethods(ObjectArray* new_virtual_methods) { +inline void Class::SetVirtualMethods(ObjectArray* new_virtual_methods) { // TODO: we reassign virtual methods to grow the table for miranda // methods.. they should really just be assigned once DCHECK_NE(0, new_virtual_methods->GetLength()); @@ -105,37 +105,37 @@ inline size_t Class::NumVirtualMethods() const { return (GetVirtualMethods() != NULL) ? GetVirtualMethods()->GetLength() : 0; } -inline AbstractMethod* Class::GetVirtualMethod(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsResolved() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline AbstractMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const +inline ArtMethod* Class::GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(IsLoaded() || IsErroneous()); return GetVirtualMethods()->Get(i); } -inline void Class::SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t +inline void Class::SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* virtual_methods = - GetFieldObject*>( + ObjectArray* virtual_methods = + GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, virtual_methods_), false); virtual_methods->Set(i, f); } -inline ObjectArray* Class::GetVTable() const { +inline ObjectArray* Class::GetVTable() const { DCHECK(IsResolved() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline ObjectArray* Class::GetVTableDuringLinking() const { +inline ObjectArray* Class::GetVTableDuringLinking() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), false); } -inline void Class::SetVTable(ObjectArray* new_vtable) +inline void Class::SetVTable(ObjectArray* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, vtable_), new_vtable, false); } @@ -208,7 +208,7 @@ inline bool Class::IsSubClass(const Class* klass) const { return false; } -inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForInterface(ArtMethod* method) const { Class* declaring_class = method->GetDeclaringClass(); DCHECK(declaring_class != NULL) << PrettyClass(this); DCHECK(declaring_class->IsInterface()) << PrettyMethod(method); @@ -223,7 +223,7 @@ inline AbstractMethod* Class::FindVirtualMethodForInterface(AbstractMethod* meth return NULL; } -inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface() || method->IsMiranda()); // The argument method may from a super class. @@ -231,13 +231,13 @@ inline AbstractMethod* Class::FindVirtualMethodForVirtual(AbstractMethod* method return GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForSuper(AbstractMethod* method) const +inline ArtMethod* Class::FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(!method->GetDeclaringClass()->IsInterface()); return GetSuperClass()->GetVTable()->Get(method->GetMethodIndex()); } -inline AbstractMethod* Class::FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const { +inline ArtMethod* Class::FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const { if (method->IsDirect()) { return method; } @@ -263,26 +263,26 @@ inline void Class::SetIfTable(IfTable* new_iftable) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, iftable_), new_iftable, false); } -inline ObjectArray* Class::GetIFields() const { +inline ObjectArray* Class::GetIFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); } -inline void Class::SetIFields(ObjectArray* new_ifields) +inline void Class::SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, ifields_), new_ifields, false); } -inline ObjectArray* Class::GetSFields() const { +inline ObjectArray* Class::GetSFields() const { DCHECK(IsLoaded() || IsErroneous()); - return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); + return GetFieldObject*>(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); } -inline void Class::SetSFields(ObjectArray* new_sfields) +inline void Class::SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(NULL == GetFieldObject*>( + DCHECK(NULL == GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false)); SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, sfields_), new_sfields, false); } @@ -291,14 +291,14 @@ inline size_t Class::NumStaticFields() const { return (GetSFields() != NULL) ? GetSFields()->GetLength() : 0; } -inline Field* Class::GetStaticField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetStaticField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetSFields()->Get(i); } -inline void Class::SetStaticField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetStaticField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* sfields= GetFieldObject*>( + ObjectArray* sfields= GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, sfields_), false); sfields->Set(i, f); } @@ -307,15 +307,15 @@ inline size_t Class::NumInstanceFields() const { return (GetIFields() != NULL) ? GetIFields()->GetLength() : 0; } -inline Field* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t +inline ArtField* Class::GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_NE(NumInstanceFields(), 0U); return GetIFields()->Get(i); } -inline void Class::SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t +inline void Class::SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* ifields= GetFieldObject*>( + ObjectArray* ifields= GetFieldObject*>( OFFSET_OF_OBJECT_MEMBER(Class, ifields_), false); ifields->Set(i, f); } @@ -330,9 +330,8 @@ inline uint32_t Class::GetAccessFlags() const { // circularity issue during loading the names of its members DCHECK(IsLoaded() || IsErroneous() || this == String::GetJavaLangString() || - this == Field::GetJavaLangReflectField() || - this == AbstractMethod::GetConstructorClass() || - this == AbstractMethod::GetMethodClass()); + this == ArtField::GetJavaLangReflectArtField() || + this == ArtMethod::GetJavaLangReflectArtMethod()); return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_), false); } diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index e490d97f80..29025f26c8 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -16,13 +16,13 @@ #include "class.h" -#include "abstract_method-inl.h" +#include "art_field-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "class_linker.h" #include "class_loader.h" #include "dex_cache.h" #include "dex_file-inl.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "object-inl.h" #include "object_array-inl.h" @@ -63,7 +63,7 @@ void Class::SetStatus(Status new_status) { // Stash current exception. Thread* self = Thread::Current(); SirtRef old_throw_this_object(self, NULL); - SirtRef old_throw_method(self, NULL); + SirtRef old_throw_method(self, NULL); SirtRef old_exception(self, NULL); uint32_t old_throw_dex_pc; { @@ -316,24 +316,23 @@ bool Class::IsThrowableClass() const { return WellKnownClasses::ToClass(WellKnownClasses::java_lang_Throwable)->IsAssignableFrom(this); } -bool Class::IsFieldClass() const { +bool Class::IsArtFieldClass() const { Class* java_lang_Class = GetClass(); - Class* java_lang_reflect_Field = java_lang_Class->GetInstanceField(0)->GetClass(); - return this == java_lang_reflect_Field; + Class* java_lang_reflect_ArtField = java_lang_Class->GetInstanceField(0)->GetClass(); + return this == java_lang_reflect_ArtField; } -bool Class::IsMethodClass() const { - return (this == AbstractMethod::GetMethodClass()) || - (this == AbstractMethod::GetConstructorClass()); +bool Class::IsArtMethodClass() const { + return this == ArtMethod::GetJavaLangReflectArtMethod(); } void Class::SetClassLoader(ClassLoader* new_class_loader) { SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, class_loader_), new_class_loader, false); } -AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindInterfaceMethod(const StringPiece& name, const StringPiece& signature) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -349,9 +348,9 @@ AbstractMethod* Class::FindInterfaceMethod(const StringPiece& name, const String return NULL; } -AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { // Check the current class before checking the interfaces. - AbstractMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -368,10 +367,10 @@ AbstractMethod* Class::FindInterfaceMethod(const DexCache* dex_cache, uint32_t d } -AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -380,10 +379,10 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const StringPiece& name, const S return NULL; } -AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumDirectMethods(); ++i) { - AbstractMethod* method = GetDirectMethod(i); + ArtMethod* method = GetDirectMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -392,9 +391,9 @@ AbstractMethod* Class::FindDeclaredDirectMethod(const DexCache* dex_cache, uint3 return NULL; } -AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindDirectMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(name, signature); + ArtMethod* method = klass->FindDeclaredDirectMethod(name, signature); if (method != NULL) { return method; } @@ -402,9 +401,9 @@ AbstractMethod* Class::FindDirectMethod(const StringPiece& name, const StringPie return NULL; } -AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredDirectMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -412,11 +411,11 @@ AbstractMethod* Class::FindDirectMethod(const DexCache* dex_cache, uint32_t dex_ return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, +ArtMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const { MethodHelper mh; for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); mh.ChangeMethod(method); if (name == mh.GetName() && signature == mh.GetSignature()) { return method; @@ -425,10 +424,10 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const StringPiece& name, return NULL; } -AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumVirtualMethods(); ++i) { - AbstractMethod* method = GetVirtualMethod(i); + ArtMethod* method = GetVirtualMethod(i); if (method->GetDexMethodIndex() == dex_method_idx) { return method; } @@ -437,9 +436,9 @@ AbstractMethod* Class::FindDeclaredVirtualMethod(const DexCache* dex_cache, uint return NULL; } -AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { +ArtMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPiece& signature) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(name, signature); + ArtMethod* method = klass->FindDeclaredVirtualMethod(name, signature); if (method != NULL) { return method; } @@ -447,9 +446,9 @@ AbstractMethod* Class::FindVirtualMethod(const StringPiece& name, const StringPi return NULL; } -AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { +ArtMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const { for (const Class* klass = this; klass != NULL; klass = klass->GetSuperClass()) { - AbstractMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); + ArtMethod* method = klass->FindDeclaredVirtualMethod(dex_cache, dex_method_idx); if (method != NULL) { return method; } @@ -457,12 +456,12 @@ AbstractMethod* Class::FindVirtualMethod(const DexCache* dex_cache, uint32_t dex return NULL; } -Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class? // Interfaces are not relevant because they can't contain instance fields. FieldHelper fh; for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -471,10 +470,10 @@ Field* Class::FindDeclaredInstanceField(const StringPiece& name, const StringPie return NULL; } -Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (GetDexCache() == dex_cache) { for (size_t i = 0; i < NumInstanceFields(); ++i) { - Field* f = GetInstanceField(i); + ArtField* f = GetInstanceField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -483,11 +482,11 @@ Field* Class::FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_ return NULL; } -Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindInstanceField(const StringPiece& name, const StringPiece& type) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(name, type); + ArtField* f = c->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -495,11 +494,11 @@ Field* Class::FindInstanceField(const StringPiece& name, const StringPiece& type return NULL; } -Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) { // Is the field in this class, or any of its superclasses? // Interfaces are not relevant because they can't contain instance fields. for (Class* c = this; c != NULL; c = c->GetSuperClass()) { - Field* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); + ArtField* f = c->FindDeclaredInstanceField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -507,11 +506,11 @@ Field* Class::FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_id return NULL; } -Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) { DCHECK(type != NULL); FieldHelper fh; for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); fh.ChangeField(f); if (name == fh.GetName() && type == fh.GetTypeDescriptor()) { return f; @@ -520,10 +519,10 @@ Field* Class::FindDeclaredStaticField(const StringPiece& name, const StringPiece return NULL; } -Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { if (dex_cache == GetDexCache()) { for (size_t i = 0; i < NumStaticFields(); ++i) { - Field* f = GetStaticField(i); + ArtField* f = GetStaticField(i); if (f->GetDexFieldIndex() == dex_field_idx) { return f; } @@ -532,13 +531,13 @@ Field* Class::FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_fi return NULL; } -Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindStaticField(const StringPiece& name, const StringPiece& type) { // Is the field in this class (or its interfaces), or any of its // superclasses (or their interfaces)? ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(name, type); + ArtField* f = k->FindDeclaredStaticField(name, type); if (f != NULL) { return f; } @@ -555,11 +554,11 @@ Field* Class::FindStaticField(const StringPiece& name, const StringPiece& type) return NULL; } -Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { +ArtField* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) { ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); + ArtField* f = k->FindDeclaredStaticField(dex_cache, dex_field_idx); if (f != NULL) { return f; } @@ -576,12 +575,12 @@ Field* Class::FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) return NULL; } -Field* Class::FindField(const StringPiece& name, const StringPiece& type) { +ArtField* Class::FindField(const StringPiece& name, const StringPiece& type) { // Find a field using the JLS field resolution order ClassHelper kh; for (Class* k = this; k != NULL; k = k->GetSuperClass()) { // Is the field in this class? - Field* f = k->FindDeclaredInstanceField(name, type); + ArtField* f = k->FindDeclaredInstanceField(name, type); if (f != NULL) { return f; } @@ -602,11 +601,11 @@ Field* Class::FindField(const StringPiece& name, const StringPiece& type) { return NULL; } -static void SetPreverifiedFlagOnMethods(mirror::ObjectArray* methods) +static void SetPreverifiedFlagOnMethods(mirror::ObjectArray* methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (methods != NULL) { for (int32_t index = 0, end = methods->GetLength(); index < end; ++index) { - mirror::AbstractMethod* method = methods->GetWithoutChecks(index); + mirror::ArtMethod* method = methods->GetWithoutChecks(index); DCHECK(method != NULL); method->SetPreverified(); } diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 1dd02c0256..638b67f485 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -63,9 +63,9 @@ class StringPiece; namespace mirror { +class ArtField; class ClassLoader; class DexCache; -class Field; class IfTable; // Type for the InitializedStaticStorage table. Currently the Class @@ -341,9 +341,9 @@ class MANAGED Class : public StaticStorageBase { bool IsThrowableClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtFieldClass() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethodClass() const; + bool IsArtMethodClass() const; Class* GetComponentType() const { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, component_type_), false); @@ -502,42 +502,42 @@ class MANAGED Class : public StaticStorageBase { void SetDexCache(DexCache* new_dex_cache) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ObjectArray* GetDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethods(ObjectArray* new_direct_methods) + void SetDirectMethods(ObjectArray* new_direct_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtMethod* GetDirectMethod(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDirectMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetDirectMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of static, private, and constructor methods. size_t NumDirectMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetVirtualMethods() const + ObjectArray* GetVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethods(ObjectArray* new_virtual_methods) + void SetVirtualMethods(ObjectArray* new_virtual_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of non-inherited virtual methods. size_t NumVirtualMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethod(uint32_t i) const + ArtMethod* GetVirtualMethod(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* GetVirtualMethodDuringLinking(uint32_t i) const + ArtMethod* GetVirtualMethodDuringLinking(uint32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVirtualMethod(uint32_t i, AbstractMethod* f) // TODO: uint16_t + void SetVirtualMethod(uint32_t i, ArtMethod* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetVTable() const; + ObjectArray* GetVTable() const; - ObjectArray* GetVTableDuringLinking() const; + ObjectArray* GetVTableDuringLinking() const; - void SetVTable(ObjectArray* new_vtable) + void SetVTable(ObjectArray* new_vtable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static MemberOffset VTableOffset() { @@ -546,51 +546,51 @@ class MANAGED Class : public StaticStorageBase { // Given a method implemented by this class but potentially from a super class, return the // specific implementation method for this class. - AbstractMethod* FindVirtualMethodForVirtual(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class' super class, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForSuper(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForSuper(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Given a method implemented by this class, but potentially from a // super class or interface, return the specific implementation // method for this class. - AbstractMethod* FindVirtualMethodForInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE; - AbstractMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindInterfaceMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindInterfaceMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethodForVirtualOrInterface(AbstractMethod* method) const + ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredVirtualMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const + ArtMethod* FindVirtualMethod(const StringPiece& name, const StringPiece& descriptor) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindVirtualMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDeclaredDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDeclaredDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const + ArtMethod* FindDirectMethod(const StringPiece& name, const StringPiece& signature) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - AbstractMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const + ArtMethod* FindDirectMethod(const DexCache* dex_cache, uint32_t dex_method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetIfTableCount() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -600,16 +600,16 @@ class MANAGED Class : public StaticStorageBase { void SetIfTable(IfTable* new_iftable) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get instance fields of the class (See also GetSFields). - ObjectArray* GetIFields() const; + ObjectArray* GetIFields() const; - void SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetIFields(ObjectArray* new_ifields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumInstanceFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* GetInstanceField(uint32_t i) const // TODO: uint16_t + ArtField* GetInstanceField(uint32_t i) const // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetInstanceField(uint32_t i, Field* f) // TODO: uint16_t + void SetInstanceField(uint32_t i, ArtField* f) // TODO: uint16_t SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the number of instance fields containing reference types. @@ -662,15 +662,15 @@ class MANAGED Class : public StaticStorageBase { } // Gets the static fields of the class. - ObjectArray* GetSFields() const; + ObjectArray* GetSFields() const; - void SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void SetSFields(ObjectArray* new_sfields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); size_t NumStaticFields() const; - Field* GetStaticField(uint32_t i) const; // TODO: uint16_t + ArtField* GetStaticField(uint32_t i) const; // TODO: uint16_t - void SetStaticField(uint32_t i, Field* f); // TODO: uint16_t + void SetStaticField(uint32_t i, ArtField* f); // TODO: uint16_t uint32_t GetReferenceStaticOffsets() const { return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, reference_static_offsets_), false); @@ -679,37 +679,37 @@ class MANAGED Class : public StaticStorageBase { void SetReferenceStaticOffsets(uint32_t new_reference_offsets); // Find a static or instance field using the JLS resolution order - Field* FindField(const StringPiece& name, const StringPiece& type) + ArtField* FindField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass. - Field* FindInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given instance field in this class or a superclass, only searches classes that // have the same dex cache. - Field* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredInstanceField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or a superclass. - Field* FindStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the given static field in this class or superclass, only searches classes that // have the same dex cache. - Field* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) + ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) + ArtField* FindDeclaredStaticField(const DexCache* dex_cache, uint32_t dex_field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); pid_t GetClinitThreadId() const { @@ -768,7 +768,7 @@ class MANAGED Class : public StaticStorageBase { DexCache* dex_cache_; // static, private, and methods - ObjectArray* direct_methods_; + ObjectArray* direct_methods_; // instance fields // @@ -780,7 +780,7 @@ class MANAGED Class : public StaticStorageBase { // All instance fields that refer to objects are guaranteed to be at // the beginning of the field list. num_reference_instance_fields_ // specifies the number of reference fields. - ObjectArray* ifields_; + ObjectArray* ifields_; // The interface table (iftable_) contains pairs of a interface class and an array of the // interface methods. There is one pair per interface supported by this class. That means one @@ -799,7 +799,7 @@ class MANAGED Class : public StaticStorageBase { String* name_; // Static fields - ObjectArray* sfields_; + ObjectArray* sfields_; // The superclass, or NULL if this is java.lang.Object, an interface or primitive type. Class* super_class_; @@ -808,13 +808,13 @@ class MANAGED Class : public StaticStorageBase { Class* verify_error_class_; // virtual methods defined in this class; invoked through vtable - ObjectArray* virtual_methods_; + ObjectArray* virtual_methods_; // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is // copied in, and virtual methods from our class either replace those from the super or are // appended. For abstract classes, methods may be created in the vtable that aren't in // virtual_ methods_ for miranda methods. - ObjectArray* vtable_; + ObjectArray* vtable_; // access flags; low 16 bits are defined by VM spec uint32_t access_flags_; diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 369dc49ed0..da26be59b9 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -22,9 +22,9 @@ namespace art { namespace mirror { -inline AbstractMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const +inline ArtMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - AbstractMethod* method = GetResolvedMethods()->Get(method_idx); + ArtMethod* method = GetResolvedMethods()->Get(method_idx); // Hide resolution trampoline methods from the caller if (method != NULL && method->IsRuntimeMethod()) { DCHECK(method == Runtime::Current()->GetResolutionMethod()); diff --git a/runtime/mirror/dex_cache.cc b/runtime/mirror/dex_cache.cc index 239dc5e0c3..00531e3076 100644 --- a/runtime/mirror/dex_cache.cc +++ b/runtime/mirror/dex_cache.cc @@ -16,7 +16,7 @@ #include "dex_cache.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "base/logging.h" #include "class_linker.h" #include "gc/accounting/card_table-inl.h" @@ -35,8 +35,8 @@ void DexCache::Init(const DexFile* dex_file, String* location, ObjectArray* strings, ObjectArray* resolved_types, - ObjectArray* resolved_methods, - ObjectArray* resolved_fields, + ObjectArray* resolved_methods, + ObjectArray* resolved_fields, ObjectArray* initialized_static_storage) { CHECK(dex_file != NULL); CHECK(location != NULL); @@ -58,7 +58,7 @@ void DexCache::Init(const DexFile* dex_file, Runtime* runtime = Runtime::Current(); if (runtime->HasResolutionMethod()) { // Initialize the resolve methods array to contain trampolines for resolution. - AbstractMethod* trampoline = runtime->GetResolutionMethod(); + ArtMethod* trampoline = runtime->GetResolutionMethod(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { resolved_methods->SetWithoutChecks(i, trampoline); @@ -66,10 +66,10 @@ void DexCache::Init(const DexFile* dex_file, } } -void DexCache::Fixup(AbstractMethod* trampoline) { +void DexCache::Fixup(ArtMethod* trampoline) { // Fixup the resolve methods array to contain trampoline for resolution. CHECK(trampoline != NULL); - ObjectArray* resolved_methods = GetResolvedMethods(); + ObjectArray* resolved_methods = GetResolvedMethods(); size_t length = resolved_methods->GetLength(); for (size_t i = 0; i < length; i++) { if (resolved_methods->GetWithoutChecks(i) == NULL) { diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 9c0f09ba21..6cfab9e425 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_DEX_CACHE_H_ #define ART_RUNTIME_MIRROR_DEX_CACHE_H_ -#include "abstract_method.h" +#include "art_method.h" #include "class.h" #include "object.h" #include "object_array.h" @@ -32,8 +32,8 @@ union JValue; namespace mirror { +class ArtField; class Class; -class Field; class MANAGED DexCacheClass : public Class { private: @@ -46,12 +46,12 @@ class MANAGED DexCache : public Object { String* location, ObjectArray* strings, ObjectArray* types, - ObjectArray* methods, - ObjectArray* fields, + ObjectArray* methods, + ObjectArray* fields, ObjectArray* initialized_static_storage) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Fixup(AbstractMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void Fixup(ArtMethod* trampoline) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); String* GetLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(DexCache, location_), false); @@ -110,20 +110,20 @@ class MANAGED DexCache : public Object { GetResolvedTypes()->Set(type_idx, resolved); } - AbstractMethod* GetResolvedMethod(uint32_t method_idx) const + ArtMethod* GetResolvedMethod(uint32_t method_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetResolvedMethod(uint32_t method_idx, AbstractMethod* resolved) + void SetResolvedMethod(uint32_t method_idx, ArtMethod* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedMethods()->Set(method_idx, resolved); } - Field* GetResolvedField(uint32_t field_idx) const + ArtField* GetResolvedField(uint32_t field_idx) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return GetResolvedFields()->Get(field_idx); } - void SetResolvedField(uint32_t field_idx, Field* resolved) + void SetResolvedField(uint32_t field_idx, ArtField* resolved) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { GetResolvedFields()->Set(field_idx, resolved); } @@ -139,14 +139,14 @@ class MANAGED DexCache : public Object { OFFSET_OF_OBJECT_MEMBER(DexCache, resolved_types_), false); } - ObjectArray* GetResolvedMethods() const + ObjectArray* GetResolvedMethods() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray* >(ResolvedMethodsOffset(), false); + return GetFieldObject< ObjectArray* >(ResolvedMethodsOffset(), false); } - ObjectArray* GetResolvedFields() const + ObjectArray* GetResolvedFields() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return GetFieldObject< ObjectArray* >(ResolvedFieldsOffset(), false); + return GetFieldObject< ObjectArray* >(ResolvedFieldsOffset(), false); } ObjectArray* GetInitializedStaticStorage() const @@ -166,8 +166,8 @@ class MANAGED DexCache : public Object { private: ObjectArray* initialized_static_storage_; String* location_; - ObjectArray* resolved_fields_; - ObjectArray* resolved_methods_; + ObjectArray* resolved_fields_; + ObjectArray* resolved_methods_; ObjectArray* resolved_types_; ObjectArray* strings_; uint32_t dex_file_; diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h deleted file mode 100644 index 3e3d6db4a6..0000000000 --- a/runtime/mirror/field-inl.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ART_RUNTIME_MIRROR_FIELD_INL_H_ -#define ART_RUNTIME_MIRROR_FIELD_INL_H_ - -#include "field.h" - -#include "base/logging.h" -#include "gc/accounting/card_table-inl.h" -#include "jvalue.h" -#include "object-inl.h" -#include "object_utils.h" -#include "primitive.h" - -namespace art { -namespace mirror { - -inline Class* Field::GetDeclaringClass() const { - Class* result = GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), false); - DCHECK(result != NULL); - DCHECK(result->IsLoaded() || result->IsErroneous()); - return result; -} - -inline void Field::SetDeclaringClass(Class *new_declaring_class) { - SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Field, declaring_class_), new_declaring_class, false); -} - -inline uint32_t Field::GetAccessFlags() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), false); -} - -inline MemberOffset Field::GetOffset() const { - DCHECK(GetDeclaringClass()->IsResolved() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); -} - -inline MemberOffset Field::GetOffsetDuringLinking() const { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); - return MemberOffset(GetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), false)); -} - -inline uint32_t Field::Get32(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetField32(GetOffset(), IsVolatile()); -} - -inline void Field::Set32(Object* object, uint32_t new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetField32(GetOffset(), new_value, IsVolatile()); -} - -inline uint64_t Field::Get64(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetField64(GetOffset(), IsVolatile()); -} - -inline void Field::Set64(Object* object, uint64_t new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetField64(GetOffset(), new_value, IsVolatile()); -} - -inline Object* Field::GetObj(const Object* object) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - return object->GetFieldObject(GetOffset(), IsVolatile()); -} - -inline void Field::SetObj(Object* object, const Object* new_value) const { - DCHECK(object != NULL) << PrettyField(this); - DCHECK(!IsStatic() || (object == GetDeclaringClass()) || !Runtime::Current()->IsStarted()); - object->SetFieldObject(GetOffset(), new_value, IsVolatile()); -} - -inline bool Field::GetBoolean(const Object* object) const { - DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetBoolean(Object* object, bool z) const { - DCHECK_EQ(Primitive::kPrimBoolean, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, z); -} - -inline int8_t Field::GetByte(const Object* object) const { - DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetByte(Object* object, int8_t b) const { - DCHECK_EQ(Primitive::kPrimByte, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, b); -} - -inline uint16_t Field::GetChar(const Object* object) const { - DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetChar(Object* object, uint16_t c) const { - DCHECK_EQ(Primitive::kPrimChar, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, c); -} - -inline int16_t Field::GetShort(const Object* object) const { - DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return Get32(object); -} - -inline void Field::SetShort(Object* object, int16_t s) const { - DCHECK_EQ(Primitive::kPrimShort, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - Set32(object, s); -} - -inline int32_t Field::GetInt(const Object* object) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); -#endif - return Get32(object); -} - -inline void Field::SetInt(Object* object, int32_t i) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimInt || type == Primitive::kPrimFloat) << PrettyField(this); -#endif - Set32(object, i); -} - -inline int64_t Field::GetLong(const Object* object) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); -#endif - return Get64(object); -} - -inline void Field::SetLong(Object* object, int64_t j) const { -#ifndef NDEBUG - Primitive::Type type = FieldHelper(this).GetTypeAsPrimitiveType(); - CHECK(type == Primitive::kPrimLong || type == Primitive::kPrimDouble) << PrettyField(this); -#endif - Set64(object, j); -} - -inline float Field::GetFloat(const Object* object) const { - DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetI(Get32(object)); - return bits.GetF(); -} - -inline void Field::SetFloat(Object* object, float f) const { - DCHECK_EQ(Primitive::kPrimFloat, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetF(f); - Set32(object, bits.GetI()); -} - -inline double Field::GetDouble(const Object* object) const { - DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetJ(Get64(object)); - return bits.GetD(); -} - -inline void Field::SetDouble(Object* object, double d) const { - DCHECK_EQ(Primitive::kPrimDouble, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - JValue bits; - bits.SetD(d); - Set64(object, bits.GetJ()); -} - -inline Object* Field::GetObject(const Object* object) const { - DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - return GetObj(object); -} - -inline void Field::SetObject(Object* object, const Object* l) const { - DCHECK_EQ(Primitive::kPrimNot, FieldHelper(this).GetTypeAsPrimitiveType()) - << PrettyField(this); - SetObj(object, l); -} - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_FIELD_INL_H_ diff --git a/runtime/mirror/field.cc b/runtime/mirror/field.cc deleted file mode 100644 index 12f395f6b6..0000000000 --- a/runtime/mirror/field.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2011 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 "field.h" - -#include "field-inl.h" -#include "gc/accounting/card_table-inl.h" -#include "object-inl.h" -#include "object_utils.h" -#include "runtime.h" -#include "utils.h" - -namespace art { -namespace mirror { - -// TODO: get global references for these -Class* Field::java_lang_reflect_Field_ = NULL; - -void Field::SetClass(Class* java_lang_reflect_Field) { - CHECK(java_lang_reflect_Field_ == NULL); - CHECK(java_lang_reflect_Field != NULL); - java_lang_reflect_Field_ = java_lang_reflect_Field; -} - -void Field::ResetClass() { - CHECK(java_lang_reflect_Field_ != NULL); - java_lang_reflect_Field_ = NULL; -} - -void Field::SetOffset(MemberOffset num_bytes) { - DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous()); -#if 0 // TODO enable later in boot and under !NDEBUG - FieldHelper fh(this); - Primitive::Type type = fh.GetTypeAsPrimitiveType(); - if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) { - DCHECK_ALIGNED(num_bytes.Uint32Value(), 8); - } -#endif - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, offset_), num_bytes.Uint32Value(), false); -} - -} // namespace mirror -} // namespace art diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h deleted file mode 100644 index 6e508a362f..0000000000 --- a/runtime/mirror/field.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ART_RUNTIME_MIRROR_FIELD_H_ -#define ART_RUNTIME_MIRROR_FIELD_H_ - -#include "class.h" -#include "modifiers.h" -#include "object.h" - -namespace art { - -struct FieldClassOffsets; -struct FieldOffsets; - -namespace mirror { - -// C++ mirror of java.lang.reflect.Field -class MANAGED Field : public Object { - public: - Class* GetDeclaringClass() const; - - void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - uint32_t GetAccessFlags() const; - - void SetAccessFlags(uint32_t new_access_flags) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, access_flags_), new_access_flags, false); - } - - bool IsPublic() const { - return (GetAccessFlags() & kAccPublic) != 0; - } - - bool IsStatic() const { - return (GetAccessFlags() & kAccStatic) != 0; - } - - bool IsFinal() const { - return (GetAccessFlags() & kAccFinal) != 0; - } - - uint32_t GetDexFieldIndex() const { - return GetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), false); - } - - void SetDexFieldIndex(uint32_t new_idx) { - SetField32(OFFSET_OF_OBJECT_MEMBER(Field, field_dex_idx_), new_idx, false); - } - - // Offset to field within an Object - MemberOffset GetOffset() const; - - static MemberOffset OffsetOffset() { - return MemberOffset(OFFSETOF_MEMBER(Field, offset_)); - } - - MemberOffset GetOffsetDuringLinking() const; - - void SetOffset(MemberOffset num_bytes); - - // field access, null object for static fields - bool GetBoolean(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetBoolean(Object* object, bool z) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int8_t GetByte(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetByte(Object* object, int8_t b) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint16_t GetChar(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetChar(Object* object, uint16_t c) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int16_t GetShort(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetShort(Object* object, int16_t s) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int32_t GetInt(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetInt(Object* object, int32_t i) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - int64_t GetLong(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetLong(Object* object, int64_t j) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - float GetFloat(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetFloat(Object* object, float f) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - double GetDouble(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetDouble(Object* object, double d) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Object* GetObject(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetObject(Object* object, const Object* l) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - // raw field accesses - uint32_t Get32(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Set32(Object* object, uint32_t new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - uint64_t Get64(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Set64(Object* object, uint64_t new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Object* GetObj(const Object* object) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetObj(Object* object, const Object* new_value) const - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - static Class* GetJavaLangReflectField() { - DCHECK(java_lang_reflect_Field_ != NULL); - return java_lang_reflect_Field_; - } - - static void SetClass(Class* java_lang_reflect_Field); - static void ResetClass(); - - bool IsVolatile() const { - return (GetAccessFlags() & kAccVolatile) != 0; - } - - private: - // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". - // The class we are a part of - Class* declaring_class_; - - uint32_t access_flags_; - - // Dex cache index of field id - uint32_t field_dex_idx_; - - // Offset of field within an instance or in the Class' static fields - uint32_t offset_; - - static Class* java_lang_reflect_Field_; - - friend struct art::FieldOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(Field); -}; - -class MANAGED FieldClass : public Class { - private: - Object* ORDER_BY_NAME_AND_DECLARING_CLASS_; - friend struct art::FieldClassOffsets; // for verifying offset information - DISALLOW_IMPLICIT_CONSTRUCTORS(FieldClass); -}; - -} // namespace mirror -} // namespace art - -#endif // ART_RUNTIME_MIRROR_FIELD_H_ diff --git a/runtime/mirror/iftable.h b/runtime/mirror/iftable.h index aea8fddafe..421893d3db 100644 --- a/runtime/mirror/iftable.h +++ b/runtime/mirror/iftable.h @@ -32,24 +32,24 @@ class MANAGED IfTable : public ObjectArray { void SetInterface(int32_t i, Class* interface) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ObjectArray* GetMethodArray(int32_t i) const + ObjectArray* GetMethodArray(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* method_array = - down_cast*>(Get((i * kMax) + kMethodArray)); + ObjectArray* method_array = + down_cast*>(Get((i * kMax) + kMethodArray)); DCHECK(method_array != NULL); return method_array; } size_t GetMethodArrayCount(int32_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - ObjectArray* method_array = - down_cast*>(Get((i * kMax) + kMethodArray)); + ObjectArray* method_array = + down_cast*>(Get((i * kMax) + kMethodArray)); if (method_array == NULL) { return 0; } return method_array->GetLength(); } - void SetMethodArray(int32_t i, ObjectArray* new_ma) + void SetMethodArray(int32_t i, ObjectArray* new_ma) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_ma != NULL); DCHECK(Get((i * kMax) + kMethodArray) == NULL); diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 5818a800bf..63396d2f59 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -19,10 +19,10 @@ #include "object.h" -#include "abstract_method.h" +#include "art_field.h" +#include "art_method.h" #include "atomic.h" #include "array-inl.h" -#include "field.h" #include "class.h" #include "monitor.h" #include "runtime.h" @@ -112,32 +112,32 @@ inline bool Object::IsArrayInstance() const { return GetClass()->IsArrayClass(); } -inline bool Object::IsField() const { - return GetClass()->IsFieldClass(); +inline bool Object::IsArtField() const { + return GetClass()->IsArtFieldClass(); } -inline Field* Object::AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast(this); +inline ArtField* Object::AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast(this); } -inline const Field* Object::AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - DCHECK(IsField()); - return down_cast(this); +inline const ArtField* Object::AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(IsArtField()); + return down_cast(this); } -inline bool Object::IsMethod() const { - return GetClass()->IsMethodClass(); +inline bool Object::IsArtMethod() const { + return GetClass()->IsArtMethodClass(); } -inline AbstractMethod* Object::AsMethod() { - DCHECK(IsMethod()); - return down_cast(this); +inline ArtMethod* Object::AsArtMethod() { + DCHECK(IsArtMethod()); + return down_cast(this); } -inline const AbstractMethod* Object::AsMethod() const { - DCHECK(IsMethod()); - return down_cast(this); +inline const ArtMethod* Object::AsArtMethod() const { + DCHECK(IsArtMethod()); + return down_cast(this); } inline bool Object::IsReferenceInstance() const { @@ -227,8 +227,8 @@ inline size_t Object::SizeOf() const { } else { result = GetClass()->GetObjectSize(); } - DCHECK(!IsField() || result == sizeof(Field)); - DCHECK(!IsMethod() || result == sizeof(AbstractMethod)); + DCHECK(!IsArtField() || result == sizeof(ArtField)); + DCHECK(!IsArtMethod() || result == sizeof(ArtMethod)); return result; } diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index b2d6e71478..92c05b26ca 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -16,12 +16,12 @@ #include "object.h" +#include "art_field.h" +#include "art_field-inl.h" #include "array-inl.h" #include "class.h" #include "class-inl.h" #include "class_linker-inl.h" -#include "field.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" @@ -67,7 +67,7 @@ Object* Object::Clone(Thread* self) { for (const Class* klass = c; klass != NULL; klass = klass->GetSuperClass()) { size_t num_reference_fields = klass->NumReferenceInstanceFields(); for (size_t i = 0; i < num_reference_fields; ++i) { - Field* field = klass->GetInstanceField(i); + ArtField* field = klass->GetInstanceField(i); MemberOffset field_offset = field->GetOffset(); const Object* ref = copy->GetFieldObject(field_offset, false); heap->WriteBarrierField(copy.get(), field_offset, ref); @@ -90,11 +90,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } for (const Class* cur = c; cur != NULL; cur = cur->GetSuperClass()) { - ObjectArray* fields = cur->GetIFields(); + ObjectArray* fields = cur->GetIFields(); if (fields != NULL) { size_t num_ref_ifields = cur->NumReferenceInstanceFields(); for (size_t i = 0; i < num_ref_ifields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); @@ -108,11 +108,11 @@ void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, const Object* n return; } if (IsClass()) { - ObjectArray* fields = AsClass()->GetSFields(); + ObjectArray* fields = AsClass()->GetSFields(); if (fields != NULL) { size_t num_ref_sfields = AsClass()->NumReferenceStaticFields(); for (size_t i = 0; i < num_ref_sfields; ++i) { - Field* field = fields->Get(i); + ArtField* field = fields->Get(i); if (field->GetOffset().Int32Value() == field_offset.Int32Value()) { FieldHelper fh(field); CHECK(fh.GetType()->IsAssignableFrom(new_value->GetClass())); diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index a40c906eb0..28a91dd8e5 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -31,10 +31,10 @@ class Thread; namespace mirror { -class AbstractMethod; +class ArtField; +class ArtMethod; class Array; class Class; -class Field; template class ObjectArray; template class PrimitiveArray; typedef PrimitiveArray BooleanArray; @@ -144,17 +144,17 @@ class MANAGED Object { Throwable* AsThrowable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsMethod() const; + bool IsArtMethod() const; - AbstractMethod* AsMethod(); + ArtMethod* AsArtMethod(); - const AbstractMethod* AsMethod() const; + const ArtMethod* AsArtMethod() const; - bool IsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool IsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - Field* AsField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + ArtField* AsArtField() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const Field* AsField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + const ArtField* AsArtField() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsReferenceInstance() const; diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index 8675c31b37..6f22618340 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -20,8 +20,8 @@ #include "object_array.h" #include "gc/heap.h" +#include "mirror/art_field.h" #include "mirror/class.h" -#include "mirror/field.h" #include "runtime.h" #include "thread.h" diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc index 540ff9f68e..814305c3af 100644 --- a/runtime/mirror/object_test.cc +++ b/runtime/mirror/object_test.cc @@ -20,6 +20,7 @@ #include #include "array-inl.h" +#include "art_field-inl.h" #include "asm_support.h" #include "class-inl.h" #include "class_linker.h" @@ -27,11 +28,10 @@ #include "common_test.h" #include "dex_file.h" #include "entrypoints/entrypoint_utils.h" -#include "field-inl.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" #include "iftable-inl.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "object-inl.h" #include "object_array-inl.h" #include "sirt_ref.h" @@ -75,7 +75,7 @@ TEST_F(ObjectTest, AsmConstants) { ASSERT_EQ(STRING_OFFSET_OFFSET, String::OffsetOffset().Int32Value()); ASSERT_EQ(STRING_DATA_OFFSET, Array::DataOffset(sizeof(uint16_t)).Int32Value()); - ASSERT_EQ(METHOD_CODE_OFFSET, AbstractMethod::EntryPointFromCompiledCodeOffset().Int32Value()); + ASSERT_EQ(METHOD_CODE_OFFSET, ArtMethod::EntryPointFromCompiledCodeOffset().Int32Value()); } TEST_F(ObjectTest, IsInSamePackage) { @@ -204,7 +204,7 @@ TEST_F(ObjectTest, CheckAndAllocArrayFromCode) { // pretend we are trying to call 'new char[3]' from String.toCharArray ScopedObjectAccess soa(Thread::Current()); Class* java_util_Arrays = class_linker_->FindSystemClass("Ljava/util/Arrays;"); - AbstractMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); + ArtMethod* sort = java_util_Arrays->FindDirectMethod("sort", "([I)V"); const DexFile::StringId* string_id = java_lang_dex_file_->FindStringId("[I"); ASSERT_TRUE(string_id != NULL); const DexFile::TypeId* type_id = java_lang_dex_file_->FindTypeId( @@ -261,7 +261,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { Class* klass = class_linker_->FindClass("LStaticsFromCode;", soa.Decode(class_loader)); - AbstractMethod* clinit = klass->FindDirectMethod("", "()V"); + ArtMethod* clinit = klass->FindDirectMethod("", "()V"); const DexFile::StringId* klass_string_id = dex_file->FindStringId("LStaticsFromCode;"); ASSERT_TRUE(klass_string_id != NULL); const DexFile::TypeId* klass_type_id = dex_file->FindTypeId( @@ -282,8 +282,8 @@ TEST_F(ObjectTest, StaticFieldFromCode) { ASSERT_TRUE(field_id != NULL); uint32_t field_idx = dex_file->GetIndexForFieldId(*field_id); - Field* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, - sizeof(Object*), true); + ArtField* field = FindFieldFromCode(field_idx, clinit, Thread::Current(), StaticObjectRead, + sizeof(Object*), true); Object* s0 = field->GetObj(klass); EXPECT_TRUE(s0 != NULL); @@ -294,7 +294,7 @@ TEST_F(ObjectTest, StaticFieldFromCode) { field->SetObj(field->GetDeclaringClass(), NULL); EXPECT_EQ(NULL, field->GetObj(klass)); - // TODO: more exhaustive tests of all 6 cases of Field::*FromCode + // TODO: more exhaustive tests of all 6 cases of ArtField::*FromCode } TEST_F(ObjectTest, String) { @@ -395,29 +395,29 @@ TEST_F(ObjectTest, DescriptorCompare) { Class* klass2 = linker->FindClass("LProtoCompare2;", class_loader_2.get()); ASSERT_TRUE(klass2 != NULL); - AbstractMethod* m1_1 = klass1->GetVirtualMethod(0); + ArtMethod* m1_1 = klass1->GetVirtualMethod(0); MethodHelper mh(m1_1); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_1 = klass1->GetVirtualMethod(1); + ArtMethod* m2_1 = klass1->GetVirtualMethod(1); mh.ChangeMethod(m2_1); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_1 = klass1->GetVirtualMethod(2); + ArtMethod* m3_1 = klass1->GetVirtualMethod(2); mh.ChangeMethod(m3_1); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_1 = klass1->GetVirtualMethod(3); + ArtMethod* m4_1 = klass1->GetVirtualMethod(3); mh.ChangeMethod(m4_1); EXPECT_STREQ(mh.GetName(), "m4"); - AbstractMethod* m1_2 = klass2->GetVirtualMethod(0); + ArtMethod* m1_2 = klass2->GetVirtualMethod(0); mh.ChangeMethod(m1_2); EXPECT_STREQ(mh.GetName(), "m1"); - AbstractMethod* m2_2 = klass2->GetVirtualMethod(1); + ArtMethod* m2_2 = klass2->GetVirtualMethod(1); mh.ChangeMethod(m2_2); EXPECT_STREQ(mh.GetName(), "m2"); - AbstractMethod* m3_2 = klass2->GetVirtualMethod(2); + ArtMethod* m3_2 = klass2->GetVirtualMethod(2); mh.ChangeMethod(m3_2); EXPECT_STREQ(mh.GetName(), "m3"); - AbstractMethod* m4_2 = klass2->GetVirtualMethod(3); + ArtMethod* m4_2 = klass2->GetVirtualMethod(3); mh.ChangeMethod(m4_2); EXPECT_STREQ(mh.GetName(), "m4"); @@ -593,8 +593,8 @@ TEST_F(ObjectTest, FindInstanceField) { EXPECT_TRUE(c->FindInstanceField("Count", "I") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredInstanceField("count", "I"); - Field* f2 = c->FindInstanceField("count", "I"); + ArtField* f1 = c->FindDeclaredInstanceField("count", "I"); + ArtField* f2 = c->FindInstanceField("count", "I"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); @@ -626,8 +626,8 @@ TEST_F(ObjectTest, FindStaticField) { EXPECT_TRUE(c->FindStaticField("cASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;") == NULL); // Right name and type. - Field* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); - Field* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f1 = c->FindDeclaredStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); + ArtField* f2 = c->FindStaticField("CASE_INSENSITIVE_ORDER", "Ljava/util/Comparator;"); EXPECT_TRUE(f1 != NULL); EXPECT_TRUE(f2 != NULL); EXPECT_EQ(f1, f2); diff --git a/runtime/mirror/throwable.cc b/runtime/mirror/throwable.cc index 78b76dc6ef..961f6deed3 100644 --- a/runtime/mirror/throwable.cc +++ b/runtime/mirror/throwable.cc @@ -16,7 +16,7 @@ #include "throwable.h" -#include "abstract_method-inl.h" +#include "art_method-inl.h" #include "class-inl.h" #include "dex_file-inl.h" #include "gc/accounting/card_table-inl.h" @@ -65,7 +65,7 @@ std::string Throwable::Dump() const { IntArray* pc_trace = down_cast(method_trace->Get(depth)); MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { - AbstractMethod* method = down_cast(method_trace->Get(i)); + ArtMethod* method = down_cast(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 09a952b3cf..48c05692b4 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -23,7 +23,7 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "dex_instruction.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" @@ -204,7 +204,7 @@ void Monitor::Lock(Thread* self) { uint64_t waitStart = 0; uint64_t waitEnd = 0; uint32_t wait_threshold = lock_profiling_threshold_; - const mirror::AbstractMethod* current_locking_method = NULL; + const mirror::ArtMethod* current_locking_method = NULL; uint32_t current_locking_dex_pc = 0; { ScopedThreadStateChange tsc(self, kBlocked); @@ -433,7 +433,7 @@ void Monitor::WaitWithLock(Thread* self, int64_t ms, int32_t ns, int prev_lock_count = lock_count_; lock_count_ = 0; owner_ = NULL; - const mirror::AbstractMethod* saved_method = locking_method_; + const mirror::ArtMethod* saved_method = locking_method_; locking_method_ = NULL; uintptr_t saved_dex_pc = locking_dex_pc_; locking_dex_pc_ = 0; @@ -888,7 +888,7 @@ mirror::Object* Monitor::GetContendedMonitor(Thread* thread) { void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::Object*, void*), void* callback_context) { - mirror::AbstractMethod* m = stack_visitor->GetMethod(); + mirror::ArtMethod* m = stack_visitor->GetMethod(); CHECK(m != NULL); // Native methods are an easy special case. @@ -948,7 +948,7 @@ void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::O } } -void Monitor::TranslateLocation(const mirror::AbstractMethod* method, uint32_t dex_pc, +void Monitor::TranslateLocation(const mirror::ArtMethod* method, uint32_t dex_pc, const char*& source_file, uint32_t& line_number) const { // If method is null, location is unknown if (method == NULL) { diff --git a/runtime/monitor.h b/runtime/monitor.h index 3b06217374..02c10a7a10 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -56,8 +56,8 @@ namespace art { #define LW_LOCK_OWNER(x) (((x) >> LW_LOCK_OWNER_SHIFT) & LW_LOCK_OWNER_MASK) namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Thread; class StackVisitor; @@ -141,7 +141,7 @@ class Monitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Translates the provided method and pc into its declaring class' source file and line number. - void TranslateLocation(const mirror::AbstractMethod* method, uint32_t pc, + void TranslateLocation(const mirror::ArtMethod* method, uint32_t pc, const char*& source_file, uint32_t& line_number) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -165,7 +165,7 @@ class Monitor { // Method and dex pc where the lock owner acquired the lock, used when lock // sampling is enabled. locking_method_ may be null if the lock is currently // unlocked, or if the lock is acquired by the system when the stack is empty. - const mirror::AbstractMethod* locking_method_ GUARDED_BY(monitor_lock_); + const mirror::ArtMethod* locking_method_ GUARDED_BY(monitor_lock_); uint32_t locking_dex_pc_ GUARDED_BY(monitor_lock_); friend class MonitorInfo; diff --git a/runtime/monitor_android.cc b/runtime/monitor_android.cc index 9265cd649d..8efa0721e8 100644 --- a/runtime/monitor_android.cc +++ b/runtime/monitor_android.cc @@ -78,7 +78,7 @@ void Monitor::LogContentionEvent(Thread* self, uint32_t wait_ms, uint32_t sample // Emit the source code file name, <= 37 bytes. uint32_t pc; - mirror::AbstractMethod* m = self->GetCurrentMethod(&pc); + mirror::ArtMethod* m = self->GetCurrentMethod(&pc); const char* filename; uint32_t line_number; TranslateLocation(m, pc, filename, line_number); diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc index 1a80d6286b..eaf67b8f02 100644 --- a/runtime/native/dalvik_system_VMStack.cc +++ b/runtime/native/dalvik_system_VMStack.cc @@ -16,7 +16,7 @@ #include "jni_internal.h" #include "nth_caller_visitor.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" diff --git a/runtime/native/java_lang_reflect_Constructor.cc b/runtime/native/java_lang_reflect_Constructor.cc index 918021748b..85556ac16e 100644 --- a/runtime/native/java_lang_reflect_Constructor.cc +++ b/runtime/native/java_lang_reflect_Constructor.cc @@ -16,13 +16,14 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { @@ -35,7 +36,10 @@ namespace art { */ static jobject Constructor_newInstance(JNIEnv* env, jobject javaMethod, jobjectArray javaArgs) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* m = soa.Decode(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* m = soa.Decode(art_method)->AsArtMethod(); mirror::Class* c = m->GetDeclaringClass(); if (UNLIKELY(c->IsAbstract())) { ThrowLocation throw_location = soa.Self()->GetCurrentLocationForThrow(); diff --git a/runtime/native/java_lang_reflect_Field.cc b/runtime/native/java_lang_reflect_Field.cc index b0daa916c6..00f89b65ea 100644 --- a/runtime/native/java_lang_reflect_Field.cc +++ b/runtime/native/java_lang_reflect_Field.cc @@ -19,16 +19,15 @@ #include "common_throws.h" #include "dex_file-inl.h" #include "jni_internal.h" +#include "mirror/art_field-inl.h" #include "mirror/class-inl.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" namespace art { -static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::Field* f, +static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirror::ArtField* f, JValue& value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK_EQ(value.GetJ(), 0LL); @@ -78,7 +77,7 @@ static bool GetFieldValue(const ScopedObjectAccess& soa, mirror::Object* o, mirr return false; } -static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::Field* f, +static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror::ArtField* f, mirror::Object*& class_or_rcvr) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (f->IsStatic()) { @@ -96,7 +95,7 @@ static bool CheckReceiver(const ScopedObjectAccess& soa, jobject j_rcvr, mirror: static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return NULL; @@ -111,9 +110,10 @@ static jobject Field_get(JNIEnv* env, jobject javaField, jobject javaObj) { soa.AddLocalReference(BoxPrimitive(FieldHelper(f).GetTypeAsPrimitiveType(), value)); } -static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char dst_descriptor) { +static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, + char dst_descriptor) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return JValue(); @@ -127,7 +127,8 @@ static JValue GetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, // Widen it if necessary (and possible). JValue wide_value; - mirror::Class* dst_type = Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); + mirror::Class* dst_type = + Runtime::Current()->GetClassLinker()->FindPrimitiveClass(dst_descriptor); if (!ConvertPrimitiveValue(NULL, false, FieldHelper(f).GetTypeAsPrimitiveType(), dst_type->GetPrimitiveType(), field_value, wide_value)) { return JValue(); @@ -167,7 +168,7 @@ static jshort Field_getShort(JNIEnv* env, jobject javaField, jobject javaObj) { return GetPrimitiveField(env, javaField, javaObj, 'S').GetS(); } -static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new_value, +static void SetFieldValue(mirror::Object* o, mirror::ArtField* f, const JValue& new_value, bool allow_references) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(f->GetDeclaringClass(), @@ -221,7 +222,7 @@ static void SetFieldValue(mirror::Object* o, mirror::Field* f, const JValue& new static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject javaValue) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); // Unbox the value, if necessary. mirror::Object* boxed_value = soa.Decode(javaValue); @@ -242,7 +243,7 @@ static void Field_set(JNIEnv* env, jobject javaField, jobject javaObj, jobject j static void SetPrimitiveField(JNIEnv* env, jobject javaField, jobject javaObj, char src_descriptor, const JValue& new_value) { ScopedObjectAccess soa(env); - mirror::Field* f = soa.DecodeField(env->FromReflectedField(javaField)); + mirror::ArtField* f = soa.DecodeField(env->FromReflectedField(javaField)); mirror::Object* o = NULL; if (!CheckReceiver(soa, javaObj, f, o)) { return; diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc index 14dc6a44ee..d29de3debe 100644 --- a/runtime/native/java_lang_reflect_Method.cc +++ b/runtime/native/java_lang_reflect_Method.cc @@ -16,26 +16,31 @@ #include "class_linker.h" #include "jni_internal.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/proxy.h" #include "object_utils.h" #include "reflection.h" #include "scoped_thread_state_change.h" +#include "well_known_classes.h" namespace art { -static jobject Method_invoke(JNIEnv* env, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { +static jobject Method_invoke(JNIEnv* env, + jobject javaMethod, jobject javaReceiver, jobject javaArgs) { ScopedObjectAccess soa(env); return InvokeMethod(soa, javaMethod, javaReceiver, javaArgs); } static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { ScopedObjectAccess soa(env); - mirror::AbstractMethod* proxy_method = soa.Decode(javaMethod)->AsMethod(); + jobject art_method = soa.Env()->GetObjectField( + javaMethod, WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod); + + mirror::ArtMethod* proxy_method = soa.Decode(art_method)->AsArtMethod(); CHECK(proxy_method->GetDeclaringClass()->IsProxyClass()); mirror::SynthesizedProxyClass* proxy_class = down_cast(proxy_method->GetDeclaringClass()); @@ -48,20 +53,14 @@ static jobject Method_getExceptionTypesNative(JNIEnv* env, jobject javaMethod) { } } CHECK_NE(throws_index, -1); - mirror::ObjectArray* declared_exceptions = proxy_class->GetThrows()->Get(throws_index); + mirror::ObjectArray* declared_exceptions = + proxy_class->GetThrows()->Get(throws_index); return soa.AddLocalReference(declared_exceptions->Clone(soa.Self())); } -static jobject Method_findOverriddenMethodNative(JNIEnv* env, jobject javaMethod) { - ScopedObjectAccess soa(env); - mirror::AbstractMethod* method = soa.Decode(javaMethod)->AsMethod(); - return soa.AddLocalReference(method->FindOverriddenMethod()); -} - static JNINativeMethod gMethods[] = { NATIVE_METHOD(Method, invoke, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"), NATIVE_METHOD(Method, getExceptionTypesNative, "()[Ljava/lang/Class;"), - NATIVE_METHOD(Method, findOverriddenMethodNative, "()Ljava/lang/reflect/Method;"), }; void register_java_lang_reflect_Method(JNIEnv* env) { diff --git a/runtime/native/java_lang_reflect_Proxy.cc b/runtime/native/java_lang_reflect_Proxy.cc index 547ce7b38d..a92823a85d 100644 --- a/runtime/native/java_lang_reflect_Proxy.cc +++ b/runtime/native/java_lang_reflect_Proxy.cc @@ -31,8 +31,8 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, mirror::ObjectArray* interfaces = soa.Decode*>(javaInterfaces); mirror::ClassLoader* loader = soa.Decode(javaLoader); - mirror::ObjectArray* methods = - soa.Decode*>(javaMethods); + mirror::ObjectArray* methods = + soa.Decode*>(javaMethods); mirror::ObjectArray >* throws = soa.Decode >*>(javaThrows); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); @@ -41,7 +41,7 @@ static jclass Proxy_generateProxy(JNIEnv* env, jclass, jstring javaName, } static JNINativeMethod gMethods[] = { - NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/Method;[[Ljava/lang/Class;)Ljava/lang/Class;"), + NATIVE_METHOD(Proxy, generateProxy, "(Ljava/lang/String;[Ljava/lang/Class;Ljava/lang/ClassLoader;[Ljava/lang/reflect/ArtMethod;[[Ljava/lang/Class;)Ljava/lang/Class;"), }; void register_java_lang_reflect_Proxy(JNIEnv* env) { diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index e3593d805d..794878a08e 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -17,7 +17,7 @@ #ifndef ART_RUNTIME_NTH_CALLER_VISITOR_H_ #define ART_RUNTIME_NTH_CALLER_VISITOR_H_ -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "locks.h" #include "stack.h" @@ -31,7 +31,7 @@ struct NthCallerVisitor : public StackVisitor { count(0), caller(NULL) {} bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); bool do_count = false; if (m == NULL || m->IsRuntimeMethod()) { // Upcall. @@ -53,7 +53,7 @@ struct NthCallerVisitor : public StackVisitor { const size_t n; const bool include_runtime_and_upcalls_; size_t count; - mirror::AbstractMethod* caller; + mirror::ArtMethod* caller; }; } // namespace art diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 93e98ad894..1f34317d26 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -22,9 +22,9 @@ #include "base/unix_file/fd_file.h" #include "elf_file.h" #include "oat.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" #include "mirror/object-inl.h" #include "os.h" #include "utils.h" @@ -453,7 +453,7 @@ uint32_t OatFile::OatMethod::GetCodeSize() const { #endif } -void OatFile::OatMethod::LinkMethod(mirror::AbstractMethod* method) const { +void OatFile::OatMethod::LinkMethod(mirror::ArtMethod* method) const { CHECK(method != NULL); method->SetEntryPointFromCompiledCode(GetCode()); method->SetFrameSizeInBytes(frame_size_in_bytes_); diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 650301465b..325ebb2914 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -23,7 +23,7 @@ #include "dex_file.h" #include "invoke_type.h" #include "mem_map.h" -#include "mirror/abstract_method.h" +#include "mirror/art_method.h" #include "oat.h" #include "os.h" @@ -70,7 +70,7 @@ class OatFile { class OatMethod { public: - void LinkMethod(mirror::AbstractMethod* method) const; + void LinkMethod(mirror::ArtMethod* method) const; uint32_t GetCodeOffset() const { return code_offset_; diff --git a/runtime/oat_test.cc b/runtime/oat_test.cc index 68595c896d..74b5da9eff 100644 --- a/runtime/oat_test.cc +++ b/runtime/oat_test.cc @@ -15,7 +15,7 @@ */ #include "compiler/oat_writer.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -28,7 +28,7 @@ namespace art { class OatTest : public CommonTest { protected: - void CheckMethod(mirror::AbstractMethod* method, + void CheckMethod(mirror::ArtMethod* method, const OatFile::OatMethod& oat_method, const DexFile* dex_file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 3639a80e77..29102437a2 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -20,10 +20,10 @@ #include "class_linker-inl.h" #include "dex_file.h" #include "monitor.h" -#include "mirror/abstract_method.h" +#include "mirror/art_field.h" +#include "mirror/art_method.h" #include "mirror/class.h" #include "mirror/dex_cache.h" -#include "mirror/field.h" #include "mirror/iftable.h" #include "mirror/string.h" @@ -256,11 +256,11 @@ class ClassHelper { class FieldHelper { public: FieldHelper() : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(NULL) {} - explicit FieldHelper(const mirror::Field* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - FieldHelper(const mirror::Field* f, ClassLinker* l) + explicit FieldHelper(const mirror::ArtField* f) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), field_(f) {} + FieldHelper(const mirror::ArtField* f, ClassLinker* l) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), field_(f) {} - void ChangeField(const mirror::Field* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeField(const mirror::ArtField* new_f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_f != NULL); if (dex_cache_ != NULL) { mirror::DexCache* new_f_dex_cache = new_f->GetDeclaringClass()->GetDexCache(); @@ -366,7 +366,7 @@ class FieldHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::Field* field_; + const mirror::ArtField* field_; std::string declaring_class_descriptor_; DISALLOW_COPY_AND_ASSIGN(FieldHelper); @@ -378,21 +378,21 @@ class MethodHelper { : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) {} - explicit MethodHelper(const mirror::AbstractMethod* m) + explicit MethodHelper(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - MethodHelper(const mirror::AbstractMethod* m, ClassLinker* l) + MethodHelper(const mirror::ArtMethod* m, ClassLinker* l) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL), shorty_len_(0) { SetMethod(m); } - void ChangeMethod(mirror::AbstractMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void ChangeMethod(mirror::ArtMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(new_m != NULL); if (dex_cache_ != NULL) { mirror::Class* klass = new_m->GetDeclaringClass(); @@ -411,7 +411,7 @@ class MethodHelper { shorty_ = NULL; } - const mirror::AbstractMethod* GetMethod() const { + const mirror::ArtMethod* GetMethod() const { return method_; } @@ -653,11 +653,11 @@ class MethodHelper { private: // Set the method_ field, for proxy methods looking up the interface method via the resolved // methods table. - void SetMethod(const mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + void SetMethod(const mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (method != NULL) { mirror::Class* klass = method->GetDeclaringClass(); if (UNLIKELY(klass->IsProxyClass())) { - mirror::AbstractMethod* interface_method = + mirror::ArtMethod* interface_method = method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex()); DCHECK(interface_method != NULL); DCHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method)); @@ -679,7 +679,7 @@ class MethodHelper { ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; - const mirror::AbstractMethod* method_; + const mirror::ArtMethod* method_; const char* shorty_; uint32_t shorty_len_; diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 8e478ff969..3e58b4bd94 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -21,11 +21,10 @@ #include "dex_file-inl.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" -#include "mirror/field-inl.h" #include "mirror/object_array.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -37,7 +36,7 @@ namespace art { jobject InvokeMethod(const ScopedObjectAccess& soa, jobject javaMethod, jobject javaReceiver, jobject javaArgs) { jmethodID mid = soa.Env()->FromReflectedMethod(javaMethod); - mirror::AbstractMethod* m = soa.DecodeMethod(mid); + mirror::ArtMethod* m = soa.DecodeMethod(mid); mirror::Class* declaring_class = m->GetDeclaringClass(); if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(declaring_class, true, true)) { @@ -267,7 +266,7 @@ mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) { return result.GetL(); } -static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mirror::Field* f) +static std::string UnboxingFailureKind(mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (m != NULL && index != -1) { ++index; // Humans count from 1. @@ -281,7 +280,7 @@ static std::string UnboxingFailureKind(mirror::AbstractMethod* m, int index, mir static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, int index, mirror::Field* f) + mirror::ArtMethod* m, int index, mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { bool unbox_for_result = (f == NULL) && (index == -1); if (!dst_class->IsPrimitive()) { @@ -327,7 +326,7 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* std::string src_descriptor(ClassHelper(o->GetClass()).GetDescriptor()); mirror::Class* src_class = NULL; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Field* primitive_field = o->GetClass()->GetIFields()->Get(0); + mirror::ArtField* primitive_field = o->GetClass()->GetIFields()->Get(0); if (src_descriptor == "Ljava/lang/Boolean;") { src_class = class_linker->FindPrimitiveClass('Z'); boxed_value.SetZ(primitive_field->GetBoolean(o)); @@ -367,13 +366,13 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* } bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) { + mirror::ArtMethod* m, size_t index) { CHECK(m != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, m, index, NULL); } bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) { + mirror::ArtField* f) { CHECK(f != NULL); return UnboxPrimitive(NULL, o, dst_class, unboxed_value, NULL, -1, f); } diff --git a/runtime/reflection.h b/runtime/reflection.h index 56ab4712db..13c90af895 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -22,10 +22,10 @@ namespace art { namespace mirror { -class AbstractMethod; -class Class; -class Field; -class Object; + class ArtField; + class ArtMethod; + class Class; + class Object; } // namespace mirror union JValue; class ScopedObjectAccess; @@ -34,10 +34,10 @@ class ThrowLocation; mirror::Object* BoxPrimitive(Primitive::Type src_class, const JValue& value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForArgument(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::AbstractMethod* m, size_t index) + mirror::ArtMethod* m, size_t index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForField(mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value, - mirror::Field* f) + mirror::ArtField* f) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool UnboxPrimitiveForResult(const ThrowLocation& throw_location, mirror::Object* o, mirror::Class* dst_class, JValue& unboxed_value) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 70d8816401..7b12870872 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -42,12 +42,11 @@ #include "intern_table.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/throwable.h" #include "monitor.h" #include "oat_file.h" @@ -654,7 +653,7 @@ static void CreateSystemClassLoader() { soa.Decode(WellKnownClasses::java_lang_ClassLoader); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(class_loader_class, true, true)); - mirror::AbstractMethod* getSystemClassLoader = + mirror::ArtMethod* getSystemClassLoader = class_loader_class->FindDirectMethod("getSystemClassLoader", "()Ljava/lang/ClassLoader;"); CHECK(getSystemClassLoader != NULL); @@ -669,8 +668,8 @@ static void CreateSystemClassLoader() { mirror::Class* thread_class = soa.Decode(WellKnownClasses::java_lang_Thread); CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(thread_class, true, true)); - mirror::Field* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", - "Ljava/lang/ClassLoader;"); + mirror::ArtField* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader", + "Ljava/lang/ClassLoader;"); CHECK(contextClassLoader != NULL); contextClassLoader->SetObject(soa.Self()->GetPeer(), class_loader); @@ -1125,11 +1124,11 @@ void Runtime::VisitRoots(RootVisitor* visitor, void* arg, bool only_dirty, bool VisitNonConcurrentRoots(visitor, arg); } -mirror::AbstractMethod* Runtime::CreateResolutionMethod() { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); +mirror::ArtMethod* Runtime::CreateResolutionMethod() { + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef - method(self, down_cast(method_class->AllocObject(self))); + SirtRef + method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for resolution method saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1140,12 +1139,12 @@ mirror::AbstractMethod* Runtime::CreateResolutionMethod() { return method.get(); } -mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, +mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) { - mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass(); + mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod(); Thread* self = Thread::Current(); - SirtRef - method(self, down_cast(method_class->AllocObject(self))); + SirtRef + method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for callee saves method->SetDexMethodIndex(DexFile::kDexNoIndex16); @@ -1205,7 +1204,7 @@ mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instructi return method.get(); } -void Runtime::SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type) { +void Runtime::SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type) { DCHECK_LT(static_cast(type), static_cast(kLastCalleeSaveType)); callee_save_methods_[type] = method; } diff --git a/runtime/runtime.h b/runtime/runtime.h index d67265a42d..b93ae9daeb 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -43,7 +43,7 @@ namespace gc { class Heap; } namespace mirror { - class AbstractMethod; + class ArtMethod; class ClassLoader; template class PrimitiveArray; typedef PrimitiveArray ByteArray; @@ -310,7 +310,7 @@ class Runtime { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that calls into a trampoline for runtime method resolution - mirror::AbstractMethod* GetResolutionMethod() const { + mirror::ArtMethod* GetResolutionMethod() const { CHECK(HasResolutionMethod()); return resolution_method_; } @@ -319,11 +319,11 @@ class Runtime { return resolution_method_ != NULL; } - void SetResolutionMethod(mirror::AbstractMethod* method) { + void SetResolutionMethod(mirror::ArtMethod* method) { resolution_method_ = method; } - mirror::AbstractMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns a special method that describes all callee saves being spilled to the stack. enum CalleeSaveType { @@ -337,21 +337,21 @@ class Runtime { return callee_save_methods_[type] != NULL; } - mirror::AbstractMethod* GetCalleeSaveMethod(CalleeSaveType type) const { + mirror::ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) const { DCHECK(HasCalleeSaveMethod(type)); return callee_save_methods_[type]; } - void SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type); + void SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type); - mirror::AbstractMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, + mirror::ArtMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, CalleeSaveType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) + mirror::ArtMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); int32_t GetStat(int kind); @@ -451,9 +451,9 @@ class Runtime { mirror::Throwable* pre_allocated_OutOfMemoryError_; - mirror::AbstractMethod* callee_save_methods_[kLastCalleeSaveType]; + mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; - mirror::AbstractMethod* resolution_method_; + mirror::ArtMethod* resolution_method_; // As returned by ClassLoader.getSystemClassLoader() mirror::ClassLoader* system_class_loader_; diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h index 965e6b85ac..5f649b117b 100644 --- a/runtime/scoped_thread_state_change.h +++ b/runtime/scoped_thread_state_change.h @@ -204,7 +204,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return down_cast(Self()->DecodeJObject(obj)); } - mirror::Field* DecodeField(jfieldID fid) const + mirror::ArtField* DecodeField(jfieldID fid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -214,10 +214,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Field instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast(fid); + return reinterpret_cast(fid); } - jfieldID EncodeField(mirror::Field* field) const + jfieldID EncodeField(mirror::ArtField* field) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -229,7 +229,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { return reinterpret_cast(field); } - mirror::AbstractMethod* DecodeMethod(jmethodID mid) const + mirror::ArtMethod* DecodeMethod(jmethodID mid) const LOCKS_EXCLUDED(JavaVMExt::globals_lock, JavaVMExt::weak_globals_lock) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -239,10 +239,10 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange { // TODO: we should make these unique weak globals if Method instances can ever move. UNIMPLEMENTED(WARNING); #endif - return reinterpret_cast(mid); + return reinterpret_cast(mid); } - jmethodID EncodeMethod(mirror::AbstractMethod* method) const + jmethodID EncodeMethod(mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { Locks::mutator_lock_->AssertSharedHeld(Self()); DCHECK_EQ(thread_state_, kRunnable); // Don't work with raw objects in non-runnable states. diff --git a/runtime/stack.cc b/runtime/stack.cc index e1a752adb9..206bff3425 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -16,7 +16,7 @@ #include "stack.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" @@ -29,7 +29,7 @@ namespace art { mirror::Object* ShadowFrame::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -43,7 +43,7 @@ mirror::Object* ShadowFrame::GetThisObject() const { } mirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else { @@ -101,7 +101,7 @@ uint32_t StackVisitor::GetDexPc() const { } mirror::Object* StackVisitor::GetThisObject() const { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsStatic()) { return NULL; } else if (m->IsNative()) { @@ -132,7 +132,7 @@ size_t StackVisitor::GetNativePcOffset() const { return GetMethod()->NativePcOffset(cur_quick_frame_pc_); } -uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const { +uint32_t StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably read registers without a context. DCHECK(m == GetMethod()); @@ -156,7 +156,7 @@ uint32_t StackVisitor::GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKin } } -void StackVisitor::SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, +void StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) { if (cur_quick_frame_ != NULL) { DCHECK(context_ != NULL); // You can't reliably write registers without a context. @@ -195,14 +195,14 @@ void StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { } uintptr_t StackVisitor::GetReturnPc() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); DCHECK(sp != NULL); byte* pc_addr = reinterpret_cast(sp) + GetMethod()->GetReturnPcOffsetInBytes(); return *reinterpret_cast(pc_addr); } void StackVisitor::SetReturnPc(uintptr_t new_ret_pc) { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); CHECK(sp != NULL); byte* pc_addr = reinterpret_cast(sp) + GetMethod()->GetReturnPcOffsetInBytes(); *reinterpret_cast(pc_addr) = new_ret_pc; @@ -241,7 +241,7 @@ void StackVisitor::DescribeStack(Thread* thread) { std::string StackVisitor::DescribeLocation() const { std::string result("Visiting method '"); - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m == NULL) { return "upcall"; } @@ -259,9 +259,8 @@ instrumentation::InstrumentationStackFrame StackVisitor::GetInstrumentationStack void StackVisitor::SanityCheckFrame() const { #ifndef NDEBUG - mirror::AbstractMethod* method = GetMethod(); - CHECK(method->GetClass() == mirror::AbstractMethod::GetMethodClass() || - method->GetClass() == mirror::AbstractMethod::GetConstructorClass()); + mirror::ArtMethod* method = GetMethod(); + CHECK(method->GetClass() == mirror::ArtMethod::GetJavaLangReflectArtMethod()); if (cur_quick_frame_ != NULL) { method->AssertPcIsWithinCode(cur_quick_frame_pc_); // Frame sanity. @@ -291,7 +290,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (cur_quick_frame_ != NULL) { // Handle quick stack frames. // Can't be both a shadow and a quick fragment. DCHECK(current_fragment->GetTopShadowFrame() == NULL); - mirror::AbstractMethod* method = *cur_quick_frame_; + mirror::ArtMethod* method = *cur_quick_frame_; while (method != NULL) { SanityCheckFrame(); bool should_continue = VisitFrame(); @@ -316,7 +315,7 @@ void StackVisitor::WalkStack(bool include_transitions) { if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveAll)) { // Skip runtime save all callee frames which are used to deliver exceptions. } else if (instrumentation_frame.interpreter_entry_) { - mirror::AbstractMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); + mirror::ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: " << PrettyMethod(GetMethod()); } else if (instrumentation_frame.method_ != GetMethod()) { @@ -335,7 +334,7 @@ void StackVisitor::WalkStack(bool include_transitions) { } cur_quick_frame_pc_ = return_pc; byte* next_frame = reinterpret_cast(cur_quick_frame_) + frame_size; - cur_quick_frame_ = reinterpret_cast(next_frame); + cur_quick_frame_ = reinterpret_cast(next_frame); cur_depth_++; method = *cur_quick_frame_; } diff --git a/runtime/stack.h b/runtime/stack.h index 388e4014c1..8ecf8f0571 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -28,8 +28,8 @@ namespace art { namespace mirror { -class AbstractMethod; -class Object; + class ArtMethod; + class Object; } // namespace mirror class Context; @@ -66,7 +66,7 @@ class ShadowFrame { // Create ShadowFrame in heap for deoptimization. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc) { + mirror::ArtMethod* method, uint32_t dex_pc) { uint8_t* memory = new uint8_t[ComputeSize(num_vregs)]; ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; @@ -74,7 +74,7 @@ class ShadowFrame { // Create ShadowFrame for interpreter using provided memory. static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, - mirror::AbstractMethod* method, uint32_t dex_pc, void* memory) { + mirror::ArtMethod* method, uint32_t dex_pc, void* memory) { ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); return sf; } @@ -195,7 +195,7 @@ class ShadowFrame { } } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { DCHECK_NE(method_, static_cast(NULL)); return method_; } @@ -206,7 +206,7 @@ class ShadowFrame { ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetMethod(mirror::AbstractMethod* method) { + void SetMethod(mirror::ArtMethod* method) { #if defined(ART_USE_PORTABLE_COMPILER) DCHECK_NE(method, static_cast(NULL)); method_ = method; @@ -248,7 +248,7 @@ class ShadowFrame { } private: - ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::AbstractMethod* method, + ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method, uint32_t dex_pc, bool has_reference_array) : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { if (has_reference_array) { @@ -285,9 +285,9 @@ class ShadowFrame { ShadowFrame* link_; #if defined(ART_USE_PORTABLE_COMPILER) // TODO: make const in the portable case. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; #else - mirror::AbstractMethod* const method_; + mirror::ArtMethod* const method_; #endif uint32_t dex_pc_; uint32_t vregs_[0]; @@ -323,11 +323,11 @@ class PACKED(4) ManagedStack { return link_; } - mirror::AbstractMethod** GetTopQuickFrame() const { + mirror::ArtMethod** GetTopQuickFrame() const { return top_quick_frame_; } - void SetTopQuickFrame(mirror::AbstractMethod** top) { + void SetTopQuickFrame(mirror::ArtMethod** top) { DCHECK(top_shadow_frame_ == NULL); top_quick_frame_ = top; } @@ -385,7 +385,7 @@ class PACKED(4) ManagedStack { private: ManagedStack* link_; ShadowFrame* top_shadow_frame_; - mirror::AbstractMethod** top_quick_frame_; + mirror::ArtMethod** top_quick_frame_; uintptr_t top_quick_frame_pc_; }; @@ -402,7 +402,7 @@ class StackVisitor { void WalkStack(bool include_transitions = false) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { if (cur_shadow_frame_ != NULL) { return cur_shadow_frame_->GetMethod(); } else if (cur_quick_frame_ != NULL) { @@ -450,16 +450,16 @@ class StackVisitor { return num_frames_; } - uint32_t GetVReg(mirror::AbstractMethod* m, uint16_t vreg, VRegKind kind) const + uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) + void SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uintptr_t GetGPR(uint32_t reg) const; void SetGPR(uint32_t reg, uintptr_t value); - uint32_t GetVReg(mirror::AbstractMethod** cur_quick_frame, const DexFile::CodeItem* code_item, + uint32_t GetVReg(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, uint32_t core_spills, uint32_t fp_spills, size_t frame_size, uint16_t vreg) const { int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg); @@ -533,7 +533,7 @@ class StackVisitor { return cur_quick_frame_pc_; } - mirror::AbstractMethod** GetCurrentQuickFrame() const { + mirror::ArtMethod** GetCurrentQuickFrame() const { return cur_quick_frame_; } @@ -542,7 +542,7 @@ class StackVisitor { } StackIndirectReferenceTable* GetCurrentSirt() const { - mirror::AbstractMethod** sp = GetCurrentQuickFrame(); + mirror::ArtMethod** sp = GetCurrentQuickFrame(); ++sp; // Skip Method*; SIRT comes next; return reinterpret_cast(sp); } @@ -560,7 +560,7 @@ class StackVisitor { Thread* const thread_; ShadowFrame* cur_shadow_frame_; - mirror::AbstractMethod** cur_quick_frame_; + mirror::ArtMethod** cur_quick_frame_; uintptr_t cur_quick_frame_pc_; // Lazily computed, number of frames in the stack. size_t num_frames_; diff --git a/runtime/thread.cc b/runtime/thread.cc index 07a003d330..7e3afb59a5 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -45,10 +45,10 @@ #include "gc/space/space.h" #include "invoke_arg_array_builder.h" #include "jni_internal.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field-inl.h" #include "mirror/object_array-inl.h" #include "mirror/stack_trace_element.h" #include "monitor.h" @@ -168,7 +168,7 @@ void* Thread::CreateCallback(void* arg) { // Invoke the 'run' method of our java.lang.Thread. mirror::Object* receiver = self->opeer_; jmethodID mid = WellKnownClasses::java_lang_Thread_run; - mirror::AbstractMethod* m = + mirror::ArtMethod* m = receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(soa.DecodeMethod(mid)); JValue result; ArgArray arg_array(NULL, 0); @@ -183,7 +183,7 @@ void* Thread::CreateCallback(void* arg) { Thread* Thread::FromManagedThread(const ScopedObjectAccessUnchecked& soa, mirror::Object* thread_peer) { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_nativePeer); Thread* result = reinterpret_cast(static_cast(f->GetInt(thread_peer))); // Sanity check that if we have a result it is either suspended or we hold the thread_list_lock_ // to stop it from going away. @@ -488,7 +488,7 @@ void Thread::Dump(std::ostream& os) const { } mirror::String* Thread::GetThreadName(const ScopedObjectAccessUnchecked& soa) const { - mirror::Field* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); + mirror::ArtField* f = soa.DecodeField(WellKnownClasses::java_lang_Thread_name); return (opeer_ != NULL) ? reinterpret_cast(f->GetObject(opeer_)) : NULL; } @@ -678,7 +678,7 @@ void Thread::DumpState(std::ostream& os, const Thread* thread, pid_t tid) { soa.DecodeField(WellKnownClasses::java_lang_Thread_group)->GetObject(thread->opeer_); if (thread_group != NULL) { - mirror::Field* group_name_field = + mirror::ArtField* group_name_field = soa.DecodeField(WellKnownClasses::java_lang_ThreadGroup_name); mirror::String* group_name_string = reinterpret_cast(group_name_field->GetObject(thread_group)); @@ -776,7 +776,7 @@ struct StackDumpVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; } @@ -831,7 +831,7 @@ struct StackDumpVisitor : public StackVisitor { const Thread* thread; const bool can_allocate; MethodHelper mh; - mirror::AbstractMethod* last_method; + mirror::ArtMethod* last_method; int last_line_number; int repetition_count; int frame_count; @@ -855,7 +855,7 @@ static bool ShouldShowNativeStack(const Thread* thread) // We don't just check kNative because native methods will be in state kSuspended if they're // calling back into the VM, or kBlocked if they're blocked on a monitor, or one of the // thread-startup states if it's early enough in their life cycle (http://b/7432159). - mirror::AbstractMethod* current_method = thread->GetCurrentMethod(NULL); + mirror::ArtMethod* current_method = thread->GetCurrentMethod(NULL); return current_method != NULL && current_method->IsNative(); } @@ -1238,7 +1238,7 @@ class CountStackDepthVisitor : public StackVisitor { // We want to skip frames up to and including the exception's constructor. // Note we also skip the frame if it doesn't have a method (namely the callee // save frame) - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (skipping_ && !m->IsRuntimeMethod() && !mirror::Throwable::GetJavaLangThrowable()->IsAssignableFrom(m->GetDeclaringClass())) { skipping_ = false; @@ -1313,7 +1313,7 @@ class BuildInternalStackTraceVisitor : public StackVisitor { skip_depth_--; return true; } - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { return true; // Ignore runtime frames (in particular callee save). } @@ -1398,7 +1398,7 @@ jobjectArray Thread::InternalStackTraceToStackTraceElementArray(JNIEnv* env, job MethodHelper mh; for (int32_t i = 0; i < depth; ++i) { // Prepare parameters for StackTraceElement(String cls, String method, String file, int line) - mirror::AbstractMethod* method = down_cast(method_trace->Get(i)); + mirror::ArtMethod* method = down_cast(method_trace->Get(i)); mh.ChangeMethod(method); uint32_t dex_pc = pc_trace->Get(i); int32_t line_number = mh.GetLineNumFromDexPC(dex_pc); @@ -1472,7 +1472,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, DCHECK_EQ(this, Thread::Current()); // Ensure we don't forget arguments over object allocation. SirtRef saved_throw_this(this, throw_location.GetThis()); - SirtRef saved_throw_method(this, throw_location.GetMethod()); + SirtRef saved_throw_method(this, throw_location.GetMethod()); // Ignore the cause throw location. TODO: should we report this as a re-throw? SirtRef cause(this, GetException(NULL)); ClearException(); @@ -1520,7 +1520,7 @@ void Thread::ThrowNewWrappedException(const ThrowLocation& throw_location, signature = "(Ljava/lang/Throwable;)V"; } } - mirror::AbstractMethod* exception_init_method = + mirror::ArtMethod* exception_init_method = exception_class->FindDeclaredDirectMethod("", signature); CHECK(exception_init_method != NULL) << "No " << signature << " in " @@ -1740,7 +1740,7 @@ class CatchBlockStackVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* method = GetMethod(); + mirror::ArtMethod* method = GetMethod(); if (method == NULL) { // This is the upcall, we remember the frame and last pc so that we may long jump to them. handler_quick_frame_pc_ = GetCurrentQuickFramePc(); @@ -1764,7 +1764,7 @@ class CatchBlockStackVisitor : public StackVisitor { } } - bool HandleTryItems(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleTryItems(mirror::ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { uint32_t dex_pc = DexFile::kDexNoIndex; if (method->IsNative()) { native_method_count_++; @@ -1783,7 +1783,7 @@ class CatchBlockStackVisitor : public StackVisitor { return true; // Continue stack walk. } - bool HandleDeoptimization(mirror::AbstractMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + bool HandleDeoptimization(mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { MethodHelper mh(m); const DexFile::CodeItem* code_item = mh.GetCodeItem(); CHECK(code_item != NULL); @@ -1825,7 +1825,7 @@ class CatchBlockStackVisitor : public StackVisitor { } void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* catch_method = *handler_quick_frame_; + mirror::ArtMethod* catch_method = *handler_quick_frame_; if (catch_method == NULL) { if (kDebugExceptionDelivery) { LOG(INFO) << "Handler is upcall"; @@ -1880,7 +1880,7 @@ class CatchBlockStackVisitor : public StackVisitor { // Location of the throw. const ThrowLocation& throw_location_; // Quick frame with found handler or last frame if no handler found. - mirror::AbstractMethod** handler_quick_frame_; + mirror::ArtMethod** handler_quick_frame_; // PC to branch to for the handler. uintptr_t handler_quick_frame_pc_; // Associated dex PC. @@ -1940,7 +1940,7 @@ struct CurrentMethodVisitor : public StackVisitor { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : StackVisitor(thread, context), this_object_(NULL), method_(NULL), dex_pc_(0) {} virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (m->IsRuntimeMethod()) { // Continue if this is a runtime method. return true; @@ -1953,11 +1953,11 @@ struct CurrentMethodVisitor : public StackVisitor { return false; } mirror::Object* this_object_; - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; uint32_t dex_pc_; }; -mirror::AbstractMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { +mirror::ArtMethod* Thread::GetCurrentMethod(uint32_t* dex_pc) const { CurrentMethodVisitor visitor(const_cast(this), NULL); visitor.WalkStack(false); if (dex_pc != NULL) { @@ -1996,7 +1996,7 @@ class ReferenceMapVisitor : public StackVisitor { } ShadowFrame* shadow_frame = GetCurrentShadowFrame(); if (shadow_frame != NULL) { - mirror::AbstractMethod* m = shadow_frame->GetMethod(); + mirror::ArtMethod* m = shadow_frame->GetMethod(); size_t num_regs = shadow_frame->NumberOfVRegs(); if (m->IsNative() || shadow_frame->HasReferenceArray()) { // SIRT for JNI or References for interpreter. @@ -2030,7 +2030,7 @@ class ReferenceMapVisitor : public StackVisitor { } } } else { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); // Process register map (which native and runtime methods don't have) if (!m->IsNative() && !m->IsRuntimeMethod() && !m->IsProxyMethod()) { const uint8_t* native_gc_map = m->GetNativeGcMap(); @@ -2049,7 +2049,7 @@ class ReferenceMapVisitor : public StackVisitor { uint32_t fp_spills = m->GetFpSpillMask(); size_t frame_size = m->GetFrameSizeInBytes(); // For all dex registers in the bitmap - mirror::AbstractMethod** cur_quick_frame = GetCurrentQuickFrame(); + mirror::ArtMethod** cur_quick_frame = GetCurrentQuickFrame(); DCHECK(cur_quick_frame != NULL); for (size_t reg = 0; reg < num_regs; ++reg) { // Does this register hold a reference? @@ -2164,7 +2164,7 @@ void Thread::VerifyRoots(VerifyRootVisitor* visitor, void* arg) { if (this_object != NULL) { VerifyRootWrapperCallback(this_object, &wrapperArg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; VerifyRootWrapperCallback(method, &wrapperArg); } } @@ -2199,7 +2199,7 @@ void Thread::VisitRoots(RootVisitor* visitor, void* arg) { if (this_object != NULL) { visitor(this_object, arg); } - mirror::AbstractMethod* method = (*it).method_; + mirror::ArtMethod* method = (*it).method_; visitor(method, arg); } } diff --git a/runtime/thread.h b/runtime/thread.h index 8b6771e60c..b9b93dd8f1 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -45,7 +45,7 @@ namespace art { namespace mirror { - class AbstractMethod; + class ArtMethod; class Array; class Class; class ClassLoader; @@ -318,13 +318,13 @@ class PACKED(4) Thread { long_jump_context_ = context; } - mirror::AbstractMethod* GetCurrentMethod(uint32_t* dex_pc) const + mirror::ArtMethod* GetCurrentMethod(uint32_t* dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ThrowLocation GetCurrentLocationForThrow() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void SetTopOfStack(void* stack, uintptr_t pc) { - mirror::AbstractMethod** top_method = reinterpret_cast(stack); + mirror::ArtMethod** top_method = reinterpret_cast(stack); managed_stack_.SetTopQuickFrame(top_method); managed_stack_.SetTopQuickFramePc(pc); } diff --git a/runtime/throw_location.cc b/runtime/throw_location.cc index 84d2c9b446..6d1ca1b4f0 100644 --- a/runtime/throw_location.cc +++ b/runtime/throw_location.cc @@ -16,7 +16,7 @@ #include "throw_location.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object-inl.h" #include "object_utils.h" diff --git a/runtime/throw_location.h b/runtime/throw_location.h index b2cd4d5803..5da446e9c5 100644 --- a/runtime/throw_location.h +++ b/runtime/throw_location.h @@ -26,7 +26,7 @@ namespace art { namespace mirror { -class AbstractMethod; +class ArtMethod; class Object; } // mirror @@ -36,7 +36,7 @@ class PACKED(4) ThrowLocation { Clear(); } - ThrowLocation(mirror::Object* throw_this_object, mirror::AbstractMethod* throw_method, + ThrowLocation(mirror::Object* throw_this_object, mirror::ArtMethod* throw_method, uint32_t throw_dex_pc) : this_object_(throw_this_object), method_(throw_method), @@ -46,7 +46,7 @@ class PACKED(4) ThrowLocation { return this_object_; } - mirror::AbstractMethod* GetMethod() const { + mirror::ArtMethod* GetMethod() const { return method_; } @@ -68,7 +68,7 @@ class PACKED(4) ThrowLocation { // The 'this' reference of the throwing method. mirror::Object* this_object_; // The throwing method. - mirror::AbstractMethod* method_; + mirror::ArtMethod* method_; // The instruction within the throwing method. uint32_t dex_pc_; }; diff --git a/runtime/trace.cc b/runtime/trace.cc index 2bce70f7c1..84df6a9e8b 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -24,7 +24,7 @@ #include "debugger.h" #include "dex_file-inl.h" #include "instrumentation.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/dex_cache.h" #include "mirror/object_array-inl.h" @@ -98,15 +98,15 @@ ProfilerClockSource Trace::default_clock_source_ = kProfilerClockSourceWall; Trace* Trace::the_trace_ = NULL; -static mirror::AbstractMethod* DecodeTraceMethodId(uint32_t tmid) { - return reinterpret_cast(tmid & ~kTraceMethodActionMask); +static mirror::ArtMethod* DecodeTraceMethodId(uint32_t tmid) { + return reinterpret_cast(tmid & ~kTraceMethodActionMask); } static TraceAction DecodeTraceAction(uint32_t tmid) { return static_cast(tmid & kTraceMethodActionMask); } -static uint32_t EncodeTraceMethodAndAction(const mirror::AbstractMethod* method, +static uint32_t EncodeTraceMethodAndAction(const mirror::ArtMethod* method, TraceAction action) { uint32_t tmid = reinterpret_cast(method) | action; DCHECK_EQ(method, DecodeTraceMethodId(tmid)); @@ -311,7 +311,7 @@ static void DumpBuf(uint8_t* buf, size_t buf_size, ProfilerClockSource clock_sou while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); TraceAction action = DecodeTraceAction(tmid); LOG(INFO) << PrettyMethod(method) << " " << static_cast(action); ptr += GetRecordSize(clock_source); @@ -329,7 +329,7 @@ void Trace::FinishTracing() { Runtime::Current()->SetStatsEnabled(false); } - std::set visited_methods; + std::set visited_methods; GetVisitedMethods(final_offset, &visited_methods); std::ostringstream os; @@ -386,35 +386,35 @@ void Trace::FinishTracing() { } void Trace::DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) { + const mirror::ArtMethod* method, uint32_t new_dex_pc) { // We're not recorded to listen to this kind of event, so complain. LOG(ERROR) << "Unexpected dex PC event in tracing " << PrettyMethod(method) << " " << new_dex_pc; }; void Trace::MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) { + const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodEntered); } void Trace::MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) { UNUSED(return_value); LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodExited); } -void Trace::MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) { +void Trace::MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) { LogMethodTraceEvent(thread, method, instrumentation::Instrumentation::kMethodUnwind); } void Trace::ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { LOG(ERROR) << "Unexpected exception caught event in tracing"; } -void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, +void Trace::LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event) { // Advance cur_offset_ atomically. int32_t new_offset; @@ -473,24 +473,24 @@ void Trace::LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* me } void Trace::GetVisitedMethods(size_t buf_size, - std::set* visited_methods) { + std::set* visited_methods) { uint8_t* ptr = buf_.get() + kTraceHeaderLength; uint8_t* end = buf_.get() + buf_size; while (ptr < end) { uint32_t tmid = ptr[2] | (ptr[3] << 8) | (ptr[4] << 16) | (ptr[5] << 24); - mirror::AbstractMethod* method = DecodeTraceMethodId(tmid); + mirror::ArtMethod* method = DecodeTraceMethodId(tmid); visited_methods->insert(method); ptr += GetRecordSize(clock_source_); } } void Trace::DumpMethodList(std::ostream& os, - const std::set& visited_methods) { - typedef std::set::const_iterator It; // TODO: C++0x auto + const std::set& visited_methods) { + typedef std::set::const_iterator It; // TODO: C++0x auto MethodHelper mh; for (It it = visited_methods.begin(); it != visited_methods.end(); ++it) { - mirror::AbstractMethod* method = *it; + mirror::ArtMethod* method = *it; mh.ChangeMethod(method); os << StringPrintf("%p\t%s\t%s\t%s\t%s\n", method, PrettyDescriptor(mh.GetDeclaringClassDescriptor()).c_str(), mh.GetName(), diff --git a/runtime/trace.h b/runtime/trace.h index bd9c140d26..ae583cae2d 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -31,7 +31,7 @@ namespace art { namespace mirror { -class AbstractMethod; + class ArtMethod; } // namespace mirror class Thread; @@ -63,19 +63,19 @@ class Trace : public instrumentation::InstrumentationListener { bool UseThreadCpuClock(); virtual void MethodEntered(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc) + const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void MethodExited(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t dex_pc, + const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - virtual void MethodUnwind(Thread* thread, const mirror::AbstractMethod* method, uint32_t dex_pc) + virtual void MethodUnwind(Thread* thread, const mirror::ArtMethod* method, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, - const mirror::AbstractMethod* method, uint32_t new_dex_pc) + const mirror::ArtMethod* method, uint32_t new_dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); virtual void ExceptionCaught(Thread* thread, const ThrowLocation& throw_location, - mirror::AbstractMethod* catch_method, uint32_t catch_dex_pc, + mirror::ArtMethod* catch_method, uint32_t catch_dex_pc, mirror::Throwable* exception_object) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -84,12 +84,12 @@ class Trace : public instrumentation::InstrumentationListener { void FinishTracing() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void LogMethodTraceEvent(Thread* thread, const mirror::AbstractMethod* method, + void LogMethodTraceEvent(Thread* thread, const mirror::ArtMethod* method, instrumentation::Instrumentation::InstrumentationEvent event); // Methods to output traced methods and threads. - void GetVisitedMethods(size_t end_offset, std::set* visited_methods); - void DumpMethodList(std::ostream& os, const std::set& visited_methods) + void GetVisitedMethods(size_t end_offset, std::set* visited_methods); + void DumpMethodList(std::ostream& os, const std::set& visited_methods) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void DumpThreadList(std::ostream& os) LOCKS_EXCLUDED(Locks::thread_list_lock_); diff --git a/runtime/utils.cc b/runtime/utils.cc index 71e502df29..87cd21c478 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -25,11 +25,10 @@ #include "UniquePtr.h" #include "base/unix_file/fd_file.h" #include "dex_file-inl.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" -#include "mirror/field.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "mirror/string.h" @@ -295,7 +294,7 @@ std::string PrettyDescriptor(Primitive::Type type) { return PrettyDescriptor(descriptor_string); } -std::string PrettyField(const mirror::Field* f, bool with_type) { +std::string PrettyField(const mirror::ArtField* f, bool with_type) { if (f == NULL) { return "null"; } @@ -370,7 +369,7 @@ std::string PrettyReturnType(const char* signature) { return PrettyDescriptor(return_type); } -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature) { +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature) { if (m == NULL) { return "null"; } @@ -629,7 +628,7 @@ std::string DescriptorToName(const char* descriptor) { return descriptor; } -std::string JniShortName(const mirror::AbstractMethod* m) { +std::string JniShortName(const mirror::ArtMethod* m) { MethodHelper mh(m); std::string class_name(mh.GetDeclaringClassDescriptor()); // Remove the leading 'L' and trailing ';'... @@ -648,7 +647,7 @@ std::string JniShortName(const mirror::AbstractMethod* m) { return short_name; } -std::string JniLongName(const mirror::AbstractMethod* m) { +std::string JniLongName(const mirror::ArtMethod* m) { std::string long_name; long_name += JniShortName(m); long_name += "__"; diff --git a/runtime/utils.h b/runtime/utils.h index 1c45048c13..9e724d0ac4 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -33,9 +33,9 @@ namespace art { class DexFile; namespace mirror { +class ArtField; +class ArtMethod; class Class; -class Field; -class AbstractMethod; class Object; class String; } // namespace mirror @@ -195,13 +195,13 @@ std::string PrettyDescriptor(const mirror::Class* klass) // Returns a human-readable signature for 'f'. Something like "a.b.C.f" or // "int a.b.C.f" (depending on the value of 'with_type'). -std::string PrettyField(const mirror::Field* f, bool with_type = true) +std::string PrettyField(const mirror::ArtField* f, bool with_type = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyField(uint32_t field_idx, const DexFile& dex_file, bool with_type = true); // Returns a human-readable signature for 'm'. Something like "a.b.C.m" or // "a.b.C.m(II)V" (depending on the value of 'with_signature'). -std::string PrettyMethod(const mirror::AbstractMethod* m, bool with_signature = true) +std::string PrettyMethod(const mirror::ArtMethod* m, bool with_signature = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string PrettyMethod(uint32_t method_idx, const DexFile& dex_file, bool with_signature = true); @@ -265,10 +265,10 @@ bool IsValidDescriptor(const char* s); // "Ljava/lang/String;" bool IsValidMemberName(const char* s); // Returns the JNI native function name for the non-overloaded method 'm'. -std::string JniShortName(const mirror::AbstractMethod* m) +std::string JniShortName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the JNI native function name for the overloaded method 'm'. -std::string JniLongName(const mirror::AbstractMethod* m) +std::string JniLongName(const mirror::ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool ReadFileToString(const std::string& file_name, std::string* result); diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc index 0966e717ca..2633964b57 100644 --- a/runtime/utils_test.cc +++ b/runtime/utils_test.cc @@ -130,7 +130,7 @@ TEST_F(UtilsTest, PrettyField) { mirror::Class* java_lang_String = class_linker_->FindSystemClass("Ljava/lang/String;"); - mirror::Field* f; + mirror::ArtField* f; f = java_lang_String->FindDeclaredInstanceField("count", "I"); EXPECT_EQ("int java.lang.String.count", PrettyField(f)); EXPECT_EQ("java.lang.String.count", PrettyField(f, false)); @@ -199,7 +199,7 @@ TEST_F(UtilsTest, JniShortName_JniLongName) { ScopedObjectAccess soa(Thread::Current()); mirror::Class* c = class_linker_->FindSystemClass("Ljava/lang/String;"); ASSERT_TRUE(c != NULL); - mirror::AbstractMethod* m; + mirror::ArtMethod* m; m = c->FindVirtualMethod("charAt", "(I)C"); ASSERT_TRUE(m != NULL); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index fc595d90d9..02168446b1 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -29,11 +29,11 @@ #include "indenter.h" #include "intern_table.h" #include "leb128.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_field-inl.h" +#include "mirror/art_method-inl.h" #include "mirror/class.h" #include "mirror/class-inl.h" #include "mirror/dex_cache-inl.h" -#include "mirror/field-inl.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -139,7 +139,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_direct_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -181,7 +181,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, } previous_virtual_method_idx = method_idx; InvokeType type = it.GetMethodInvokeType(class_def); - mirror::AbstractMethod* method = + mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { DCHECK(Thread::Current()->IsExceptionPending()); @@ -225,7 +225,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) { MethodVerifier::FailureKind result = kNoFailure; @@ -266,7 +266,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, + mirror::ArtMethod* method, uint32_t method_access_flags) { MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def_idx, code_item, dex_method_idx, method, method_access_flags, true, true); @@ -279,7 +279,7 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t dex_method_idx, mirror::AbstractMethod* method, + uint32_t dex_method_idx, mirror::ArtMethod* method, uint32_t method_access_flags, bool can_load_classes, bool allow_soft_failures) : reg_types_(can_load_classes), @@ -305,7 +305,7 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_ca has_virtual_or_interface_invokes_(false) { } -void MethodVerifier::FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, +void MethodVerifier::FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -327,7 +327,7 @@ void MethodVerifier::FindLocksAtDexPc() { Verify(); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -336,7 +336,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(mirror::AbstractMethod* return verifier.FindAccessedFieldAtDexPc(dex_pc); } -mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { +mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -355,7 +355,7 @@ mirror::Field* MethodVerifier::FindAccessedFieldAtDexPc(uint32_t dex_pc) { return GetQuickFieldAccess(inst, register_line); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), @@ -364,7 +364,7 @@ mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::Abstrac return verifier.FindInvokedMethodAtDexPc(dex_pc); } -mirror::AbstractMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { +mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(uint32_t dex_pc) { CHECK(code_item_ != NULL); // This only makes sense for methods with code. // Strictly speaking, we ought to be able to get away with doing a subset of the full method @@ -2113,7 +2113,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); bool is_super = (inst->Opcode() == Instruction::INVOKE_SUPER || inst->Opcode() == Instruction::INVOKE_SUPER_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_VIRTUAL, is_range, is_super); const char* descriptor; if (called_method == NULL) { @@ -2136,7 +2136,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_DIRECT: case Instruction::INVOKE_DIRECT_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_DIRECT_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_DIRECT, is_range, false); const char* return_type_descriptor; bool is_constructor; @@ -2203,7 +2203,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_STATIC: case Instruction::INVOKE_STATIC_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_STATIC_RANGE); - mirror::AbstractMethod* called_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* called_method = VerifyInvocationArgs(inst, METHOD_STATIC, is_range, false); @@ -2228,7 +2228,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_INTERFACE: case Instruction::INVOKE_INTERFACE_RANGE: { bool is_range = (inst->Opcode() == Instruction::INVOKE_INTERFACE_RANGE); - mirror::AbstractMethod* abs_method = VerifyInvocationArgs(inst, + mirror::ArtMethod* abs_method = VerifyInvocationArgs(inst, METHOD_INTERFACE, is_range, false); @@ -2536,7 +2536,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { case Instruction::INVOKE_VIRTUAL_QUICK: case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: { bool is_range = (inst->Opcode() == Instruction::INVOKE_VIRTUAL_RANGE_QUICK); - mirror::AbstractMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); + mirror::ArtMethod* called_method = VerifyInvokeVirtualQuickArgs(inst, is_range); if (called_method != NULL) { const char* descriptor = MethodHelper(called_method).GetReturnTypeDescriptor(); const RegType& return_type = reg_types_.FromDescriptor(class_loader_, descriptor, false); @@ -2871,7 +2871,7 @@ const RegType& MethodVerifier::GetCaughtExceptionType() { return *common_super; } -mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, +mirror::ArtMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex_method_idx, MethodType method_type) { const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx); const RegType& klass_type = ResolveClassAndCheckAccess(method_id.class_idx_); @@ -2886,7 +2886,7 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex } mirror::Class* klass = klass_type.GetClass(); const RegType& referrer = GetDeclaringClass(); - mirror::AbstractMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); + mirror::ArtMethod* res_method = dex_cache_->GetResolvedMethod(dex_method_idx); if (res_method == NULL) { const char* name = dex_file_->GetMethodName(method_id); std::string signature(dex_file_->CreateMethodSignature(method_id.proto_idx_, NULL)); @@ -2963,14 +2963,14 @@ mirror::AbstractMethod* MethodVerifier::ResolveMethodAndCheckAccess(uint32_t dex return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* inst, MethodType method_type, bool is_range, bool is_super) { // Resolve the method. This could be an abstract or concrete method depending on what sort of call // we're making. const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); - mirror::AbstractMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); + mirror::ArtMethod* res_method = ResolveMethodAndCheckAccess(method_idx, method_type); if (res_method == NULL) { // error or class is unresolved return NULL; } @@ -3078,7 +3078,7 @@ mirror::AbstractMethod* MethodVerifier::VerifyInvocationArgs(const Instruction* } } -mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* inst, RegisterLine* reg_line, bool is_range) { DCHECK(inst->Opcode() == Instruction::INVOKE_VIRTUAL_QUICK || @@ -3103,19 +3103,19 @@ mirror::AbstractMethod* MethodVerifier::GetQuickInvokedMethod(const Instruction* if (this_class == NULL) { return NULL; } - mirror::ObjectArray* vtable = this_class->GetVTable(); + mirror::ObjectArray* vtable = this_class->GetVTable(); CHECK(vtable != NULL); uint16_t vtable_index = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); CHECK(vtable_index < vtable->GetLength()); - mirror::AbstractMethod* res_method = vtable->Get(vtable_index); + mirror::ArtMethod* res_method = vtable->Get(vtable_index); CHECK(!Thread::Current()->IsExceptionPending()); return res_method; } -mirror::AbstractMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, +mirror::ArtMethod* MethodVerifier::VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) { DCHECK(Runtime::Current()->IsStarted()); - mirror::AbstractMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), + mirror::ArtMethod* res_method = GetQuickInvokedMethod(inst, work_line_.get(), is_range); if (res_method == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer method from " << inst->Name(); @@ -3368,7 +3368,7 @@ void MethodVerifier::VerifyAPut(const Instruction* inst, } } -mirror::Field* MethodVerifier::GetStaticField(int field_idx) { +mirror::ArtField* MethodVerifier::GetStaticField(int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3381,7 +3381,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here, will do checking at runtime. } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3405,7 +3405,7 @@ mirror::Field* MethodVerifier::GetStaticField(int field_idx) { } } -mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { +mirror::ArtField* MethodVerifier::GetInstanceField(const RegType& obj_type, int field_idx) { const DexFile::FieldId& field_id = dex_file_->GetFieldId(field_idx); // Check access to class const RegType& klass_type = ResolveClassAndCheckAccess(field_id.class_idx_); @@ -3418,7 +3418,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie if (klass_type.IsUnresolvedTypes()) { return NULL; // Can't resolve Class so no more to do here } - mirror::Field* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, + mirror::ArtField* field = Runtime::Current()->GetClassLinker()->ResolveFieldJLS(*dex_file_, field_idx, dex_cache_, class_loader_); @@ -3471,7 +3471,7 @@ mirror::Field* MethodVerifier::GetInstanceField(const RegType& obj_type, int fie void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3525,7 +3525,7 @@ void MethodVerifier::VerifyISGet(const Instruction* inst, const RegType& insn_ty void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_type, bool is_primitive, bool is_static) { uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); - mirror::Field* field; + mirror::ArtField* field; if (is_static) { field = GetStaticField(field_idx); } else { @@ -3567,13 +3567,13 @@ void MethodVerifier::VerifyISPut(const Instruction* inst, const RegType& insn_ty // Look for an instance field with this offset. // TODO: we may speed up the search if offsets are sorted by doing a quick search. -static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, +static mirror::ArtField* FindInstanceFieldWithOffset(const mirror::Class* klass, uint32_t field_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const mirror::ObjectArray* instance_fields = klass->GetIFields(); + const mirror::ObjectArray* instance_fields = klass->GetIFields(); if (instance_fields != NULL) { for (int32_t i = 0, e = instance_fields->GetLength(); i < e; ++i) { - mirror::Field* field = instance_fields->Get(i); + mirror::ArtField* field = instance_fields->Get(i); if (field->GetOffset().Uint32Value() == field_offset) { return field; } @@ -3589,7 +3589,7 @@ static mirror::Field* FindInstanceFieldWithOffset(const mirror::Class* klass, // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. -mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, +mirror::ArtField* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) { DCHECK(inst->Opcode() == Instruction::IGET_QUICK || inst->Opcode() == Instruction::IGET_WIDE_QUICK || @@ -3624,7 +3624,7 @@ mirror::Field* MethodVerifier::GetQuickFieldAccess(const Instruction* inst, void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3668,7 +3668,7 @@ void MethodVerifier::VerifyIGetQuick(const Instruction* inst, const RegType& ins void MethodVerifier::VerifyIPutQuick(const Instruction* inst, const RegType& insn_type, bool is_primitive) { DCHECK(Runtime::Current()->IsStarted()); - mirror::Field* field = GetQuickFieldAccess(inst, work_line_.get()); + mirror::ArtField* field = GetQuickFieldAccess(inst, work_line_.get()); if (field == NULL) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Cannot infer field from " << inst->Name(); return; @@ -3922,7 +3922,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { // We can't devirtualize abstract classes except on arrays of abstract classes. continue; } - mirror::AbstractMethod* abstract_method = + mirror::ArtMethod* abstract_method = dex_cache_->GetResolvedMethod(is_range ? inst->VRegB_3rc() : inst->VRegB_35c()); if (abstract_method == NULL) { // If the method is not found in the cache this means that it was never found @@ -3930,7 +3930,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { continue; } // Find the concrete method. - mirror::AbstractMethod* concrete_method = NULL; + mirror::ArtMethod* concrete_method = NULL; if (is_interface) { concrete_method = reg_type.GetClass()->FindVirtualMethodForInterface(abstract_method); } diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index e01f2c08c1..6171943a6c 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -156,7 +156,7 @@ class MethodVerifier { static void VerifyMethodAndDump(std::ostream& os, uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags) + mirror::ArtMethod* method, uint32_t method_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); uint8_t EncodePcToReferenceMapData() const; @@ -197,20 +197,18 @@ class MethodVerifier { // Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding // to the locks held at 'dex_pc' in method 'm'. - static void FindLocksAtDexPc(mirror::AbstractMethod* m, uint32_t dex_pc, + static void FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the accessed field corresponding to the quick instruction's field // offset at 'dex_pc' in method 'm'. - static mirror::Field* FindAccessedFieldAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtField* FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns the invoked method corresponding to the quick instruction's vtable // index at 'dex_pc' in method 'm'. - static mirror::AbstractMethod* FindInvokedMethodAtDexPc(mirror::AbstractMethod* m, - uint32_t dex_pc) + static mirror::ArtMethod* FindInvokedMethodAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -226,7 +224,7 @@ class MethodVerifier { MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - uint32_t method_idx, mirror::AbstractMethod* method, + uint32_t method_idx, mirror::ArtMethod* method, uint32_t access_flags, bool can_load_classes, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -266,16 +264,16 @@ class MethodVerifier { mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, uint32_t class_def_idx, const DexFile::CodeItem* code_item, - mirror::AbstractMethod* method, uint32_t method_access_flags, + mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FindLocksAtDexPc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::Field* FindAccessedFieldAtDexPc(uint32_t dex_pc) + mirror::ArtField* FindAccessedFieldAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) + mirror::ArtMethod* FindInvokedMethodAtDexPc(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -496,11 +494,11 @@ class MethodVerifier { bool is_primitive) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup instance field and fail for resolution violations - mirror::Field* GetInstanceField(const RegType& obj_type, int field_idx) + mirror::ArtField* GetInstanceField(const RegType& obj_type, int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Lookup static field and fail for resolution violations - mirror::Field* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::ArtField* GetStaticField(int field_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget or sget instruction. void VerifyISGet(const Instruction* inst, const RegType& insn_type, @@ -514,7 +512,7 @@ class MethodVerifier { // Returns the access field of a quick field access (iget/iput-quick) or NULL // if it cannot be found. - mirror::Field* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) + mirror::ArtField* GetQuickFieldAccess(const Instruction* inst, RegisterLine* reg_line) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Perform verification of an iget-quick instruction. @@ -545,7 +543,7 @@ class MethodVerifier { * the referrer can access the resolved method. * Does not throw exceptions. */ - mirror::AbstractMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) + mirror::ArtMethod* ResolveMethodAndCheckAccess(uint32_t method_idx, MethodType method_type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -570,18 +568,17 @@ class MethodVerifier { * Returns the resolved method on success, NULL on failure (with *failure * set appropriately). */ - mirror::AbstractMethod* VerifyInvocationArgs(const Instruction* inst, - MethodType method_type, - bool is_range, bool is_super) + mirror::ArtMethod* VerifyInvocationArgs(const Instruction* inst, + MethodType method_type, + bool is_range, bool is_super) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* GetQuickInvokedMethod(const Instruction* inst, - RegisterLine* reg_line, - bool is_range) + mirror::ArtMethod* GetQuickInvokedMethod(const Instruction* inst, + RegisterLine* reg_line, + bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::AbstractMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, - bool is_range) + mirror::ArtMethod* VerifyInvokeVirtualQuickArgs(const Instruction* inst, bool is_range) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); /* @@ -686,7 +683,7 @@ class MethodVerifier { const uint32_t dex_method_idx_; // The method we're working on. // Its object representation if known. - mirror::AbstractMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); + mirror::ArtMethod* mirror_method_ GUARDED_BY(Locks::mutator_lock_); const uint32_t method_access_flags_; // Method's access flags. const DexFile* const dex_file_; // The dex file containing the method. // The dex_cache for the declaring class of the method. diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 434fcf00f5..8de020a975 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -32,8 +32,11 @@ jclass WellKnownClasses::java_lang_ClassNotFoundException; jclass WellKnownClasses::java_lang_Daemons; jclass WellKnownClasses::java_lang_Error; jclass WellKnownClasses::java_lang_Object; -jclass WellKnownClasses::java_lang_reflect_InvocationHandler; jclass WellKnownClasses::java_lang_reflect_AbstractMethod; +jclass WellKnownClasses::java_lang_reflect_ArtMethod; +jclass WellKnownClasses::java_lang_reflect_Constructor; +jclass WellKnownClasses::java_lang_reflect_Field; +jclass WellKnownClasses::java_lang_reflect_Method; jclass WellKnownClasses::java_lang_reflect_Proxy; jclass WellKnownClasses::java_lang_RuntimeException; jclass WellKnownClasses::java_lang_StackOverflowError; @@ -61,7 +64,7 @@ jmethodID WellKnownClasses::java_lang_Integer_valueOf; jmethodID WellKnownClasses::java_lang_Long_valueOf; jmethodID WellKnownClasses::java_lang_ref_FinalizerReference_add; jmethodID WellKnownClasses::java_lang_ref_ReferenceQueue_add; -jmethodID WellKnownClasses::java_lang_reflect_InvocationHandler_invoke; +jmethodID WellKnownClasses::java_lang_reflect_Proxy_invoke; jmethodID WellKnownClasses::java_lang_Runtime_nativeLoad; jmethodID WellKnownClasses::java_lang_Short_valueOf; jmethodID WellKnownClasses::java_lang_System_runFinalization = NULL; @@ -83,6 +86,8 @@ jfieldID WellKnownClasses::java_lang_Thread_nativePeer; jfieldID WellKnownClasses::java_lang_ThreadGroup_mainThreadGroup; jfieldID WellKnownClasses::java_lang_ThreadGroup_name; jfieldID WellKnownClasses::java_lang_ThreadGroup_systemThreadGroup; +jfieldID WellKnownClasses::java_lang_reflect_AbstractMethod_artMethod; +jfieldID WellKnownClasses::java_lang_reflect_Field_artField; jfieldID WellKnownClasses::java_lang_reflect_Proxy_h; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_capacity; jfieldID WellKnownClasses::java_nio_DirectByteBuffer_effectiveDirectAddress; @@ -121,7 +126,7 @@ static jmethodID CachePrimitiveBoxingMethod(JNIEnv* env, char prim_name, const c StringPrintf("(%c)L%s;", prim_name, boxed_name).c_str()); } -void WellKnownClasses::InitClasses(JNIEnv* env) { +void WellKnownClasses::Init(JNIEnv* env) { com_android_dex_Dex = CacheClass(env, "com/android/dex/Dex"); dalvik_system_PathClassLoader = CacheClass(env, "dalvik/system/PathClassLoader"); java_lang_ClassLoader = CacheClass(env, "java/lang/ClassLoader"); @@ -129,8 +134,11 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_lang_Daemons = CacheClass(env, "java/lang/Daemons"); java_lang_Object = CacheClass(env, "java/lang/Object"); java_lang_Error = CacheClass(env, "java/lang/Error"); - java_lang_reflect_InvocationHandler = CacheClass(env, "java/lang/reflect/InvocationHandler"); java_lang_reflect_AbstractMethod = CacheClass(env, "java/lang/reflect/AbstractMethod"); + java_lang_reflect_ArtMethod = CacheClass(env, "java/lang/reflect/ArtMethod"); + java_lang_reflect_Constructor = CacheClass(env, "java/lang/reflect/Constructor"); + java_lang_reflect_Field = CacheClass(env, "java/lang/reflect/Field"); + java_lang_reflect_Method = CacheClass(env, "java/lang/reflect/Method"); java_lang_reflect_Proxy = CacheClass(env, "java/lang/reflect/Proxy"); java_lang_RuntimeException = CacheClass(env, "java/lang/RuntimeException"); java_lang_StackOverflowError = CacheClass(env, "java/lang/StackOverflowError"); @@ -142,10 +150,6 @@ void WellKnownClasses::InitClasses(JNIEnv* env) { java_nio_DirectByteBuffer = CacheClass(env, "java/nio/DirectByteBuffer"); org_apache_harmony_dalvik_ddmc_Chunk = CacheClass(env, "org/apache/harmony/dalvik/ddmc/Chunk"); org_apache_harmony_dalvik_ddmc_DdmServer = CacheClass(env, "org/apache/harmony/dalvik/ddmc/DdmServer"); -} - -void WellKnownClasses::Init(JNIEnv* env) { - InitClasses(env); com_android_dex_Dex_create = CacheMethod(env, com_android_dex_Dex, true, "create", "(Ljava/nio/ByteBuffer;)Lcom/android/dex/Dex;"); java_lang_ClassNotFoundException_init = CacheMethod(env, java_lang_ClassNotFoundException, false, "", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); @@ -160,7 +164,7 @@ void WellKnownClasses::Init(JNIEnv* env) { ScopedLocalRef java_lang_ref_ReferenceQueue(env, env->FindClass("java/lang/ref/ReferenceQueue")); java_lang_ref_ReferenceQueue_add = CacheMethod(env, java_lang_ref_ReferenceQueue.get(), true, "add", "(Ljava/lang/ref/Reference;)V"); - java_lang_reflect_InvocationHandler_invoke = CacheMethod(env, java_lang_reflect_InvocationHandler, false, "invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"); + java_lang_reflect_Proxy_invoke = CacheMethod(env, java_lang_reflect_Proxy, true, "invoke", "(Ljava/lang/reflect/Proxy;Ljava/lang/reflect/ArtMethod;[Ljava/lang/Object;)Ljava/lang/Object;"); java_lang_Thread_init = CacheMethod(env, java_lang_Thread, false, "", "(Ljava/lang/ThreadGroup;Ljava/lang/String;IZ)V"); java_lang_Thread_run = CacheMethod(env, java_lang_Thread, false, "run", "()V"); java_lang_Thread$UncaughtExceptionHandler_uncaughtException = CacheMethod(env, java_lang_Thread$UncaughtExceptionHandler, false, "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); @@ -179,6 +183,8 @@ void WellKnownClasses::Init(JNIEnv* env) { java_lang_ThreadGroup_mainThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "mainThreadGroup", "Ljava/lang/ThreadGroup;"); java_lang_ThreadGroup_name = CacheField(env, java_lang_ThreadGroup, false, "name", "Ljava/lang/String;"); java_lang_ThreadGroup_systemThreadGroup = CacheField(env, java_lang_ThreadGroup, true, "systemThreadGroup", "Ljava/lang/ThreadGroup;"); + java_lang_reflect_AbstractMethod_artMethod = CacheField(env, java_lang_reflect_AbstractMethod, false, "artMethod", "Ljava/lang/reflect/ArtMethod;"); + java_lang_reflect_Field_artField = CacheField(env, java_lang_reflect_Field, false, "artField", "Ljava/lang/reflect/ArtField;"); java_lang_reflect_Proxy_h = CacheField(env, java_lang_reflect_Proxy, false, "h", "Ljava/lang/reflect/InvocationHandler;"); java_nio_DirectByteBuffer_capacity = CacheField(env, java_nio_DirectByteBuffer, false, "capacity", "I"); java_nio_DirectByteBuffer_effectiveDirectAddress = CacheField(env, java_nio_DirectByteBuffer, false, "effectiveDirectAddress", "J"); diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index fc2bffb485..bc928d0dbe 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -32,7 +32,7 @@ class Class; jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, const char* name, const char* signature); struct WellKnownClasses { - static void InitClasses(JNIEnv* env); + public: static void Init(JNIEnv* env); // Run before native methods are registered. static void LateInit(JNIEnv* env); // Run after native methods are registered. @@ -46,8 +46,11 @@ struct WellKnownClasses { static jclass java_lang_Daemons; static jclass java_lang_Error; static jclass java_lang_Object; - static jclass java_lang_reflect_InvocationHandler; static jclass java_lang_reflect_AbstractMethod; + static jclass java_lang_reflect_ArtMethod; + static jclass java_lang_reflect_Constructor; + static jclass java_lang_reflect_Field; + static jclass java_lang_reflect_Method; static jclass java_lang_reflect_Proxy; static jclass java_lang_RuntimeException; static jclass java_lang_StackOverflowError; @@ -75,7 +78,7 @@ struct WellKnownClasses { static jmethodID java_lang_Long_valueOf; static jmethodID java_lang_ref_FinalizerReference_add; static jmethodID java_lang_ref_ReferenceQueue_add; - static jmethodID java_lang_reflect_InvocationHandler_invoke; + static jmethodID java_lang_reflect_Proxy_invoke; static jmethodID java_lang_Runtime_nativeLoad; static jmethodID java_lang_Short_valueOf; static jmethodID java_lang_System_runFinalization; @@ -87,6 +90,8 @@ struct WellKnownClasses { static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_broadcast; static jmethodID org_apache_harmony_dalvik_ddmc_DdmServer_dispatch; + static jfieldID java_lang_reflect_AbstractMethod_artMethod; + static jfieldID java_lang_reflect_Field_artField; static jfieldID java_lang_reflect_Proxy_h; static jfieldID java_lang_Thread_daemon; static jfieldID java_lang_Thread_group; diff --git a/test/046-reflect/expected.txt b/test/046-reflect/expected.txt index 8de373caa6..fcfaf2ff3f 100644 --- a/test/046-reflect/expected.txt +++ b/test/046-reflect/expected.txt @@ -81,8 +81,9 @@ Field name is cantTouchThis Field type is int Access flags are 0x11 cantTouchThis is 77 - setAccessible is always true cantTouchThis is now 99 + public final int Target.cantTouchThis accessible=false + public final int Target.cantTouchThis accessible=true cantTouchThis is now 87 cantTouchThis is now 88 cons modifiers=1 @@ -92,6 +93,8 @@ myMethod (I)I arg=17 anInt=7 ReflectTest done! public method +static java.lang.Object java.util.Collections.checkType(java.lang.Object,java.lang.Class) accessible=false +static java.lang.Object java.util.Collections.checkType(java.lang.Object,java.lang.Class) accessible=true checkType invoking null checkType got expected exception calling const-class FieldNoisyInitUser.class @@ -113,3 +116,7 @@ MethodNoisyInit is initializing generic field: java.util.List generic method fancyMethod params='[1] java.util.ArrayList' ret='java.util.Map' generic ctor Main params='[1] java.util.ArrayList' +fields are unique +fields are .equals +methods are unique +methods are .equals diff --git a/test/046-reflect/src/Main.java b/test/046-reflect/src/Main.java index 9d4cacf499..dfb0d8fe9b 100644 --- a/test/046-reflect/src/Main.java +++ b/test/046-reflect/src/Main.java @@ -335,14 +335,15 @@ public class Main { System.out.println(" cantTouchThis is " + intVal); try { field.setInt(instance, 99); - System.out.println(" setAccessible is always true"); } catch (IllegalAccessException iae) { System.out.println("ERROR: set-final failed"); } intVal = field.getInt(instance); System.out.println(" cantTouchThis is now " + intVal); + System.out.println(" " + field + " accessible=" + field.isAccessible()); field.setAccessible(true); + System.out.println(" " + field + " accessible=" + field.isAccessible()); field.setInt(instance, 87); // exercise int version intVal = field.getInt(instance); System.out.println(" cantTouchThis is now " + intVal); @@ -378,8 +379,9 @@ public class Main { nsme.printStackTrace(); return; } - + System.out.println(m + " accessible=" + m.isAccessible()); m.setAccessible(true); + System.out.println(m + " accessible=" + m.isAccessible()); try { m.invoke(null, new Object(), Object.class); } catch (IllegalAccessException iae) { @@ -518,6 +520,42 @@ public class Main { return stb.toString(); } + public static void checkUnique() { + Field field1, field2; + try { + field1 = Main.class.getField("dummy"); + field2 = Main.class.getField("dummy"); + } catch (NoSuchFieldException nsfe) { + throw new RuntimeException(nsfe); + } + if (field1 == field2) { + System.out.println("ERROR: fields shouldn't have reference equality"); + } else { + System.out.println("fields are unique"); + } + if (field1.hashCode() == field2.hashCode() && field1.equals(field2)) { + System.out.println("fields are .equals"); + } else { + System.out.println("ERROR: fields fail equality"); + } + Method method1, method2; + try { + method1 = Main.class.getMethod("fancyMethod", new Class[] { ArrayList.class }); + method2 = Main.class.getMethod("fancyMethod", new Class[] { ArrayList.class }); + } catch (NoSuchMethodException nsme) { + throw new RuntimeException(nsme); + } + if (method1 == method2) { + System.out.println("ERROR: methods shouldn't have reference equality"); + } else { + System.out.println("methods are unique"); + } + if (method1.hashCode() == method2.hashCode() && method1.equals(method2)) { + System.out.println("methods are .equals"); + } else { + System.out.println("ERROR: methods fail equality"); + } + } public static void main(String[] args) throws Exception { Main test = new Main(); @@ -528,6 +566,7 @@ public class Main { checkClinitForFields(); checkClinitForMethods(); checkGeneric(); + checkUnique(); } } diff --git a/test/100-reflect2/expected.txt b/test/100-reflect2/expected.txt index f56fd98947..3d87ebc559 100644 --- a/test/100-reflect2/expected.txt +++ b/test/100-reflect2/expected.txt @@ -36,7 +36,7 @@ z (class java.lang.Character) 14 (class java.lang.Short) [public java.lang.String(), java.lang.String(int,int,char[]), public java.lang.String(java.lang.String), public java.lang.String(java.lang.StringBuffer), public java.lang.String(java.lang.StringBuilder), public java.lang.String(byte[]), public java.lang.String(byte[],int), public java.lang.String(byte[],int,int), public java.lang.String(byte[],int,int,int), public java.lang.String(byte[],int,int,java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],int,int,java.nio.charset.Charset), public java.lang.String(byte[],java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],java.nio.charset.Charset), public java.lang.String(char[]), public java.lang.String(char[],int,int), public java.lang.String(int[],int,int)] [private final char[] java.lang.String.value, private final int java.lang.String.count, private int java.lang.String.hashCode, private final int java.lang.String.offset, private static final char[] java.lang.String.ASCII, public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER, private static final char java.lang.String.REPLACEMENT_CHAR, private static final long java.lang.String.serialVersionUID] -[void java.lang.String._getChars(int,int,char[],int), public char java.lang.String.charAt(int), public int java.lang.String.codePointAt(int), public int java.lang.String.codePointBefore(int), public int java.lang.String.codePointCount(int,int), public volatile int java.lang.String.compareTo(java.lang.Object), public native int java.lang.String.compareTo(java.lang.String), public int java.lang.String.compareToIgnoreCase(java.lang.String), public java.lang.String java.lang.String.concat(java.lang.String), public boolean java.lang.String.contains(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.StringBuffer), public boolean java.lang.String.endsWith(java.lang.String), public boolean java.lang.String.equals(java.lang.Object), public boolean java.lang.String.equalsIgnoreCase(java.lang.String), public void java.lang.String.getBytes(int,int,byte[],int), public [B java.lang.String.getBytes(), public [B java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException, public [B java.lang.String.getBytes(java.nio.charset.Charset), public void java.lang.String.getChars(int,int,char[],int), public int java.lang.String.hashCode(), public int java.lang.String.indexOf(int), public int java.lang.String.indexOf(int,int), public int java.lang.String.indexOf(java.lang.String), public int java.lang.String.indexOf(java.lang.String,int), public native java.lang.String java.lang.String.intern(), public boolean java.lang.String.isEmpty(), public int java.lang.String.lastIndexOf(int), public int java.lang.String.lastIndexOf(int,int), public int java.lang.String.lastIndexOf(java.lang.String), public int java.lang.String.lastIndexOf(java.lang.String,int), public int java.lang.String.length(), public boolean java.lang.String.matches(java.lang.String), public int java.lang.String.offsetByCodePoints(int,int), public boolean java.lang.String.regionMatches(int,java.lang.String,int,int), public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int), public java.lang.String java.lang.String.replace(char,char), public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence), public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String), public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String,int), public boolean java.lang.String.startsWith(java.lang.String), public boolean java.lang.String.startsWith(java.lang.String,int), public java.lang.CharSequence java.lang.String.subSequence(int,int), public java.lang.String java.lang.String.substring(int), public java.lang.String java.lang.String.substring(int,int), public [C java.lang.String.toCharArray(), public java.lang.String java.lang.String.toLowerCase(), public java.lang.String java.lang.String.toLowerCase(java.util.Locale), public java.lang.String java.lang.String.toString(), public java.lang.String java.lang.String.toUpperCase(), public java.lang.String java.lang.String.toUpperCase(java.util.Locale), public java.lang.String java.lang.String.trim(), static void java.lang.String.(), public static java.lang.String java.lang.String.copyValueOf(char[]), public static java.lang.String java.lang.String.copyValueOf(char[],int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.failedBoundsCheck(int,int,int), private native int java.lang.String.fastIndexOf(int,int), private char java.lang.String.foldCase(char), public static transient java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[]), public static transient java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[]), private java.lang.StringIndexOutOfBoundsException java.lang.String.indexAndLength(int), private static int java.lang.String.indexOf(java.lang.String,java.lang.String,int,int,char), private int java.lang.String.indexOfSupplementary(int,int), private int java.lang.String.lastIndexOfSupplementary(int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.startEndAndLength(int,int), public static java.lang.String java.lang.String.valueOf(char), public static java.lang.String java.lang.String.valueOf(double), public static java.lang.String java.lang.String.valueOf(float), public static java.lang.String java.lang.String.valueOf(int), public static java.lang.String java.lang.String.valueOf(long), public static java.lang.String java.lang.String.valueOf(java.lang.Object), public static java.lang.String java.lang.String.valueOf(boolean), public static java.lang.String java.lang.String.valueOf(char[]), public static java.lang.String java.lang.String.valueOf(char[],int,int)] +[void java.lang.String._getChars(int,int,char[],int), public char java.lang.String.charAt(int), public int java.lang.String.codePointAt(int), public int java.lang.String.codePointBefore(int), public int java.lang.String.codePointCount(int,int), public volatile int java.lang.String.compareTo(java.lang.Object), public native int java.lang.String.compareTo(java.lang.String), public int java.lang.String.compareToIgnoreCase(java.lang.String), public java.lang.String java.lang.String.concat(java.lang.String), public boolean java.lang.String.contains(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.StringBuffer), public boolean java.lang.String.endsWith(java.lang.String), public boolean java.lang.String.equals(java.lang.Object), public boolean java.lang.String.equalsIgnoreCase(java.lang.String), public void java.lang.String.getBytes(int,int,byte[],int), public [B java.lang.String.getBytes(), public [B java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException, public [B java.lang.String.getBytes(java.nio.charset.Charset), public void java.lang.String.getChars(int,int,char[],int), public int java.lang.String.hashCode(), public int java.lang.String.indexOf(int), public int java.lang.String.indexOf(int,int), public int java.lang.String.indexOf(java.lang.String), public int java.lang.String.indexOf(java.lang.String,int), public native java.lang.String java.lang.String.intern(), public boolean java.lang.String.isEmpty(), public int java.lang.String.lastIndexOf(int), public int java.lang.String.lastIndexOf(int,int), public int java.lang.String.lastIndexOf(java.lang.String), public int java.lang.String.lastIndexOf(java.lang.String,int), public int java.lang.String.length(), public boolean java.lang.String.matches(java.lang.String), public int java.lang.String.offsetByCodePoints(int,int), public boolean java.lang.String.regionMatches(int,java.lang.String,int,int), public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int), public java.lang.String java.lang.String.replace(char,char), public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence), public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String), public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String,int), public boolean java.lang.String.startsWith(java.lang.String), public boolean java.lang.String.startsWith(java.lang.String,int), public java.lang.CharSequence java.lang.String.subSequence(int,int), public java.lang.String java.lang.String.substring(int), public java.lang.String java.lang.String.substring(int,int), public [C java.lang.String.toCharArray(), public java.lang.String java.lang.String.toLowerCase(), public java.lang.String java.lang.String.toLowerCase(java.util.Locale), public java.lang.String java.lang.String.toString(), public java.lang.String java.lang.String.toUpperCase(), public java.lang.String java.lang.String.toUpperCase(java.util.Locale), public java.lang.String java.lang.String.trim(), public static java.lang.String java.lang.String.copyValueOf(char[]), public static java.lang.String java.lang.String.copyValueOf(char[],int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.failedBoundsCheck(int,int,int), private native int java.lang.String.fastIndexOf(int,int), private char java.lang.String.foldCase(char), public static transient java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[]), public static transient java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[]), private java.lang.StringIndexOutOfBoundsException java.lang.String.indexAndLength(int), private static int java.lang.String.indexOf(java.lang.String,java.lang.String,int,int,char), private int java.lang.String.indexOfSupplementary(int,int), private int java.lang.String.lastIndexOfSupplementary(int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.startEndAndLength(int,int), public static java.lang.String java.lang.String.valueOf(char), public static java.lang.String java.lang.String.valueOf(double), public static java.lang.String java.lang.String.valueOf(float), public static java.lang.String java.lang.String.valueOf(int), public static java.lang.String java.lang.String.valueOf(long), public static java.lang.String java.lang.String.valueOf(java.lang.Object), public static java.lang.String java.lang.String.valueOf(boolean), public static java.lang.String java.lang.String.valueOf(char[]), public static java.lang.String java.lang.String.valueOf(char[],int,int)] [] [interface java.io.Serializable, interface java.lang.Comparable, interface java.lang.CharSequence] 0 diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc index 84f5f2ea29..1f6e307f26 100644 --- a/test/ReferenceMap/stack_walk_refmap_jni.cc +++ b/test/ReferenceMap/stack_walk_refmap_jni.cc @@ -20,8 +20,8 @@ #include "class_linker.h" #include "dex_file-inl.h" #include "gc_map.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "object_utils.h" @@ -52,7 +52,7 @@ struct ReferenceMap2Visitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); if (!m || m->IsNative() || m->IsRuntimeMethod() || IsShadowFrame()) { return true; } diff --git a/test/StackWalk/stack_walk_jni.cc b/test/StackWalk/stack_walk_jni.cc index 8f4aae61fd..528586ed7b 100644 --- a/test/StackWalk/stack_walk_jni.cc +++ b/test/StackWalk/stack_walk_jni.cc @@ -19,8 +19,8 @@ #include "UniquePtr.h" #include "class_linker.h" #include "gc_map.h" -#include "mirror/abstract_method.h" -#include "mirror/abstract_method-inl.h" +#include "mirror/art_method.h" +#include "mirror/art_method-inl.h" #include "mirror/class-inl.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" @@ -50,7 +50,7 @@ struct TestReferenceMapVisitor : public StackVisitor { } bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::AbstractMethod* m = GetMethod(); + mirror::ArtMethod* m = GetMethod(); CHECK(m != NULL); LOG(INFO) << "At " << PrettyMethod(m, false); -- cgit v1.2.3-59-g8ed1b From e6bb3b2ce5a69c31c2adfc7eb2705633b7f966eb Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Mon, 19 Aug 2013 21:51:45 -0700 Subject: Reduce AOT initialization. When compiling apps there is no need to resolve all types in the dex file, just those declared in the dex file. There's also no need to initialize static fields if we can only leave the class in a verified state. Increase use of CompilerDriver::IsImage. Move timing of dex2oat setup to before Runtime::Create. On run-test 056 the performance improvement is an order of magnitude, for ThinkFree dex2oat time is dominated by compilation and this change has no effect. Bug 10316099. Change-Id: Ibdd7caa43284e7448e6a56d810967100ae4a7898 --- compiler/driver/compiler_driver.cc | 253 +++++++++++++++++++++---------------- compiler/driver/compiler_driver.h | 1 + dex2oat/dex2oat.cc | 2 +- runtime/class_linker.cc | 57 ++++----- runtime/class_linker.h | 2 +- 5 files changed, 173 insertions(+), 142 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 120f232d7a..38ffa10e45 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -582,10 +582,11 @@ void CompilerDriver::PreCompile(jobject class_loader, const std::vectorfind(descriptor) != image_classes_->end(); } - return image_classes_->find(descriptor) != image_classes_->end(); } static void ResolveExceptionsForMethod(MethodHelper* mh, @@ -655,7 +656,7 @@ static bool RecordImageClassesVisitor(mirror::Class* klass, void* arg) // Make a list of descriptors for classes to include in the image void CompilerDriver::LoadImageClasses(base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_) { - if (image_classes_.get() == NULL) { + if (!IsImage()) { return; } @@ -669,7 +670,7 @@ void CompilerDriver::LoadImageClasses(base::TimingLogger& timings) SirtRef klass(self, class_linker->FindSystemClass(descriptor.c_str())); if (klass.get() == NULL) { image_classes_->erase(it++); - LOG(WARNING) << "Failed to find class " << descriptor; + VLOG(compiler) << "Failed to find class " << descriptor; Thread::Current()->ClearException(); } else { ++it; @@ -742,21 +743,19 @@ void CompilerDriver::FindClinitImageClassesCallback(mirror::Object* object, void } void CompilerDriver::UpdateImageClasses(base::TimingLogger& timings) { - if (image_classes_.get() == NULL) { - return; - } - - timings.NewSplit("UpdateImageClasses"); + if (IsImage()) { + timings.NewSplit("UpdateImageClasses"); - // Update image_classes_ with classes for objects created by methods. - Thread* self = Thread::Current(); - const char* old_cause = self->StartAssertNoThreadSuspension("ImageWriter"); - gc::Heap* heap = Runtime::Current()->GetHeap(); - // TODO: Image spaces only? - WriterMutexLock mu(self, *Locks::heap_bitmap_lock_); - heap->FlushAllocStack(); - heap->GetLiveBitmap()->Walk(FindClinitImageClassesCallback, this); - self->EndAssertNoThreadSuspension(old_cause); + // Update image_classes_ with classes for objects created by methods. + Thread* self = Thread::Current(); + const char* old_cause = self->StartAssertNoThreadSuspension("ImageWriter"); + gc::Heap* heap = Runtime::Current()->GetHeap(); + // TODO: Image spaces only? + WriterMutexLock mu(self, *Locks::heap_bitmap_lock_); + heap->FlushAllocStack(); + heap->GetLiveBitmap()->Walk(FindClinitImageClassesCallback, this); + self->EndAssertNoThreadSuspension(old_cause); + } } void CompilerDriver::RecordClassStatus(ClassReference ref, CompiledClass* compiled_class) { @@ -1436,12 +1435,18 @@ static bool SkipClass(mirror::ClassLoader* class_loader, return true; } -static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manager, size_t class_def_index) +static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manager, + size_t class_def_index) LOCKS_EXCLUDED(Locks::mutator_lock_) { ScopedObjectAccess soa(Thread::Current()); mirror::ClassLoader* class_loader = soa.Decode(manager->GetClassLoader()); const DexFile& dex_file = *manager->GetDexFile(); + // If an instance field is final then we need to have a barrier on the return, static final + // fields are assigned within the lock held for class initialization. Conservatively assume + // constructor barriers are always required. + bool requires_constructor_barrier = true; + // Method and Field are the worst. We can't resolve without either // context from the code use (to disambiguate virtual vs direct // method and instance vs static field) or from class @@ -1450,72 +1455,89 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag // definitions, since many of them many never be referenced by // generated code. const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index); - if (SkipClass(class_loader, dex_file, class_def)) { - return; - } - - // Note the class_data pointer advances through the headers, - // static fields, instance fields, direct methods, and virtual - // methods. - const byte* class_data = dex_file.GetClassData(class_def); - if (class_data == NULL) { - // empty class such as a marker interface - return; - } - Thread* self = Thread::Current(); - ClassLinker* class_linker = manager->GetClassLinker(); - mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file); - ClassDataItemIterator it(dex_file, class_data); - while (it.HasNextStaticField()) { - mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, - class_loader, true); - if (field == NULL) { - CHECK(self->IsExceptionPending()); - self->ClearException(); - } - it.Next(); - } - // If an instance field is final then we need to have a barrier on the return, static final - // fields are assigned within the lock held for class initialization. - bool requires_constructor_barrier = false; - while (it.HasNextInstanceField()) { - if ((it.GetMemberAccessFlags() & kAccFinal) != 0) { - requires_constructor_barrier = true; - } - - mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), dex_cache, - class_loader, false); - if (field == NULL) { - CHECK(self->IsExceptionPending()); - self->ClearException(); + if (!SkipClass(class_loader, dex_file, class_def)) { + // Note the class_data pointer advances through the headers, + // static fields, instance fields, direct methods, and virtual + // methods. + const byte* class_data = dex_file.GetClassData(class_def); + if (class_data == NULL) { + // Empty class such as a marker interface. + requires_constructor_barrier = false; + } else { + ClassLinker* class_linker = manager->GetClassLinker(); + mirror::DexCache* dex_cache = class_linker->FindDexCache(dex_file); + + // Resolve the class. + mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache, + class_loader); + + bool resolve_fields_and_methods; + if (klass == NULL) { + // Class couldn't be resolved, for example, super-class is in a different dex file. Don't + // attempt to resolve methods and fields when there is no declaring class. + CHECK(soa.Self()->IsExceptionPending()); + Thread::Current()->ClearException(); + resolve_fields_and_methods = false; + } else { + resolve_fields_and_methods = manager->GetCompiler()->IsImage(); + } + ClassDataItemIterator it(dex_file, class_data); + while (it.HasNextStaticField()) { + if (resolve_fields_and_methods) { + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), + dex_cache, class_loader, true); + if (field == NULL) { + CHECK(soa.Self()->IsExceptionPending()); + soa.Self()->ClearException(); + } + } + it.Next(); + } + // We require a constructor barrier if there are final instance fields. + requires_constructor_barrier = false; + while (it.HasNextInstanceField()) { + if ((it.GetMemberAccessFlags() & kAccFinal) != 0) { + requires_constructor_barrier = true; + } + if (resolve_fields_and_methods) { + mirror::ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(), + dex_cache, class_loader, false); + if (field == NULL) { + CHECK(soa.Self()->IsExceptionPending()); + soa.Self()->ClearException(); + } + } + it.Next(); + } + if (resolve_fields_and_methods) { + while (it.HasNextDirectMethod()) { + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + dex_cache, class_loader, NULL, + it.GetMethodInvokeType(class_def)); + if (method == NULL) { + CHECK(soa.Self()->IsExceptionPending()); + soa.Self()->ClearException(); + } + it.Next(); + } + while (it.HasNextVirtualMethod()) { + mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), + dex_cache, class_loader, NULL, + it.GetMethodInvokeType(class_def)); + if (method == NULL) { + CHECK(soa.Self()->IsExceptionPending()); + soa.Self()->ClearException(); + } + it.Next(); + } + DCHECK(!it.HasNext()); + } } - it.Next(); } if (requires_constructor_barrier) { manager->GetCompiler()->AddRequiresConstructorBarrier(soa.Self(), manager->GetDexFile(), class_def_index); } - while (it.HasNextDirectMethod()) { - mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), - dex_cache, class_loader, NULL, - it.GetMethodInvokeType(class_def)); - if (method == NULL) { - CHECK(self->IsExceptionPending()); - self->ClearException(); - } - it.Next(); - } - while (it.HasNextVirtualMethod()) { - mirror::ArtMethod* method = class_linker->ResolveMethod(dex_file, it.GetMemberIndex(), - dex_cache, class_loader, NULL, - it.GetMethodInvokeType(class_def)); - if (method == NULL) { - CHECK(self->IsExceptionPending()); - self->ClearException(); - } - it.Next(); - } - DCHECK(!it.HasNext()); } static void ResolveType(const ParallelCompilationManager* manager, size_t type_idx) @@ -1541,10 +1563,16 @@ void CompilerDriver::ResolveDexFile(jobject class_loader, const DexFile& dex_fil // TODO: we could resolve strings here, although the string table is largely filled with class // and method names. - timings.NewSplit(strdup(("Resolve " + dex_file.GetLocation() + " Types").c_str())); ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, thread_pool); - context.ForAll(0, dex_file.NumTypeIds(), ResolveType, thread_count_); + if (IsImage()) { + // For images we resolve all types, such as array, whereas for applications just those with + // classdefs are resolved by ResolveClassFieldsAndMethods. + // TODO: strdup memory leak. + timings.NewSplit(strdup(("Resolve " + dex_file.GetLocation() + " Types").c_str())); + context.ForAll(0, dex_file.NumTypeIds(), ResolveType, thread_count_); + } + // TODO: strdup memory leak. timings.NewSplit(strdup(("Resolve " + dex_file.GetLocation() + " MethodsAndFields").c_str())); context.ForAll(0, dex_file.NumClassDefs(), ResolveClassFieldsAndMethods, thread_count_); } @@ -1567,7 +1595,8 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor, soa.Decode(manager->GetClassLoader())); - if (klass == NULL) { CHECK(soa.Self()->IsExceptionPending()); + if (klass == NULL) { + CHECK(soa.Self()->IsExceptionPending()); soa.Self()->ClearException(); /* @@ -1587,25 +1616,25 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ << PrettyDescriptor(manager->GetDexFile()->GetClassDescriptor(class_def)) << " because: " << error_msg; } - return; - } - CHECK(klass->IsResolved()) << PrettyClass(klass); - manager->GetClassLinker()->VerifyClass(klass); - - if (klass->IsErroneous()) { - // ClassLinker::VerifyClass throws, which isn't useful in the compiler. - CHECK(soa.Self()->IsExceptionPending()); - soa.Self()->ClearException(); - } + } else { + CHECK(klass->IsResolved()) << PrettyClass(klass); + manager->GetClassLinker()->VerifyClass(klass); + if (klass->IsErroneous()) { + // ClassLinker::VerifyClass throws, which isn't useful in the compiler. + CHECK(soa.Self()->IsExceptionPending()); + soa.Self()->ClearException(); + } - CHECK(klass->IsCompileTimeVerified() || klass->IsErroneous()) - << PrettyDescriptor(klass) << ": state=" << klass->GetStatus(); + CHECK(klass->IsCompileTimeVerified() || klass->IsErroneous()) + << PrettyDescriptor(klass) << ": state=" << klass->GetStatus(); + } soa.Self()->AssertNoPendingException(); } void CompilerDriver::VerifyDexFile(jobject class_loader, const DexFile& dex_file, ThreadPool& thread_pool, base::TimingLogger& timings) { + // TODO: strdup memory leak. timings.NewSplit(strdup(("Verify " + dex_file.GetLocation()).c_str())); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, thread_pool); @@ -2032,23 +2061,20 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl mirror::ClassLoader* class_loader = soa.Decode(manager->GetClassLoader()); const char* descriptor = manager->GetDexFile()->GetClassDescriptor(class_def); mirror::Class* klass = manager->GetClassLinker()->FindClass(descriptor, class_loader); - bool compiling_boot = Runtime::Current()->GetHeap()->GetContinuousSpaces().size() == 1; - bool can_init_static_fields = compiling_boot && - manager->GetCompiler()->IsImageClass(descriptor); if (klass != NULL) { - // We don't want class initialization occurring on multiple threads due to deadlock problems. - // For example, a parent class is initialized (holding its lock) that refers to a sub-class - // in its static/class initializer causing it to try to acquire the sub-class' lock. While - // on a second thread the sub-class is initialized (holding its lock) after first initializing - // its parents, whose locks are acquired. This leads to a parent-to-child and a child-to-parent - // lock ordering and consequent potential deadlock. - // We need to use an ObjectLock due to potential suspension in the interpreting code. Rather - // than use a special Object for the purpose we use the Class of java.lang.Class. - ObjectLock lock1(soa.Self(), klass->GetClass()); - // The lock required to initialize the class. - ObjectLock lock2(soa.Self(), klass); // Only try to initialize classes that were successfully verified. if (klass->IsVerified()) { + // We don't want class initialization occurring on multiple threads due to deadlock problems. + // For example, a parent class is initialized (holding its lock) that refers to a sub-class + // in its static/class initializer causing it to try to acquire the sub-class' lock. While + // on a second thread the sub-class is initialized (holding its lock) after first initializing + // its parents, whose locks are acquired. This leads to a parent-to-child and a child-to-parent + // lock ordering and consequent potential deadlock. + // We need to use an ObjectLock due to potential suspension in the interpreting code. Rather + // than use a special Object for the purpose we use the Class of java.lang.Class. + ObjectLock lock(soa.Self(), klass->GetClass()); + bool can_init_static_fields = manager->GetCompiler()->IsImage() && + manager->GetCompiler()->IsImageClass(descriptor); manager->GetClassLinker()->EnsureInitialized(klass, false, can_init_static_fields); if (soa.Self()->IsExceptionPending()) { soa.Self()->GetException(NULL)->Dump(); @@ -2069,6 +2095,7 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl VLOG(compiler) << "Initializing: " << descriptor; if (StringPiece(descriptor) == "Ljava/lang/Void;") { // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. + ObjectLock lock(soa.Self(), klass); mirror::ObjectArray* fields = klass->GetSFields(); CHECK_EQ(fields->GetLength(), 1); fields->Get(0)->SetObj(klass, manager->GetClassLinker()->FindPrimitiveClass('V')); @@ -2102,11 +2129,15 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl void CompilerDriver::InitializeClasses(jobject jni_class_loader, const DexFile& dex_file, ThreadPool& thread_pool, base::TimingLogger& timings) { + // TODO: strdup memory leak. timings.NewSplit(strdup(("InitializeNoClinit " + dex_file.GetLocation()).c_str())); #ifndef NDEBUG - for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) { - const char* descriptor = class_initializer_black_list[i]; - CHECK(IsValidDescriptor(descriptor)) << descriptor; + // Sanity check blacklist descriptors. + if (IsImage()) { + for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) { + const char* descriptor = class_initializer_black_list[i]; + CHECK(IsValidDescriptor(descriptor)) << descriptor; + } } #endif ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 21a44eaf12..bcde178b76 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -110,6 +110,7 @@ class CompilerDriver { return compiler_backend_; } + // Are we compiling and creating an image file? bool IsImage() const { return image_; } diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index ceb6bf6d80..89552a375e 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -825,6 +825,7 @@ static int dex2oat(int argc, char** argv) { return EXIT_FAILURE; } + timings.StartSplit("dex2oat Setup"); LOG(INFO) << "dex2oat: " << oat_location; Runtime::Options options; @@ -926,7 +927,6 @@ static int dex2oat(int argc, char** argv) { } } - timings.StartSplit("dex2oat Setup"); UniquePtr compiler(dex2oat->CreateOatFile(boot_image_option, host_prefix.get(), android_root, diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index d0b8bbdbe6..b4c767dd0a 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2311,8 +2311,9 @@ void ClassLinker::VerifyClass(mirror::Class* klass) { mirror::Class::Status oat_file_class_status(mirror::Class::kStatusNotReady); bool preverified = VerifyClassUsingOatFile(dex_file, klass, oat_file_class_status); if (oat_file_class_status == mirror::Class::kStatusError) { - LOG(WARNING) << "Skipping runtime verification of erroneous class " << PrettyDescriptor(klass) - << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8(); + VLOG(class_linker) << "Skipping runtime verification of erroneous class " + << PrettyDescriptor(klass) << " in " + << klass->GetDexCache()->GetLocation()->ToModifiedUtf8(); ThrowVerifyError(klass, "Rejecting class %s because it failed compile-time verification", PrettyDescriptor(klass).c_str()); klass->SetStatus(mirror::Class::kStatusError); @@ -2326,7 +2327,7 @@ void ClassLinker::VerifyClass(mirror::Class* klass) { } if (preverified || verifier_failure != verifier::MethodVerifier::kHardFailure) { if (!preverified && verifier_failure != verifier::MethodVerifier::kNoFailure) { - LOG(WARNING) << "Soft verification failure in class " << PrettyDescriptor(klass) + VLOG(class_linker) << "Soft verification failure in class " << PrettyDescriptor(klass) << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8() << " because: " << error_msg; } @@ -2722,14 +2723,6 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo } clinit = klass->FindDeclaredDirectMethod("", "()V"); - if (clinit != NULL && !can_run_clinit) { - // if the class has a but we can't run it during compilation, - // don't bother going to kStatusInitializing. We return false so that - // sub-classes don't believe this class is initialized. - // Opportunistically link non-static methods, TODO: don't initialize and dirty pages - // in second pass. - return false; - } // If the class is kStatusInitializing, either this thread is // initializing higher up the stack or another thread has beat us @@ -2775,9 +2768,9 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo return false; } - bool has_static_field_initializers = InitializeStaticFields(klass); + bool has_static_field_initializers = InitializeStaticFields(klass, can_init_statics); - if (clinit != NULL) { + if (clinit != NULL && can_run_clinit) { if (Runtime::Current()->IsStarted()) { JValue result; clinit->Invoke(self, NULL, 0, &result, 'V'); @@ -2786,7 +2779,11 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo } } - FixupStaticTrampolines(klass); + // Opportunistically set static method trampolines to their destiniation. Unless initialization + // is being hindered at compile time. + if (can_init_statics || can_run_clinit || (!has_static_field_initializers && clinit == NULL)) { + FixupStaticTrampolines(klass); + } uint64_t t1 = NanoTime(); @@ -2805,15 +2802,15 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo ++thread_stats->class_init_count; global_stats->class_init_time_ns += (t1 - t0); thread_stats->class_init_time_ns += (t1 - t0); - // Set the class as initialized except if we can't initialize static fields and static field - // initialization is necessary. - if (!can_init_statics && has_static_field_initializers) { - klass->SetStatus(mirror::Class::kStatusVerified); // Don't leave class in initializing state. + // Set the class as initialized except if failed to initialize static fields. + if ((!can_init_statics && has_static_field_initializers) || + (!can_run_clinit && clinit != NULL)) { + klass->SetStatus(mirror::Class::kStatusVerified); success = false; } else { klass->SetStatus(mirror::Class::kStatusInitialized); } - if (VLOG_IS_ON(class_linker)) { + if (success && VLOG_IS_ON(class_linker)) { ClassHelper kh(klass); LOG(INFO) << "Initialized class " << kh.GetDescriptor() << " from " << kh.GetLocation(); } @@ -2986,10 +2983,9 @@ bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool return true; } - Thread* self = Thread::Current(); - ScopedThreadStateChange tsc(self, kRunnable); bool success = InitializeClass(c, can_run_clinit, can_init_fields); if (!success) { + Thread* self = Thread::Current(); CHECK(self->IsExceptionPending() || !can_run_clinit) << PrettyClass(c); } return success; @@ -3005,7 +3001,7 @@ void ClassLinker::ConstructFieldMap(const DexFile& dex_file, const DexFile::Clas } } -bool ClassLinker::InitializeStaticFields(mirror::Class* klass) { +bool ClassLinker::InitializeStaticFields(mirror::Class* klass, bool can_init_statics) { size_t num_static_fields = klass->NumStaticFields(); if (num_static_fields == 0) { return false; @@ -3022,16 +3018,19 @@ bool ClassLinker::InitializeStaticFields(mirror::Class* klass) { EncodedStaticFieldValueIterator it(dex_file, dex_cache, klass->GetClassLoader(), this, *dex_class_def); - if (it.HasNext()) { - // We reordered the fields, so we need to be able to map the field indexes to the right fields. - SafeMap field_map; - ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); - for (size_t i = 0; it.HasNext(); i++, it.Next()) { - it.ReadValueToField(field_map.Get(i)); + if (!it.HasNext()) { + return false; + } else { + if (can_init_statics) { + // We reordered the fields, so we need to be able to map the field indexes to the right fields. + SafeMap field_map; + ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); + for (size_t i = 0; it.HasNext(); i++, it.Next()) { + it.ReadValueToField(field_map.Get(i)); + } } return true; } - return false; } bool ClassLinker::LinkClass(SirtRef& klass, diff --git a/runtime/class_linker.h b/runtime/class_linker.h index d0cc562ca5..fdf17a25ee 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -443,7 +443,7 @@ class ClassLinker { bool InitializeSuperClass(mirror::Class* klass, bool can_run_clinit, bool can_init_fields) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Initialize static fields, returns true if fields were initialized. - bool InitializeStaticFields(mirror::Class* klass) + bool InitializeStaticFields(mirror::Class* klass, bool can_init_statics) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsSameDescriptorInDifferentClassContexts(const char* descriptor, -- cgit v1.2.3-59-g8ed1b From 8f3c9ae38df2460940a26dff889a84430b6c38d3 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 20 Aug 2013 17:26:41 -0700 Subject: Don't allow class status to go backward except for error. Allow greater parallelism of initialization. Bug 10393546. Change-Id: Ic194ed490bb0a986250c09fcf335eb1be9714657 --- compiler/driver/compiler_driver.cc | 126 +++++++++++-------- compiler/driver/compiler_driver.h | 5 +- runtime/class_linker.cc | 247 ++++++++++++++++++++----------------- runtime/class_linker.h | 7 +- runtime/exception_test.cc | 2 +- runtime/mirror/class.cc | 17 ++- 6 files changed, 226 insertions(+), 178 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index bf541c6e04..d265ed1c0d 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -758,11 +758,6 @@ void CompilerDriver::UpdateImageClasses(base::TimingLogger& timings) { } } -void CompilerDriver::RecordClassStatus(ClassReference ref, CompiledClass* compiled_class) { - MutexLock mu(Thread::Current(), CompilerDriver::compiled_classes_lock_); - compiled_classes_.Put(ref, compiled_class); -} - bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx) { if (IsImage() && IsImageClass(dex_file.GetTypeDescriptor(dex_file.GetTypeId(type_idx)))) { @@ -1428,6 +1423,7 @@ static bool SkipClass(ClassLinker* class_linker, jobject class_loader, const Dex static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manager, size_t class_def_index) LOCKS_EXCLUDED(Locks::mutator_lock_) { + ATRACE_CALL(); Thread* self = Thread::Current(); jobject jclass_loader = manager->GetClassLoader(); const DexFile& dex_file = *manager->GetDexFile(); @@ -2048,6 +2044,7 @@ static const char* class_initializer_black_list[] = { static void InitializeClass(const ParallelCompilationManager* manager, size_t class_def_index) LOCKS_EXCLUDED(Locks::mutator_lock_) { + ATRACE_CALL(); const DexFile::ClassDef& class_def = manager->GetDexFile()->GetClassDef(class_def_index); ScopedObjectAccess soa(Thread::Current()); mirror::ClassLoader* class_loader = soa.Decode(manager->GetClassLoader()); @@ -2056,48 +2053,54 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl if (klass != NULL) { // Only try to initialize classes that were successfully verified. if (klass->IsVerified()) { - // We don't want class initialization occurring on multiple threads due to deadlock problems. - // For example, a parent class is initialized (holding its lock) that refers to a sub-class - // in its static/class initializer causing it to try to acquire the sub-class' lock. While - // on a second thread the sub-class is initialized (holding its lock) after first initializing - // its parents, whose locks are acquired. This leads to a parent-to-child and a child-to-parent - // lock ordering and consequent potential deadlock. - // We need to use an ObjectLock due to potential suspension in the interpreting code. Rather - // than use a special Object for the purpose we use the Class of java.lang.Class. - ObjectLock lock(soa.Self(), klass->GetClass()); - bool can_init_static_fields = manager->GetCompiler()->IsImage() && - manager->GetCompiler()->IsImageClass(descriptor); - manager->GetClassLinker()->EnsureInitialized(klass, false, can_init_static_fields); - if (soa.Self()->IsExceptionPending()) { - soa.Self()->GetException(NULL)->Dump(); - } + // Attempt to initialize the class but bail if we either need to initialize the super-class + // or static fields. + manager->GetClassLinker()->EnsureInitialized(klass, false, false); if (!klass->IsInitialized()) { - if (can_init_static_fields) { - // NoPreloadHolder inner class implies this should not be initialized early. - bool is_black_listed = StringPiece(descriptor).ends_with("$NoPreloadHolder;"); - if (!is_black_listed) { - for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) { - if (StringPiece(descriptor) == class_initializer_black_list[i]) { - is_black_listed = true; - break; + // We don't want non-trivial class initialization occurring on multiple threads due to + // deadlock problems. For example, a parent class is initialized (holding its lock) that + // refers to a sub-class in its static/class initializer causing it to try to acquire the + // sub-class' lock. While on a second thread the sub-class is initialized (holding its lock) + // after first initializing its parents, whose locks are acquired. This leads to a + // parent-to-child and a child-to-parent lock ordering and consequent potential deadlock. + // We need to use an ObjectLock due to potential suspension in the interpreting code. Rather + // than use a special Object for the purpose we use the Class of java.lang.Class. + ObjectLock lock(soa.Self(), klass->GetClass()); + // Attempt to initialize allowing initialization of parent classes but still not static + // fields. + manager->GetClassLinker()->EnsureInitialized(klass, false, true); + if (!klass->IsInitialized()) { + // We need to initialize static fields, we only do this for image classes that aren't + // black listed or marked with the $NoPreloadHolder. + bool can_init_static_fields = manager->GetCompiler()->IsImage() && + manager->GetCompiler()->IsImageClass(descriptor); + if (can_init_static_fields) { + // NoPreloadHolder inner class implies this should not be initialized early. + bool is_black_listed = StringPiece(descriptor).ends_with("$NoPreloadHolder;"); + if (!is_black_listed) { + for (size_t i = 0; i < arraysize(class_initializer_black_list); ++i) { + if (StringPiece(descriptor) == class_initializer_black_list[i]) { + is_black_listed = true; + break; + } } } - } - if (!is_black_listed) { - VLOG(compiler) << "Initializing: " << descriptor; - if (StringPiece(descriptor) == "Ljava/lang/Void;") { - // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. - ObjectLock lock(soa.Self(), klass); - mirror::ObjectArray* fields = klass->GetSFields(); - CHECK_EQ(fields->GetLength(), 1); - fields->Get(0)->SetObj(klass, manager->GetClassLinker()->FindPrimitiveClass('V')); - klass->SetStatus(mirror::Class::kStatusInitialized); - } else { - manager->GetClassLinker()->EnsureInitialized(klass, true, can_init_static_fields); + if (!is_black_listed) { + VLOG(compiler) << "Initializing: " << descriptor; + if (StringPiece(descriptor) == "Ljava/lang/Void;") { + // Hand initialize j.l.Void to avoid Dex file operations in un-started runtime. + ObjectLock lock(soa.Self(), klass); + mirror::ObjectArray* fields = klass->GetSFields(); + CHECK_EQ(fields->GetLength(), 1); + fields->Get(0)->SetObj(klass, manager->GetClassLinker()->FindPrimitiveClass('V')); + klass->SetStatus(mirror::Class::kStatusInitialized); + } else { + manager->GetClassLinker()->EnsureInitialized(klass, true, true); + } } - soa.Self()->AssertNoPendingException(); } } + soa.Self()->AssertNoPendingException(); } // If successfully initialized place in SSB array. if (klass->IsInitialized()) { @@ -2105,15 +2108,8 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl } } // Record the final class status if necessary. - mirror::Class::Status status = klass->GetStatus(); ClassReference ref(manager->GetDexFile(), class_def_index); - CompiledClass* compiled_class = manager->GetCompiler()->GetCompiledClass(ref); - if (compiled_class == NULL) { - compiled_class = new CompiledClass(status); - manager->GetCompiler()->RecordClassStatus(ref, compiled_class); - } else { - DCHECK_GE(status, compiled_class->GetStatus()) << descriptor; - } + manager->GetCompiler()->RecordClassStatus(ref, klass->GetStatus()); } // Clear any class not found or verification exceptions. soa.Self()->ClearException(); @@ -2288,7 +2284,7 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t Thread* self = Thread::Current(); if (compiled_method != NULL) { MethodReference ref(&dex_file, method_idx); - CHECK(GetCompiledMethod(ref) == NULL) << PrettyMethod(method_idx, dex_file); + DCHECK(GetCompiledMethod(ref) == NULL) << PrettyMethod(method_idx, dex_file); { MutexLock mu(self, compiled_methods_lock_); compiled_methods_.Put(ref, compiled_method); @@ -2313,6 +2309,32 @@ CompiledClass* CompilerDriver::GetCompiledClass(ClassReference ref) const { return it->second; } +void CompilerDriver::RecordClassStatus(ClassReference ref, mirror::Class::Status status) { + MutexLock mu(Thread::Current(), compiled_classes_lock_); + auto it = compiled_classes_.find(ref); + if (it == compiled_classes_.end() || it->second->GetStatus() != status) { + // An entry doesn't exist or the status is lower than the new status. + if (it != compiled_classes_.end()) { + CHECK_GT(status, it->second->GetStatus()); + delete it->second; + } + switch (status) { + case mirror::Class::kStatusNotReady: + case mirror::Class::kStatusError: + case mirror::Class::kStatusRetryVerificationAtRuntime: + case mirror::Class::kStatusVerified: + case mirror::Class::kStatusInitialized: + break; // Expected states. + default: + LOG(FATAL) << "Unexpected class status for class " + << PrettyDescriptor(ref.first->GetClassDescriptor(ref.first->GetClassDef(ref.second))) + << " of " << status; + } + CompiledClass* compiled_class = new CompiledClass(status); + compiled_classes_.Overwrite(ref, compiled_class); + } +} + CompiledMethod* CompilerDriver::GetCompiledMethod(MethodReference ref) const { MutexLock mu(Thread::Current(), compiled_methods_lock_); MethodTable::const_iterator it = compiled_methods_.find(ref); @@ -2335,13 +2357,13 @@ void CompilerDriver::SetBitcodeFileName(std::string const& filename) { void CompilerDriver::AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index) { - MutexLock mu(self, freezing_constructor_lock_); + WriterMutexLock mu(self, freezing_constructor_lock_); freezing_constructor_classes_.insert(ClassReference(dex_file, class_def_index)); } bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index) { - MutexLock mu(self, freezing_constructor_lock_); + ReaderMutexLock mu(self, freezing_constructor_lock_); return freezing_constructor_classes_.count(ClassReference(dex_file, class_def_index)) != 0; } diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index bcde178b76..22a510b86b 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -296,7 +296,8 @@ class CompilerDriver { // Checks if class specified by type_idx is one of the image_classes_ bool IsImageClass(const char* descriptor) const; - void RecordClassStatus(ClassReference ref, CompiledClass* compiled_class); + void RecordClassStatus(ClassReference ref, mirror::Class::Status status) + LOCKS_EXCLUDED(compiled_classes_lock_); private: // Compute constant code and method pointers when possible @@ -362,7 +363,7 @@ class CompilerDriver { InstructionSet instruction_set_; // All class references that require - mutable Mutex freezing_constructor_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + mutable ReaderWriterMutex freezing_constructor_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; std::set freezing_constructor_classes_ GUARDED_BY(freezing_constructor_lock_); typedef SafeMap ClassTable; diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 0110b366d6..96c74203e6 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -782,8 +782,10 @@ class ScopedFlock { } ~ScopedFlock() { - int flock_result = TEMP_FAILURE_RETRY(flock(file_->Fd(), LOCK_UN)); - CHECK_EQ(0, flock_result); + if (file_.get() != NULL) { + int flock_result = TEMP_FAILURE_RETRY(flock(file_->Fd(), LOCK_UN)); + CHECK_EQ(0, flock_result); + } } private: @@ -2284,18 +2286,18 @@ void ClassLinker::VerifyClass(mirror::Class* klass) { } // Verify super class. - mirror::Class* super = klass->GetSuperClass(); - if (super != NULL) { + SirtRef super(self, klass->GetSuperClass()); + if (super.get() != NULL) { // Acquire lock to prevent races on verifying the super class. - ObjectLock lock(self, super); + ObjectLock lock(self, super.get()); if (!super->IsVerified() && !super->IsErroneous()) { - Runtime::Current()->GetClassLinker()->VerifyClass(super); + VerifyClass(super.get()); } if (!super->IsCompileTimeVerified()) { std::string error_msg(StringPrintf("Rejecting class %s that attempts to sub-class erroneous class %s", PrettyDescriptor(klass).c_str(), - PrettyDescriptor(super).c_str())); + PrettyDescriptor(super.get()).c_str())); LOG(ERROR) << error_msg << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8(); SirtRef cause(self, self->GetException(NULL)); if (cause.get() != NULL) { @@ -2339,7 +2341,14 @@ void ClassLinker::VerifyClass(mirror::Class* klass) { // Make sure all classes referenced by catch blocks are resolved. ResolveClassExceptionHandlerTypes(dex_file, klass); if (verifier_failure == verifier::MethodVerifier::kNoFailure) { - klass->SetStatus(mirror::Class::kStatusVerified); + // Even though there were no verifier failures we need to respect whether the super-class + // was verified or requiring runtime reverification. + if (super.get() == NULL || super->IsVerified()) { + klass->SetStatus(mirror::Class::kStatusVerified); + } else { + CHECK_EQ(super->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime); + klass->SetStatus(mirror::Class::kStatusRetryVerificationAtRuntime); + } } else { CHECK_EQ(verifier_failure, verifier::MethodVerifier::kSoftFailure); // Soft failures at compile time should be retried at runtime. Soft @@ -2695,31 +2704,85 @@ static void CheckProxyMethod(mirror::ArtMethod* method, CHECK_EQ(mh.GetReturnType(), mh2.GetReturnType()); } -bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, bool can_init_statics) { - CHECK(klass->IsResolved() || klass->IsErroneous()) - << PrettyClass(klass) << ": state=" << klass->GetStatus(); +static bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics, + bool can_init_parents) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + if (can_init_statics && can_init_statics) { + return true; + } + if (!can_init_statics) { + // Check if there's a class initializer. + mirror::ArtMethod* clinit = klass->FindDeclaredDirectMethod("", "()V"); + if (clinit != NULL) { + return false; + } + // Check if there are encoded static values needing initialization. + if (klass->NumStaticFields() != 0) { + ClassHelper kh(klass); + const DexFile::ClassDef* dex_class_def = kh.GetClassDef(); + DCHECK(dex_class_def != NULL); + if (dex_class_def->static_values_off_ != 0) { + return false; + } + } + } + if (!klass->IsInterface() && klass->HasSuperClass()) { + mirror::Class* super_class = klass->GetSuperClass(); + if (!can_init_parents && !super_class->IsInitialized()) { + return false; + } else { + if (!CanWeInitializeClass(super_class, can_init_statics, true)) { + return false; + } + } + } + return true; +} + +bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_init_statics, + bool can_init_parents) { + // see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol - Thread* self = Thread::Current(); + // Are we already initialized and therefore done? + // Note: we differ from the JLS here as we don't do this under the lock, this is benign as + // an initialized class will never change its state. + if (klass->IsInitialized()) { + return true; + } + + // Fast fail if initialization requires a full runtime. Not part of the JLS. + if (!CanWeInitializeClass(klass, can_init_statics, can_init_parents)) { + return false; + } + Thread* self = Thread::Current(); + uint64_t t0; { - // see JLS 3rd edition, 12.4.2 "Detailed Initialization Procedure" for the locking protocol ObjectLock lock(self, klass); - if (klass->GetStatus() == mirror::Class::kStatusInitialized) { + // Re-check under the lock in case another thread initialized ahead of us. + if (klass->IsInitialized()) { return true; } + // Was the class already found to be erroneous? Done under the lock to match the JLS. if (klass->IsErroneous()) { ThrowEarlierClassFailure(klass); return false; } - if (klass->GetStatus() == mirror::Class::kStatusResolved || - klass->GetStatus() == mirror::Class::kStatusRetryVerificationAtRuntime) { + CHECK(klass->IsResolved()) << PrettyClass(klass) << ": state=" << klass->GetStatus(); + + if (!klass->IsVerified()) { VerifyClass(klass); - if (klass->GetStatus() != mirror::Class::kStatusVerified) { - if (klass->GetStatus() == mirror::Class::kStatusError) { + if (!klass->IsVerified()) { + // We failed to verify, expect either the klass to be erroneous or verification failed at + // compile time. + if (klass->IsErroneous()) { CHECK(self->IsExceptionPending()); + } else { + CHECK(Runtime::Current()->IsCompiler()); + CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime); } return false; } @@ -2742,38 +2805,65 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo if (!ValidateSuperClassDescriptors(klass)) { klass->SetStatus(mirror::Class::kStatusError); - lock.NotifyAll(); return false; } - DCHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass); + CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass); + // From here out other threads may observe that we're initializing and so changes of state + // require the a notification. klass->SetClinitThreadId(self->GetTid()); klass->SetStatus(mirror::Class::kStatusInitializing); - } - uint64_t t0 = NanoTime(); + t0 = NanoTime(); + } - if (!InitializeSuperClass(klass, can_run_clinit, can_init_statics)) { - // Super class initialization failed, this can be because we can't run - // super-class class initializers in which case we'll be verified. - // Otherwise this class is erroneous. - if (!can_run_clinit) { - CHECK(klass->IsVerified()); - } else { - CHECK(klass->IsErroneous()); + // Initialize super classes, must be done will initializing for the JLS. + if (!klass->IsInterface() && klass->HasSuperClass()) { + mirror::Class* super_class = klass->GetSuperClass(); + if (!super_class->IsInitialized()) { + CHECK(!super_class->IsInterface()); + CHECK(can_init_parents); + bool super_initialized = InitializeClass(super_class, can_init_statics, true); + if (!super_initialized) { + // The super class was verified ahead of entering initializing, we should only be here if + // the super class became erroneous due to initialization. + CHECK(super_class->IsErroneous() && self->IsExceptionPending()) + << "Super class initialization failed for " << PrettyDescriptor(super_class) + << " that has unexpected status " << super_class->GetStatus() + << "\nPending exception:\n" + << (self->GetException(NULL) != NULL ? self->GetException(NULL)->Dump() : ""); + ObjectLock lock(self, klass); + // Initialization failed because the super-class is erroneous. + klass->SetStatus(mirror::Class::kStatusError); + lock.NotifyAll(); + return false; + } } - // Signal to any waiting threads that saw this class as initializing. - ObjectLock lock(self, klass); - lock.NotifyAll(); - return false; } - bool has_static_field_initializers = InitializeStaticFields(klass, can_init_statics); + if (klass->NumStaticFields() > 0) { + ClassHelper kh(klass); + const DexFile::ClassDef* dex_class_def = kh.GetClassDef(); + CHECK(dex_class_def != NULL); + const DexFile& dex_file = kh.GetDexFile(); + EncodedStaticFieldValueIterator it(dex_file, kh.GetDexCache(), klass->GetClassLoader(), + this, *dex_class_def); + if (it.HasNext()) { + CHECK(can_init_statics); + // We reordered the fields, so we need to be able to map the field indexes to the right fields. + SafeMap field_map; + ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); + for (size_t i = 0; it.HasNext(); i++, it.Next()) { + it.ReadValueToField(field_map.Get(i)); + } + } + } mirror::ArtMethod* clinit = klass->FindDeclaredDirectMethod("", "()V"); - if (clinit != NULL && can_run_clinit) { - if (Runtime::Current()->IsStarted()) { + if (clinit != NULL) { + CHECK(can_init_statics); + if (LIKELY(Runtime::Current()->IsStarted())) { JValue result; clinit->Invoke(self, NULL, 0, &result, 'V'); } else { @@ -2781,11 +2871,8 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo } } - // Opportunistically set static method trampolines to their destination. Unless initialization - // is being hindered at compile time. - if (can_init_statics || can_run_clinit || (!has_static_field_initializers && clinit == NULL)) { - FixupStaticTrampolines(klass); - } + // Opportunistically set static method trampolines to their destination. + FixupStaticTrampolines(klass); uint64_t t1 = NanoTime(); @@ -2805,14 +2892,8 @@ bool ClassLinker::InitializeClass(mirror::Class* klass, bool can_run_clinit, boo global_stats->class_init_time_ns += (t1 - t0); thread_stats->class_init_time_ns += (t1 - t0); // Set the class as initialized except if failed to initialize static fields. - if ((!can_init_statics && has_static_field_initializers) || - (!can_run_clinit && clinit != NULL)) { - klass->SetStatus(mirror::Class::kStatusVerified); - success = false; - } else { - klass->SetStatus(mirror::Class::kStatusInitialized); - } - if (success && VLOG_IS_ON(class_linker)) { + klass->SetStatus(mirror::Class::kStatusInitialized); + if (VLOG_IS_ON(class_linker)) { ClassHelper kh(klass); LOG(INFO) << "Initialized class " << kh.GetDescriptor() << " from " << kh.GetLocation(); } @@ -2826,6 +2907,7 @@ bool ClassLinker::WaitForInitializeClass(mirror::Class* klass, Thread* self, Obj SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { while (true) { self->AssertNoPendingException(); + CHECK(!klass->IsInitialized()); lock.WaitIgnoringInterrupts(); // When we wake up, repeat the test for init-in-progress. If @@ -2952,43 +3034,16 @@ bool ClassLinker::IsSameDescriptorInDifferentClassContexts(const char* descripto return found1 == found2; } -bool ClassLinker::InitializeSuperClass(mirror::Class* klass, bool can_run_clinit, bool can_init_fields) { - CHECK(klass != NULL); - if (!klass->IsInterface() && klass->HasSuperClass()) { - mirror::Class* super_class = klass->GetSuperClass(); - if (!super_class->IsInitialized()) { - CHECK(!super_class->IsInterface()); - // Must hold lock on object when initializing and setting status. - Thread* self = Thread::Current(); - ObjectLock lock(self, klass); - bool super_initialized = InitializeClass(super_class, can_run_clinit, can_init_fields); - // TODO: check for a pending exception - if (!super_initialized) { - if (!can_run_clinit) { - // Don't set status to error when we can't run . - CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusInitializing) << PrettyClass(klass); - klass->SetStatus(mirror::Class::kStatusVerified); - return false; - } - klass->SetStatus(mirror::Class::kStatusError); - klass->NotifyAll(self); - return false; - } - } - } - return true; -} - -bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool can_init_fields) { +bool ClassLinker::EnsureInitialized(mirror::Class* c, bool can_init_fields, bool can_init_parents) { DCHECK(c != NULL); if (c->IsInitialized()) { return true; } - bool success = InitializeClass(c, can_run_clinit, can_init_fields); + bool success = InitializeClass(c, can_init_fields, can_init_parents); if (!success) { Thread* self = Thread::Current(); - CHECK(self->IsExceptionPending() || !can_run_clinit) << PrettyClass(c); + CHECK(self->IsExceptionPending() || !can_init_fields || !can_init_parents) << PrettyClass(c); } return success; } @@ -3003,38 +3058,6 @@ void ClassLinker::ConstructFieldMap(const DexFile& dex_file, const DexFile::Clas } } -bool ClassLinker::InitializeStaticFields(mirror::Class* klass, bool can_init_statics) { - size_t num_static_fields = klass->NumStaticFields(); - if (num_static_fields == 0) { - return false; - } - mirror::DexCache* dex_cache = klass->GetDexCache(); - // TODO: this seems like the wrong check. do we really want !IsPrimitive && !IsArray? - if (dex_cache == NULL) { - return false; - } - ClassHelper kh(klass); - const DexFile::ClassDef* dex_class_def = kh.GetClassDef(); - CHECK(dex_class_def != NULL); - const DexFile& dex_file = kh.GetDexFile(); - EncodedStaticFieldValueIterator it(dex_file, dex_cache, klass->GetClassLoader(), - this, *dex_class_def); - - if (!it.HasNext()) { - return false; - } else { - if (can_init_statics) { - // We reordered the fields, so we need to be able to map the field indexes to the right fields. - SafeMap field_map; - ConstructFieldMap(dex_file, *dex_class_def, klass, field_map); - for (size_t i = 0; it.HasNext(); i++, it.Next()) { - it.ReadValueToField(field_map.Get(i)); - } - } - return true; - } -} - bool ClassLinker::LinkClass(SirtRef& klass, mirror::ObjectArray* interfaces) { CHECK_EQ(mirror::Class::kStatusLoaded, klass->GetStatus()); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 624b7cecec..5ef6d8f006 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -437,16 +437,11 @@ class ClassLinker { void RegisterOatFileLocked(const OatFile& oat_file) EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) EXCLUSIVE_LOCKS_REQUIRED(dex_lock_); - bool InitializeClass(mirror::Class* klass, bool can_run_clinit, bool can_init_statics) + bool InitializeClass(mirror::Class* klass, bool can_run_clinit, bool can_init_parents) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool WaitForInitializeClass(mirror::Class* klass, Thread* self, ObjectLock& lock); bool ValidateSuperClassDescriptors(const mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool InitializeSuperClass(mirror::Class* klass, bool can_run_clinit, bool can_init_fields) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Initialize static fields, returns true if fields were initialized. - bool InitializeStaticFields(mirror::Class* klass, bool can_init_statics) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsSameDescriptorInDifferentClassContexts(const char* descriptor, const mirror::Class* klass1, diff --git a/runtime/exception_test.cc b/runtime/exception_test.cc index e48208d771..2e6b0a8f56 100644 --- a/runtime/exception_test.cc +++ b/runtime/exception_test.cc @@ -41,7 +41,7 @@ class ExceptionTest : public CommonTest { soa.Decode(LoadDex("ExceptionHandle"))); my_klass_ = class_linker_->FindClass("LExceptionHandle;", class_loader.get()); ASSERT_TRUE(my_klass_ != NULL); - class_linker_->EnsureInitialized(my_klass_, false, true); + class_linker_->EnsureInitialized(my_klass_, true, true); dex_ = my_klass_->GetDexCache()->GetDexFile(); diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 29025f26c8..19e134fdfe 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -51,14 +51,20 @@ void Class::ResetClass() { } void Class::SetStatus(Status new_status) { - CHECK(new_status > GetStatus() || new_status == kStatusError || !Runtime::Current()->IsStarted()) - << PrettyClass(this) << " " << GetStatus() << " -> " << new_status; - CHECK(sizeof(Status) == sizeof(uint32_t)) << PrettyClass(this); + if (UNLIKELY(new_status <= GetStatus() && new_status != kStatusError)) { + bool class_linker_initialized = Runtime::Current()->GetClassLinker() != nullptr; + if (class_linker_initialized) { + LOG(FATAL) << "Unexpected change back of class status for " << PrettyClass(this) << " " + << GetStatus() << " -> " << new_status; + } + } if (new_status > kStatusResolved) { - CHECK_EQ(GetThinLockId(), Thread::Current()->GetThinLockId()) << PrettyClass(this); + CHECK_EQ(GetThinLockId(), Thread::Current()->GetThinLockId()) + << "Attempt to change status of class while not holding its lock " << PrettyClass(this); } if (new_status == kStatusError) { - CHECK_NE(GetStatus(), kStatusError) << PrettyClass(this); + CHECK_NE(GetStatus(), kStatusError) + << "Attempt to set as erroneous an already erroneous class " << PrettyClass(this); // Stash current exception. Thread* self = Thread::Current(); @@ -96,6 +102,7 @@ void Class::SetStatus(Status new_status) { self->SetException(gc_safe_throw_location, old_exception.get()); } + CHECK(sizeof(Status) == sizeof(uint32_t)) << PrettyClass(this); return SetField32(OFFSET_OF_OBJECT_MEMBER(Class, status_), new_status, false); } -- cgit v1.2.3-59-g8ed1b From f6c4b3ba3825de1dbb3e747a68b809c6cc8eb4db Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Sat, 24 Aug 2013 16:11:37 -0700 Subject: New arena memory allocator. Before we were creating arenas for each method. The issue with doing this is that we needed to memset each memory allocation. This can be improved if you start out with arenas that contain all zeroed memory and recycle them for each method. When you give memory back to the arena pool you do a single memset to zero out all of the memory that you used. Always inlined the fast path of the allocation code. Removed the "zero" parameter since the new arena allocator always returns zeroed memory. Host dex2oat time on target oat apks (2 samples each). Before: real 1m11.958s user 4m34.020s sys 1m28.570s After: real 1m9.690s user 4m17.670s sys 1m23.960s Target device dex2oat samples (Mako, Thinkfree.apk): Without new arena allocator: 0m26.47s real 0m54.60s user 0m25.85s system 0m25.91s real 0m54.39s user 0m26.69s system 0m26.61s real 0m53.77s user 0m27.35s system 0m26.33s real 0m54.90s user 0m25.30s system 0m26.34s real 0m53.94s user 0m27.23s system With new arena allocator: 0m25.02s real 0m54.46s user 0m19.94s system 0m25.17s real 0m55.06s user 0m20.72s system 0m24.85s real 0m55.14s user 0m19.30s system 0m24.59s real 0m54.02s user 0m20.07s system 0m25.06s real 0m55.00s user 0m20.42s system Correctness of Thinkfree.apk.oat verified by diffing both of the oat files. Change-Id: I5ff7b85ffe86c57d3434294ca7a621a695bf57a9 --- compiler/dex/arena_allocator.cc | 213 ++++++++++++++++++------------ compiler/dex/arena_allocator.h | 154 ++++++++++++++------- compiler/dex/arena_bit_vector.cc | 8 +- compiler/dex/arena_bit_vector.h | 6 +- compiler/dex/compiler_ir.h | 3 +- compiler/dex/frontend.cc | 93 +++++++------ compiler/dex/growable_array.h | 12 +- compiler/dex/mir_dataflow.cc | 52 ++++---- compiler/dex/mir_graph.cc | 26 ++-- compiler/dex/mir_graph.h | 4 +- compiler/dex/mir_optimization.cc | 20 ++- compiler/dex/quick/arm/call_arm.cc | 15 +-- compiler/dex/quick/arm/target_arm.cc | 10 +- compiler/dex/quick/codegen_util.cc | 8 +- compiler/dex/quick/local_optimizations.cc | 4 +- compiler/dex/quick/mips/call_mips.cc | 14 +- compiler/dex/quick/mips/target_mips.cc | 10 +- compiler/dex/quick/mir_to_lir-inl.h | 2 +- compiler/dex/quick/mir_to_lir.cc | 4 +- compiler/dex/quick/ralloc_util.cc | 8 +- compiler/dex/quick/x86/call_x86.cc | 10 +- compiler/dex/quick/x86/target_x86.cc | 12 +- compiler/dex/ssa_transformation.cc | 21 ++- compiler/dex/vreg_analysis.cc | 4 +- compiler/driver/compiler_driver.h | 7 + 25 files changed, 405 insertions(+), 315 deletions(-) (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/dex/arena_allocator.cc b/compiler/dex/arena_allocator.cc index 3a3e3858b3..36393e7387 100644 --- a/compiler/dex/arena_allocator.cc +++ b/compiler/dex/arena_allocator.cc @@ -18,9 +18,14 @@ #include "dex_file-inl.h" #include "arena_allocator.h" #include "base/logging.h" +#include "base/mutex.h" namespace art { +// Memmap is a bit slower than malloc according to my measurements. +static constexpr bool kUseMemMap = false; +static constexpr bool kUseMemSet = true && kUseMemMap; + static const char* alloc_names[ArenaAllocator::kNumAllocKinds] = { "Misc ", "BasicBlock ", @@ -37,108 +42,144 @@ static const char* alloc_names[ArenaAllocator::kNumAllocKinds] = { "Preds ", }; -ArenaAllocator::ArenaAllocator(size_t default_size) - : default_size_(default_size), - block_size_(default_size - sizeof(ArenaMemBlock)), - arena_head_(NULL), - current_block_(NULL), - num_arena_blocks_(0), - malloc_bytes_(0), - lost_bytes_(0), - num_allocations_(0) { - memset(&alloc_stats_[0], 0, sizeof(alloc_stats_)); - // Start with an empty arena. - arena_head_ = current_block_ = EmptyArenaBlock(); - num_arena_blocks_++; -} - -ArenaAllocator::~ArenaAllocator() { - // Reclaim all the arena blocks allocated so far. - ArenaMemBlock* head = arena_head_; - while (head != NULL) { - ArenaMemBlock* p = head; - head = head->next; - free(p); +Arena::Arena(size_t size) + : bytes_allocated_(0), + map_(nullptr), + next_(nullptr) { + if (kUseMemMap) { + map_ = MemMap::MapAnonymous("dalvik-arena", NULL, size, PROT_READ | PROT_WRITE); + memory_ = map_->Begin(); + size_ = map_->Size(); + } else { + memory_ = reinterpret_cast(calloc(1, size)); + size_ = size; } - arena_head_ = NULL; - num_arena_blocks_ = 0; } -// Return an arena with no storage for use as a sentinal. -ArenaAllocator::ArenaMemBlock* ArenaAllocator::EmptyArenaBlock() { - ArenaMemBlock* res = static_cast(malloc(sizeof(ArenaMemBlock))); - malloc_bytes_ += sizeof(ArenaMemBlock); - res->block_size = 0; - res->bytes_allocated = 0; - res->next = NULL; - return res; +Arena::~Arena() { + if (kUseMemMap) { + delete map_; + } else { + free(reinterpret_cast(memory_)); + } } -// Arena-based malloc for compilation tasks. -void* ArenaAllocator::NewMem(size_t size, bool zero, ArenaAllocKind kind) { - DCHECK(current_block_ != NULL); - DCHECK(arena_head_ != NULL); - size = (size + 3) & ~3; - alloc_stats_[kind] += size; - ArenaMemBlock* allocation_block = current_block_; // Assume we'll fit. - size_t remaining_space = current_block_->block_size - current_block_->bytes_allocated; - if (remaining_space < size) { - /* - * Time to allocate a new block. If this is a large allocation or we have - * significant space remaining in the current block then fulfill the allocation - * request with a custom-sized malloc() - otherwise grab a new standard block. - */ - size_t allocation_size = sizeof(ArenaMemBlock); - if ((remaining_space >= ARENA_HIGH_WATER) || (size > block_size_)) { - allocation_size += size; +void Arena::Reset() { + if (bytes_allocated_) { + if (kUseMemSet || !kUseMemMap) { + memset(Begin(), 0, bytes_allocated_); } else { - allocation_size += block_size_; - } - ArenaMemBlock *new_block = static_cast(malloc(allocation_size)); - if (new_block == NULL) { - LOG(FATAL) << "Arena allocation failure"; + madvise(Begin(), bytes_allocated_, MADV_DONTNEED); } - malloc_bytes_ += allocation_size; - new_block->block_size = allocation_size - sizeof(ArenaMemBlock); - new_block->bytes_allocated = 0; - new_block->next = NULL; - num_arena_blocks_++; - /* - * If the new block is completely full, insert it into the head of the list so we don't - * bother trying to fit more and won't hide the potentially allocatable space on the - * last (current_block_) block. TUNING: if we move to a mark scheme, revisit - * this code to keep allocation order intact. - */ - if (new_block->block_size == size) { - new_block->next = arena_head_; - arena_head_ = new_block; - } else { - int lost = (current_block_->block_size - current_block_->bytes_allocated); - lost_bytes_ += lost; - current_block_->next = new_block; - current_block_ = new_block; + bytes_allocated_ = 0; + } +} + +ArenaPool::ArenaPool() + : lock_("Arena pool lock"), + free_arenas_(nullptr) { +} + +ArenaPool::~ArenaPool() { + while (free_arenas_ != nullptr) { + auto* arena = free_arenas_; + free_arenas_ = free_arenas_->next_; + delete arena; + } +} + +Arena* ArenaPool::AllocArena(size_t size) { + Thread* self = Thread::Current(); + Arena* ret = nullptr; + { + MutexLock lock(self, lock_); + if (free_arenas_ != nullptr && LIKELY(free_arenas_->Size() >= size)) { + ret = free_arenas_; + free_arenas_ = free_arenas_->next_; } - allocation_block = new_block; } - void* ptr = &allocation_block->ptr[allocation_block->bytes_allocated]; - allocation_block->bytes_allocated += size; - if (zero) { - memset(ptr, 0, size); + if (ret == nullptr) { + ret = new Arena(size); } - num_allocations_++; - return ptr; + ret->Reset(); + return ret; } -// Dump memory usage stats. -void ArenaAllocator::DumpMemStats(std::ostream& os) const { +void ArenaPool::FreeArena(Arena* arena) { + Thread* self = Thread::Current(); + { + MutexLock lock(self, lock_); + arena->next_ = free_arenas_; + free_arenas_ = arena; + } +} + +size_t ArenaAllocator::BytesAllocated() const { size_t total = 0; for (int i = 0; i < kNumAllocKinds; i++) { total += alloc_stats_[i]; } - os << " MEM: used: " << total << ", allocated: " << malloc_bytes_ - << ", lost: " << lost_bytes_ << "\n"; - os << "Number of blocks allocated: " << num_arena_blocks_ << ", Number of allocations: " - << num_allocations_ << ", avg: " << total / num_allocations_ << "\n"; + return total; +} + +ArenaAllocator::ArenaAllocator(ArenaPool* pool) + : pool_(pool), + begin_(nullptr), + end_(nullptr), + ptr_(nullptr), + arena_head_(nullptr), + num_allocations_(0) { + memset(&alloc_stats_[0], 0, sizeof(alloc_stats_)); +} + +void ArenaAllocator::UpdateBytesAllocated() { + if (arena_head_ != nullptr) { + // Update how many bytes we have allocated into the arena so that the arena pool knows how + // much memory to zero out. + arena_head_->bytes_allocated_ = ptr_ - begin_; + } +} + +ArenaAllocator::~ArenaAllocator() { + // Reclaim all the arenas by giving them back to the thread pool. + UpdateBytesAllocated(); + while (arena_head_ != nullptr) { + Arena* arena = arena_head_; + arena_head_ = arena_head_->next_; + pool_->FreeArena(arena); + } +} + +void ArenaAllocator::ObtainNewArenaForAllocation(size_t allocation_size) { + UpdateBytesAllocated(); + Arena* new_arena = pool_->AllocArena(std::max(Arena::kDefaultSize, allocation_size)); + new_arena->next_ = arena_head_; + arena_head_ = new_arena; + // Update our internal data structures. + ptr_ = begin_ = new_arena->Begin(); + end_ = new_arena->End(); +} + +// Dump memory usage stats. +void ArenaAllocator::DumpMemStats(std::ostream& os) const { + size_t malloc_bytes = 0; + // Start out with how many lost bytes we have in the arena we are currently allocating into. + size_t lost_bytes(end_ - ptr_); + size_t num_arenas = 0; + for (Arena* arena = arena_head_; arena != nullptr; arena = arena->next_) { + malloc_bytes += arena->Size(); + if (arena != arena_head_) { + lost_bytes += arena->RemainingSpace(); + } + ++num_arenas; + } + const size_t bytes_allocated = BytesAllocated(); + os << " MEM: used: " << bytes_allocated << ", allocated: " << malloc_bytes + << ", lost: " << lost_bytes << "\n"; + if (num_allocations_ != 0) { + os << "Number of arenas allocated: " << num_arenas << ", Number of allocations: " + << num_allocations_ << ", avg size: " << bytes_allocated / num_allocations_ << "\n"; + } os << "===== Allocation by kind\n"; for (int i = 0; i < kNumAllocKinds; i++) { os << alloc_names[i] << std::setw(10) << alloc_stats_[i] << "\n"; diff --git a/compiler/dex/arena_allocator.h b/compiler/dex/arena_allocator.h index e8e2c027d0..dda52a2ed0 100644 --- a/compiler/dex/arena_allocator.h +++ b/compiler/dex/arena_allocator.h @@ -19,64 +19,126 @@ #include #include + +#include "base/mutex.h" #include "compiler_enums.h" +#include "mem_map.h" namespace art { -#define ARENA_DEFAULT_BLOCK_SIZE (256 * 1024) -#define ARENA_HIGH_WATER (16 * 1024) +class Arena; +class ArenaPool; +class ArenaAllocator; + +class Arena { + public: + static constexpr size_t kDefaultSize = 128 * KB; + explicit Arena(size_t size = kDefaultSize); + ~Arena(); + void Reset(); + uint8_t* Begin() { + return memory_; + } + + uint8_t* End() { + return memory_ + size_; + } + + size_t Size() const { + return size_; + } + + size_t RemainingSpace() const { + return Size() - bytes_allocated_; + } + + private: + size_t bytes_allocated_; + uint8_t* memory_; + size_t size_; + MemMap* map_; + Arena* next_; + friend class ArenaPool; + friend class ArenaAllocator; + DISALLOW_COPY_AND_ASSIGN(Arena); +}; + +class ArenaPool { + public: + ArenaPool(); + ~ArenaPool(); + Arena* AllocArena(size_t size); + void FreeArena(Arena* arena); + + private: + Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + Arena* free_arenas_ GUARDED_BY(lock_); + DISALLOW_COPY_AND_ASSIGN(ArenaPool); +}; class ArenaAllocator { - public: - // Type of allocation for memory tuning. - enum ArenaAllocKind { - kAllocMisc, - kAllocBB, - kAllocLIR, - kAllocMIR, - kAllocDFInfo, - kAllocGrowableArray, - kAllocGrowableBitMap, - kAllocDalvikToSSAMap, - kAllocDebugInfo, - kAllocSuccessor, - kAllocRegAlloc, - kAllocData, - kAllocPredecessors, - kNumAllocKinds - }; - - explicit ArenaAllocator(size_t default_size = ARENA_DEFAULT_BLOCK_SIZE); + public: + // Type of allocation for memory tuning. + enum ArenaAllocKind { + kAllocMisc, + kAllocBB, + kAllocLIR, + kAllocMIR, + kAllocDFInfo, + kAllocGrowableArray, + kAllocGrowableBitMap, + kAllocDalvikToSSAMap, + kAllocDebugInfo, + kAllocSuccessor, + kAllocRegAlloc, + kAllocData, + kAllocPredecessors, + kNumAllocKinds + }; + + static constexpr bool kCountAllocations = false; + + explicit ArenaAllocator(ArenaPool* pool); ~ArenaAllocator(); - void* NewMem(size_t size, bool zero, ArenaAllocKind kind); - size_t BytesAllocated() { - return malloc_bytes_; + + // Returns zeroed memory. + void* Alloc(size_t bytes, ArenaAllocKind kind) ALWAYS_INLINE { + bytes = (bytes + 3) & ~3; + if (UNLIKELY(ptr_ + bytes > end_)) { + // Obtain a new block. + ObtainNewArenaForAllocation(bytes); + if (UNLIKELY(ptr_ == nullptr)) { + return nullptr; + } + } + if (kCountAllocations) { + alloc_stats_[kind] += bytes; + ++num_allocations_; + } + uint8_t* ret = ptr_; + ptr_ += bytes; + return ret; } + void ObtainNewArenaForAllocation(size_t allocation_size); + size_t BytesAllocated() const; void DumpMemStats(std::ostream& os) const; - private: - // Variable-length allocation block. - struct ArenaMemBlock { - size_t block_size; - size_t bytes_allocated; - ArenaMemBlock *next; - char ptr[0]; - }; - - ArenaMemBlock* EmptyArenaBlock(); - - size_t default_size_; // Smallest size of new allocation block. - size_t block_size_; // Amount of allocatable bytes on a default block. - ArenaMemBlock* arena_head_; // Head of linked list of allocation blocks. - ArenaMemBlock* current_block_; // NOTE: code assumes there's always at least 1 block. - int num_arena_blocks_; - uint32_t malloc_bytes_; // Number of actual bytes malloc'd - uint32_t alloc_stats_[kNumAllocKinds]; // Bytes used by various allocation kinds. - uint32_t lost_bytes_; // Lost memory at end of too-small region - uint32_t num_allocations_; -}; // ArenaAllocator + private: + void UpdateBytesAllocated(); + + ArenaPool* pool_; + uint8_t* begin_; + uint8_t* end_; + uint8_t* ptr_; + Arena* arena_head_; + // Statistics. + size_t num_allocations_; + size_t alloc_stats_[kNumAllocKinds]; // Bytes used by various allocation kinds. + + DISALLOW_COPY_AND_ASSIGN(ArenaAllocator); +}; // ArenaAllocator struct MemStats { public: diff --git a/compiler/dex/arena_bit_vector.cc b/compiler/dex/arena_bit_vector.cc index 724fdf81c7..3fa9295276 100644 --- a/compiler/dex/arena_bit_vector.cc +++ b/compiler/dex/arena_bit_vector.cc @@ -35,8 +35,8 @@ ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits, expandable_(expandable), kind_(kind), storage_size_((start_bits + 31) >> 5), - storage_(static_cast(arena_->NewMem(storage_size_ * sizeof(uint32_t), true, - ArenaAllocator::kAllocGrowableBitMap))) { + storage_(static_cast(arena_->Alloc(storage_size_ * sizeof(uint32_t), + ArenaAllocator::kAllocGrowableBitMap))) { DCHECK_EQ(sizeof(storage_[0]), 4U); // Assuming 32-bit units. } @@ -68,8 +68,8 @@ void ArenaBitVector::SetBit(unsigned int num) { unsigned int new_size = (num + 1 + 31) >> 5; DCHECK_GT(new_size, storage_size_); uint32_t *new_storage = - static_cast(arena_->NewMem(new_size * sizeof(uint32_t), false, - ArenaAllocator::kAllocGrowableBitMap)); + static_cast(arena_->Alloc(new_size * sizeof(uint32_t), + ArenaAllocator::kAllocGrowableBitMap)); memcpy(new_storage, storage_, storage_size_ * sizeof(uint32_t)); // Zero out the new storage words. memset(&new_storage[storage_size_], 0, (new_size - storage_size_) * sizeof(uint32_t)); diff --git a/compiler/dex/arena_bit_vector.h b/compiler/dex/arena_bit_vector.h index 4ec8c886ee..8bcd628dc0 100644 --- a/compiler/dex/arena_bit_vector.h +++ b/compiler/dex/arena_bit_vector.h @@ -67,8 +67,8 @@ class ArenaBitVector { } static void* operator new(size_t size, ArenaAllocator* arena) { - return arena->NewMem(sizeof(ArenaBitVector::Iterator), true, - ArenaAllocator::kAllocGrowableBitMap); + return arena->Alloc(sizeof(ArenaBitVector::Iterator), + ArenaAllocator::kAllocGrowableBitMap); }; static void operator delete(void* p) {} // Nop. @@ -84,7 +84,7 @@ class ArenaBitVector { ~ArenaBitVector() {} static void* operator new(size_t size, ArenaAllocator* arena) { - return arena->NewMem(sizeof(ArenaBitVector), true, ArenaAllocator::kAllocGrowableBitMap); + return arena->Alloc(sizeof(ArenaBitVector), ArenaAllocator::kAllocGrowableBitMap); } static void operator delete(void* p) {} // Nop. diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h index a9b5bf68fc..26d0923baa 100644 --- a/compiler/dex/compiler_ir.h +++ b/compiler/dex/compiler_ir.h @@ -43,7 +43,7 @@ class MIRGraph; class Mir2Lir; struct CompilationUnit { - CompilationUnit() + explicit CompilationUnit(ArenaPool* pool) : compiler_driver(NULL), class_linker(NULL), dex_file(NULL), @@ -66,6 +66,7 @@ struct CompilationUnit { num_regs(0), num_compiler_temps(0), compiler_flip_match(false), + arena(pool), mir_graph(NULL), cg(NULL) {} /* diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index d1f7f3e2f4..23036495ce 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -119,30 +119,30 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "..."; ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - UniquePtr cu(new CompilationUnit); + CompilationUnit cu(&compiler.GetArenaPool()); - cu->compiler_driver = &compiler; - cu->class_linker = class_linker; - cu->instruction_set = compiler.GetInstructionSet(); - cu->compiler_backend = compiler_backend; - DCHECK((cu->instruction_set == kThumb2) || - (cu->instruction_set == kX86) || - (cu->instruction_set == kMips)); + cu.compiler_driver = &compiler; + cu.class_linker = class_linker; + cu.instruction_set = compiler.GetInstructionSet(); + cu.compiler_backend = compiler_backend; + DCHECK((cu.instruction_set == kThumb2) || + (cu.instruction_set == kX86) || + (cu.instruction_set == kMips)); /* Adjust this value accordingly once inlining is performed */ - cu->num_dalvik_registers = code_item->registers_size_; + cu.num_dalvik_registers = code_item->registers_size_; // TODO: set this from command line - cu->compiler_flip_match = false; - bool use_match = !cu->compiler_method_match.empty(); - bool match = use_match && (cu->compiler_flip_match ^ - (PrettyMethod(method_idx, dex_file).find(cu->compiler_method_match) != + cu.compiler_flip_match = false; + bool use_match = !cu.compiler_method_match.empty(); + bool match = use_match && (cu.compiler_flip_match ^ + (PrettyMethod(method_idx, dex_file).find(cu.compiler_method_match) != std::string::npos)); if (!use_match || match) { - cu->disable_opt = kCompilerOptimizerDisableFlags; - cu->enable_debug = kCompilerDebugFlags; - cu->verbose = VLOG_IS_ON(compiler) || - (cu->enable_debug & (1 << kDebugVerbose)); + cu.disable_opt = kCompilerOptimizerDisableFlags; + cu.enable_debug = kCompilerDebugFlags; + cu.verbose = VLOG_IS_ON(compiler) || + (cu.enable_debug & (1 << kDebugVerbose)); } /* @@ -152,12 +152,12 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, if (compiler_backend == kPortable) { // Fused long branches not currently usseful in bitcode. - cu->disable_opt |= (1 << kBranchFusing); + cu.disable_opt |= (1 << kBranchFusing); } - if (cu->instruction_set == kMips) { + if (cu.instruction_set == kMips) { // Disable some optimizations for mips for now - cu->disable_opt |= ( + cu.disable_opt |= ( (1 << kLoadStoreElimination) | (1 << kLoadHoisting) | (1 << kSuppressLoads) | @@ -170,72 +170,71 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, (1 << kPromoteCompilerTemps)); } - cu->mir_graph.reset(new MIRGraph(cu.get(), &cu->arena)); + cu.mir_graph.reset(new MIRGraph(&cu, &cu.arena)); /* Gathering opcode stats? */ if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { - cu->mir_graph->EnableOpcodeCounting(); + cu.mir_graph->EnableOpcodeCounting(); } /* Build the raw MIR graph */ - cu->mir_graph->InlineMethod(code_item, access_flags, invoke_type, class_def_idx, method_idx, + cu.mir_graph->InlineMethod(code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); #if !defined(ART_USE_PORTABLE_COMPILER) - if (cu->mir_graph->SkipCompilation(Runtime::Current()->GetCompilerFilter())) { + if (cu.mir_graph->SkipCompilation(Runtime::Current()->GetCompilerFilter())) { return NULL; } #endif /* Do a code layout pass */ - cu->mir_graph->CodeLayout(); + cu.mir_graph->CodeLayout(); /* Perform SSA transformation for the whole method */ - cu->mir_graph->SSATransformation(); + cu.mir_graph->SSATransformation(); /* Do constant propagation */ - cu->mir_graph->PropagateConstants(); + cu.mir_graph->PropagateConstants(); /* Count uses */ - cu->mir_graph->MethodUseCount(); + cu.mir_graph->MethodUseCount(); /* Perform null check elimination */ - cu->mir_graph->NullCheckElimination(); + cu.mir_graph->NullCheckElimination(); /* Combine basic blocks where possible */ - cu->mir_graph->BasicBlockCombine(); + cu.mir_graph->BasicBlockCombine(); /* Do some basic block optimizations */ - cu->mir_graph->BasicBlockOptimization(); + cu.mir_graph->BasicBlockOptimization(); - if (cu->enable_debug & (1 << kDebugDumpCheckStats)) { - cu->mir_graph->DumpCheckStats(); + if (cu.enable_debug & (1 << kDebugDumpCheckStats)) { + cu.mir_graph->DumpCheckStats(); } if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { - cu->mir_graph->ShowOpcodeStats(); + cu.mir_graph->ShowOpcodeStats(); } /* Set up regLocation[] array to describe values - one for each ssa_name. */ - cu->mir_graph->BuildRegLocations(); + cu.mir_graph->BuildRegLocations(); CompiledMethod* result = NULL; #if defined(ART_USE_PORTABLE_COMPILER) if (compiler_backend == kPortable) { - cu->cg.reset(PortableCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena, - llvm_compilation_unit)); + cu.cg.reset(PortableCodeGenerator(&cu, cu.mir_graph.get(), &cu.arena, llvm_compilation_unit)); } else { #endif switch (compiler.GetInstructionSet()) { case kThumb2: - cu->cg.reset(ArmCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); + cu.cg.reset(ArmCodeGenerator(&cu, cu.mir_graph.get(), &cu.arena)); break; case kMips: - cu->cg.reset(MipsCodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); + cu.cg.reset(MipsCodeGenerator(&cu, cu.mir_graph.get(), &cu.arena)); break; case kX86: - cu->cg.reset(X86CodeGenerator(cu.get(), cu->mir_graph.get(), &cu->arena)); + cu.cg.reset(X86CodeGenerator(&cu, cu.mir_graph.get(), &cu.arena)); break; default: LOG(FATAL) << "Unexpected instruction set: " << compiler.GetInstructionSet(); @@ -244,9 +243,9 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, } #endif - cu->cg->Materialize(); + cu.cg->Materialize(); - result = cu->cg->GetCompiledMethod(); + result = cu.cg->GetCompiledMethod(); if (result) { VLOG(compiler) << "Compiled " << PrettyMethod(method_idx, dex_file); @@ -254,15 +253,15 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, VLOG(compiler) << "Deferred " << PrettyMethod(method_idx, dex_file); } - if (cu->enable_debug & (1 << kDebugShowMemoryUsage)) { - if (cu->arena.BytesAllocated() > (5 * 1024 *1024)) { - MemStats mem_stats(cu->arena); + if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) { + if (cu.arena.BytesAllocated() > (5 * 1024 *1024)) { + MemStats mem_stats(cu.arena); LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable(mem_stats); } } - if (cu->enable_debug & (1 << kDebugShowSummaryMemoryUsage)) { - LOG(INFO) << "MEMINFO " << cu->arena.BytesAllocated() << " " << cu->mir_graph->GetNumBlocks() + if (cu.enable_debug & (1 << kDebugShowSummaryMemoryUsage)) { + LOG(INFO) << "MEMINFO " << cu.arena.BytesAllocated() << " " << cu.mir_graph->GetNumBlocks() << " " << PrettyMethod(method_idx, dex_file); } diff --git a/compiler/dex/growable_array.h b/compiler/dex/growable_array.h index 08a6478e97..8e2abfbaf1 100644 --- a/compiler/dex/growable_array.h +++ b/compiler/dex/growable_array.h @@ -67,7 +67,7 @@ class GrowableArray { } static void* operator new(size_t size, ArenaAllocator* arena) { - return arena->NewMem(sizeof(GrowableArray::Iterator), true, ArenaAllocator::kAllocGrowableArray); + return arena->Alloc(sizeof(GrowableArray::Iterator), ArenaAllocator::kAllocGrowableArray); }; static void operator delete(void* p) {} // Nop. @@ -81,8 +81,8 @@ class GrowableArray { num_allocated_(init_length), num_used_(0), kind_(kind) { - elem_list_ = static_cast(arena_->NewMem(sizeof(T) * init_length, true, - ArenaAllocator::kAllocGrowableArray)); + elem_list_ = static_cast(arena_->Alloc(sizeof(T) * init_length, + ArenaAllocator::kAllocGrowableArray)); }; @@ -95,8 +95,8 @@ class GrowableArray { if (new_length > target_length) { target_length = new_length; } - T* new_array = static_cast(arena_->NewMem(sizeof(T) * target_length, true, - ArenaAllocator::kAllocGrowableArray)); + T* new_array = static_cast(arena_->Alloc(sizeof(T) * target_length, + ArenaAllocator::kAllocGrowableArray)); memcpy(new_array, elem_list_, sizeof(T) * num_allocated_); num_allocated_ = target_length; elem_list_ = new_array; @@ -153,7 +153,7 @@ class GrowableArray { T* GetRawStorage() const { return elem_list_; } static void* operator new(size_t size, ArenaAllocator* arena) { - return arena->NewMem(sizeof(GrowableArray), true, ArenaAllocator::kAllocGrowableArray); + return arena->Alloc(sizeof(GrowableArray), ArenaAllocator::kAllocGrowableArray); }; static void operator delete(void* p) {} // Nop. diff --git a/compiler/dex/mir_dataflow.cc b/compiler/dex/mir_dataflow.cc index c3a33ff7a8..3a73717a7b 100644 --- a/compiler/dex/mir_dataflow.cc +++ b/compiler/dex/mir_dataflow.cc @@ -954,11 +954,11 @@ void MIRGraph::DataFlowSSAFormat35C(MIR* mir) { int i; mir->ssa_rep->num_uses = num_uses; - mir->ssa_rep->uses = static_cast(arena_->NewMem(sizeof(int) * num_uses, true, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->uses = static_cast(arena_->Alloc(sizeof(int) * num_uses, + ArenaAllocator::kAllocDFInfo)); // NOTE: will be filled in during type & size inference pass - mir->ssa_rep->fp_use = static_cast(arena_->NewMem(sizeof(bool) * num_uses, true, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->fp_use = static_cast(arena_->Alloc(sizeof(bool) * num_uses, + ArenaAllocator::kAllocDFInfo)); for (i = 0; i < num_uses; i++) { HandleSSAUse(mir->ssa_rep->uses, d_insn->arg[i], i); @@ -972,11 +972,11 @@ void MIRGraph::DataFlowSSAFormat3RC(MIR* mir) { int i; mir->ssa_rep->num_uses = num_uses; - mir->ssa_rep->uses = static_cast(arena_->NewMem(sizeof(int) * num_uses, true, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->uses = static_cast(arena_->Alloc(sizeof(int) * num_uses, + ArenaAllocator::kAllocDFInfo)); // NOTE: will be filled in during type & size inference pass - mir->ssa_rep->fp_use = static_cast(arena_->NewMem(sizeof(bool) * num_uses, true, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->fp_use = static_cast(arena_->Alloc(sizeof(bool) * num_uses, + ArenaAllocator::kAllocDFInfo)); for (i = 0; i < num_uses; i++) { HandleSSAUse(mir->ssa_rep->uses, d_insn->vC+i, i); @@ -991,8 +991,8 @@ bool MIRGraph::DoSSAConversion(BasicBlock* bb) { for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { mir->ssa_rep = - static_cast(arena_->NewMem(sizeof(SSARepresentation), true, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(SSARepresentation), + ArenaAllocator::kAllocDFInfo)); int df_attributes = oat_data_flow_attributes_[mir->dalvikInsn.opcode]; @@ -1041,10 +1041,10 @@ bool MIRGraph::DoSSAConversion(BasicBlock* bb) { if (num_uses) { mir->ssa_rep->num_uses = num_uses; - mir->ssa_rep->uses = static_cast(arena_->NewMem(sizeof(int) * num_uses, false, - ArenaAllocator::kAllocDFInfo)); - mir->ssa_rep->fp_use = static_cast(arena_->NewMem(sizeof(bool) * num_uses, false, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->uses = static_cast(arena_->Alloc(sizeof(int) * num_uses, + ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->fp_use = static_cast(arena_->Alloc(sizeof(bool) * num_uses, + ArenaAllocator::kAllocDFInfo)); } int num_defs = 0; @@ -1058,10 +1058,10 @@ bool MIRGraph::DoSSAConversion(BasicBlock* bb) { if (num_defs) { mir->ssa_rep->num_defs = num_defs; - mir->ssa_rep->defs = static_cast(arena_->NewMem(sizeof(int) * num_defs, false, - ArenaAllocator::kAllocDFInfo)); - mir->ssa_rep->fp_def = static_cast(arena_->NewMem(sizeof(bool) * num_defs, false, - ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->defs = static_cast(arena_->Alloc(sizeof(int) * num_defs, + ArenaAllocator::kAllocDFInfo)); + mir->ssa_rep->fp_def = static_cast(arena_->Alloc(sizeof(bool) * num_defs, + ArenaAllocator::kAllocDFInfo)); } DecodedInstruction *d_insn = &mir->dalvikInsn; @@ -1109,8 +1109,8 @@ bool MIRGraph::DoSSAConversion(BasicBlock* bb) { * predecessor blocks. */ bb->data_flow_info->vreg_to_ssa_map = - static_cast(arena_->NewMem(sizeof(int) * cu_->num_dalvik_registers, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * cu_->num_dalvik_registers, + ArenaAllocator::kAllocDFInfo)); memcpy(bb->data_flow_info->vreg_to_ssa_map, vreg_to_ssa_map_, sizeof(int) * cu_->num_dalvik_registers); @@ -1146,12 +1146,12 @@ void MIRGraph::CompilerInitializeSSAConversion() { * Dalvik register, and the SSA names for those are the same. */ vreg_to_ssa_map_ = - static_cast(arena_->NewMem(sizeof(int) * num_dalvik_reg, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * num_dalvik_reg, + ArenaAllocator::kAllocDFInfo)); /* Keep track of the higest def for each dalvik reg */ ssa_last_defs_ = - static_cast(arena_->NewMem(sizeof(int) * num_dalvik_reg, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * num_dalvik_reg, + ArenaAllocator::kAllocDFInfo)); for (unsigned int i = 0; i < num_dalvik_reg; i++) { vreg_to_ssa_map_[i] = i; @@ -1174,8 +1174,8 @@ void MIRGraph::CompilerInitializeSSAConversion() { bb->block_type == kEntryBlock || bb->block_type == kExitBlock) { bb->data_flow_info = - static_cast(arena_->NewMem(sizeof(BasicBlockDataFlow), true, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(BasicBlockDataFlow), + ArenaAllocator::kAllocDFInfo)); } } } diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc index 86f6ee5cbd..81702e3842 100644 --- a/compiler/dex/mir_graph.cc +++ b/compiler/dex/mir_graph.cc @@ -399,8 +399,8 @@ void MIRGraph::ProcessCanSwitch(BasicBlock* cur_block, MIR* insn, int cur_offset BasicBlock *case_block = FindBlock(cur_offset + target_table[i], /* split */ true, /* create */ true, /* immed_pred_block_p */ &cur_block); SuccessorBlockInfo *successor_block_info = - static_cast(arena_->NewMem(sizeof(SuccessorBlockInfo), false, - ArenaAllocator::kAllocSuccessor)); + static_cast(arena_->Alloc(sizeof(SuccessorBlockInfo), + ArenaAllocator::kAllocSuccessor)); successor_block_info->block = case_block; successor_block_info->key = (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? @@ -444,7 +444,7 @@ BasicBlock* MIRGraph::ProcessCanThrow(BasicBlock* cur_block, MIR* insn, int cur_ catches_.insert(catch_block->start_offset); } SuccessorBlockInfo *successor_block_info = reinterpret_cast - (arena_->NewMem(sizeof(SuccessorBlockInfo), false, ArenaAllocator::kAllocSuccessor)); + (arena_->Alloc(sizeof(SuccessorBlockInfo), ArenaAllocator::kAllocSuccessor)); successor_block_info->block = catch_block; successor_block_info->key = iterator.GetHandlerTypeIndex(); cur_block->successor_block_list.blocks->Insert(successor_block_info); @@ -490,7 +490,7 @@ BasicBlock* MIRGraph::ProcessCanThrow(BasicBlock* cur_block, MIR* insn, int cur_ new_block->start_offset = insn->offset; cur_block->fall_through = new_block; new_block->predecessors->Insert(cur_block); - MIR* new_insn = static_cast(arena_->NewMem(sizeof(MIR), true, ArenaAllocator::kAllocMIR)); + MIR* new_insn = static_cast(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocMIR)); *new_insn = *insn; insn->dalvikInsn.opcode = static_cast(kMirOpCheck); @@ -571,13 +571,12 @@ void MIRGraph::InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_ int num_patterns = sizeof(special_patterns)/sizeof(special_patterns[0]); bool live_pattern = (num_patterns > 0) && !(cu_->disable_opt & (1 << kMatch)); bool* dead_pattern = - static_cast(arena_->NewMem(sizeof(bool) * num_patterns, true, - ArenaAllocator::kAllocMisc)); + static_cast(arena_->Alloc(sizeof(bool) * num_patterns, ArenaAllocator::kAllocMisc)); int pattern_pos = 0; /* Parse all instructions and put them into containing basic blocks */ while (code_ptr < code_end) { - MIR *insn = static_cast(arena_->NewMem(sizeof(MIR), true, ArenaAllocator::kAllocMIR)); + MIR *insn = static_cast(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocMIR)); insn->offset = current_offset_; insn->m_unit_index = current_method_; int width = ParseInsn(code_ptr, &insn->dalvikInsn); @@ -1002,7 +1001,7 @@ char* MIRGraph::GetDalvikDisassembly(const MIR* mir) { str.append("]--optimized away"); } int length = str.length() + 1; - ret = static_cast(arena_->NewMem(length, false, ArenaAllocator::kAllocDFInfo)); + ret = static_cast(arena_->Alloc(length, ArenaAllocator::kAllocDFInfo)); strncpy(ret, str.c_str(), length); return ret; } @@ -1115,8 +1114,8 @@ void MIRGraph::DumpMIRGraph() { */ CallInfo* MIRGraph::NewMemCallInfo(BasicBlock* bb, MIR* mir, InvokeType type, bool is_range) { - CallInfo* info = static_cast(arena_->NewMem(sizeof(CallInfo), true, - ArenaAllocator::kAllocMisc)); + CallInfo* info = static_cast(arena_->Alloc(sizeof(CallInfo), + ArenaAllocator::kAllocMisc)); MIR* move_result_mir = FindMoveResult(bb, mir); if (move_result_mir == NULL) { info->result.location = kLocInvalid; @@ -1127,8 +1126,7 @@ CallInfo* MIRGraph::NewMemCallInfo(BasicBlock* bb, MIR* mir, InvokeType type, } info->num_arg_words = mir->ssa_rep->num_uses; info->args = (info->num_arg_words == 0) ? NULL : static_cast - (arena_->NewMem(sizeof(RegLocation) * info->num_arg_words, false, - ArenaAllocator::kAllocMisc)); + (arena_->Alloc(sizeof(RegLocation) * info->num_arg_words, ArenaAllocator::kAllocMisc)); for (int i = 0; i < info->num_arg_words; i++) { info->args[i] = GetRawSrc(mir, i); } @@ -1142,8 +1140,8 @@ CallInfo* MIRGraph::NewMemCallInfo(BasicBlock* bb, MIR* mir, InvokeType type, // Allocate a new basic block. BasicBlock* MIRGraph::NewMemBB(BBType block_type, int block_id) { - BasicBlock* bb = static_cast(arena_->NewMem(sizeof(BasicBlock), true, - ArenaAllocator::kAllocBB)); + BasicBlock* bb = static_cast(arena_->Alloc(sizeof(BasicBlock), + ArenaAllocator::kAllocBB)); bb->block_type = block_type; bb->id = block_id; // TUNING: better estimate of the exit block predecessors? diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index c02deab00f..28ab2834e1 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -426,8 +426,8 @@ class MIRGraph { } void EnableOpcodeCounting() { - opcode_count_ = static_cast(arena_->NewMem(kNumPackedOpcodes * sizeof(int), true, - ArenaAllocator::kAllocMisc)); + opcode_count_ = static_cast(arena_->Alloc(kNumPackedOpcodes * sizeof(int), + ArenaAllocator::kAllocMisc)); } void ShowOpcodeStats(); diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index 9f694de6a5..b7611f8f5b 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -94,8 +94,8 @@ void MIRGraph::DoConstantPropogation(BasicBlock* bb) { void MIRGraph::PropagateConstants() { is_constant_v_ = new (arena_) ArenaBitVector(arena_, GetNumSSARegs(), false); - constant_values_ = static_cast(arena_->NewMem(sizeof(int) * GetNumSSARegs(), true, - ArenaAllocator::kAllocDFInfo)); + constant_values_ = static_cast(arena_->Alloc(sizeof(int) * GetNumSSARegs(), + ArenaAllocator::kAllocDFInfo)); AllNodesIterator iter(this, false /* not iterative */); for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) { DoConstantPropogation(bb); @@ -399,8 +399,7 @@ bool MIRGraph::BasicBlockOpt(BasicBlock* bb) { DCHECK_EQ(SelectKind(if_true), kSelectMove); DCHECK_EQ(SelectKind(if_false), kSelectMove); int* src_ssa = - static_cast(arena_->NewMem(sizeof(int) * 3, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * 3, ArenaAllocator::kAllocDFInfo)); src_ssa[0] = mir->ssa_rep->uses[0]; src_ssa[1] = if_true->ssa_rep->uses[0]; src_ssa[2] = if_false->ssa_rep->uses[0]; @@ -409,16 +408,14 @@ bool MIRGraph::BasicBlockOpt(BasicBlock* bb) { } mir->ssa_rep->num_defs = 1; mir->ssa_rep->defs = - static_cast(arena_->NewMem(sizeof(int) * 1, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * 1, ArenaAllocator::kAllocDFInfo)); mir->ssa_rep->fp_def = - static_cast(arena_->NewMem(sizeof(bool) * 1, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(bool) * 1, ArenaAllocator::kAllocDFInfo)); mir->ssa_rep->fp_def[0] = if_true->ssa_rep->fp_def[0]; // Match type of uses to def. mir->ssa_rep->fp_use = - static_cast(arena_->NewMem(sizeof(bool) * mir->ssa_rep->num_uses, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(bool) * mir->ssa_rep->num_uses, + ArenaAllocator::kAllocDFInfo)); for (int i = 0; i < mir->ssa_rep->num_uses; i++) { mir->ssa_rep->fp_use[i] = mir->ssa_rep->fp_def[0]; } @@ -805,8 +802,7 @@ void MIRGraph::CodeLayout() { void MIRGraph::DumpCheckStats() { Checkstats* stats = - static_cast(arena_->NewMem(sizeof(Checkstats), true, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(Checkstats), ArenaAllocator::kAllocDFInfo)); checkstats_ = stats; AllNodesIterator iter(this, false /* not iterative */); for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) { diff --git a/compiler/dex/quick/arm/call_arm.cc b/compiler/dex/quick/arm/call_arm.cc index 2d8e24f58e..2dbe5f5c36 100644 --- a/compiler/dex/quick/arm/call_arm.cc +++ b/compiler/dex/quick/arm/call_arm.cc @@ -316,13 +316,12 @@ void ArmMir2Lir::GenSparseSwitch(MIR* mir, uint32_t table_offset, } // Add the table to the list - we'll process it later SwitchTable *tab_rec = - static_cast(arena_->NewMem(sizeof(SwitchTable), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(SwitchTable), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; int size = table[1]; - tab_rec->targets = static_cast(arena_->NewMem(size * sizeof(LIR*), true, - ArenaAllocator::kAllocLIR)); + tab_rec->targets = static_cast(arena_->Alloc(size * sizeof(LIR*), + ArenaAllocator::kAllocLIR)); switch_tables_.Insert(tab_rec); // Get the switch value @@ -365,13 +364,12 @@ void ArmMir2Lir::GenPackedSwitch(MIR* mir, uint32_t table_offset, } // Add the table to the list - we'll process it later SwitchTable *tab_rec = - static_cast(arena_->NewMem(sizeof(SwitchTable), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(SwitchTable), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; int size = table[1]; tab_rec->targets = - static_cast(arena_->NewMem(size * sizeof(LIR*), true, ArenaAllocator::kAllocLIR)); + static_cast(arena_->Alloc(size * sizeof(LIR*), ArenaAllocator::kAllocLIR)); switch_tables_.Insert(tab_rec); // Get the switch value @@ -419,8 +417,7 @@ void ArmMir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { const uint16_t* table = cu_->insns + current_dalvik_offset_ + table_offset; // Add the table to the list - we'll process it later FillArrayData *tab_rec = - static_cast(arena_->NewMem(sizeof(FillArrayData), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(FillArrayData), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; uint16_t width = tab_rec->table[1]; diff --git a/compiler/dex/quick/arm/target_arm.cc b/compiler/dex/quick/arm/target_arm.cc index 47d3d974ef..6cc3052da1 100644 --- a/compiler/dex/quick/arm/target_arm.cc +++ b/compiler/dex/quick/arm/target_arm.cc @@ -538,16 +538,14 @@ void ArmMir2Lir::CompilerInitializeRegAlloc() { int num_temps = sizeof(core_temps)/sizeof(*core_temps); int num_fp_regs = sizeof(FpRegs)/sizeof(*FpRegs); int num_fp_temps = sizeof(fp_temps)/sizeof(*fp_temps); - reg_pool_ = static_cast(arena_->NewMem(sizeof(*reg_pool_), true, - ArenaAllocator::kAllocRegAlloc)); + reg_pool_ = static_cast(arena_->Alloc(sizeof(*reg_pool_), + ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_core_regs = num_regs; reg_pool_->core_regs = reinterpret_cast - (arena_->NewMem(num_regs * sizeof(*reg_pool_->core_regs), true, - ArenaAllocator::kAllocRegAlloc)); + (arena_->Alloc(num_regs * sizeof(*reg_pool_->core_regs), ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_fp_regs = num_fp_regs; reg_pool_->FPRegs = static_cast - (arena_->NewMem(num_fp_regs * sizeof(*reg_pool_->FPRegs), true, - ArenaAllocator::kAllocRegAlloc)); + (arena_->Alloc(num_fp_regs * sizeof(*reg_pool_->FPRegs), ArenaAllocator::kAllocRegAlloc)); CompilerInitPool(reg_pool_->core_regs, core_regs, reg_pool_->num_core_regs); CompilerInitPool(reg_pool_->FPRegs, FpRegs, reg_pool_->num_fp_regs); // Keep special registers from being allocated diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index 5f6f3d51e9..d89f1ed227 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -321,7 +321,7 @@ LIR* Mir2Lir::ScanLiteralPoolWide(LIR* data_target, int val_lo, int val_hi) { LIR* Mir2Lir::AddWordData(LIR* *constant_list_p, int value) { /* Add the constant to the literal pool */ if (constant_list_p) { - LIR* new_value = static_cast(arena_->NewMem(sizeof(LIR), true, ArenaAllocator::kAllocData)); + LIR* new_value = static_cast(arena_->Alloc(sizeof(LIR), ArenaAllocator::kAllocData)); new_value->operands[0] = value; new_value->next = *constant_list_p; *constant_list_p = new_value; @@ -793,7 +793,7 @@ LIR* Mir2Lir::InsertCaseLabel(int vaddr, int keyVal) { if (it == boundary_map_.end()) { LOG(FATAL) << "Error: didn't find vaddr 0x" << std::hex << vaddr; } - LIR* new_label = static_cast(arena_->NewMem(sizeof(LIR), true, ArenaAllocator::kAllocLIR)); + LIR* new_label = static_cast(arena_->Alloc(sizeof(LIR), ArenaAllocator::kAllocLIR)); new_label->dalvik_offset = vaddr; new_label->opcode = kPseudoCaseLabel; new_label->operands[0] = keyVal; @@ -961,8 +961,8 @@ Mir2Lir::Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena first_lir_insn_(NULL), last_lir_insn_(NULL) { promotion_map_ = static_cast - (arena_->NewMem((cu_->num_dalvik_registers + cu_->num_compiler_temps + 1) * - sizeof(promotion_map_[0]), true, ArenaAllocator::kAllocRegAlloc)); + (arena_->Alloc((cu_->num_dalvik_registers + cu_->num_compiler_temps + 1) * + sizeof(promotion_map_[0]), ArenaAllocator::kAllocRegAlloc)); } void Mir2Lir::Materialize() { diff --git a/compiler/dex/quick/local_optimizations.cc b/compiler/dex/quick/local_optimizations.cc index 2e9c845d05..630e990733 100644 --- a/compiler/dex/quick/local_optimizations.cc +++ b/compiler/dex/quick/local_optimizations.cc @@ -249,7 +249,7 @@ void Mir2Lir::ApplyLoadStoreElimination(LIR* head_lir, LIR* tail_lir) { /* Only sink store instructions */ if (sink_distance && !is_this_lir_load) { LIR* new_store_lir = - static_cast(arena_->NewMem(sizeof(LIR), true, ArenaAllocator::kAllocLIR)); + static_cast(arena_->Alloc(sizeof(LIR), ArenaAllocator::kAllocLIR)); *new_store_lir = *this_lir; /* * Stop point found - insert *before* the check_lir @@ -446,7 +446,7 @@ void Mir2Lir::ApplyLoadHoisting(LIR* head_lir, LIR* tail_lir) { if (slot >= 0) { LIR* cur_lir = prev_inst_list[slot]; LIR* new_load_lir = - static_cast(arena_->NewMem(sizeof(LIR), true, ArenaAllocator::kAllocLIR)); + static_cast(arena_->Alloc(sizeof(LIR), ArenaAllocator::kAllocLIR)); *new_load_lir = *this_lir; /* * Insertion is guaranteed to succeed since check_lir diff --git a/compiler/dex/quick/mips/call_mips.cc b/compiler/dex/quick/mips/call_mips.cc index eaae0e1964..d53c012466 100644 --- a/compiler/dex/quick/mips/call_mips.cc +++ b/compiler/dex/quick/mips/call_mips.cc @@ -67,13 +67,12 @@ void MipsMir2Lir::GenSparseSwitch(MIR* mir, uint32_t table_offset, } // Add the table to the list - we'll process it later SwitchTable *tab_rec = - static_cast(arena_->NewMem(sizeof(SwitchTable), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(SwitchTable), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; int elements = table[1]; tab_rec->targets = - static_cast(arena_->NewMem(elements * sizeof(LIR*), true, ArenaAllocator::kAllocLIR)); + static_cast(arena_->Alloc(elements * sizeof(LIR*), ArenaAllocator::kAllocLIR)); switch_tables_.Insert(tab_rec); // The table is composed of 8-byte key/disp pairs @@ -147,12 +146,11 @@ void MipsMir2Lir::GenPackedSwitch(MIR* mir, uint32_t table_offset, } // Add the table to the list - we'll process it later SwitchTable *tab_rec = - static_cast(arena_->NewMem(sizeof(SwitchTable), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(SwitchTable), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; int size = table[1]; - tab_rec->targets = static_cast(arena_->NewMem(size * sizeof(LIR*), true, + tab_rec->targets = static_cast(arena_->Alloc(size * sizeof(LIR*), ArenaAllocator::kAllocLIR)); switch_tables_.Insert(tab_rec); @@ -228,8 +226,8 @@ void MipsMir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { const uint16_t* table = cu_->insns + current_dalvik_offset_ + table_offset; // Add the table to the list - we'll process it later FillArrayData *tab_rec = - reinterpret_cast(arena_->NewMem(sizeof(FillArrayData), true, - ArenaAllocator::kAllocData)); + reinterpret_cast(arena_->Alloc(sizeof(FillArrayData), + ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; uint16_t width = tab_rec->table[1]; diff --git a/compiler/dex/quick/mips/target_mips.cc b/compiler/dex/quick/mips/target_mips.cc index 7a9e91a994..4ee5b23eb9 100644 --- a/compiler/dex/quick/mips/target_mips.cc +++ b/compiler/dex/quick/mips/target_mips.cc @@ -462,16 +462,14 @@ void MipsMir2Lir::CompilerInitializeRegAlloc() { int num_temps = sizeof(core_temps)/sizeof(*core_temps); int num_fp_regs = sizeof(FpRegs)/sizeof(*FpRegs); int num_fp_temps = sizeof(fp_temps)/sizeof(*fp_temps); - reg_pool_ = static_cast(arena_->NewMem(sizeof(*reg_pool_), true, - ArenaAllocator::kAllocRegAlloc)); + reg_pool_ = static_cast(arena_->Alloc(sizeof(*reg_pool_), + ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_core_regs = num_regs; reg_pool_->core_regs = static_cast - (arena_->NewMem(num_regs * sizeof(*reg_pool_->core_regs), true, - ArenaAllocator::kAllocRegAlloc)); + (arena_->Alloc(num_regs * sizeof(*reg_pool_->core_regs), ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_fp_regs = num_fp_regs; reg_pool_->FPRegs = static_cast - (arena_->NewMem(num_fp_regs * sizeof(*reg_pool_->FPRegs), true, - ArenaAllocator::kAllocRegAlloc)); + (arena_->Alloc(num_fp_regs * sizeof(*reg_pool_->FPRegs), ArenaAllocator::kAllocRegAlloc)); CompilerInitPool(reg_pool_->core_regs, core_regs, reg_pool_->num_core_regs); CompilerInitPool(reg_pool_->FPRegs, FpRegs, reg_pool_->num_fp_regs); // Keep special registers from being allocated diff --git a/compiler/dex/quick/mir_to_lir-inl.h b/compiler/dex/quick/mir_to_lir-inl.h index d9aef5d968..440df2afa6 100644 --- a/compiler/dex/quick/mir_to_lir-inl.h +++ b/compiler/dex/quick/mir_to_lir-inl.h @@ -40,7 +40,7 @@ inline void Mir2Lir::ClobberBody(RegisterInfo* p) { inline LIR* Mir2Lir::RawLIR(int dalvik_offset, int opcode, int op0, int op1, int op2, int op3, int op4, LIR* target) { - LIR* insn = static_cast(arena_->NewMem(sizeof(LIR), true, ArenaAllocator::kAllocLIR)); + LIR* insn = static_cast(arena_->Alloc(sizeof(LIR), ArenaAllocator::kAllocLIR)); insn->dalvik_offset = dalvik_offset; insn->opcode = opcode; insn->operands[0] = op0; diff --git a/compiler/dex/quick/mir_to_lir.cc b/compiler/dex/quick/mir_to_lir.cc index 862c1d74c6..c41feb1348 100644 --- a/compiler/dex/quick/mir_to_lir.cc +++ b/compiler/dex/quick/mir_to_lir.cc @@ -812,8 +812,8 @@ void Mir2Lir::SpecialMIR2LIR(SpecialCaseHandler special_case) { void Mir2Lir::MethodMIR2LIR() { // Hold the labels of each block. block_label_list_ = - static_cast(arena_->NewMem(sizeof(LIR) * mir_graph_->GetNumBlocks(), true, - ArenaAllocator::kAllocLIR)); + static_cast(arena_->Alloc(sizeof(LIR) * mir_graph_->GetNumBlocks(), + ArenaAllocator::kAllocLIR)); PreOrderDfsIterator iter(mir_graph_, false /* not iterative */); for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) { diff --git a/compiler/dex/quick/ralloc_util.cc b/compiler/dex/quick/ralloc_util.cc index a0b98dd304..71b74a4a68 100644 --- a/compiler/dex/quick/ralloc_util.cc +++ b/compiler/dex/quick/ralloc_util.cc @@ -971,11 +971,11 @@ void Mir2Lir::DoPromotion() { * to describe register live ranges for GC. */ RefCounts *core_regs = - static_cast(arena_->NewMem(sizeof(RefCounts) * num_regs, true, - ArenaAllocator::kAllocRegAlloc)); + static_cast(arena_->Alloc(sizeof(RefCounts) * num_regs, + ArenaAllocator::kAllocRegAlloc)); RefCounts *FpRegs = - static_cast(arena_->NewMem(sizeof(RefCounts) * num_regs, true, - ArenaAllocator::kAllocRegAlloc)); + static_cast(arena_->Alloc(sizeof(RefCounts) * num_regs, + ArenaAllocator::kAllocRegAlloc)); // Set ssa names for original Dalvik registers for (int i = 0; i < dalvik_regs; i++) { core_regs[i].s_reg = FpRegs[i].s_reg = i; diff --git a/compiler/dex/quick/x86/call_x86.cc b/compiler/dex/quick/x86/call_x86.cc index 6e3e55fc4e..2be2aa9a0e 100644 --- a/compiler/dex/quick/x86/call_x86.cc +++ b/compiler/dex/quick/x86/call_x86.cc @@ -74,13 +74,12 @@ void X86Mir2Lir::GenPackedSwitch(MIR* mir, uint32_t table_offset, } // Add the table to the list - we'll process it later SwitchTable *tab_rec = - static_cast(arena_->NewMem(sizeof(SwitchTable), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(SwitchTable), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; int size = table[1]; - tab_rec->targets = static_cast(arena_->NewMem(size * sizeof(LIR*), true, - ArenaAllocator::kAllocLIR)); + tab_rec->targets = static_cast(arena_->Alloc(size * sizeof(LIR*), + ArenaAllocator::kAllocLIR)); switch_tables_.Insert(tab_rec); // Get the switch value @@ -131,8 +130,7 @@ void X86Mir2Lir::GenFillArrayData(uint32_t table_offset, RegLocation rl_src) { const uint16_t* table = cu_->insns + current_dalvik_offset_ + table_offset; // Add the table to the list - we'll process it later FillArrayData *tab_rec = - static_cast(arena_->NewMem(sizeof(FillArrayData), true, - ArenaAllocator::kAllocData)); + static_cast(arena_->Alloc(sizeof(FillArrayData), ArenaAllocator::kAllocData)); tab_rec->table = table; tab_rec->vaddr = current_dalvik_offset_; uint16_t width = tab_rec->table[1]; diff --git a/compiler/dex/quick/x86/target_x86.cc b/compiler/dex/quick/x86/target_x86.cc index 699f3ae5bb..26accab360 100644 --- a/compiler/dex/quick/x86/target_x86.cc +++ b/compiler/dex/quick/x86/target_x86.cc @@ -438,16 +438,16 @@ void X86Mir2Lir::CompilerInitializeRegAlloc() { int num_temps = sizeof(core_temps)/sizeof(*core_temps); int num_fp_regs = sizeof(FpRegs)/sizeof(*FpRegs); int num_fp_temps = sizeof(fp_temps)/sizeof(*fp_temps); - reg_pool_ = static_cast(arena_->NewMem(sizeof(*reg_pool_), true, - ArenaAllocator::kAllocRegAlloc)); + reg_pool_ = static_cast(arena_->Alloc(sizeof(*reg_pool_), + ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_core_regs = num_regs; reg_pool_->core_regs = - static_cast(arena_->NewMem(num_regs * sizeof(*reg_pool_->core_regs), true, - ArenaAllocator::kAllocRegAlloc)); + static_cast(arena_->Alloc(num_regs * sizeof(*reg_pool_->core_regs), + ArenaAllocator::kAllocRegAlloc)); reg_pool_->num_fp_regs = num_fp_regs; reg_pool_->FPRegs = - static_cast(arena_->NewMem(num_fp_regs * sizeof(*reg_pool_->FPRegs), true, - ArenaAllocator::kAllocRegAlloc)); + static_cast(arena_->Alloc(num_fp_regs * sizeof(*reg_pool_->FPRegs), + ArenaAllocator::kAllocRegAlloc)); CompilerInitPool(reg_pool_->core_regs, core_regs, reg_pool_->num_core_regs); CompilerInitPool(reg_pool_->FPRegs, FpRegs, reg_pool_->num_fp_regs); // Keep special registers from being allocated diff --git a/compiler/dex/ssa_transformation.cc b/compiler/dex/ssa_transformation.cc index 18d8e93b1b..cd1602f674 100644 --- a/compiler/dex/ssa_transformation.cc +++ b/compiler/dex/ssa_transformation.cc @@ -136,8 +136,8 @@ void MIRGraph::ComputeDefBlockMatrix() { int num_registers = cu_->num_dalvik_registers; /* Allocate num_dalvik_registers bit vector pointers */ def_block_matrix_ = static_cast - (arena_->NewMem(sizeof(ArenaBitVector *) * num_registers, true, - ArenaAllocator::kAllocDFInfo)); + (arena_->Alloc(sizeof(ArenaBitVector *) * num_registers, + ArenaAllocator::kAllocDFInfo)); int i; /* Initialize num_register vectors with num_blocks bits each */ @@ -384,8 +384,8 @@ void MIRGraph::ComputeDominators() { /* Initalize & Clear i_dom_list */ if (i_dom_list_ == NULL) { - i_dom_list_ = static_cast(arena_->NewMem(sizeof(int) * num_reachable_blocks, false, - ArenaAllocator::kAllocDFInfo)); + i_dom_list_ = static_cast(arena_->Alloc(sizeof(int) * num_reachable_blocks, + ArenaAllocator::kAllocDFInfo)); } for (int i = 0; i < num_reachable_blocks; i++) { i_dom_list_[i] = NOTVISITED; @@ -564,7 +564,7 @@ void MIRGraph::InsertPhiNodes() { continue; } MIR *phi = - static_cast(arena_->NewMem(sizeof(MIR), true, ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocDFInfo)); phi->dalvikInsn.opcode = static_cast(kMirOpPhi); phi->dalvikInsn.vA = dalvik_reg; phi->offset = phi_bb->start_offset; @@ -610,14 +610,11 @@ bool MIRGraph::InsertPhiNodeOperands(BasicBlock* bb) { int num_uses = uses.size(); mir->ssa_rep->num_uses = num_uses; mir->ssa_rep->uses = - static_cast(arena_->NewMem(sizeof(int) * num_uses, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * num_uses, ArenaAllocator::kAllocDFInfo)); mir->ssa_rep->fp_use = - static_cast(arena_->NewMem(sizeof(bool) * num_uses, true, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(bool) * num_uses, ArenaAllocator::kAllocDFInfo)); int* incoming = - static_cast(arena_->NewMem(sizeof(int) * num_uses, false, - ArenaAllocator::kAllocDFInfo)); + static_cast(arena_->Alloc(sizeof(int) * num_uses, ArenaAllocator::kAllocDFInfo)); // TODO: Ugly, rework (but don't burden each MIR/LIR for Phi-only needs) mir->dalvikInsn.vB = reinterpret_cast(incoming); @@ -644,7 +641,7 @@ void MIRGraph::DoDFSPreOrderSSARename(BasicBlock* block) { /* Save SSA map snapshot */ int* saved_ssa_map = - static_cast(arena_->NewMem(map_size, false, ArenaAllocator::kAllocDalvikToSSAMap)); + static_cast(arena_->Alloc(map_size, ArenaAllocator::kAllocDalvikToSSAMap)); memcpy(saved_ssa_map, vreg_to_ssa_map_, map_size); if (block->fall_through) { diff --git a/compiler/dex/vreg_analysis.cc b/compiler/dex/vreg_analysis.cc index 5ee675306d..07f37bbbbb 100644 --- a/compiler/dex/vreg_analysis.cc +++ b/compiler/dex/vreg_analysis.cc @@ -374,8 +374,8 @@ static const RegLocation fresh_loc = {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0, */ void MIRGraph::BuildRegLocations() { /* Allocate the location map */ - RegLocation* loc = static_cast(arena_->NewMem(GetNumSSARegs() * sizeof(*loc), true, - ArenaAllocator::kAllocRegAlloc)); + RegLocation* loc = static_cast(arena_->Alloc(GetNumSSARegs() * sizeof(*loc), + ArenaAllocator::kAllocRegAlloc)); for (int i = 0; i < GetNumSSARegs(); i++) { loc[i] = fresh_loc; loc[i].s_reg_low = i; diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 22a510b86b..fa1b8f9854 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -26,6 +26,7 @@ #include "compiled_class.h" #include "compiled_method.h" #include "dex_file.h" +#include "dex/arena_allocator.h" #include "instruction_set.h" #include "invoke_type.h" #include "method_reference.h" @@ -213,6 +214,9 @@ class CompilerDriver { support_boot_image_fixup_ = support_boot_image_fixup; } + ArenaPool& GetArenaPool() { + return arena_pool_; + } bool WriteElf(const std::string& android_root, bool is_host, @@ -423,6 +427,9 @@ class CompilerDriver { pthread_key_t tls_key_; + // Arena pool used by the compiler. + ArenaPool arena_pool_; + typedef void (*CompilerEnableAutoElfLoadingFn)(CompilerDriver& driver); CompilerEnableAutoElfLoadingFn compiler_enable_auto_elf_loading_; -- cgit v1.2.3-59-g8ed1b From 193bad9b9cfd10642043fa2ebbfc68bd5f9ede4b Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 29 Aug 2013 18:46:00 -0700 Subject: Multi threaded hashed deduplication during compilation. Moved deduplication to be in the compiler driver instead of oat writer. This enables deduplication to be performed on multiple threads. Also added a hash function to avoid excessive comparison of byte arrays. Improvements: Before (alloats host): real 1m6.967s user 4m22.940s sys 1m22.610s Thinkfree.apk (target mako): 0m23.74s real 0m50.95s user 0m9.50s system 0m24.62s real 0m50.61s user 0m10.07s system 0m24.22s real 0m51.44s user 0m10.09s system 0m23.70s real 0m51.05s user 0m9.97s system 0m23.50s real 0m50.74s user 0m10.63s system After (alloats host): real 1m5.705s user 4m44.030s sys 1m29.990s Thinkfree.apk (target mako): 0m23.32s real 0m51.38s user 0m10.00s system 0m23.49s real 0m51.20s user 0m9.80s system 0m23.18s real 0m50.80s user 0m9.77s system 0m23.52s real 0m51.22s user 0m10.02s system 0m23.50s real 0m51.55s user 0m9.46s system Bug: 10552630 Change-Id: Ia6d06a747b86b0bfc4473b3cd68f8ce1a1c7eb22 --- build/Android.gtest.mk | 1 + compiler/Android.mk | 1 + compiler/compiled_method.cc | 170 +++++++++++++++++++++++++++++++ compiler/compiled_method.h | 176 +++++++++++++++++++++++++++++++++ compiler/dex/quick/codegen_util.cc | 13 ++- compiler/driver/compiler_driver.cc | 16 +++ compiler/driver/compiler_driver.h | 32 ++++++ compiler/jni/portable/jni_compiler.cc | 5 +- compiler/jni/portable/jni_compiler.h | 4 +- compiler/jni/quick/jni_compiler.cc | 3 +- compiler/llvm/compiler_llvm.cc | 5 +- compiler/oat_writer.h | 18 ++-- compiler/sea_ir/frontend.cc | 8 +- compiler/utils/dedupe_set.h | 82 +++++++++++++++ compiler/utils/dedupe_set_test.cc | 78 +++++++++++++++ runtime/Android.mk | 1 - runtime/compiled_method.cc | 133 ------------------------- runtime/compiled_method.h | 181 ---------------------------------- 18 files changed, 579 insertions(+), 348 deletions(-) create mode 100644 compiler/compiled_method.cc create mode 100644 compiler/compiled_method.h create mode 100644 compiler/utils/dedupe_set.h create mode 100644 compiler/utils/dedupe_set_test.cc delete mode 100644 runtime/compiled_method.cc delete mode 100644 runtime/compiled_method.h (limited to 'compiler/driver/compiler_driver.h') diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index a150f0653c..4c658a2bb7 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -23,6 +23,7 @@ TEST_COMMON_SRC_FILES := \ compiler/jni/jni_compiler_test.cc \ compiler/oat_test.cc \ compiler/output_stream_test.cc \ + compiler/utils/dedupe_set_test.cc \ compiler/utils/arm/managed_register_arm_test.cc \ compiler/utils/x86/managed_register_x86_test.cc \ runtime/barrier_test.cc \ diff --git a/compiler/Android.mk b/compiler/Android.mk index 8eb8db7140..66ff46163b 100644 --- a/compiler/Android.mk +++ b/compiler/Android.mk @@ -19,6 +19,7 @@ LOCAL_PATH := $(call my-dir) include art/build/Android.common.mk LIBART_COMPILER_SRC_FILES := \ + compiled_method.cc \ dex/local_value_numbering.cc \ dex/arena_allocator.cc \ dex/arena_bit_vector.cc \ diff --git a/compiler/compiled_method.cc b/compiler/compiled_method.cc new file mode 100644 index 0000000000..29ff390678 --- /dev/null +++ b/compiler/compiled_method.cc @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2011 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 "compiled_method.h" +#include "driver/compiler_driver.h" + +namespace art { + +CompiledCode::CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set, + const std::vector& code) + : compiler_driver_(compiler_driver), instruction_set_(instruction_set), code_(nullptr) { + SetCode(code); +} + +CompiledCode::CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set, + const std::string& elf_object, const std::string& symbol) + : compiler_driver_(compiler_driver), instruction_set_(instruction_set), symbol_(symbol) { + CHECK_NE(elf_object.size(), 0U); + CHECK_NE(symbol.size(), 0U); + std::vector temp_code(elf_object.size()); + for (size_t i = 0; i < elf_object.size(); ++i) { + temp_code[i] = elf_object[i]; + } + // TODO: we shouldn't just shove ELF objects in as "code" but + // change to have different kinds of compiled methods. This is + // being deferred until we work on hybrid execution or at least + // until we work on batch compilation. + SetCode(temp_code); +} + +void CompiledCode::SetCode(const std::vector& code) { + CHECK(!code.empty()); + code_ = compiler_driver_->DeduplicateCode(code); +} + +uint32_t CompiledCode::AlignCode(uint32_t offset) const { + return AlignCode(offset, instruction_set_); +} + +uint32_t CompiledCode::AlignCode(uint32_t offset, InstructionSet instruction_set) { + switch (instruction_set) { + case kArm: + case kThumb2: + return RoundUp(offset, kArmAlignment); + case kMips: + return RoundUp(offset, kMipsAlignment); + case kX86: + return RoundUp(offset, kX86Alignment); + default: + LOG(FATAL) << "Unknown InstructionSet: " << instruction_set; + return 0; + } +} + +size_t CompiledCode::CodeDelta() const { + switch (instruction_set_) { + case kArm: + case kMips: + case kX86: + return 0; + case kThumb2: { + // +1 to set the low-order bit so a BLX will switch to Thumb mode + return 1; + } + default: + LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; + return 0; + } +} + +const void* CompiledCode::CodePointer(const void* code_pointer, + InstructionSet instruction_set) { + switch (instruction_set) { + case kArm: + case kMips: + case kX86: + return code_pointer; + case kThumb2: { + uintptr_t address = reinterpret_cast(code_pointer); + // Set the low-order bit so a BLX will switch to Thumb mode + address |= 0x1; + return reinterpret_cast(address); + } + default: + LOG(FATAL) << "Unknown InstructionSet: " << instruction_set; + return NULL; + } +} + +#if defined(ART_USE_PORTABLE_COMPILER) +const std::string& CompiledCode::GetSymbol() const { + CHECK_NE(0U, symbol_.size()); + return symbol_; +} + +const std::vector& CompiledCode::GetOatdataOffsetsToCompliledCodeOffset() const { + CHECK_NE(0U, oatdata_offsets_to_compiled_code_offset_.size()) << symbol_; + return oatdata_offsets_to_compiled_code_offset_; +} + +void CompiledCode::AddOatdataOffsetToCompliledCodeOffset(uint32_t offset) { + oatdata_offsets_to_compiled_code_offset_.push_back(offset); +} +#endif + +CompiledMethod::CompiledMethod(CompilerDriver& driver, + InstructionSet instruction_set, + const std::vector& code, + const size_t frame_size_in_bytes, + const uint32_t core_spill_mask, + const uint32_t fp_spill_mask, + const std::vector& mapping_table, + const std::vector& vmap_table, + const std::vector& native_gc_map) + : CompiledCode(&driver, instruction_set, code), frame_size_in_bytes_(frame_size_in_bytes), + core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask), + mapping_table_(driver.DeduplicateMappingTable(mapping_table)), + vmap_table_(driver.DeduplicateVMapTable(vmap_table)), + gc_map_(driver.DeduplicateGCMap(native_gc_map)) { +} + +CompiledMethod::CompiledMethod(CompilerDriver& driver, + InstructionSet instruction_set, + const std::vector& code, + const size_t frame_size_in_bytes, + const uint32_t core_spill_mask, + const uint32_t fp_spill_mask) + : CompiledCode(&driver, instruction_set, code), + frame_size_in_bytes_(frame_size_in_bytes), + core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask) { + mapping_table_ = driver.DeduplicateMappingTable(std::vector()); + vmap_table_ = driver.DeduplicateVMapTable(std::vector()); + gc_map_ = driver.DeduplicateGCMap(std::vector()); +} + +// Constructs a CompiledMethod for the Portable compiler. +CompiledMethod::CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, + const std::string& code, const std::vector& gc_map, + const std::string& symbol) + : CompiledCode(&driver, instruction_set, code, symbol), + frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), + fp_spill_mask_(0), gc_map_(driver.DeduplicateGCMap(gc_map)) { + mapping_table_ = driver.DeduplicateMappingTable(std::vector()); + vmap_table_ = driver.DeduplicateVMapTable(std::vector()); +} + +CompiledMethod::CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, + const std::string& code, const std::string& symbol) + : CompiledCode(&driver, instruction_set, code, symbol), + frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), + fp_spill_mask_(0) { + mapping_table_ = driver.DeduplicateMappingTable(std::vector()); + vmap_table_ = driver.DeduplicateVMapTable(std::vector()); + gc_map_ = driver.DeduplicateGCMap(std::vector()); +} + +} // namespace art diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h new file mode 100644 index 0000000000..e4fedf1ab4 --- /dev/null +++ b/compiler/compiled_method.h @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2011 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. + */ + +#ifndef ART_COMPILER_COMPILED_METHOD_H_ +#define ART_COMPILER_COMPILED_METHOD_H_ + +#include +#include + +#include "instruction_set.h" +#include "utils.h" +#include "UniquePtr.h" + +namespace llvm { + class Function; +} // namespace llvm + +namespace art { + +class CompilerDriver; + +class CompiledCode { + public: + // For Quick to supply an code blob + CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set, + const std::vector& code); + + // For Portable to supply an ELF object + CompiledCode(CompilerDriver* compiler_driver, InstructionSet instruction_set, + const std::string& elf_object, const std::string &symbol); + + InstructionSet GetInstructionSet() const { + return instruction_set_; + } + + const std::vector& GetCode() const { + return *code_; + } + + void SetCode(const std::vector& code); + + bool operator==(const CompiledCode& rhs) const { + return (code_ == rhs.code_); + } + + // To align an offset from a page-aligned value to make it suitable + // for code storage. For example on ARM, to ensure that PC relative + // valu computations work out as expected. + uint32_t AlignCode(uint32_t offset) const; + static uint32_t AlignCode(uint32_t offset, InstructionSet instruction_set); + + // returns the difference between the code address and a usable PC. + // mainly to cope with kThumb2 where the lower bit must be set. + size_t CodeDelta() const; + + // Returns a pointer suitable for invoking the code at the argument + // code_pointer address. Mainly to cope with kThumb2 where the + // lower bit must be set to indicate Thumb mode. + static const void* CodePointer(const void* code_pointer, + InstructionSet instruction_set); + +#if defined(ART_USE_PORTABLE_COMPILER) + const std::string& GetSymbol() const; + const std::vector& GetOatdataOffsetsToCompliledCodeOffset() const; + void AddOatdataOffsetToCompliledCodeOffset(uint32_t offset); +#endif + + private: + CompilerDriver* compiler_driver_; + + const InstructionSet instruction_set_; + + // Used to store the PIC code for Quick and an ELF image for portable. + std::vector* code_; + + // Used for the Portable ELF symbol name. + const std::string symbol_; + + // There are offsets from the oatdata symbol to where the offset to + // the compiled method will be found. These are computed by the + // OatWriter and then used by the ElfWriter to add relocations so + // that MCLinker can update the values to the location in the linked .so. + std::vector oatdata_offsets_to_compiled_code_offset_; +}; + +class CompiledMethod : public CompiledCode { + public: + // Constructs a CompiledMethod for the non-LLVM compilers. + CompiledMethod(CompilerDriver& driver, + InstructionSet instruction_set, + const std::vector& code, + const size_t frame_size_in_bytes, + const uint32_t core_spill_mask, + const uint32_t fp_spill_mask, + const std::vector& mapping_table, + const std::vector& vmap_table, + const std::vector& native_gc_map); + + // Constructs a CompiledMethod for the JniCompiler. + CompiledMethod(CompilerDriver& driver, + InstructionSet instruction_set, + const std::vector& code, + const size_t frame_size_in_bytes, + const uint32_t core_spill_mask, + const uint32_t fp_spill_mask); + + // Constructs a CompiledMethod for the Portable compiler. + CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, const std::string& code, + const std::vector& gc_map, const std::string& symbol); + + // Constructs a CompiledMethod for the Portable JniCompiler. + CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, const std::string& code, + const std::string& symbol); + + ~CompiledMethod() {} + + size_t GetFrameSizeInBytes() const { + return frame_size_in_bytes_; + } + + uint32_t GetCoreSpillMask() const { + return core_spill_mask_; + } + + uint32_t GetFpSpillMask() const { + return fp_spill_mask_; + } + + const std::vector& GetMappingTable() const { + DCHECK(mapping_table_ != nullptr); + return *mapping_table_; + } + + const std::vector& GetVmapTable() const { + DCHECK(vmap_table_ != nullptr); + return *vmap_table_; + } + + const std::vector& GetGcMap() const { + DCHECK(gc_map_ != nullptr); + return *gc_map_; + } + + private: + // For quick code, the size of the activation used by the code. + const size_t frame_size_in_bytes_; + // For quick code, a bit mask describing spilled GPR callee-save registers. + const uint32_t core_spill_mask_; + // For quick code, a bit mask describing spilled FPR callee-save registers. + const uint32_t fp_spill_mask_; + // For quick code, a uleb128 encoded map from native PC offset to dex PC aswell as dex PC to + // native PC offset. Size prefixed. + std::vector* mapping_table_; + // For quick code, a uleb128 encoded map from GPR/FPR register to dex register. Size prefixed. + std::vector* vmap_table_; + // For quick code, a map keyed by native PC indices to bitmaps describing what dalvik registers + // are live. For portable code, the key is a dalvik PC. + std::vector* gc_map_; +}; + +} // namespace art + +#endif // ART_COMPILER_COMPILED_METHOD_H_ diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index d89f1ed227..e081c16bb5 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -1004,7 +1004,7 @@ CompiledMethod* Mir2Lir::GetCompiledMethod() { std::vector raw_vmap_table; // Core regs may have been inserted out of order - sort first std::sort(core_vmap_table_.begin(), core_vmap_table_.end()); - for (size_t i = 0 ; i < core_vmap_table_.size(); i++) { + for (size_t i = 0 ; i < core_vmap_table_.size(); ++i) { // Copy, stripping out the phys register sort key raw_vmap_table.push_back(~(-1 << VREG_NUM_WIDTH) & core_vmap_table_[i]); } @@ -1022,14 +1022,13 @@ CompiledMethod* Mir2Lir::GetCompiledMethod() { UnsignedLeb128EncodingVector vmap_encoder; // Prefix the encoded data with its size. vmap_encoder.PushBack(raw_vmap_table.size()); - typedef std::vector::const_iterator It; - for (It cur = raw_vmap_table.begin(), end = raw_vmap_table.end(); cur != end; ++cur) { - vmap_encoder.PushBack(*cur); + for (uint16_t cur : raw_vmap_table) { + vmap_encoder.PushBack(cur); } CompiledMethod* result = - new CompiledMethod(cu_->instruction_set, code_buffer_, - frame_size_, core_spill_mask_, fp_spill_mask_, - encoded_mapping_table_.GetData(), vmap_encoder.GetData(), native_gc_map_); + new CompiledMethod(*cu_->compiler_driver, cu_->instruction_set, code_buffer_, frame_size_, + core_spill_mask_, fp_spill_mask_, encoded_mapping_table_.GetData(), + vmap_encoder.GetData(), native_gc_map_); return result; } diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index b17df4e443..cbd9020df4 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -394,6 +394,22 @@ CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet } } +std::vector* CompilerDriver::DeduplicateCode(const std::vector& code) { + return dedupe_code_.Add(Thread::Current(), code); +} + +std::vector* CompilerDriver::DeduplicateMappingTable(const std::vector& code) { + return dedupe_mapping_table_.Add(Thread::Current(), code); +} + +std::vector* CompilerDriver::DeduplicateVMapTable(const std::vector& code) { + return dedupe_vmap_table_.Add(Thread::Current(), code); +} + +std::vector* CompilerDriver::DeduplicateGCMap(const std::vector& code) { + return dedupe_gc_map_.Add(Thread::Current(), code); +} + CompilerDriver::~CompilerDriver() { Thread* self = Thread::Current(); { diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index fa1b8f9854..cd6b5fab02 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -34,6 +34,7 @@ #include "runtime.h" #include "safe_map.h" #include "thread_pool.h" +#include "utils/dedupe_set.h" namespace art { @@ -303,6 +304,11 @@ class CompilerDriver { void RecordClassStatus(ClassReference ref, mirror::Class::Status status) LOCKS_EXCLUDED(compiled_classes_lock_); + std::vector* DeduplicateCode(const std::vector& code); + std::vector* DeduplicateMappingTable(const std::vector& code); + std::vector* DeduplicateVMapTable(const std::vector& code); + std::vector* DeduplicateGCMap(const std::vector& code); + private: // Compute constant code and method pointers when possible void GetCodeAndMethodForDirectCall(InvokeType type, InvokeType sharp_type, @@ -439,6 +445,32 @@ class CompilerDriver { bool support_boot_image_fixup_; + // DeDuplication data structures, these own the corresponding byte arrays. + class DedupeHashFunc { + public: + size_t operator()(const std::vector& array) const { + // Take a random sample of bytes. + static const size_t kSmallArrayThreshold = 16; + static const size_t kRandomHashCount = 16; + size_t hash = 0; + if (array.size() < kSmallArrayThreshold) { + for (auto c : array) { + hash = hash * 54 + c; + } + } else { + for (size_t i = 0; i < kRandomHashCount; ++i) { + size_t r = i * 1103515245 + 12345; + hash = hash * 54 + array[r % array.size()]; + } + } + return hash; + } + }; + DedupeSet, size_t, DedupeHashFunc> dedupe_code_; + DedupeSet, size_t, DedupeHashFunc> dedupe_mapping_table_; + DedupeSet, size_t, DedupeHashFunc> dedupe_vmap_table_; + DedupeSet, size_t, DedupeHashFunc> dedupe_gc_map_; + DISALLOW_COPY_AND_ASSIGN(CompilerDriver); }; diff --git a/compiler/jni/portable/jni_compiler.cc b/compiler/jni/portable/jni_compiler.cc index fc2e4e2b2e..43408a7d64 100644 --- a/compiler/jni/portable/jni_compiler.cc +++ b/compiler/jni/portable/jni_compiler.cc @@ -50,7 +50,7 @@ using ::art::llvm::runtime_support::JniMethodStartSynchronized; using ::art::llvm::runtime_support::RuntimeId; JniCompiler::JniCompiler(LlvmCompilationUnit* cunit, - const CompilerDriver& driver, + CompilerDriver& driver, const DexCompilationUnit* dex_compilation_unit) : cunit_(cunit), driver_(&driver), module_(cunit_->GetModule()), context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()), @@ -251,8 +251,7 @@ CompiledMethod* JniCompiler::Compile() { cunit_->Materialize(); - return new CompiledMethod(cunit_->GetInstructionSet(), - cunit_->GetElfObject(), + return new CompiledMethod(*driver_, cunit_->GetInstructionSet(), cunit_->GetElfObject(), func_name); } diff --git a/compiler/jni/portable/jni_compiler.h b/compiler/jni/portable/jni_compiler.h index 49cc9f4abf..d20c63bc1e 100644 --- a/compiler/jni/portable/jni_compiler.h +++ b/compiler/jni/portable/jni_compiler.h @@ -54,7 +54,7 @@ class IRBuilder; class JniCompiler { public: JniCompiler(LlvmCompilationUnit* cunit, - const CompilerDriver& driver, + CompilerDriver& driver, const DexCompilationUnit* dex_compilation_unit); CompiledMethod* Compile(); @@ -67,7 +67,7 @@ class JniCompiler { private: LlvmCompilationUnit* cunit_; - const CompilerDriver* const driver_; + CompilerDriver* driver_; ::llvm::Module* module_; ::llvm::LLVMContext* context_; diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index 069def60f9..1417fb9e40 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -370,7 +370,8 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, UniquePtr disassembler(Disassembler::Create(instruction_set)); disassembler->Dump(LOG(INFO), &managed_code[0], &managed_code[managed_code.size()]); } - return new CompiledMethod(instruction_set, + return new CompiledMethod(compiler, + instruction_set, managed_code, frame_size, main_jni_conv->CoreSpillMask(), diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc index 6b19a37b6f..fd440d5bf0 100644 --- a/compiler/llvm/compiler_llvm.cc +++ b/compiler/llvm/compiler_llvm.cc @@ -153,9 +153,8 @@ CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_typ MethodReference mref(dex_compilation_unit->GetDexFile(), dex_compilation_unit->GetDexMethodIndex()); - return new CompiledMethod(compiler_driver_->GetInstructionSet(), - cunit->GetElfObject(), - *verifier::MethodVerifier::GetDexGcMap(mref), + return new CompiledMethod(*compiler_driver_, compiler_driver_->GetInstructionSet(), + cunit->GetElfObject(), *verifier::MethodVerifier::GetDexGcMap(mref), cunit->GetDexCompilationUnit()->GetSymbol()); } diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index 8111c9f7a0..d5f7e21a1a 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -217,18 +217,12 @@ class OatWriter { uint32_t size_oat_class_status_; uint32_t size_oat_class_method_offsets_; - template struct MapCompare { - public: - bool operator() (const T* const &a, const T* const &b) const { - return *a < *b; - } - }; - - // code mappings for deduplication - SafeMap*, uint32_t, MapCompare > > code_offsets_; - SafeMap*, uint32_t, MapCompare > > vmap_table_offsets_; - SafeMap*, uint32_t, MapCompare > > mapping_table_offsets_; - SafeMap*, uint32_t, MapCompare > > gc_map_offsets_; + // Code mappings for deduplication. Deduplication is already done on a pointer basis by the + // compiler driver, so we can simply compare the pointers to find out if things are duplicated. + SafeMap*, uint32_t> code_offsets_; + SafeMap*, uint32_t> vmap_table_offsets_; + SafeMap*, uint32_t> mapping_table_offsets_; + SafeMap*, uint32_t> gc_map_offsets_; DISALLOW_COPY_AND_ASSIGN(OatWriter); }; diff --git a/compiler/sea_ir/frontend.cc b/compiler/sea_ir/frontend.cc index 6efc103f40..93f6f25461 100644 --- a/compiler/sea_ir/frontend.cc +++ b/compiler/sea_ir/frontend.cc @@ -57,11 +57,9 @@ static CompiledMethod* CompileMethodWithSeaIr(CompilerDriver& compiler, dc.DumpSea(ir_graph, "/tmp/temp.dot", types); MethodReference mref(&dex_file, method_idx); std::string llvm_code = llvm_data->GetElf(compiler.GetInstructionSet()); - CompiledMethod* compiled_method = new CompiledMethod( - compiler.GetInstructionSet(), - llvm_code, - *verifier::MethodVerifier::GetDexGcMap(mref), - symbol); + CompiledMethod* compiled_method = + new CompiledMethod(compiler, compiler.GetInstructionSet(), llvm_code, + *verifier::MethodVerifier::GetDexGcMap(mref), symbol); LOG(INFO) << "Compiled SEA IR method " << PrettyMethod(method_idx, dex_file) << "."; return compiled_method; } diff --git a/compiler/utils/dedupe_set.h b/compiler/utils/dedupe_set.h new file mode 100644 index 0000000000..f3d35d728c --- /dev/null +++ b/compiler/utils/dedupe_set.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2013 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. + */ + +#ifndef ART_COMPILER_UTILS_DEDUPE_SET_H_ +#define ART_COMPILER_UTILS_DEDUPE_SET_H_ + +#include + +#include "base/mutex.h" +#include "base/stl_util.h" + +namespace art { + +// A simple data structure to handle hashed deduplication. Add is thread safe. +template +class DedupeSet { + typedef std::pair HashedKey; + + class Comparator { + public: + bool operator()(const HashedKey& a, const HashedKey& b) const { + if (a.first < b.first) return true; + if (a.first > b.first) return true; + return *a.second < *b.second; + } + }; + + typedef std::set Keys; + + public: + typedef typename Keys::iterator iterator; + typedef typename Keys::const_iterator const_iterator; + typedef typename Keys::size_type size_type; + typedef typename Keys::value_type value_type; + + iterator begin() { return keys_.begin(); } + const_iterator begin() const { return keys_.begin(); } + iterator end() { return keys_.end(); } + const_iterator end() const { return keys_.end(); } + + Key* Add(Thread* self, const Key& key) { + HashType hash = HashFunc()(key); + HashedKey hashed_key(hash, const_cast(&key)); + MutexLock lock(self, lock_); + auto it = keys_.find(hashed_key); + if (it != keys_.end()) { + return it->second; + } + hashed_key.second = new Key(key); + keys_.insert(hashed_key); + return hashed_key.second; + } + + DedupeSet() : lock_("dedupe lock") { + } + + ~DedupeSet() { + STLDeleteValues(&keys_); + } + + private: + Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + Keys keys_; + DISALLOW_COPY_AND_ASSIGN(DedupeSet); +}; + +} // namespace art + +#endif // ART_COMPILER_UTILS_DEDUPE_SET_H_ diff --git a/compiler/utils/dedupe_set_test.cc b/compiler/utils/dedupe_set_test.cc new file mode 100644 index 0000000000..9f5e292f53 --- /dev/null +++ b/compiler/utils/dedupe_set_test.cc @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2013 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 "common_test.h" +#include "dedupe_set.h" + +namespace art { + +class DedupeSetTest : public testing::Test { + public: +}; + +class DedupeHashFunc { + public: + size_t operator()(const std::vector& array) const { + size_t hash = 0; + for (uint8_t c : array) { + hash += c; + hash += hash << 10; + hash += hash >> 6; + } + return hash; + } +}; +TEST_F(DedupeSetTest, Test) { + Thread* self = Thread::Current(); + typedef std::vector ByteArray; + DedupeSet deduplicator; + ByteArray* array1; + { + ByteArray test1; + test1.push_back(10); + test1.push_back(20); + test1.push_back(30); + test1.push_back(45); + array1 = deduplicator.Add(self, test1); + ASSERT_EQ(test1, *array1); + } + + ByteArray* array2; + { + ByteArray test1; + test1.push_back(10); + test1.push_back(20); + test1.push_back(30); + test1.push_back(45); + array2 = deduplicator.Add(self, test1); + ASSERT_EQ(array2, array1); + ASSERT_EQ(test1, *array2); + } + + ByteArray* array3; + { + ByteArray test1; + test1.push_back(10); + test1.push_back(22); + test1.push_back(30); + test1.push_back(47); + array3 = deduplicator.Add(self, test1); + ASSERT_NE(array3, &test1); + ASSERT_EQ(test1, *array3); + } +} + +} // namespace art diff --git a/runtime/Android.mk b/runtime/Android.mk index 1ce7a3055d..a8d505e1f5 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -34,7 +34,6 @@ LIBART_COMMON_SRC_FILES := \ check_jni.cc \ class_linker.cc \ common_throws.cc \ - compiled_method.cc \ debugger.cc \ dex_file.cc \ dex_file_verifier.cc \ diff --git a/runtime/compiled_method.cc b/runtime/compiled_method.cc deleted file mode 100644 index 4631cb5db4..0000000000 --- a/runtime/compiled_method.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2011 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 "compiled_method.h" - -namespace art { - -CompiledCode::CompiledCode(InstructionSet instruction_set, const std::vector& code) - : instruction_set_(instruction_set), code_(code) { - CHECK_NE(code.size(), 0U); -} - -CompiledCode::CompiledCode(InstructionSet instruction_set, - const std::string& elf_object, - const std::string& symbol) - : instruction_set_(instruction_set), symbol_(symbol) { - CHECK_NE(elf_object.size(), 0U); - CHECK_NE(symbol.size(), 0U); - // TODO: we shouldn't just shove ELF objects in as "code" but - // change to have different kinds of compiled methods. This is - // being deferred until we work on hybrid execution or at least - // until we work on batch compilation. - code_.resize(elf_object.size()); - memcpy(&code_[0], &elf_object[0], elf_object.size()); -} - -uint32_t CompiledCode::AlignCode(uint32_t offset) const { - return AlignCode(offset, instruction_set_); -} - -uint32_t CompiledCode::AlignCode(uint32_t offset, InstructionSet instruction_set) { - switch (instruction_set) { - case kArm: - case kThumb2: - return RoundUp(offset, kArmAlignment); - case kMips: - return RoundUp(offset, kMipsAlignment); - case kX86: - return RoundUp(offset, kX86Alignment); - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set; - return 0; - } -} - -size_t CompiledCode::CodeDelta() const { - switch (instruction_set_) { - case kArm: - case kMips: - case kX86: - return 0; - case kThumb2: { - // +1 to set the low-order bit so a BLX will switch to Thumb mode - return 1; - } - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set_; - return 0; - } -} - -const void* CompiledCode::CodePointer(const void* code_pointer, - InstructionSet instruction_set) { - switch (instruction_set) { - case kArm: - case kMips: - case kX86: - return code_pointer; - case kThumb2: { - uintptr_t address = reinterpret_cast(code_pointer); - // Set the low-order bit so a BLX will switch to Thumb mode - address |= 0x1; - return reinterpret_cast(address); - } - default: - LOG(FATAL) << "Unknown InstructionSet: " << instruction_set; - return NULL; - } -} - -#if defined(ART_USE_PORTABLE_COMPILER) -const std::string& CompiledCode::GetSymbol() const { - CHECK_NE(0U, symbol_.size()); - return symbol_; -} - -const std::vector& CompiledCode::GetOatdataOffsetsToCompliledCodeOffset() const { - CHECK_NE(0U, oatdata_offsets_to_compiled_code_offset_.size()) << symbol_; - return oatdata_offsets_to_compiled_code_offset_; -} - -void CompiledCode::AddOatdataOffsetToCompliledCodeOffset(uint32_t offset) { - oatdata_offsets_to_compiled_code_offset_.push_back(offset); -} -#endif - -CompiledMethod::CompiledMethod(InstructionSet instruction_set, - const std::vector& code, - const size_t frame_size_in_bytes, - const uint32_t core_spill_mask, - const uint32_t fp_spill_mask, - const std::vector& mapping_table, - const std::vector& vmap_table, - const std::vector& native_gc_map) - : CompiledCode(instruction_set, code), frame_size_in_bytes_(frame_size_in_bytes), - core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask), - mapping_table_(mapping_table), vmap_table_(vmap_table), - gc_map_(native_gc_map) { -} - -CompiledMethod::CompiledMethod(InstructionSet instruction_set, - const std::vector& code, - const size_t frame_size_in_bytes, - const uint32_t core_spill_mask, - const uint32_t fp_spill_mask) - : CompiledCode(instruction_set, code), - frame_size_in_bytes_(frame_size_in_bytes), - core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask) {} - -} // namespace art diff --git a/runtime/compiled_method.h b/runtime/compiled_method.h deleted file mode 100644 index b3bb20fac4..0000000000 --- a/runtime/compiled_method.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ART_RUNTIME_COMPILED_METHOD_H_ -#define ART_RUNTIME_COMPILED_METHOD_H_ - -#include -#include - -#include "instruction_set.h" -#include "utils.h" -#include "UniquePtr.h" - -namespace llvm { - class Function; -} // namespace llvm - -namespace art { - -class CompiledCode { - public: - // For Quick to supply an code blob - CompiledCode(InstructionSet instruction_set, const std::vector& code); - - // For Portable to supply an ELF object - CompiledCode(InstructionSet instruction_set, - const std::string& elf_object, - const std::string &symbol); - - InstructionSet GetInstructionSet() const { - return instruction_set_; - } - - const std::vector& GetCode() const { - return code_; - } - - void SetCode(const std::vector& code) { - CHECK_NE(code.size(), 0U); - code_ = code; - } - - bool operator==(const CompiledCode& rhs) const { - return (code_ == rhs.code_); - } - - // To align an offset from a page-aligned value to make it suitable - // for code storage. For example on ARM, to ensure that PC relative - // valu computations work out as expected. - uint32_t AlignCode(uint32_t offset) const; - static uint32_t AlignCode(uint32_t offset, InstructionSet instruction_set); - - // returns the difference between the code address and a usable PC. - // mainly to cope with kThumb2 where the lower bit must be set. - size_t CodeDelta() const; - - // Returns a pointer suitable for invoking the code at the argument - // code_pointer address. Mainly to cope with kThumb2 where the - // lower bit must be set to indicate Thumb mode. - static const void* CodePointer(const void* code_pointer, - InstructionSet instruction_set); - -#if defined(ART_USE_PORTABLE_COMPILER) - const std::string& GetSymbol() const; - const std::vector& GetOatdataOffsetsToCompliledCodeOffset() const; - void AddOatdataOffsetToCompliledCodeOffset(uint32_t offset); -#endif - - private: - const InstructionSet instruction_set_; - - // Used to store the PIC code for Quick and an ELF image for portable. - std::vector code_; - - // Used for the Portable ELF symbol name. - const std::string symbol_; - - // There are offsets from the oatdata symbol to where the offset to - // the compiled method will be found. These are computed by the - // OatWriter and then used by the ElfWriter to add relocations so - // that MCLinker can update the values to the location in the linked .so. - std::vector oatdata_offsets_to_compiled_code_offset_; -}; - -class CompiledMethod : public CompiledCode { - public: - // Constructs a CompiledMethod for the non-LLVM compilers. - CompiledMethod(InstructionSet instruction_set, - const std::vector& code, - const size_t frame_size_in_bytes, - const uint32_t core_spill_mask, - const uint32_t fp_spill_mask, - const std::vector& mapping_table, - const std::vector& vmap_table, - const std::vector& native_gc_map); - - // Constructs a CompiledMethod for the JniCompiler. - CompiledMethod(InstructionSet instruction_set, - const std::vector& code, - const size_t frame_size_in_bytes, - const uint32_t core_spill_mask, - const uint32_t fp_spill_mask); - - // Constructs a CompiledMethod for the Portable compiler. - CompiledMethod(InstructionSet instruction_set, - const std::string& code, - const std::vector& gc_map, - const std::string& symbol) - : CompiledCode(instruction_set, code, symbol), - frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), - fp_spill_mask_(0), gc_map_(gc_map) { - } - - // Constructs a CompiledMethod for the Portable JniCompiler. - CompiledMethod(InstructionSet instruction_set, - const std::string& code, - const std::string& symbol) - : CompiledCode(instruction_set, code, symbol), - frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), - fp_spill_mask_(0) { - } - - ~CompiledMethod() {} - - size_t GetFrameSizeInBytes() const { - return frame_size_in_bytes_; - } - - uint32_t GetCoreSpillMask() const { - return core_spill_mask_; - } - - uint32_t GetFpSpillMask() const { - return fp_spill_mask_; - } - - const std::vector& GetMappingTable() const { - return mapping_table_; - } - - const std::vector& GetVmapTable() const { - return vmap_table_; - } - - const std::vector& GetGcMap() const { - return gc_map_; - } - - private: - // For quick code, the size of the activation used by the code. - const size_t frame_size_in_bytes_; - // For quick code, a bit mask describing spilled GPR callee-save registers. - const uint32_t core_spill_mask_; - // For quick code, a bit mask describing spilled FPR callee-save registers. - const uint32_t fp_spill_mask_; - // For quick code, a uleb128 encoded map from native PC offset to dex PC aswell as dex PC to - // native PC offset. Size prefixed. - std::vector mapping_table_; - // For quick code, a uleb128 encoded map from GPR/FPR register to dex register. Size prefixed. - std::vector vmap_table_; - // For quick code, a map keyed by native PC indices to bitmaps describing what dalvik registers - // are live. For portable code, the key is a dalvik PC. - std::vector gc_map_; -}; - -} // namespace art - -#endif // ART_RUNTIME_COMPILED_METHOD_H_ -- cgit v1.2.3-59-g8ed1b From ee39a10e45a6a0880e8b829525c40d6055818560 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 19 Sep 2013 02:56:49 -0700 Subject: Use class def index from java.lang.Class. Bug: 10244719 This removes the computation of the dex file index, when necessary this is computed by searching the dex file. Its only necessary in dalvik.system.DexFile.defineClassNative and DexFile::FindInClassPath, the latter not showing up significantly in profiling with this change. (cherry-picked from 8b2c0b9abc3f520495f4387ea040132ba85cae69) Change-Id: I20c73a3b17d86286428ab0fd21bc13f51f36c85c --- compiler/dex/compiler_ir.h | 2 +- compiler/dex/dex_to_dex_compiler.cc | 2 +- compiler/dex/frontend.cc | 6 +- compiler/dex/frontend.h | 2 +- compiler/dex/mir_graph.cc | 2 +- compiler/dex/mir_graph.h | 2 +- compiler/dex/quick/codegen_util.cc | 22 ++-- compiler/driver/compiler_driver.cc | 49 +++++---- compiler/driver/compiler_driver.h | 27 +++-- compiler/driver/dex_compilation_unit.cc | 2 +- compiler/driver/dex_compilation_unit.h | 6 +- compiler/image_writer.cc | 1 + compiler/llvm/compiler_llvm.cc | 4 +- compiler/sea_ir/frontend.cc | 6 +- compiler/sea_ir/ir/sea.cc | 4 +- compiler/sea_ir/ir/sea.h | 6 +- oatdump/oatdump.cc | 32 +++--- runtime/Android.mk | 1 + runtime/class_linker.cc | 111 ++++++++++----------- runtime/class_linker.h | 4 +- runtime/class_linker_test.cc | 12 +-- runtime/dex_file.cc | 91 +++++------------ runtime/dex_file.h | 44 +++----- .../entrypoints/quick/quick_invoke_entrypoints.cc | 2 +- runtime/mirror/art_method-inl.h | 2 +- runtime/mirror/class.cc | 23 ++--- runtime/mirror/class.h | 31 ++++-- runtime/mirror/dex_cache.h | 1 + runtime/mirror/proxy.h | 3 + runtime/mirror/string.h | 2 +- runtime/native/dalvik_system_DexFile.cc | 2 +- runtime/native/java_lang_Class.cc | 31 ------ runtime/native/java_lang_DexCache.cc | 56 +++++++++++ runtime/oat_file.cc | 2 +- runtime/oat_file.h | 2 +- runtime/object_utils.h | 87 +++++++--------- runtime/runtime.cc | 5 +- runtime/thread.cc | 2 +- runtime/verifier/method_verifier.cc | 96 +++++++++--------- runtime/verifier/method_verifier.h | 19 ++-- runtime/verifier/method_verifier_test.cc | 3 +- test/100-reflect2/expected.txt | 2 +- 42 files changed, 397 insertions(+), 412 deletions(-) create mode 100644 runtime/native/java_lang_DexCache.cc (limited to 'compiler/driver/compiler_driver.h') diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h index 26d0923baa..6607562b13 100644 --- a/compiler/dex/compiler_ir.h +++ b/compiler/dex/compiler_ir.h @@ -77,7 +77,7 @@ struct CompilationUnit { ClassLinker* class_linker; // Linker to resolve fields and methods. const DexFile* dex_file; // DexFile containing the method being compiled. jobject class_loader; // compiling method's class loader. - uint32_t class_def_idx; // compiling method's defining class definition index. + uint16_t class_def_idx; // compiling method's defining class definition index. uint32_t method_idx; // compiling method's index into method_ids of DexFile. const DexFile::CodeItem* code_item; // compiling method's DexFile code_item. uint32_t access_flags; // compiling method's access flags. diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index a392f829f6..63d8aa04f8 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -277,7 +277,7 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, extern "C" void ArtCompileDEX(art::CompilerDriver& compiler, 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, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file, art::DexToDexCompilationLevel dex_to_dex_compilation_level) { if (dex_to_dex_compilation_level != art::kDontDexToDexCompile) { diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index 23036495ce..fefcab9e87 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -110,7 +110,7 @@ static CompiledMethod* CompileMethod(CompilerDriver& compiler, const CompilerBackend compiler_backend, const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, - uint32_t class_def_idx, uint32_t method_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file #if defined(ART_USE_PORTABLE_COMPILER) , llvm::LlvmCompilationUnit* llvm_compilation_unit @@ -273,7 +273,7 @@ CompiledMethod* CompileOneMethod(CompilerDriver& compiler, const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, @@ -292,7 +292,7 @@ extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& compiler, 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, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file) { // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default art::CompilerBackend backend = compiler.GetCompilerBackend(); diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h index bafa46892c..6c33d109e3 100644 --- a/compiler/dex/frontend.h +++ b/compiler/dex/frontend.h @@ -117,7 +117,7 @@ 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_dex_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file); diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc index 81702e3842..a12bf39e64 100644 --- a/compiler/dex/mir_graph.cc +++ b/compiler/dex/mir_graph.cc @@ -503,7 +503,7 @@ BasicBlock* MIRGraph::ProcessCanThrow(BasicBlock* cur_block, MIR* insn, int cur_ /* Parse a Dex method and insert it into the MIRGraph at the current insert point. */ void MIRGraph::InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, - InvokeType invoke_type, uint32_t class_def_idx, + InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file) { current_code_item_ = code_item; method_stack_.push_back(std::make_pair(current_method_, current_offset_)); diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index 28ab2834e1..6f8bd85630 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -357,7 +357,7 @@ class MIRGraph { * actually the index of the method in the m_units_ array). */ void InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, - InvokeType invoke_type, uint32_t class_def_idx, + InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file); /* Find existing block */ diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index e081c16bb5..a49fa7b44d 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -362,11 +362,12 @@ void Mir2Lir::InstallLiteralPools() { while (data_lir != NULL) { uint32_t target = data_lir->operands[0]; cu_->compiler_driver->AddCodePatch(cu_->dex_file, - cu_->method_idx, - cu_->invoke_type, - target, - static_cast(data_lir->operands[1]), - code_buffer_.size()); + cu_->class_def_idx, + cu_->method_idx, + cu_->invoke_type, + target, + static_cast(data_lir->operands[1]), + code_buffer_.size()); const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target); // unique based on target to ensure code deduplication works uint32_t unique_patch_value = reinterpret_cast(&id); @@ -377,11 +378,12 @@ void Mir2Lir::InstallLiteralPools() { while (data_lir != NULL) { uint32_t target = data_lir->operands[0]; cu_->compiler_driver->AddMethodPatch(cu_->dex_file, - cu_->method_idx, - cu_->invoke_type, - target, - static_cast(data_lir->operands[1]), - code_buffer_.size()); + cu_->class_def_idx, + cu_->method_idx, + cu_->invoke_type, + target, + static_cast(data_lir->operands[1]), + code_buffer_.size()); const DexFile::MethodId& id = cu_->dex_file->GetMethodId(target); // unique based on target to ensure code deduplication works uint32_t unique_patch_value = reinterpret_cast(&id); diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index cbd9020df4..1c831cf3f6 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -293,7 +293,7 @@ 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, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file); @@ -301,7 +301,7 @@ extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& compi const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file); @@ -310,7 +310,7 @@ extern "C" art::CompiledMethod* ArtCompileDEX(art::CompilerDriver& compiler, const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file); @@ -319,7 +319,7 @@ extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& compiler const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file); @@ -536,7 +536,7 @@ void CompilerDriver::CompileOne(const mirror::ArtMethod* method, base::TimingLog Thread* self = Thread::Current(); jobject jclass_loader; const DexFile* dex_file; - uint32_t class_def_idx; + uint16_t class_def_idx; { ScopedObjectAccessUnchecked soa(self); ScopedLocalRef @@ -1301,13 +1301,15 @@ bool CompilerDriver::IsSafeCast(const MethodReference& mr, uint32_t dex_pc) { void CompilerDriver::AddCodePatch(const DexFile* dex_file, - uint32_t referrer_method_idx, - InvokeType referrer_invoke_type, - uint32_t target_method_idx, - InvokeType target_invoke_type, - size_t literal_offset) { + uint16_t referrer_class_def_idx, + uint32_t referrer_method_idx, + InvokeType referrer_invoke_type, + uint32_t target_method_idx, + InvokeType target_invoke_type, + size_t literal_offset) { MutexLock mu(Thread::Current(), compiled_methods_lock_); code_to_patch_.push_back(new PatchInformation(dex_file, + referrer_class_def_idx, referrer_method_idx, referrer_invoke_type, target_method_idx, @@ -1315,13 +1317,15 @@ void CompilerDriver::AddCodePatch(const DexFile* dex_file, literal_offset)); } void CompilerDriver::AddMethodPatch(const DexFile* dex_file, - uint32_t referrer_method_idx, - InvokeType referrer_invoke_type, - uint32_t target_method_idx, - InvokeType target_invoke_type, - size_t literal_offset) { + uint16_t referrer_class_def_idx, + uint32_t referrer_method_idx, + InvokeType referrer_invoke_type, + uint32_t target_method_idx, + InvokeType target_invoke_type, + size_t literal_offset) { MutexLock mu(Thread::Current(), compiled_methods_lock_); methods_to_patch_.push_back(new PatchInformation(dex_file, + referrer_class_def_idx, referrer_method_idx, referrer_invoke_type, target_method_idx, @@ -1624,10 +1628,12 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ */ mirror::DexCache* dex_cache = manager->GetClassLinker()->FindDexCache(*manager->GetDexFile()); std::string error_msg; - if (verifier::MethodVerifier::VerifyClass(manager->GetDexFile(), + const DexFile* dex_file = manager->GetDexFile(); + const DexFile::ClassDef* class_def = &dex_file->GetClassDef(class_def_index); + if (verifier::MethodVerifier::VerifyClass(dex_file, dex_cache, soa.Decode(manager->GetClassLoader()), - class_def_index, error_msg, true) == + class_def, true, &error_msg) == verifier::MethodVerifier::kHardFailure) { const DexFile::ClassDef& class_def = manager->GetDexFile()->GetClassDef(class_def_index); LOG(ERROR) << "Verification failed on class " @@ -2137,7 +2143,8 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl } // If successfully initialized place in SSB array. if (klass->IsInitialized()) { - klass->GetDexCache()->GetInitializedStaticStorage()->Set(klass->GetDexTypeIndex(), klass); + int32_t ssb_index = klass->GetDexTypeIndex(); + klass->GetDexCache()->GetInitializedStaticStorage()->Set(ssb_index, klass); } } // Record the final class status if necessary. @@ -2266,7 +2273,7 @@ void CompilerDriver::CompileDexFile(jobject class_loader, const DexFile& dex_fil } void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, - InvokeType invoke_type, uint32_t class_def_idx, + InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, DexToDexCompilationLevel dex_to_dex_compilation_level) { @@ -2389,13 +2396,13 @@ void CompilerDriver::SetBitcodeFileName(std::string const& filename) { void CompilerDriver::AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, - size_t class_def_index) { + uint16_t class_def_index) { WriterMutexLock mu(self, freezing_constructor_lock_); freezing_constructor_classes_.insert(ClassReference(dex_file, class_def_index)); } bool CompilerDriver::RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, - size_t class_def_index) { + uint16_t class_def_index) { ReaderMutexLock mu(self, freezing_constructor_lock_); return freezing_constructor_classes_.count(ClassReference(dex_file, class_def_index)) != 0; } diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index cd6b5fab02..3852acfd3b 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -145,8 +145,9 @@ class CompilerDriver { CompiledMethod* GetCompiledMethod(MethodReference ref) const LOCKS_EXCLUDED(compiled_methods_lock_); - void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index); - bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, size_t class_def_index); + void AddRequiresConstructorBarrier(Thread* self, const DexFile* dex_file, + uint16_t class_def_index); + bool RequiresConstructorBarrier(Thread* self, const DexFile* dex_file, uint16_t class_def_index); // Callbacks from compiler to see what runtime checks must be generated. @@ -191,6 +192,7 @@ class CompilerDriver { // Record patch information for later fix up. void AddCodePatch(const DexFile* dex_file, + uint16_t referrer_class_def_idx, uint32_t referrer_method_idx, InvokeType referrer_invoke_type, uint32_t target_method_idx, @@ -198,6 +200,7 @@ class CompilerDriver { size_t literal_offset) LOCKS_EXCLUDED(compiled_methods_lock_); void AddMethodPatch(const DexFile* dex_file, + uint16_t referrer_class_def_idx, uint32_t referrer_method_idx, InvokeType referrer_invoke_type, uint32_t target_method_idx, @@ -248,6 +251,9 @@ class CompilerDriver { const DexFile& GetDexFile() const { return *dex_file_; } + uint16_t GetReferrerClassDefIdx() const { + return referrer_class_def_idx_; + } uint32_t GetReferrerMethodIdx() const { return referrer_method_idx_; } @@ -266,12 +272,14 @@ class CompilerDriver { private: PatchInformation(const DexFile* dex_file, + uint16_t referrer_class_def_idx, uint32_t referrer_method_idx, InvokeType referrer_invoke_type, uint32_t target_method_idx, InvokeType target_invoke_type, size_t literal_offset) : dex_file_(dex_file), + referrer_class_def_idx_(referrer_class_def_idx), referrer_method_idx_(referrer_method_idx), referrer_invoke_type_(referrer_invoke_type), target_method_idx_(target_method_idx), @@ -280,12 +288,13 @@ class CompilerDriver { CHECK(dex_file_ != NULL); } - const DexFile* dex_file_; - uint32_t referrer_method_idx_; - InvokeType referrer_invoke_type_; - uint32_t target_method_idx_; - InvokeType target_invoke_type_; - size_t literal_offset_; + const DexFile* const dex_file_; + const uint16_t referrer_class_def_idx_; + const uint32_t referrer_method_idx_; + const InvokeType referrer_invoke_type_; + const uint32_t target_method_idx_; + const InvokeType target_invoke_type_; + const size_t literal_offset_; friend class CompilerDriver; DISALLOW_COPY_AND_ASSIGN(PatchInformation); @@ -357,7 +366,7 @@ class CompilerDriver { ThreadPool& thread_pool, base::TimingLogger& timings) LOCKS_EXCLUDED(Locks::mutator_lock_); void CompileMethod(const DexFile::CodeItem* code_item, uint32_t access_flags, - InvokeType invoke_type, uint32_t class_def_idx, uint32_t method_idx, + InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, DexToDexCompilationLevel dex_to_dex_compilation_level) LOCKS_EXCLUDED(compiled_methods_lock_); diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc index eb8941b15f..c441d09ab2 100644 --- a/compiler/driver/dex_compilation_unit.cc +++ b/compiler/driver/dex_compilation_unit.cc @@ -39,7 +39,7 @@ DexCompilationUnit::DexCompilationUnit(CompilationUnit* cu, ClassLinker* class_linker, const DexFile& dex_file, const DexFile::CodeItem* code_item, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags) : cu_(cu), diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h index 465139b34f..3df50ffec6 100644 --- a/compiler/driver/dex_compilation_unit.h +++ b/compiler/driver/dex_compilation_unit.h @@ -36,7 +36,7 @@ class DexCompilationUnit { DexCompilationUnit(CompilationUnit* cu, jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file, const DexFile::CodeItem* code_item, - uint32_t class_def_idx, uint32_t method_idx, uint32_t access_flags); + uint16_t class_def_idx, uint32_t method_idx, uint32_t access_flags); CompilationUnit* GetCompilationUnit() const { return cu_; @@ -54,7 +54,7 @@ class DexCompilationUnit { return dex_file_; } - uint32_t GetClassDefIndex() const { + uint16_t GetClassDefIndex() const { return class_def_idx_; } @@ -108,7 +108,7 @@ class DexCompilationUnit { const DexFile* const dex_file_; const DexFile::CodeItem* const code_item_; - const uint32_t class_def_idx_; + const uint16_t class_def_idx_; const uint32_t dex_method_idx_; const uint32_t access_flags_; diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index d1859e6f98..f82c6fb40f 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -699,6 +699,7 @@ void ImageWriter::PatchOatCodeAndMethods() { void ImageWriter::SetPatchLocation(const CompilerDriver::PatchInformation* patch, uint32_t value) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); const void* oat_code = class_linker->GetOatCodeFor(patch->GetDexFile(), + patch->GetReferrerClassDefIdx(), patch->GetReferrerMethodIdx()); OatHeader& oat_header = const_cast(oat_file_->GetOatHeader()); // TODO: make this Thumb2 specific diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc index fd440d5bf0..a917cdc6de 100644 --- a/compiler/llvm/compiler_llvm.cc +++ b/compiler/llvm/compiler_llvm.cc @@ -39,7 +39,7 @@ 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, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, llvm::LlvmCompilationUnit* llvm_info); } @@ -202,7 +202,7 @@ 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, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file) { diff --git a/compiler/sea_ir/frontend.cc b/compiler/sea_ir/frontend.cc index 93f6f25461..3512911f43 100644 --- a/compiler/sea_ir/frontend.cc +++ b/compiler/sea_ir/frontend.cc @@ -41,7 +41,7 @@ static CompiledMethod* CompileMethodWithSeaIr(CompilerDriver& compiler, const CompilerBackend compiler_backend, const DexFile::CodeItem* code_item, uint32_t method_access_flags, InvokeType invoke_type, - uint32_t class_def_idx, uint32_t method_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file #if defined(ART_USE_PORTABLE_COMPILER) , llvm::LlvmCompilationUnit* llvm_compilation_unit @@ -69,7 +69,7 @@ CompiledMethod* SeaIrCompileOneMethod(CompilerDriver& compiler, const DexFile::CodeItem* code_item, uint32_t method_access_flags, InvokeType invoke_type, - uint32_t class_def_idx, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file, @@ -86,7 +86,7 @@ extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& compiler, const art::DexFile::CodeItem* code_item, uint32_t method_access_flags, art::InvokeType invoke_type, - uint32_t class_def_idx, uint32_t method_idx, jobject class_loader, + uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const art::DexFile& dex_file) { // TODO: Check method fingerprint here to determine appropriate backend type. // Until then, use build default diff --git a/compiler/sea_ir/ir/sea.cc b/compiler/sea_ir/ir/sea.cc index 5ccaba6ad9..0734b21f12 100644 --- a/compiler/sea_ir/ir/sea.cc +++ b/compiler/sea_ir/ir/sea.cc @@ -191,7 +191,7 @@ void SeaGraph::InsertSignatureNodes(const art::DexFile::CodeItem* code_item, Reg } void SeaGraph::BuildMethodSeaGraph(const art::DexFile::CodeItem* code_item, - const art::DexFile& dex_file, uint32_t class_def_idx, + const art::DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx, uint32_t method_access_flags) { code_item_ = code_item; class_def_idx_ = class_def_idx; @@ -409,7 +409,7 @@ CodeGenData* SeaGraph::GenerateLLVM(const std::string& function_name, CodeGenData* SeaGraph::CompileMethod( const std::string& function_name, - const art::DexFile::CodeItem* code_item, uint32_t class_def_idx, + const art::DexFile::CodeItem* code_item, uint16_t class_def_idx, uint32_t method_idx, uint32_t method_access_flags, const art::DexFile& dex_file) { // Two passes: Builds the intermediate structure (non-SSA) of the sea-ir for the function. BuildMethodSeaGraph(code_item, dex_file, class_def_idx, method_idx, method_access_flags); diff --git a/compiler/sea_ir/ir/sea.h b/compiler/sea_ir/ir/sea.h index 92c2043dbd..26b16be019 100644 --- a/compiler/sea_ir/ir/sea.h +++ b/compiler/sea_ir/ir/sea.h @@ -262,7 +262,7 @@ class SeaGraph: IVisitable { static SeaGraph* GetGraph(const art::DexFile&); CodeGenData* CompileMethod(const std::string& function_name, - const art::DexFile::CodeItem* code_item, uint32_t class_def_idx, + const art::DexFile::CodeItem* code_item, uint16_t class_def_idx, uint32_t method_idx, uint32_t method_access_flags, const art::DexFile& dex_file); // Returns all regions corresponding to this SeaGraph. std::vector* GetRegions() { @@ -288,7 +288,7 @@ class SeaGraph: IVisitable { } TypeInference* ti_; - uint32_t class_def_idx_; + uint16_t class_def_idx_; uint32_t method_idx_; uint32_t method_access_flags_; @@ -311,7 +311,7 @@ class SeaGraph: IVisitable { // Builds the non-SSA sea-ir representation of the function @code_item from @dex_file // with class id @class_def_idx and method id @method_idx. void BuildMethodSeaGraph(const art::DexFile::CodeItem* code_item, - const art::DexFile& dex_file, uint32_t class_def_idx, + const art::DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx, uint32_t method_access_flags); // Computes immediate dominators for each region. // Precondition: ComputeMethodSeaGraph() diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index cf1b6af809..fc9e00c2cb 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -176,9 +176,10 @@ class OatDumper { CHECK(oat_dex_file != NULL); UniquePtr dex_file(oat_dex_file->OpenDexFile()); if (dex_file.get() != NULL) { - uint32_t class_def_index; - bool found = dex_file->FindClassDefIndex(mh.GetDeclaringClassDescriptor(), class_def_index); - if (found) { + const DexFile::ClassDef* class_def = + dex_file->FindClassDef(mh.GetDeclaringClassDescriptor()); + if (class_def != NULL) { + uint16_t class_def_index = dex_file->GetIndexForClassDef(*class_def); const OatFile::OatClass* oat_class = oat_dex_file->GetOatClass(class_def_index); CHECK(oat_class != NULL); size_t method_index = m->GetMethodIndex(); @@ -284,18 +285,17 @@ class OatDumper { } ClassDataItemIterator it(dex_file, class_data); SkipAllFields(it); - uint32_t class_def_idx = dex_file.GetIndexForClassDef(class_def); uint32_t class_method_idx = 0; while (it.HasNextDirectMethod()) { const OatFile::OatMethod oat_method = oat_class.GetOatMethod(class_method_idx); - DumpOatMethod(os, class_def_idx, class_method_idx, oat_method, dex_file, + DumpOatMethod(os, class_def, class_method_idx, oat_method, dex_file, it.GetMemberIndex(), it.GetMethodCodeItem(), it.GetMemberAccessFlags()); class_method_idx++; it.Next(); } while (it.HasNextVirtualMethod()) { const OatFile::OatMethod oat_method = oat_class.GetOatMethod(class_method_idx); - DumpOatMethod(os, class_def_idx, class_method_idx, oat_method, dex_file, + DumpOatMethod(os, class_def, class_method_idx, oat_method, dex_file, it.GetMemberIndex(), it.GetMethodCodeItem(), it.GetMemberAccessFlags()); class_method_idx++; it.Next(); @@ -304,7 +304,8 @@ class OatDumper { os << std::flush; } - void DumpOatMethod(std::ostream& os, uint32_t class_def_idx, uint32_t class_method_index, + void DumpOatMethod(std::ostream& os, const DexFile::ClassDef& class_def, + uint32_t class_method_index, const OatFile::OatMethod& oat_method, const DexFile& dex_file, uint32_t dex_method_idx, const DexFile::CodeItem* code_item, uint32_t method_access_flags) { @@ -323,7 +324,8 @@ class OatDumper { indent1_os << "VERIFIER TYPE ANALYSIS:\n"; Indenter indent2_filter(indent1_os.rdbuf(), kIndentChar, kIndentBy1Count); std::ostream indent2_os(&indent2_filter); - DumpVerifier(indent2_os, dex_method_idx, &dex_file, class_def_idx, code_item, method_access_flags); + DumpVerifier(indent2_os, dex_method_idx, &dex_file, class_def, code_item, + method_access_flags); } { indent1_os << "OAT DATA:\n"; @@ -363,7 +365,7 @@ class OatDumper { oat_method.GetCode() != NULL ? "..." : ""); Indenter indent2_filter(indent1_os.rdbuf(), kIndentChar, kIndentBy1Count); std::ostream indent2_os(&indent2_filter); - DumpCode(indent2_os, oat_method, dex_method_idx, &dex_file, class_def_idx, code_item, + DumpCode(indent2_os, oat_method, dex_method_idx, &dex_file, class_def, code_item, method_access_flags); } } @@ -554,7 +556,7 @@ class OatDumper { void DumpVRegsAtDexPc(std::ostream& os, const OatFile::OatMethod& oat_method, uint32_t dex_method_idx, const DexFile* dex_file, - uint32_t class_def_idx, const DexFile::CodeItem* code_item, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, uint32_t method_access_flags, uint32_t dex_pc) { static UniquePtr verifier; static const DexFile* verified_dex_file = NULL; @@ -563,7 +565,7 @@ class OatDumper { ScopedObjectAccess soa(Thread::Current()); mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(*dex_file); mirror::ClassLoader* class_loader = NULL; - verifier.reset(new verifier::MethodVerifier(dex_file, dex_cache, class_loader, class_def_idx, + verifier.reset(new verifier::MethodVerifier(dex_file, dex_cache, class_loader, &class_def, code_item, dex_method_idx, NULL, method_access_flags, true, true)); verifier->Verify(); @@ -615,21 +617,21 @@ class OatDumper { } void DumpVerifier(std::ostream& os, uint32_t dex_method_idx, const DexFile* dex_file, - uint32_t class_def_idx, const DexFile::CodeItem* code_item, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, uint32_t method_access_flags) { if ((method_access_flags & kAccNative) == 0) { ScopedObjectAccess soa(Thread::Current()); mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(*dex_file); mirror::ClassLoader* class_loader = NULL; verifier::MethodVerifier::VerifyMethodAndDump(os, dex_method_idx, dex_file, dex_cache, - class_loader, class_def_idx, code_item, NULL, + class_loader, &class_def, code_item, NULL, method_access_flags); } } void DumpCode(std::ostream& os, const OatFile::OatMethod& oat_method, uint32_t dex_method_idx, const DexFile* dex_file, - uint32_t class_def_idx, const DexFile::CodeItem* code_item, + const DexFile::ClassDef& class_def, const DexFile::CodeItem* code_item, uint32_t method_access_flags) { const void* code = oat_method.GetCode(); size_t code_size = oat_method.GetCodeSize(); @@ -647,7 +649,7 @@ class OatDumper { if (dex_pc != DexFile::kDexNoIndex) { DumpGcMapAtNativePcOffset(os, oat_method, code_item, offset); if (kDumpVRegs) { - DumpVRegsAtDexPc(os, oat_method, dex_method_idx, dex_file, class_def_idx, code_item, + DumpVRegsAtDexPc(os, oat_method, dex_method_idx, dex_file, class_def, code_item, method_access_flags, dex_pc); } } diff --git a/runtime/Android.mk b/runtime/Android.mk index a8d505e1f5..a0ae4bffbc 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -92,6 +92,7 @@ LIBART_COMMON_SRC_FILES := \ native/dalvik_system_VMStack.cc \ native/dalvik_system_Zygote.cc \ native/java_lang_Class.cc \ + native/java_lang_DexCache.cc \ native/java_lang_Object.cc \ native/java_lang_Runtime.cc \ native/java_lang_String.cc \ diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 0773a8d659..4043f8be5a 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -475,40 +475,33 @@ void ClassLinker::FinishInit() { // as the types of the field can't be resolved prior to the runtime being // fully initialized mirror::Class* java_lang_ref_Reference = GetClassRoot(kJavaLangRefReference); - mirror::Class* java_lang_ref_ReferenceQueue = FindSystemClass("Ljava/lang/ref/ReferenceQueue;"); - mirror::Class* java_lang_ref_FinalizerReference = FindSystemClass("Ljava/lang/ref/FinalizerReference;"); - - const DexFile& java_lang_dex = *java_lang_ref_Reference->GetDexCache()->GetDexFile(); + mirror::Class* java_lang_ref_FinalizerReference = + FindSystemClass("Ljava/lang/ref/FinalizerReference;"); mirror::ArtField* pendingNext = java_lang_ref_Reference->GetInstanceField(0); FieldHelper fh(pendingNext, this); CHECK_STREQ(fh.GetName(), "pendingNext"); - CHECK_EQ(java_lang_dex.GetFieldId(pendingNext->GetDexFieldIndex()).type_idx_, - java_lang_ref_Reference->GetDexTypeIndex()); + CHECK_STREQ(fh.GetTypeDescriptor(), "Ljava/lang/ref/Reference;"); mirror::ArtField* queue = java_lang_ref_Reference->GetInstanceField(1); fh.ChangeField(queue); CHECK_STREQ(fh.GetName(), "queue"); - CHECK_EQ(java_lang_dex.GetFieldId(queue->GetDexFieldIndex()).type_idx_, - java_lang_ref_ReferenceQueue->GetDexTypeIndex()); + CHECK_STREQ(fh.GetTypeDescriptor(), "Ljava/lang/ref/ReferenceQueue;"); mirror::ArtField* queueNext = java_lang_ref_Reference->GetInstanceField(2); fh.ChangeField(queueNext); CHECK_STREQ(fh.GetName(), "queueNext"); - CHECK_EQ(java_lang_dex.GetFieldId(queueNext->GetDexFieldIndex()).type_idx_, - java_lang_ref_Reference->GetDexTypeIndex()); + CHECK_STREQ(fh.GetTypeDescriptor(), "Ljava/lang/ref/Reference;"); mirror::ArtField* referent = java_lang_ref_Reference->GetInstanceField(3); fh.ChangeField(referent); CHECK_STREQ(fh.GetName(), "referent"); - CHECK_EQ(java_lang_dex.GetFieldId(referent->GetDexFieldIndex()).type_idx_, - GetClassRoot(kJavaLangObject)->GetDexTypeIndex()); + CHECK_STREQ(fh.GetTypeDescriptor(), "Ljava/lang/Object;"); mirror::ArtField* zombie = java_lang_ref_FinalizerReference->GetInstanceField(2); fh.ChangeField(zombie); CHECK_STREQ(fh.GetName(), "zombie"); - CHECK_EQ(java_lang_dex.GetFieldId(zombie->GetDexFieldIndex()).type_idx_, - GetClassRoot(kJavaLangObject)->GetDexTypeIndex()); + CHECK_STREQ(fh.GetTypeDescriptor(), "Ljava/lang/Object;"); gc::Heap* heap = Runtime::Current()->GetHeap(); heap->SetReferenceOffsets(referent->GetOffset(), @@ -1231,8 +1224,10 @@ mirror::Class* ClassLinker::AllocClass(Thread* self, mirror::Class* java_lang_Cl return NULL; } mirror::Class* klass = k->AsClass(); - klass->SetPrimitiveType(Primitive::kPrimNot); // default to not being primitive + klass->SetPrimitiveType(Primitive::kPrimNot); // Default to not being primitive. klass->SetClassSize(class_size); + klass->SetDexClassDefIndex(DexFile::kDexNoIndex16); // Default to no valid class def index. + klass->SetDexTypeIndex(DexFile::kDexNoIndex16); // Default to no valid type index. return klass; } @@ -1496,26 +1491,21 @@ size_t ClassLinker::SizeOfClass(const DexFile& dex_file, return size; } -const OatFile::OatClass* ClassLinker::GetOatClass(const DexFile& dex_file, const char* descriptor) { - DCHECK(descriptor != NULL); +const OatFile::OatClass* ClassLinker::GetOatClass(const DexFile& dex_file, uint16_t class_def_idx) { + DCHECK_NE(class_def_idx, DexFile::kDexNoIndex16); const OatFile* oat_file = FindOpenedOatFileForDexFile(dex_file); - CHECK(oat_file != NULL) << dex_file.GetLocation() << " " << descriptor; + CHECK(oat_file != NULL) << dex_file.GetLocation(); const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation()); - CHECK(oat_dex_file != NULL) << dex_file.GetLocation() << " " << descriptor; - uint32_t class_def_index; - bool found = dex_file.FindClassDefIndex(descriptor, class_def_index); - CHECK(found) << dex_file.GetLocation() << " " << descriptor; - const OatFile::OatClass* oat_class = oat_dex_file->GetOatClass(class_def_index); - CHECK(oat_class != NULL) << dex_file.GetLocation() << " " << descriptor; + CHECK(oat_dex_file != NULL) << dex_file.GetLocation(); + const OatFile::OatClass* oat_class = oat_dex_file->GetOatClass(class_def_idx); + CHECK(oat_class != NULL) << dex_file.GetLocation() << " " << class_def_idx; return oat_class; } -static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file, uint32_t method_idx) { - const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx); - const DexFile::TypeId& type_id = dex_file.GetTypeId(method_id.class_idx_); - const DexFile::ClassDef* class_def = dex_file.FindClassDef(dex_file.GetTypeDescriptor(type_id)); - CHECK(class_def != NULL); - const byte* class_data = dex_file.GetClassData(*class_def); +static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file, uint16_t class_def_idx, + uint32_t method_idx) { + const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx); + const byte* class_data = dex_file.GetClassData(class_def); CHECK(class_data != NULL); ClassDataItemIterator it(dex_file, class_data); // Skip fields @@ -1569,11 +1559,13 @@ const OatFile::OatMethod ClassLinker::GetOatMethodFor(const mirror::ArtMethod* m } CHECK(found) << "Didn't find oat method index for virtual method: " << PrettyMethod(method); } - ClassHelper kh(declaring_class); - UniquePtr oat_class(GetOatClass(kh.GetDexFile(), kh.GetDescriptor())); + UniquePtr + oat_class(GetOatClass(*declaring_class->GetDexCache()->GetDexFile(), + declaring_class->GetDexClassDefIndex())); CHECK(oat_class.get() != NULL); DCHECK_EQ(oat_method_index, GetOatMethodIndexFromMethodIndex(*declaring_class->GetDexCache()->GetDexFile(), + method->GetDeclaringClass()->GetDexClassDefIndex(), method->GetDexMethodIndex())); return oat_class->GetOatMethod(oat_method_index); @@ -1597,12 +1589,11 @@ const void* ClassLinker::GetOatCodeFor(const mirror::ArtMethod* method) { return result; } -const void* ClassLinker::GetOatCodeFor(const DexFile& dex_file, uint32_t method_idx) { - const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx); - const char* descriptor = dex_file.GetTypeDescriptor(dex_file.GetTypeId(method_id.class_idx_)); - uint32_t oat_method_idx = GetOatMethodIndexFromMethodIndex(dex_file, method_idx); - UniquePtr oat_class(GetOatClass(dex_file, descriptor)); - CHECK(oat_class.get() != NULL); +const void* ClassLinker::GetOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, + uint32_t method_idx) { + UniquePtr oat_class(GetOatClass(dex_file, class_def_idx)); + CHECK(oat_class.get() != nullptr); + uint32_t oat_method_idx = GetOatMethodIndexFromMethodIndex(dex_file, class_def_idx, method_idx); return oat_class->GetOatMethod(oat_method_idx).GetCode(); } @@ -1639,7 +1630,7 @@ void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) { // OAT file unavailable return; } - UniquePtr oat_class(GetOatClass(dex_file, kh.GetDescriptor())); + UniquePtr oat_class(GetOatClass(dex_file, klass->GetDexClassDefIndex())); CHECK(oat_class.get() != NULL); ClassDataItemIterator it(dex_file, class_data); // Skip fields @@ -1731,6 +1722,7 @@ void ClassLinker::LoadClass(const DexFile& dex_file, DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot); klass->SetStatus(mirror::Class::kStatusIdx, NULL); + klass->SetDexClassDefIndex(dex_file.GetIndexForClassDef(dex_class_def)); klass->SetDexTypeIndex(dex_class_def.class_idx_); // Load fields fields. @@ -1778,7 +1770,7 @@ void ClassLinker::LoadClass(const DexFile& dex_file, UniquePtr oat_class; if (Runtime::Current()->IsStarted() && !Runtime::Current()->UseCompileTimeClassPath()) { - oat_class.reset(GetOatClass(dex_file, descriptor)); + oat_class.reset(GetOatClass(dex_file, klass->GetDexClassDefIndex())); } // Load methods. @@ -1873,7 +1865,8 @@ mirror::ArtMethod* ClassLinker::LoadMethod(Thread* self, const DexFile& dex_file if (klass->GetClassLoader() != NULL) { // All non-boot finalizer methods are flagged klass->SetFinalizable(); } else { - StringPiece klass_descriptor(dex_file.StringByTypeIdx(klass->GetDexTypeIndex())); + ClassHelper kh(klass.get()); + StringPiece klass_descriptor(kh.GetDescriptor()); // The Enum class declares a "final" finalize() method to prevent subclasses from // introducing a finalizer. We don't want to set the finalizable flag for Enum or its // subclasses, so we exclude it here. @@ -2339,12 +2332,16 @@ mirror::Class* ClassLinker::LookupClassFromImage(const char* descriptor) { const DexFile* dex_file = dex_cache->GetDexFile(); // First search using the class def map, but don't bother for non-class types. if (descriptor[0] == 'L') { - const DexFile::ClassDef* class_def = dex_file->FindClassDef(descriptor); - if (class_def != NULL) { - mirror::Class* klass = dex_cache->GetResolvedType(class_def->class_idx_); - if (klass != NULL) { - self->EndAssertNoThreadSuspension(old_no_suspend_cause); - return klass; + const DexFile::StringId* descriptor_string_id = dex_file->FindStringId(descriptor); + if (descriptor_string_id != NULL) { + const DexFile::TypeId* type_id = + dex_file->FindTypeId(dex_file->GetIndexForStringId(*descriptor_string_id)); + if (type_id != NULL) { + mirror::Class* klass = dex_cache->GetResolvedType(dex_file->GetIndexForTypeId(*type_id)); + if (klass != NULL) { + self->EndAssertNoThreadSuspension(old_no_suspend_cause); + return klass; + } } } } @@ -2455,8 +2452,9 @@ void ClassLinker::VerifyClass(mirror::Class* klass) { verifier::MethodVerifier::FailureKind verifier_failure = verifier::MethodVerifier::kNoFailure; std::string error_msg; if (!preverified) { - verifier_failure = verifier::MethodVerifier::VerifyClass(klass, error_msg, - Runtime::Current()->IsCompiler()); + verifier_failure = verifier::MethodVerifier::VerifyClass(klass, + Runtime::Current()->IsCompiler(), + &error_msg); } if (preverified || verifier_failure != verifier::MethodVerifier::kHardFailure) { if (!preverified && verifier_failure != verifier::MethodVerifier::kNoFailure) { @@ -2527,7 +2525,6 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class } } - const OatFile* oat_file = FindOpenedOatFileForDexFile(dex_file); // Make this work with gtests, which do not set up the image properly. // TODO: we should clean up gtests to set up the image path properly. @@ -2539,9 +2536,7 @@ bool ClassLinker::VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_file.GetLocation()); CHECK(oat_dex_file != NULL) << dex_file.GetLocation() << " " << PrettyClass(klass); const char* descriptor = ClassHelper(klass).GetDescriptor(); - uint32_t class_def_index; - bool found = dex_file.FindClassDefIndex(descriptor, class_def_index); - CHECK(found) << dex_file.GetLocation() << " " << PrettyClass(klass) << " " << descriptor; + uint16_t class_def_index = klass->GetDexClassDefIndex(); UniquePtr oat_class(oat_dex_file->GetOatClass(class_def_index)); CHECK(oat_class.get() != NULL) << dex_file.GetLocation() << " " << PrettyClass(klass) << " " << descriptor; @@ -2654,8 +2649,6 @@ mirror::Class* ClassLinker::CreateProxyClass(mirror::String* name, klass->SetStatus(mirror::Class::kStatusIdx, self); - klass->SetDexTypeIndex(DexFile::kDexNoIndex16); - // Instance fields are inherited, but we add a couple of static fields... { mirror::ObjectArray* sfields = AllocArtFieldArray(self, 2); @@ -3262,10 +3255,8 @@ bool ClassLinker::LinkClass(SirtRef& klass, bool ClassLinker::LoadSuperAndInterfaces(SirtRef& klass, const DexFile& dex_file) { CHECK_EQ(mirror::Class::kStatusIdx, klass->GetStatus()); - StringPiece descriptor(dex_file.StringByTypeIdx(klass->GetDexTypeIndex())); - const DexFile::ClassDef* class_def = dex_file.FindClassDef(descriptor); - CHECK(class_def != NULL); - uint16_t super_class_idx = class_def->superclass_idx_; + const DexFile::ClassDef& class_def = dex_file.GetClassDef(klass->GetDexClassDefIndex()); + uint16_t super_class_idx = class_def.superclass_idx_; if (super_class_idx != DexFile::kDexNoIndex16) { mirror::Class* super_class = ResolveType(dex_file, super_class_idx, klass.get()); if (super_class == NULL) { @@ -3281,7 +3272,7 @@ bool ClassLinker::LoadSuperAndInterfaces(SirtRef& klass, const De } klass->SetSuperClass(super_class); } - const DexFile::TypeList* interfaces = dex_file.GetInterfacesList(*class_def); + const DexFile::TypeList* interfaces = dex_file.GetInterfacesList(class_def); if (interfaces != NULL) { for (size_t i = 0; i < interfaces->Size(); i++) { uint16_t idx = interfaces->GetTypeItem(i).type_idx_; diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 20efbb43a9..3ffcf14447 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -329,7 +329,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method from a method index. - const void* GetOatCodeFor(const DexFile& dex_file, uint32_t method_idx) + const void* GetOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); pid_t GetClassesLockOwner(); // For SignalCatcher. @@ -424,7 +424,7 @@ class ClassLinker { void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Finds the associated oat class for a dex_file and descriptor - const OatFile::OatClass* GetOatClass(const DexFile& dex_file, const char* descriptor) + const OatFile::OatClass* GetOatClass(const DexFile& dex_file, uint16_t class_def_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void RegisterDexFileLocked(const DexFile& dex_file, SirtRef& dex_cache) diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 995434c1f7..bbc2877b73 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -507,6 +507,7 @@ struct ClassOffsets : public CheckOffsets { offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, access_flags_), "accessFlags")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, class_size_), "classSize")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, clinit_thread_id_), "clinitThreadId")); + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_class_def_idx_), "dexClassDefIndex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, dex_type_idx_), "dexTypeIndex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_instance_fields_), "numReferenceInstanceFields")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::Class, num_reference_static_fields_), "numReferenceStaticFields")); @@ -569,10 +570,6 @@ struct ProxyOffsets : public CheckOffsets { struct ClassClassOffsets : public CheckOffsets { ClassClassOffsets() : CheckOffsets(true, "Ljava/lang/Class;") { - // padding 32-bit - CHECK_EQ(OFFSETOF_MEMBER(mirror::ClassClass, padding_) + 4, - OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_)); - // alphabetical 64-bit offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::ClassClass, serialVersionUID_), "serialVersionUID")); }; @@ -584,11 +581,11 @@ struct StringClassOffsets : public CheckOffsets { offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, ASCII_), "ASCII")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, CASE_INSENSITIVE_ORDER_), "CASE_INSENSITIVE_ORDER")); - // padding 32-bit - offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); - // alphabetical 64-bit offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, serialVersionUID_), "serialVersionUID")); + + // alphabetical 32-bit + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::StringClass, REPLACEMENT_CHAR_), "REPLACEMENT_CHAR")); }; }; @@ -605,6 +602,7 @@ struct ArtMethodClassOffsets : public CheckOffsets { struct DexCacheOffsets : public CheckOffsets { DexCacheOffsets() : CheckOffsets(false, "Ljava/lang/DexCache;") { // alphabetical references + offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, dex_), "dex")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, initialized_static_storage_), "initializedStaticStorage")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, location_), "location")); offsets.push_back(CheckOffset(OFFSETOF_MEMBER(mirror::DexCache, resolved_fields_), "resolvedFields")); diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc index 4fd9a608c1..e81c456ccf 100644 --- a/runtime/dex_file.cc +++ b/runtime/dex_file.cc @@ -48,7 +48,7 @@ namespace art { const byte DexFile::kDexMagic[] = { 'd', 'e', 'x', '\n' }; const byte DexFile::kDexMagicVersion[] = { '0', '3', '5', '\0' }; -DexFile::ClassPathEntry DexFile::FindInClassPath(const StringPiece& descriptor, +DexFile::ClassPathEntry DexFile::FindInClassPath(const char* descriptor, const ClassPath& class_path) { for (size_t i = 0; i != class_path.size(); ++i) { const DexFile* dex_file = class_path[i]; @@ -251,56 +251,11 @@ DexFile::~DexFile() { // the global reference table is otherwise empty! } -class ScopedJniMonitorLock { - public: - ScopedJniMonitorLock(JNIEnv* env, jobject locked) : env_(env), locked_(locked) { - env->MonitorEnter(locked_); - } - ~ScopedJniMonitorLock() { - env_->MonitorExit(locked_); - } - private: - JNIEnv* const env_; - const jobject locked_; -}; - -jobject DexFile::GetDexObject(JNIEnv* env) const { - { - ScopedJniMonitorLock lock(env, WellKnownClasses::com_android_dex_Dex); - if (dex_object_ != NULL) { - return dex_object_; - } - } - void* address = const_cast(reinterpret_cast(begin_)); - jobject byte_buffer = env->NewDirectByteBuffer(address, size_); - if (byte_buffer == NULL) { - return NULL; - } - - ScopedJniMonitorLock lock(env, WellKnownClasses::com_android_dex_Dex); - // Re-test to see if someone beat us to the creation when we had the lock released. - if (dex_object_ != NULL) { - return dex_object_; - } - jvalue args[1]; - args[0].l = byte_buffer; - jobject local = env->CallStaticObjectMethodA(WellKnownClasses::com_android_dex_Dex, - WellKnownClasses::com_android_dex_Dex_create, - args); - if (local == NULL) { - return NULL; - } - - dex_object_ = env->NewGlobalRef(local); - return dex_object_; -} - bool DexFile::Init() { InitMembers(); if (!CheckMagicAndVersion()) { return false; } - InitIndex(); return true; } @@ -351,28 +306,36 @@ uint32_t DexFile::GetVersion() const { return atoi(version); } -void DexFile::InitIndex() { - CHECK_EQ(index_.size(), 0U) << GetLocation(); - for (size_t i = 0; i < NumClassDefs(); ++i) { - const ClassDef& class_def = GetClassDef(i); - const char* descriptor = GetClassDescriptor(class_def); - index_.Put(descriptor, i); +const DexFile::ClassDef* DexFile::FindClassDef(const char* descriptor) const { + size_t num_class_defs = NumClassDefs(); + if (num_class_defs == 0) { + return NULL; } -} - -bool DexFile::FindClassDefIndex(const StringPiece& descriptor, uint32_t& idx) const { - Index::const_iterator it = index_.find(descriptor); - if (it == index_.end()) { - return false; + const StringId* string_id = FindStringId(descriptor); + if (string_id == NULL) { + return NULL; } - idx = it->second; - return true; + const TypeId* type_id = FindTypeId(GetIndexForStringId(*string_id)); + if (type_id == NULL) { + return NULL; + } + uint16_t type_idx = GetIndexForTypeId(*type_id); + for (size_t i = 0; i < num_class_defs; ++i) { + const ClassDef& class_def = GetClassDef(i); + if (class_def.class_idx_ == type_idx) { + return &class_def; + } + } + return NULL; } -const DexFile::ClassDef* DexFile::FindClassDef(const StringPiece& descriptor) const { - uint32_t idx; - if (FindClassDefIndex(descriptor, idx)) { - return &GetClassDef(idx); +const DexFile::ClassDef* DexFile::FindClassDef(uint16_t type_idx) const { + size_t num_class_defs = NumClassDefs(); + for (size_t i = 0; i < num_class_defs; ++i) { + const ClassDef& class_def = GetClassDef(i); + if (class_def.class_idx_ == type_idx) { + return &class_def; + } } return NULL; } diff --git a/runtime/dex_file.h b/runtime/dex_file.h index 26635ae255..7be5cb848f 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -339,7 +339,7 @@ class DexFile { typedef std::vector ClassPath; // Search a collection of DexFiles for a descriptor - static ClassPathEntry FindInClassPath(const StringPiece& descriptor, + static ClassPathEntry FindInClassPath(const char* descriptor, const ClassPath& class_path); // Returns the checksum of a file for comparison with GetLocationChecksum(). @@ -376,10 +376,6 @@ class DexFile { return location_checksum_; } - // Returns a com.android.dex.Dex object corresponding to the mapped-in dex file. - // Used by managed code to implement annotations. - jobject GetDexObject(JNIEnv* env) const; - const Header& GetHeader() const { DCHECK(header_ != NULL) << GetLocation(); return *header_; @@ -584,12 +580,12 @@ class DexFile { } // Returns the ClassDef at the specified index. - const ClassDef& GetClassDef(uint32_t idx) const { + const ClassDef& GetClassDef(uint16_t idx) const { DCHECK_LT(idx, NumClassDefs()) << GetLocation(); return class_defs_[idx]; } - uint32_t GetIndexForClassDef(const ClassDef& class_def) const { + uint16_t GetIndexForClassDef(const ClassDef& class_def) const { CHECK_GE(&class_def, class_defs_) << GetLocation(); CHECK_LT(&class_def, class_defs_ + header_->class_defs_size_) << GetLocation(); return &class_def - class_defs_; @@ -601,10 +597,10 @@ class DexFile { } // Looks up a class definition by its class descriptor. - const ClassDef* FindClassDef(const StringPiece& descriptor) const; + const ClassDef* FindClassDef(const char* descriptor) const; - // Looks up a class definition index by its class descriptor. - bool FindClassDefIndex(const StringPiece& descriptor, uint32_t& idx) const; + // Looks up a class definition by its type index. + const ClassDef* FindClassDef(uint16_t type_idx) const; const TypeList* GetInterfacesList(const ClassDef& class_def) const { if (class_def.interfaces_off_ == 0) { @@ -809,6 +805,14 @@ class DexFile { bool DisableWrite() const; + const byte* Begin() const { + return begin_; + } + + size_t Size() const { + return size_; + } + private: // Opens a .dex file static const DexFile* OpenFile(const std::string& filename, @@ -840,7 +844,6 @@ class DexFile { location_(location), location_checksum_(location_checksum), mem_map_(mem_map), - dex_object_(NULL), modification_lock("DEX modification lock"), header_(0), string_ids_(0), @@ -853,23 +856,12 @@ class DexFile { CHECK_GT(size_, 0U) << GetLocation(); } - const byte* Begin() const { - return begin_; - } - - size_t Size() const { - return size_; - } - // Top-level initializer that calls other Init methods. bool Init(); // Caches pointers into to the various file sections. void InitMembers(); - // Builds the index of descriptors to class definitions. - void InitIndex(); - // Returns true if the header magic and version numbers are of the expected values. bool CheckMagicAndVersion() const; @@ -877,10 +869,6 @@ class DexFile { DexDebugNewPositionCb position_cb, DexDebugNewLocalCb local_cb, void* context, const byte* stream, LocalInfo* local_in_reg) const; - // The index of descriptors to class definition indexes (as opposed to type id indexes) - typedef SafeMap Index; - Index index_; - // The base address of the memory mapping. const byte* const begin_; @@ -898,10 +886,6 @@ class DexFile { // Manages the underlying memory allocation. UniquePtr mem_map_; - // A cached com.android.dex.Dex instance, possibly NULL. Use GetDexObject. - // TODO: this is mutable as it shouldn't be here. We should move it to the dex cache or similar. - mutable jobject dex_object_; - // The DEX-to-DEX compiler uses this lock to ensure thread safety when // enabling write access to a read-only DEX file. // TODO: move to Locks::dex_file_modification_lock. diff --git a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc index 1d8022f803..07c1c015aa 100644 --- a/runtime/entrypoints/quick/quick_invoke_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_invoke_entrypoints.cc @@ -32,7 +32,7 @@ extern "C" uint64_t artInvokeInterfaceTrampoline(mirror::ArtMethod* interface_me Thread* self, mirror::ArtMethod** sp) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::ArtMethod* method; - if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex16)) { + if (LIKELY(interface_method->GetDexMethodIndex() != DexFile::kDexNoIndex)) { method = this_object->GetClass()->FindVirtualMethodForInterface(interface_method); if (UNLIKELY(method == NULL)) { FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsAndArgs); diff --git a/runtime/mirror/art_method-inl.h b/runtime/mirror/art_method-inl.h index 224b2ba0d4..ccf3e59f18 100644 --- a/runtime/mirror/art_method-inl.h +++ b/runtime/mirror/art_method-inl.h @@ -178,7 +178,7 @@ inline uint32_t ArtMethod::GetOatNativeGcMapOffset() const { } inline bool ArtMethod::IsRuntimeMethod() const { - return GetDexMethodIndex() == DexFile::kDexNoIndex16; + return GetDexMethodIndex() == DexFile::kDexNoIndex; } inline bool ArtMethod::IsCalleeSaveMethod() const { diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 5e8b82793a..add7e1b2af 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -128,7 +128,10 @@ Object* Class::AllocObject(Thread* self) { } void Class::SetClassSize(size_t new_class_size) { - DCHECK_GE(new_class_size, GetClassSize()) << " class=" << PrettyTypeOf(this); + if (kIsDebugBuild && (new_class_size < GetClassSize())) { + DumpClass(LOG(ERROR), kDumpClassFullDetail); + CHECK_GE(new_class_size, GetClassSize()) << " class=" << PrettyTypeOf(this); + } SetField32(OFFSET_OF_OBJECT_MEMBER(Class, class_size_), new_class_size, false); } @@ -300,22 +303,8 @@ bool Class::IsInSamePackage(const Class* that) const { return true; } // Compare the package part of the descriptor string. - if (LIKELY(!klass1->IsProxyClass() && !klass2->IsProxyClass())) { - ClassHelper kh(klass1); - const DexFile* dex_file1 = &kh.GetDexFile(); - const DexFile::TypeId* type_id1 = &dex_file1->GetTypeId(klass1->GetDexTypeIndex()); - const char* descriptor1 = dex_file1->GetTypeDescriptor(*type_id1); - kh.ChangeClass(klass2); - const DexFile* dex_file2 = &kh.GetDexFile(); - const DexFile::TypeId* type_id2 = &dex_file2->GetTypeId(klass2->GetDexTypeIndex()); - const char* descriptor2 = dex_file2->GetTypeDescriptor(*type_id2); - return IsInSamePackage(descriptor1, descriptor2); - } - ClassHelper kh(klass1); - std::string descriptor1(kh.GetDescriptor()); - kh.ChangeClass(klass2); - std::string descriptor2(kh.GetDescriptor()); - return IsInSamePackage(descriptor1, descriptor2); + return IsInSamePackage(ClassHelper(klass1).GetDescriptor(), + ClassHelper(klass2).GetDescriptor()); } bool Class::IsClassClass() const { diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 99f3850b9b..d97b603ad8 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -726,6 +726,14 @@ class MANAGED Class : public StaticStorageBase { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(Class, verify_error_class_), false); } + uint16_t GetDexClassDefIndex() const { + return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), false); + } + + void SetDexClassDefIndex(uint16_t class_def_idx) { + SetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), class_def_idx, false); + } + uint16_t GetDexTypeIndex() const { return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_), false); } @@ -807,7 +815,7 @@ class MANAGED Class : public StaticStorageBase { // If class verify fails, we must return same error on subsequent tries. Class* verify_error_class_; - // virtual methods defined in this class; invoked through vtable + // Virtual methods defined in this class; invoked through vtable. ObjectArray* virtual_methods_; // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is @@ -816,24 +824,28 @@ class MANAGED Class : public StaticStorageBase { // virtual_ methods_ for miranda methods. ObjectArray* vtable_; - // access flags; low 16 bits are defined by VM spec + // Access flags; low 16 bits are defined by VM spec. uint32_t access_flags_; // Total size of the Class instance; used when allocating storage on gc heap. // See also object_size_. size_t class_size_; - // tid used to check for recursive invocation + // Tid used to check for recursive invocation. pid_t clinit_thread_id_; - // type index from dex file + // ClassDef index in dex file, -1 if no class definition such as an array. + // TODO: really 16bits + int32_t dex_class_def_idx_; + + // Type index in dex file. // TODO: really 16bits - uint32_t dex_type_idx_; + int32_t dex_type_idx_; - // number of instance fields that are object refs + // Number of instance fields that are object refs. size_t num_reference_instance_fields_; - // number of static fields that are object refs + // Number of static fields that are object refs, size_t num_reference_static_fields_; // Total object size; used when allocating storage on gc heap. @@ -841,7 +853,7 @@ class MANAGED Class : public StaticStorageBase { // See also class_size_. size_t object_size_; - // primitive type value, or Primitive::kPrimNot (0); set for generated prim classes + // Primitive type value, or Primitive::kPrimNot (0); set for generated primitive classes. Primitive::Type primitive_type_; // Bitmap of offsets of ifields. @@ -850,7 +862,7 @@ class MANAGED Class : public StaticStorageBase { // Bitmap of offsets of sfields. uint32_t reference_static_offsets_; - // state of class initialization + // State of class initialization. Status status_; // TODO: ? @@ -873,7 +885,6 @@ std::ostream& operator<<(std::ostream& os, const Class::Status& rhs); class MANAGED ClassClass : public Class { private: - int32_t padding_; int64_t serialVersionUID_; friend struct art::ClassClassOffsets; // for verifying offset information DISALLOW_IMPLICIT_CONSTRUCTORS(ClassClass); diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 6cfab9e425..0522f134af 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -164,6 +164,7 @@ class MANAGED DexCache : public Object { } private: + Object* dex_; ObjectArray* initialized_static_storage_; String* location_; ObjectArray* resolved_fields_; diff --git a/runtime/mirror/proxy.h b/runtime/mirror/proxy.h index 7c5bc39429..18a84dcbdb 100644 --- a/runtime/mirror/proxy.h +++ b/runtime/mirror/proxy.h @@ -25,6 +25,8 @@ struct ProxyOffsets; namespace mirror { +// All proxy objects have a class which is a synthesized proxy class. The synthesized proxy class +// has the static fields used to implement reflection on proxy objects. class MANAGED SynthesizedProxyClass : public Class { public: ObjectArray* GetInterfaces() { @@ -41,6 +43,7 @@ class MANAGED SynthesizedProxyClass : public Class { DISALLOW_IMPLICIT_CONSTRUCTORS(SynthesizedProxyClass); }; +// C++ mirror of java.lang.reflect.Proxy. class MANAGED Proxy : public Object { private: Object* h_; diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index bf545eaefb..81fe42f2a6 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -155,8 +155,8 @@ class MANAGED StringClass : public Class { private: CharArray* ASCII_; Object* CASE_INSENSITIVE_ORDER_; - uint32_t REPLACEMENT_CHAR_; int64_t serialVersionUID_; + uint32_t REPLACEMENT_CHAR_; friend struct art::StringClassOffsets; // for verifying offset information DISALLOW_IMPLICIT_CONSTRUCTORS(StringClass); }; diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 2f4e427bb6..d2a6c0edb4 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -150,7 +150,7 @@ static jclass DexFile_defineClassNative(JNIEnv* env, jclass, jstring javaName, j return NULL; } const std::string descriptor(DotToDescriptor(class_name.c_str())); - const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor); + const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor.c_str()); if (dex_class_def == NULL) { VLOG(class_linker) << "Failed to find dex_class_def"; return NULL; diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index a7296996da..d3011cb013 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -78,35 +78,6 @@ static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean return soa.AddLocalReference(c); } -static jint Class_getAnnotationDirectoryOffset(JNIEnv* env, jclass javaClass) { - ScopedObjectAccess soa(env); - mirror::Class* c = DecodeClass(soa, javaClass); - if (c->IsPrimitive() || c->IsArrayClass() || c->IsProxyClass()) { - return 0; // primitive, array and proxy classes don't have class definitions - } - const DexFile::ClassDef* class_def = ClassHelper(c).GetClassDef(); - if (class_def == NULL) { - return 0; // not found - } else { - return class_def->annotations_off_; - } -} - -static jobject Class_getDex(JNIEnv* env, jobject javaClass) { - ScopedObjectAccess soa(env); - mirror::Class* c = DecodeClass(soa, javaClass); - - mirror::DexCache* dex_cache = c->GetDexCache(); - if (dex_cache == NULL) { - return NULL; - } - const DexFile* dex_file = dex_cache->GetDexFile(); - if (dex_file == NULL) { - return NULL; - } - return dex_file->GetDexObject(env); -} - static jstring Class_getNameNative(JNIEnv* env, jobject javaThis) { ScopedObjectAccess soa(env); mirror::Class* c = DecodeClass(soa, javaThis); @@ -122,8 +93,6 @@ static jobjectArray Class_getProxyInterfaces(JNIEnv* env, jobject javaThis) { static JNINativeMethod gMethods[] = { NATIVE_METHOD(Class, classForName, "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"), - NATIVE_METHOD(Class, getAnnotationDirectoryOffset, "()I"), - NATIVE_METHOD(Class, getDex, "()Lcom/android/dex/Dex;"), NATIVE_METHOD(Class, getNameNative, "()Ljava/lang/String;"), NATIVE_METHOD(Class, getProxyInterfaces, "()[Ljava/lang/Class;"), }; diff --git a/runtime/native/java_lang_DexCache.cc b/runtime/native/java_lang_DexCache.cc new file mode 100644 index 0000000000..f8eeb2906e --- /dev/null +++ b/runtime/native/java_lang_DexCache.cc @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2008 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 "dex_file.h" +#include "mirror/dex_cache.h" +#include "mirror/object-inl.h" +#include "scoped_thread_state_change.h" +#include "well_known_classes.h" + +namespace art { + +static jobject DexCache_getDexNative(JNIEnv* env, jobject javaDexCache) { + ScopedObjectAccess soa(env); + mirror::DexCache* dex_cache = soa.Decode(javaDexCache); + // Should only be called while holding the lock on the dex cache. + DCHECK_EQ(dex_cache->GetThinLockId(), soa.Self()->GetThinLockId()); + const DexFile* dex_file = dex_cache->GetDexFile(); + if (dex_file == NULL) { + return NULL; + } + void* address = const_cast(reinterpret_cast(dex_file->Begin())); + jobject byte_buffer = env->NewDirectByteBuffer(address, dex_file->Size()); + if (byte_buffer == NULL) { + DCHECK(soa.Self()->IsExceptionPending()); + return NULL; + } + + jvalue args[1]; + args[0].l = byte_buffer; + return env->CallStaticObjectMethodA(WellKnownClasses::com_android_dex_Dex, + WellKnownClasses::com_android_dex_Dex_create, + args); +} + +static JNINativeMethod gMethods[] = { + NATIVE_METHOD(DexCache, getDexNative, "()Lcom/android/dex/Dex;"), +}; + +void register_java_lang_DexCache(JNIEnv* env) { + REGISTER_NATIVE_METHODS("java/lang/DexCache"); +} + +} // namespace art diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index afa823dbd9..4c970172b4 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -365,7 +365,7 @@ const DexFile* OatFile::OatDexFile::OpenDexFile() const { dex_file_location_checksum_); } -const OatFile::OatClass* OatFile::OatDexFile::GetOatClass(uint32_t class_def_index) const { +const OatFile::OatClass* OatFile::OatDexFile::GetOatClass(uint16_t class_def_index) const { uint32_t oat_class_offset = oat_class_offsets_pointer_[class_def_index]; const byte* oat_class_pointer = oat_file_->Begin() + oat_class_offset; diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 325ebb2914..bbd2615b66 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -183,7 +183,7 @@ class OatFile { } // Returns the OatClass for the class specified by the given DexFile class_def_index. - const OatClass* GetOatClass(uint32_t class_def_index) const; + const OatClass* GetOatClass(uint16_t class_def_index) const; ~OatDexFile(); diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 29102437a2..6ee3016179 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -68,8 +68,7 @@ class ClassHelper { public: ClassHelper(const mirror::Class* c = NULL, ClassLinker* l = NULL) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) - : class_def_(NULL), - class_linker_(l), + : class_linker_(l), dex_cache_(NULL), dex_file_(NULL), interface_type_list_(NULL), @@ -92,7 +91,6 @@ class ClassHelper { } klass_ = new_c; interface_type_list_ = NULL; - class_def_ = NULL; } // The returned const char* is only guaranteed to be valid for the lifetime of the ClassHelper. @@ -108,7 +106,7 @@ class ClassHelper { return descriptor_.c_str(); } else { const DexFile& dex_file = GetDexFile(); - const DexFile::TypeId& type_id = dex_file.GetTypeId(klass_->GetDexTypeIndex()); + const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); return dex_file.GetTypeDescriptor(type_id); } } @@ -124,14 +122,13 @@ class ClassHelper { return descriptor_.c_str(); } - const DexFile::ClassDef* GetClassDef() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const DexFile::ClassDef* result = class_def_; - if (result == NULL) { - result = GetDexFile().FindClassDef(GetDescriptor()); - class_def_ = result; + const DexFile::ClassDef* GetClassDef() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + DCHECK(klass_ != nullptr); + uint16_t class_def_idx = klass_->GetDexClassDefIndex(); + if (class_def_idx == DexFile::kDexNoIndex16) { + return nullptr; } - return result; + return &GetDexFile().GetClassDef(class_def_idx); } uint32_t NumDirectInterfaces() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -187,7 +184,7 @@ class ClassHelper { const char* GetSourceFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { std::string descriptor(GetDescriptor()); const DexFile& dex_file = GetDexFile(); - const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor); + const DexFile::ClassDef* dex_class_def = GetClassDef(); CHECK(dex_class_def != NULL); return dex_file.GetSourceFile(*dex_class_def); } @@ -242,7 +239,6 @@ class ClassHelper { return result; } - const DexFile::ClassDef* class_def_; ClassLinker* class_linker_; mirror::DexCache* dex_cache_; const DexFile* dex_file_; @@ -327,12 +323,15 @@ class FieldHelper { // If you need it longer, copy it into a std::string. const char* GetDeclaringClassDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - uint16_t type_idx = field_->GetDeclaringClass()->GetDexTypeIndex(); - if (type_idx != DexFile::kDexNoIndex16) { + uint32_t field_index = field_->GetDexFieldIndex(); + if (!field_->GetDeclaringClass()->IsProxyClass()) { const DexFile& dex_file = GetDexFile(); - return dex_file.GetTypeDescriptor(dex_file.GetTypeId(type_idx)); + const DexFile::FieldId& field_id = dex_file.GetFieldId(field_index); + return dex_file.GetFieldDeclaringClassDescriptor(field_id); } else { - // Most likely a proxy class. + DCHECK(field_->IsStatic()); + DCHECK_LT(field_index, 2U); + // 0 == Class[] interfaces; 1 == Class[][] throws; ClassHelper kh(field_->GetDeclaringClass()); declaring_class_descriptor_ = kh.GetDescriptor(); return declaring_class_descriptor_.c_str(); @@ -418,7 +417,7 @@ class MethodHelper { const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); uint32_t dex_method_idx = method_->GetDexMethodIndex(); - if (dex_method_idx != DexFile::kDexNoIndex16) { + if (dex_method_idx != DexFile::kDexNoIndex) { return dex_file.GetMethodName(dex_file.GetMethodId(dex_method_idx)); } else { Runtime* runtime = Runtime::Current(); @@ -464,21 +463,19 @@ class MethodHelper { const std::string GetSignature() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); uint32_t dex_method_idx = method_->GetDexMethodIndex(); - if (dex_method_idx != DexFile::kDexNoIndex16) { + if (dex_method_idx != DexFile::kDexNoIndex) { return dex_file.GetMethodSignature(dex_file.GetMethodId(dex_method_idx)); } else { return ""; } } - const DexFile::ProtoId& GetPrototype() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const DexFile::ProtoId& GetPrototype() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); return dex_file.GetMethodPrototype(dex_file.GetMethodId(method_->GetDexMethodIndex())); } - const DexFile::TypeList* GetParameterTypeList() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const DexFile::TypeList* GetParameterTypeList() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile::ProtoId& proto = GetPrototype(); return GetDexFile().GetProtoParameters(proto); } @@ -491,8 +488,7 @@ class MethodHelper { return GetClassFromTypeIdx(return_type_idx); } - const char* GetReturnTypeDescriptor() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const char* GetReturnTypeDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); const DexFile::MethodId& method_id = dex_file.GetMethodId(method_->GetDexMethodIndex()); const DexFile::ProtoId& proto_id = dex_file.GetMethodPrototype(method_id); @@ -500,8 +496,7 @@ class MethodHelper { return dex_file.GetTypeDescriptor(dex_file.GetTypeId(return_type_idx)); } - int32_t GetLineNumFromDexPC(uint32_t dex_pc) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + int32_t GetLineNumFromDexPC(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (dex_pc == DexFile::kDexNoIndex) { return method_->IsNative() ? -2 : -1; } else { @@ -510,35 +505,29 @@ class MethodHelper { } } - const char* GetDeclaringClassDescriptor() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Class* klass = method_->GetDeclaringClass(); - DCHECK(!klass->IsProxyClass()); - uint16_t type_idx = klass->GetDexTypeIndex(); + const char* GetDeclaringClassDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const DexFile& dex_file = GetDexFile(); - return dex_file.GetTypeDescriptor(dex_file.GetTypeId(type_idx)); + uint32_t dex_method_idx = method_->GetDexMethodIndex(); + if (dex_method_idx != DexFile::kDexNoIndex) { + return dex_file.GetMethodDeclaringClassDescriptor(dex_file.GetMethodId(dex_method_idx)); + } else { + return ""; + } } - const char* GetDeclaringClassSourceFile() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const char* descriptor = GetDeclaringClassDescriptor(); - const DexFile& dex_file = GetDexFile(); - const DexFile::ClassDef* dex_class_def = dex_file.FindClassDef(descriptor); - CHECK(dex_class_def != NULL); - return dex_file.GetSourceFile(*dex_class_def); + const char* GetDeclaringClassSourceFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return ClassHelper(method_->GetDeclaringClass()).GetSourceFile(); } - uint32_t GetClassDefIndex() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - const char* descriptor = GetDeclaringClassDescriptor(); - const DexFile& dex_file = GetDexFile(); - uint32_t index; - CHECK(dex_file.FindClassDefIndex(descriptor, index)); - return index; + uint16_t GetClassDefIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return method_->GetDeclaringClass()->GetDexClassDefIndex(); } - mirror::ClassLoader* GetClassLoader() - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + const DexFile::ClassDef& GetClassDef() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + return GetDexFile().GetClassDef(GetClassDefIndex()); + } + + mirror::ClassLoader* GetClassLoader() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { return method_->GetDeclaringClass()->GetClassLoader(); } diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 657735a06b..09d1447d7b 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -1001,6 +1001,7 @@ void Runtime::RegisterRuntimeNativeMethods(JNIEnv* env) { REGISTER(register_dalvik_system_VMStack); REGISTER(register_dalvik_system_Zygote); REGISTER(register_java_lang_Class); + REGISTER(register_java_lang_DexCache); REGISTER(register_java_lang_Object); REGISTER(register_java_lang_Runtime); REGISTER(register_java_lang_String); @@ -1164,7 +1165,7 @@ mirror::ArtMethod* Runtime::CreateResolutionMethod() { method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for resolution method saves - method->SetDexMethodIndex(DexFile::kDexNoIndex16); + method->SetDexMethodIndex(DexFile::kDexNoIndex); // When compiling, the code pointer will get set later when the image is loaded. Runtime* r = Runtime::Current(); ClassLinker* cl = r->GetClassLinker(); @@ -1180,7 +1181,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se method(self, down_cast(method_class->AllocObject(self))); method->SetDeclaringClass(method_class); // TODO: use a special method for callee saves - method->SetDexMethodIndex(DexFile::kDexNoIndex16); + method->SetDexMethodIndex(DexFile::kDexNoIndex); method->SetEntryPointFromCompiledCode(NULL); if ((instruction_set == kThumb2) || (instruction_set == kArm)) { uint32_t ref_spills = (1 << art::arm::R5) | (1 << art::arm::R6) | (1 << art::arm::R7) | diff --git a/runtime/thread.cc b/runtime/thread.cc index 558ceb47f9..23cafe8707 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1807,7 +1807,7 @@ class CatchBlockStackVisitor : public StackVisitor { uint32_t new_dex_pc = dex_pc + inst->SizeInCodeUnits(); ShadowFrame* new_frame = ShadowFrame::Create(num_regs, NULL, m, new_dex_pc); verifier::MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), - mh.GetClassDefIndex(), code_item, + &mh.GetClassDef(), code_item, m->GetDexMethodIndex(), m, m->GetAccessFlags(), false, true); verifier.Verify(); std::vector kinds = verifier.DescribeVRegs(dex_pc); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index fa00c61017..9811926b16 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -74,50 +74,51 @@ void PcToRegisterLineTable::Init(RegisterTrackingMode mode, InstructionFlags* fl } MethodVerifier::FailureKind MethodVerifier::VerifyClass(const mirror::Class* klass, - std::string& error, - bool allow_soft_failures) { + bool allow_soft_failures, + std::string* error) { if (klass->IsVerified()) { return kNoFailure; } mirror::Class* super = klass->GetSuperClass(); if (super == NULL && StringPiece(ClassHelper(klass).GetDescriptor()) != "Ljava/lang/Object;") { - error = "Verifier rejected class "; - error += PrettyDescriptor(klass); - error += " that has no super class"; + *error = "Verifier rejected class "; + *error += PrettyDescriptor(klass); + *error += " that has no super class"; return kHardFailure; } if (super != NULL && super->IsFinal()) { - error = "Verifier rejected class "; - error += PrettyDescriptor(klass); - error += " that attempts to sub-class final class "; - error += PrettyDescriptor(super); + *error = "Verifier rejected class "; + *error += PrettyDescriptor(klass); + *error += " that attempts to sub-class final class "; + *error += PrettyDescriptor(super); return kHardFailure; } ClassHelper kh(klass); const DexFile& dex_file = kh.GetDexFile(); - uint32_t class_def_idx; - if (!dex_file.FindClassDefIndex(kh.GetDescriptor(), class_def_idx)) { - error = "Verifier rejected class "; - error += PrettyDescriptor(klass); - error += " that isn't present in dex file "; - error += dex_file.GetLocation(); + const DexFile::ClassDef* class_def = kh.GetClassDef(); + if (class_def == NULL) { + *error = "Verifier rejected class "; + *error += PrettyDescriptor(klass); + *error += " that isn't present in dex file "; + *error += dex_file.GetLocation(); return kHardFailure; } return VerifyClass(&dex_file, kh.GetDexCache(), klass->GetClassLoader(), - class_def_idx, error, - allow_soft_failures); + class_def, + allow_soft_failures, + error); } MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - uint32_t class_def_idx, - std::string& error, - bool allow_soft_failures) { - const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_idx); - const byte* class_data = dex_file->GetClassData(class_def); + const DexFile::ClassDef* class_def, + bool allow_soft_failures, + std::string* error) { + DCHECK(class_def != nullptr); + const byte* class_data = dex_file->GetClassData(*class_def); if (class_data == NULL) { // empty class, probably a marker interface return kNoFailure; @@ -139,7 +140,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, continue; } previous_direct_method_idx = method_idx; - InvokeType type = it.GetMethodInvokeType(class_def); + InvokeType type = it.GetMethodInvokeType(*class_def); mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { @@ -151,7 +152,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, dex_file, dex_cache, class_loader, - class_def_idx, + class_def, it.GetMethodCodeItem(), method, it.GetMemberAccessFlags(), @@ -160,12 +161,12 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, if (result == kHardFailure) { hard_fail = true; if (error_count > 0) { - error += "\n"; + *error += "\n"; } - error = "Verifier rejected class "; - error += PrettyDescriptor(dex_file->GetClassDescriptor(class_def)); - error += " due to bad method "; - error += PrettyMethod(method_idx, *dex_file); + *error = "Verifier rejected class "; + *error += PrettyDescriptor(dex_file->GetClassDescriptor(*class_def)); + *error += " due to bad method "; + *error += PrettyMethod(method_idx, *dex_file); } ++error_count; } @@ -181,7 +182,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, continue; } previous_virtual_method_idx = method_idx; - InvokeType type = it.GetMethodInvokeType(class_def); + InvokeType type = it.GetMethodInvokeType(*class_def); mirror::ArtMethod* method = linker->ResolveMethod(*dex_file, method_idx, dex_cache, class_loader, NULL, type); if (method == NULL) { @@ -193,7 +194,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, dex_file, dex_cache, class_loader, - class_def_idx, + class_def, it.GetMethodCodeItem(), method, it.GetMemberAccessFlags(), @@ -202,12 +203,12 @@ MethodVerifier::FailureKind MethodVerifier::VerifyClass(const DexFile* dex_file, if (result == kHardFailure) { hard_fail = true; if (error_count > 0) { - error += "\n"; + *error += "\n"; } - error = "Verifier rejected class "; - error += PrettyDescriptor(dex_file->GetClassDescriptor(class_def)); - error += " due to bad method "; - error += PrettyMethod(method_idx, *dex_file); + *error = "Verifier rejected class "; + *error += PrettyDescriptor(dex_file->GetClassDescriptor(*class_def)); + *error += " due to bad method "; + *error += PrettyMethod(method_idx, *dex_file); } ++error_count; } @@ -224,7 +225,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - uint32_t class_def_idx, + const DexFile::ClassDef* class_def, const DexFile::CodeItem* code_item, mirror::ArtMethod* method, uint32_t method_access_flags, @@ -232,7 +233,7 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, MethodVerifier::FailureKind result = kNoFailure; uint64_t start_ns = NanoTime(); - MethodVerifier verifier_(dex_file, dex_cache, class_loader, class_def_idx, code_item, method_idx, + MethodVerifier verifier_(dex_file, dex_cache, class_loader, class_def, code_item, method_idx, method, method_access_flags, true, allow_soft_failures); if (verifier_.Verify()) { // Verification completed, however failures may be pending that didn't cause the verification @@ -267,11 +268,12 @@ MethodVerifier::FailureKind MethodVerifier::VerifyMethod(uint32_t method_idx, void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, uint32_t class_def_idx, + mirror::ClassLoader* class_loader, + const DexFile::ClassDef* class_def, const DexFile::CodeItem* code_item, mirror::ArtMethod* method, uint32_t method_access_flags) { - MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def_idx, code_item, + MethodVerifier verifier(dex_file, dex_cache, class_loader, class_def, code_item, dex_method_idx, method, method_access_flags, true, true); verifier.Verify(); verifier.DumpFailures(os); @@ -280,7 +282,8 @@ void MethodVerifier::VerifyMethodAndDump(std::ostream& os, uint32_t dex_method_i } MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, uint32_t class_def_idx, + mirror::ClassLoader* class_loader, + const DexFile::ClassDef* class_def, const DexFile::CodeItem* code_item, uint32_t dex_method_idx, mirror::ArtMethod* method, uint32_t method_access_flags, bool can_load_classes, @@ -293,7 +296,7 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_ca dex_file_(dex_file), dex_cache_(dex_cache), class_loader_(class_loader), - class_def_idx_(class_def_idx), + class_def_(class_def), code_item_(code_item), declaring_class_(NULL), interesting_dex_pc_(-1), @@ -306,13 +309,14 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_ca allow_soft_failures_(allow_soft_failures), has_check_casts_(false), has_virtual_or_interface_invokes_(false) { + DCHECK(class_def != NULL); } void MethodVerifier::FindLocksAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), - mh.GetClassDefIndex(), mh.GetCodeItem(), m->GetDexMethodIndex(), + &mh.GetClassDef(), mh.GetCodeItem(), m->GetDexMethodIndex(), m, m->GetAccessFlags(), false, true); verifier.interesting_dex_pc_ = dex_pc; verifier.monitor_enter_dex_pcs_ = &monitor_enter_dex_pcs; @@ -334,7 +338,7 @@ mirror::ArtField* MethodVerifier::FindAccessedFieldAtDexPc(mirror::ArtMethod* m, uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), - mh.GetClassDefIndex(), mh.GetCodeItem(), m->GetDexMethodIndex(), + &mh.GetClassDef(), mh.GetCodeItem(), m->GetDexMethodIndex(), m, m->GetAccessFlags(), false, true); return verifier.FindAccessedFieldAtDexPc(dex_pc); } @@ -362,7 +366,7 @@ mirror::ArtMethod* MethodVerifier::FindInvokedMethodAtDexPc(mirror::ArtMethod* m uint32_t dex_pc) { MethodHelper mh(m); MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), - mh.GetClassDefIndex(), mh.GetCodeItem(), m->GetDexMethodIndex(), + &mh.GetClassDef(), mh.GetCodeItem(), m->GetDexMethodIndex(), m, m->GetAccessFlags(), false, true); return verifier.FindInvokedMethodAtDexPc(dex_pc); } @@ -448,7 +452,7 @@ std::ostream& MethodVerifier::Fail(VerifyError error) { // marked as rejected to prevent it from being compiled. case VERIFY_ERROR_BAD_CLASS_HARD: { if (Runtime::Current()->IsCompiler()) { - ClassReference ref(dex_file_, class_def_idx_); + ClassReference ref(dex_file_, dex_file_->GetIndexForClassDef(*class_def_)); AddRejectedClass(ref); } have_pending_hard_failure_ = true; diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index 70442fbc04..073a2f76be 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -145,17 +145,19 @@ class MethodVerifier { }; /* Verify a class. Returns "kNoFailure" on success. */ - static FailureKind VerifyClass(const mirror::Class* klass, std::string& error, - bool allow_soft_failures) + static FailureKind VerifyClass(const mirror::Class* klass, bool allow_soft_failures, + std::string* error) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static FailureKind VerifyClass(const DexFile* dex_file, mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, uint32_t class_def_idx, - std::string& error, bool allow_soft_failures) + mirror::ClassLoader* class_loader, + const DexFile::ClassDef* class_def, + bool allow_soft_failures, std::string* error) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void VerifyMethodAndDump(std::ostream& os, uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, mirror::ClassLoader* class_loader, - uint32_t class_def_idx, const DexFile::CodeItem* code_item, + const DexFile::ClassDef* class_def, + const DexFile::CodeItem* code_item, mirror::ArtMethod* method, uint32_t method_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -222,7 +224,7 @@ class MethodVerifier { } MethodVerifier(const DexFile* dex_file, mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, uint32_t class_def_idx, + mirror::ClassLoader* class_loader, const DexFile::ClassDef* class_def, const DexFile::CodeItem* code_item, uint32_t method_idx, mirror::ArtMethod* method, uint32_t access_flags, bool can_load_classes, bool allow_soft_failures) @@ -262,7 +264,8 @@ class MethodVerifier { */ static FailureKind VerifyMethod(uint32_t method_idx, const DexFile* dex_file, mirror::DexCache* dex_cache, - mirror::ClassLoader* class_loader, uint32_t class_def_idx, + mirror::ClassLoader* class_loader, + const DexFile::ClassDef* class_def_idx, const DexFile::CodeItem* code_item, mirror::ArtMethod* method, uint32_t method_access_flags, bool allow_soft_failures) @@ -690,7 +693,7 @@ class MethodVerifier { mirror::DexCache* dex_cache_ GUARDED_BY(Locks::mutator_lock_); // The class loader for the declaring class of the method. mirror::ClassLoader* class_loader_ GUARDED_BY(Locks::mutator_lock_); - const uint32_t class_def_idx_; // The class def index of the declaring class of the method. + const DexFile::ClassDef* const class_def_; // The class def of the declaring class of the method. const DexFile::CodeItem* const code_item_; // The code item containing the code for the method. const RegType* declaring_class_; // Lazily computed reg type of the method's declaring class. // Instruction widths and flags, one entry per code unit. diff --git a/runtime/verifier/method_verifier_test.cc b/runtime/verifier/method_verifier_test.cc index 611b7c06eb..a56abba3cf 100644 --- a/runtime/verifier/method_verifier_test.cc +++ b/runtime/verifier/method_verifier_test.cc @@ -34,7 +34,8 @@ class MethodVerifierTest : public CommonTest { // Verify the class std::string error_msg; - ASSERT_TRUE(MethodVerifier::VerifyClass(klass, error_msg, true) == MethodVerifier::kNoFailure) << error_msg; + ASSERT_TRUE(MethodVerifier::VerifyClass(klass, true, &error_msg) == MethodVerifier::kNoFailure) + << error_msg; } void VerifyDexFile(const DexFile* dex) diff --git a/test/100-reflect2/expected.txt b/test/100-reflect2/expected.txt index 3d87ebc559..967f167f37 100644 --- a/test/100-reflect2/expected.txt +++ b/test/100-reflect2/expected.txt @@ -35,7 +35,7 @@ z (class java.lang.Character) 62 (class java.lang.Long) 14 (class java.lang.Short) [public java.lang.String(), java.lang.String(int,int,char[]), public java.lang.String(java.lang.String), public java.lang.String(java.lang.StringBuffer), public java.lang.String(java.lang.StringBuilder), public java.lang.String(byte[]), public java.lang.String(byte[],int), public java.lang.String(byte[],int,int), public java.lang.String(byte[],int,int,int), public java.lang.String(byte[],int,int,java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],int,int,java.nio.charset.Charset), public java.lang.String(byte[],java.lang.String) throws java.io.UnsupportedEncodingException, public java.lang.String(byte[],java.nio.charset.Charset), public java.lang.String(char[]), public java.lang.String(char[],int,int), public java.lang.String(int[],int,int)] -[private final char[] java.lang.String.value, private final int java.lang.String.count, private int java.lang.String.hashCode, private final int java.lang.String.offset, private static final char[] java.lang.String.ASCII, public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER, private static final char java.lang.String.REPLACEMENT_CHAR, private static final long java.lang.String.serialVersionUID] +[private final char[] java.lang.String.value, private final int java.lang.String.count, private int java.lang.String.hashCode, private final int java.lang.String.offset, private static final char[] java.lang.String.ASCII, public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER, private static final long java.lang.String.serialVersionUID, private static final char java.lang.String.REPLACEMENT_CHAR] [void java.lang.String._getChars(int,int,char[],int), public char java.lang.String.charAt(int), public int java.lang.String.codePointAt(int), public int java.lang.String.codePointBefore(int), public int java.lang.String.codePointCount(int,int), public volatile int java.lang.String.compareTo(java.lang.Object), public native int java.lang.String.compareTo(java.lang.String), public int java.lang.String.compareToIgnoreCase(java.lang.String), public java.lang.String java.lang.String.concat(java.lang.String), public boolean java.lang.String.contains(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.CharSequence), public boolean java.lang.String.contentEquals(java.lang.StringBuffer), public boolean java.lang.String.endsWith(java.lang.String), public boolean java.lang.String.equals(java.lang.Object), public boolean java.lang.String.equalsIgnoreCase(java.lang.String), public void java.lang.String.getBytes(int,int,byte[],int), public [B java.lang.String.getBytes(), public [B java.lang.String.getBytes(java.lang.String) throws java.io.UnsupportedEncodingException, public [B java.lang.String.getBytes(java.nio.charset.Charset), public void java.lang.String.getChars(int,int,char[],int), public int java.lang.String.hashCode(), public int java.lang.String.indexOf(int), public int java.lang.String.indexOf(int,int), public int java.lang.String.indexOf(java.lang.String), public int java.lang.String.indexOf(java.lang.String,int), public native java.lang.String java.lang.String.intern(), public boolean java.lang.String.isEmpty(), public int java.lang.String.lastIndexOf(int), public int java.lang.String.lastIndexOf(int,int), public int java.lang.String.lastIndexOf(java.lang.String), public int java.lang.String.lastIndexOf(java.lang.String,int), public int java.lang.String.length(), public boolean java.lang.String.matches(java.lang.String), public int java.lang.String.offsetByCodePoints(int,int), public boolean java.lang.String.regionMatches(int,java.lang.String,int,int), public boolean java.lang.String.regionMatches(boolean,int,java.lang.String,int,int), public java.lang.String java.lang.String.replace(char,char), public java.lang.String java.lang.String.replace(java.lang.CharSequence,java.lang.CharSequence), public java.lang.String java.lang.String.replaceAll(java.lang.String,java.lang.String), public java.lang.String java.lang.String.replaceFirst(java.lang.String,java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String), public [Ljava.lang.String; java.lang.String.split(java.lang.String,int), public boolean java.lang.String.startsWith(java.lang.String), public boolean java.lang.String.startsWith(java.lang.String,int), public java.lang.CharSequence java.lang.String.subSequence(int,int), public java.lang.String java.lang.String.substring(int), public java.lang.String java.lang.String.substring(int,int), public [C java.lang.String.toCharArray(), public java.lang.String java.lang.String.toLowerCase(), public java.lang.String java.lang.String.toLowerCase(java.util.Locale), public java.lang.String java.lang.String.toString(), public java.lang.String java.lang.String.toUpperCase(), public java.lang.String java.lang.String.toUpperCase(java.util.Locale), public java.lang.String java.lang.String.trim(), public static java.lang.String java.lang.String.copyValueOf(char[]), public static java.lang.String java.lang.String.copyValueOf(char[],int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.failedBoundsCheck(int,int,int), private native int java.lang.String.fastIndexOf(int,int), private char java.lang.String.foldCase(char), public static transient java.lang.String java.lang.String.format(java.lang.String,java.lang.Object[]), public static transient java.lang.String java.lang.String.format(java.util.Locale,java.lang.String,java.lang.Object[]), private java.lang.StringIndexOutOfBoundsException java.lang.String.indexAndLength(int), private static int java.lang.String.indexOf(java.lang.String,java.lang.String,int,int,char), private int java.lang.String.indexOfSupplementary(int,int), private int java.lang.String.lastIndexOfSupplementary(int,int), private java.lang.StringIndexOutOfBoundsException java.lang.String.startEndAndLength(int,int), public static java.lang.String java.lang.String.valueOf(char), public static java.lang.String java.lang.String.valueOf(double), public static java.lang.String java.lang.String.valueOf(float), public static java.lang.String java.lang.String.valueOf(int), public static java.lang.String java.lang.String.valueOf(long), public static java.lang.String java.lang.String.valueOf(java.lang.Object), public static java.lang.String java.lang.String.valueOf(boolean), public static java.lang.String java.lang.String.valueOf(char[]), public static java.lang.String java.lang.String.valueOf(char[],int,int)] [] [interface java.io.Serializable, interface java.lang.Comparable, interface java.lang.CharSequence] -- cgit v1.2.3-59-g8ed1b