Move mirror::ArtMethod to native
Optimizing + quick tests are passing, devices boot.
TODO: Test and fix bugs in mips64.
Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.
Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
diff --git a/runtime/image.cc b/runtime/image.cc
index d9bd2a8..947c914 100644
--- a/runtime/image.cc
+++ b/runtime/image.cc
@@ -24,27 +24,21 @@
namespace art {
const uint8_t ImageHeader::kImageMagic[] = { 'a', 'r', 't', '\n' };
-const uint8_t ImageHeader::kImageVersion[] = { '0', '1', '5', '\0' };
+const uint8_t ImageHeader::kImageVersion[] = { '0', '1', '6', '\0' };
ImageHeader::ImageHeader(uint32_t image_begin,
uint32_t image_size,
- uint32_t art_fields_offset,
- uint32_t art_fields_size,
- uint32_t image_bitmap_offset,
- uint32_t image_bitmap_size,
+ ImageSection* sections,
uint32_t image_roots,
uint32_t oat_checksum,
uint32_t oat_file_begin,
uint32_t oat_data_begin,
uint32_t oat_data_end,
uint32_t oat_file_end,
+ uint32_t pointer_size,
bool compile_pic)
: image_begin_(image_begin),
image_size_(image_size),
- art_fields_offset_(art_fields_offset),
- art_fields_size_(art_fields_size),
- image_bitmap_offset_(image_bitmap_offset),
- image_bitmap_size_(image_bitmap_size),
oat_checksum_(oat_checksum),
oat_file_begin_(oat_file_begin),
oat_data_begin_(oat_data_begin),
@@ -52,6 +46,7 @@
oat_file_end_(oat_file_end),
patch_delta_(0),
image_roots_(image_roots),
+ pointer_size_(pointer_size),
compile_pic_(compile_pic) {
CHECK_EQ(image_begin, RoundUp(image_begin, kPageSize));
CHECK_EQ(oat_file_begin, RoundUp(oat_file_begin, kPageSize));
@@ -61,8 +56,10 @@
CHECK_LE(oat_file_begin, oat_data_begin);
CHECK_LT(oat_data_begin, oat_data_end);
CHECK_LE(oat_data_end, oat_file_end);
+ CHECK(ValidPointerSize(pointer_size_)) << pointer_size_;
memcpy(magic_, kImageMagic, sizeof(kImageMagic));
memcpy(version_, kImageVersion, sizeof(kImageVersion));
+ std::copy_n(sections, kSectionCount, sections_);
}
void ImageHeader::RelocateImage(off_t delta) {
@@ -74,6 +71,9 @@
oat_file_end_ += delta;
image_roots_ += delta;
patch_delta_ += delta;
+ for (size_t i = 0; i < kImageMethodsCount; ++i) {
+ image_methods_[i] += delta;
+ }
}
bool ImageHeader::IsValid() const {
@@ -128,4 +128,23 @@
return result;
}
+ArtMethod* ImageHeader::GetImageMethod(ImageMethod index) const {
+ CHECK_LT(static_cast<size_t>(index), kImageMethodsCount);
+ return reinterpret_cast<ArtMethod*>(image_methods_[index]);
+}
+
+void ImageHeader::SetImageMethod(ImageMethod index, ArtMethod* method) {
+ CHECK_LT(static_cast<size_t>(index), kImageMethodsCount);
+ image_methods_[index] = reinterpret_cast<uint64_t>(method);
+}
+
+const ImageSection& ImageHeader::GetImageSection(ImageSections index) const {
+ CHECK_LT(static_cast<size_t>(index), kSectionCount);
+ return sections_[index];
+}
+
+std::ostream& operator<<(std::ostream& os, const ImageSection& section) {
+ return os << "size=" << section.Size() << " range=" << section.Offset() << "-" << section.End();
+}
+
} // namespace art