diff options
author | Alex Light <allight@google.com> | 2015-12-03 17:38:56 -0800 |
---|---|---|
committer | Alex Light <allight@google.com> | 2015-12-14 14:27:32 -0800 |
commit | 6286a97bea0f584342803a215550038852b24776 (patch) | |
tree | 3571735bdc691bf30e33abb65a95ada8c71a18b7 /compiler/image_writer.cc | |
parent | 377cb3ba2e1cfe51967e5292268a9aae71ceca8c (diff) | |
download | android_art-6286a97bea0f584342803a215550038852b24776.tar.gz android_art-6286a97bea0f584342803a215550038852b24776.tar.bz2 android_art-6286a97bea0f584342803a215550038852b24776.zip |
Combine direct_methods_ and virtual_methods_ fields of mirror::Class
This makes several parts of the overall runtime simpler and reduces
the size of a class object by 32-bits.
Bug: 24618811
Change-Id: I36129b52189e26898ea56fa2b7b45652e06af236
Diffstat (limited to 'compiler/image_writer.cc')
-rw-r--r-- | compiler/image_writer.cc | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index fce08ea5f0..b9ec47d3fe 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. |