diff options
author | Alex Light <allight@google.com> | 2015-12-15 22:15:26 +0000 |
---|---|---|
committer | Alex Light <allight@google.com> | 2015-12-15 22:15:26 +0000 |
commit | ae358c1d5cef227b44d6f4971b79e1ab91aa26eb (patch) | |
tree | 95c22194af5ea38a4fa5fc8bbe07ba60b6d0a021 /compiler/image_writer.cc | |
parent | 6286a97bea0f584342803a215550038852b24776 (diff) | |
download | android_art-ae358c1d5cef227b44d6f4971b79e1ab91aa26eb.tar.gz android_art-ae358c1d5cef227b44d6f4971b79e1ab91aa26eb.tar.bz2 android_art-ae358c1d5cef227b44d6f4971b79e1ab91aa26eb.zip |
Revert "Combine direct_methods_ and virtual_methods_ fields of mirror::Class"
This reverts commit 6286a97bea0f584342803a215550038852b24776.
Change-Id: I5b00f6d1350e9c587acd4b185367dc815ea707de
Diffstat (limited to 'compiler/image_writer.cc')
-rw-r--r-- | compiler/image_writer.cc | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index b9ec47d3fe..fce08ea5f0 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -1030,42 +1030,44 @@ void ImageWriter::WalkFieldsInOrder(mirror::Object* obj) { } } // Visit and assign offsets for methods. - size_t num_methods = as_klass->NumMethods(); - if (num_methods != 0) { + LengthPrefixedArray<ArtMethod>* method_arrays[] = { + as_klass->GetDirectMethodsPtr(), as_klass->GetVirtualMethodsPtr(), + }; + for (LengthPrefixedArray<ArtMethod>* array : method_arrays) { + if (array == nullptr) { + continue; + } bool any_dirty = false; - for (auto& m : as_klass->GetMethods(target_ptr_size_)) { - if (WillMethodBeDirty(&m)) { - any_dirty = true; - break; - } + 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; } 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 : as_klass->GetMethods(target_ptr_size_)) { + for (auto& m : iteration_range) { AssignMethodOffset(&m, type); } - (any_dirty ? dirty_methods_ : clean_methods_) += num_methods; + (any_dirty ? dirty_methods_ : clean_methods_) += count; } } else if (h_obj->IsObjectArray()) { // Walk elements of an object array. |