diff options
author | Alex Light <allight@google.com> | 2015-12-17 18:33:57 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-12-17 18:33:57 +0000 |
commit | ec178ee58447ba23e5954eb824265e9b30f95009 (patch) | |
tree | a53ddba8fcc76291687b4ef26bf8892427c4b729 /compiler | |
parent | 14c4e90f67e71430dade7d4f20920e6352be386e (diff) | |
parent | e64300b8488716056775ecbfa2915dd1b4ce7e08 (diff) | |
download | android_art-ec178ee58447ba23e5954eb824265e9b30f95009.tar.gz android_art-ec178ee58447ba23e5954eb824265e9b30f95009.tar.bz2 android_art-ec178ee58447ba23e5954eb824265e9b30f95009.zip |
Merge "Revert "Revert "Combine direct_methods_ and virtual_methods_ fields of mirror::Class"""
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/common_compiler_test.cc | 10 | ||||
-rw-r--r-- | compiler/compiled_method.h | 2 | ||||
-rw-r--r-- | compiler/driver/compiled_method_storage.h | 2 | ||||
-rw-r--r-- | compiler/driver/compiler_driver.cc | 5 | ||||
-rw-r--r-- | compiler/driver/compiler_driver_test.cc | 5 | ||||
-rw-r--r-- | compiler/image_writer.cc | 42 | ||||
-rw-r--r-- | compiler/image_writer.h | 2 | ||||
-rw-r--r-- | compiler/oat_test.cc | 12 |
8 files changed, 33 insertions, 47 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index 638b897eea..c7c190793c 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -142,10 +142,7 @@ void CommonCompilerTest::MakeExecutable(mirror::ClassLoader* class_loader, const mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader); CHECK(klass != nullptr) << "Class not found " << class_name; size_t pointer_size = class_linker_->GetImagePointerSize(); - for (auto& m : klass->GetDirectMethods(pointer_size)) { - MakeExecutable(&m); - } - for (auto& m : klass->GetVirtualMethods(pointer_size)) { + for (auto& m : klass->GetMethods(pointer_size)) { MakeExecutable(&m); } } @@ -259,10 +256,7 @@ void CommonCompilerTest::CompileClass(mirror::ClassLoader* class_loader, const c mirror::Class* klass = class_linker_->FindClass(self, class_descriptor.c_str(), loader); CHECK(klass != nullptr) << "Class not found " << class_name; auto pointer_size = class_linker_->GetImagePointerSize(); - for (auto& m : klass->GetDirectMethods(pointer_size)) { - CompileMethod(&m); - } - for (auto& m : klass->GetVirtualMethods(pointer_size)) { + for (auto& m : klass->GetMethods(pointer_size)) { CompileMethod(&m); } } diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h index 15a4ba0f6f..7a93613481 100644 --- a/compiler/compiled_method.h +++ b/compiler/compiled_method.h @@ -23,7 +23,7 @@ #include "arch/instruction_set.h" #include "base/bit_utils.h" -#include "length_prefixed_array.h" +#include "base/length_prefixed_array.h" #include "method_reference.h" #include "utils/array_ref.h" diff --git a/compiler/driver/compiled_method_storage.h b/compiler/driver/compiled_method_storage.h index ef10b6768b..d6961a0876 100644 --- a/compiler/driver/compiled_method_storage.h +++ b/compiler/driver/compiled_method_storage.h @@ -20,8 +20,8 @@ #include <iosfwd> #include <memory> +#include "base/length_prefixed_array.h" #include "base/macros.h" -#include "length_prefixed_array.h" #include "utils/array_ref.h" #include "utils/dedupe_set.h" #include "utils/swap_space.h" diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index ba8f1d0df1..56839f85f9 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -790,10 +790,7 @@ class ResolveCatchBlockExceptionsClassVisitor : public ClassVisitor { virtual bool Visit(mirror::Class* c) OVERRIDE SHARED_REQUIRES(Locks::mutator_lock_) { const auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize(); - for (auto& m : c->GetVirtualMethods(pointer_size)) { - ResolveExceptionsForMethod(&m, pointer_size); - } - for (auto& m : c->GetDirectMethods(pointer_size)) { + for (auto& m : c->GetMethods(pointer_size)) { ResolveExceptionsForMethod(&m, pointer_size); } return true; diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index f8de9fa4a1..86f8b823cc 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -86,10 +86,7 @@ class CompilerDriverTest : public CommonCompilerTest { mirror::Class* c = class_linker->FindClass(soa.Self(), descriptor, loader); CHECK(c != nullptr); const auto pointer_size = class_linker->GetImagePointerSize(); - for (auto& m : c->GetDirectMethods(pointer_size)) { - MakeExecutable(&m); - } - for (auto& m : c->GetVirtualMethods(pointer_size)) { + for (auto& m : c->GetMethods(pointer_size)) { MakeExecutable(&m); } } diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index afa4904f46..9545c83eaf 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -1030,44 +1030,42 @@ void ImageWriter::WalkFieldsInOrder(mirror::Object* obj) { } } // Visit and assign offsets for methods. - LengthPrefixedArray<ArtMethod>* method_arrays[] = { - as_klass->GetDirectMethodsPtr(), as_klass->GetVirtualMethodsPtr(), - }; - for (LengthPrefixedArray<ArtMethod>* array : method_arrays) { - if (array == nullptr) { - continue; - } + size_t num_methods = as_klass->NumMethods(); + if (num_methods != 0) { bool any_dirty = false; - size_t count = 0; - const size_t method_alignment = ArtMethod::Alignment(target_ptr_size_); - const size_t method_size = ArtMethod::Size(target_ptr_size_); - auto iteration_range = - MakeIterationRangeFromLengthPrefixedArray(array, method_size, method_alignment); - for (auto& m : iteration_range) { - any_dirty = any_dirty || WillMethodBeDirty(&m); - ++count; + for (auto& m : as_klass->GetMethods(target_ptr_size_)) { + if (WillMethodBeDirty(&m)) { + any_dirty = true; + break; + } } NativeObjectRelocationType type = any_dirty ? kNativeObjectRelocationTypeArtMethodDirty : kNativeObjectRelocationTypeArtMethodClean; Bin bin_type = BinTypeForNativeRelocationType(type); // Forward the entire array at once, but header first. + const size_t method_alignment = ArtMethod::Alignment(target_ptr_size_); + const size_t method_size = ArtMethod::Size(target_ptr_size_); const size_t header_size = LengthPrefixedArray<ArtMethod>::ComputeSize(0, method_size, method_alignment); + LengthPrefixedArray<ArtMethod>* array = as_klass->GetMethodsPtr(); auto it = native_object_relocations_.find(array); - CHECK(it == native_object_relocations_.end()) << "Method array " << array - << " already forwarded"; + CHECK(it == native_object_relocations_.end()) + << "Method array " << array << " already forwarded"; size_t& offset = bin_slot_sizes_[bin_type]; DCHECK(!IsInBootImage(array)); - native_object_relocations_.emplace(array, NativeObjectRelocation { offset, - any_dirty ? kNativeObjectRelocationTypeArtMethodArrayDirty : - kNativeObjectRelocationTypeArtMethodArrayClean }); + native_object_relocations_.emplace( + array, NativeObjectRelocation { + offset, + any_dirty ? kNativeObjectRelocationTypeArtMethodArrayDirty + : kNativeObjectRelocationTypeArtMethodArrayClean + }); offset += header_size; - for (auto& m : iteration_range) { + for (auto& m : as_klass->GetMethods(target_ptr_size_)) { AssignMethodOffset(&m, type); } - (any_dirty ? dirty_methods_ : clean_methods_) += count; + (any_dirty ? dirty_methods_ : clean_methods_) += num_methods; } } else if (h_obj->IsObjectArray()) { // Walk elements of an object array. diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 8e930f0373..f1b2965a12 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -27,11 +27,11 @@ #include <ostream> #include "base/bit_utils.h" +#include "base/length_prefixed_array.h" #include "base/macros.h" #include "driver/compiler_driver.h" #include "gc/space/space.h" #include "image.h" -#include "length_prefixed_array.h" #include "lock_word.h" #include "mem_map.h" #include "oat_file.h" diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index eea52045cc..451aa682d6 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -238,12 +238,12 @@ TEST_F(OatTest, WriteRead) { ++method_index; } size_t visited_virtuals = 0; - for (auto& m : klass->GetVirtualMethods(pointer_size)) { - if (!m.IsMiranda()) { - CheckMethod(&m, oat_class.GetOatMethod(method_index), dex_file); - ++method_index; - ++visited_virtuals; - } + // TODO We should also check copied methods in this test. + for (auto& m : klass->GetDeclaredVirtualMethods(pointer_size)) { + EXPECT_FALSE(m.IsMiranda()); + CheckMethod(&m, oat_class.GetOatMethod(method_index), dex_file); + ++method_index; + ++visited_virtuals; } EXPECT_EQ(visited_virtuals, num_virtual_methods); } |