Address some review comments for aog/403114
Test: test-art-host
Bug: 62040831
Change-Id: Iceefdfde26f1b5feb8d6a5121ff64c12702d476f
diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc
index 9c039e2..4947233 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/runtime/jit/profile_compilation_info.cc
@@ -47,8 +47,8 @@
namespace art {
const uint8_t ProfileCompilationInfo::kProfileMagic[] = { 'p', 'r', 'o', '\0' };
-// Last profile version: Instead of method index, put the difference with the last
-// method's index.
+// Last profile version: Move startup methods to use a bitmap. Also add support for post-startup
+// methods.
const uint8_t ProfileCompilationInfo::kProfileVersion[] = { '0', '0', '8', '\0' };
static constexpr uint16_t kMaxDexFileKeyLength = PATH_MAX;
@@ -284,10 +284,13 @@
/**
* Serialization format:
* magic,version,number_of_dex_files,uncompressed_size_of_zipped_data,compressed_data_size,
- * zipped[dex_location1,number_of_classes1,methods_region_size,dex_location_checksum1, \
+ * zipped[dex_location1,number_of_classes1,methods_region_size,dex_location_checksum1
+ * num_method_ids,
* method_encoding_11,method_encoding_12...,class_id1,class_id2...
- * dex_location2,number_of_classes2,methods_region_size,dex_location_checksum2, \
+ * startup/post startup bitmap,
+ * dex_location2,number_of_classes2,methods_region_size,dex_location_checksum2, num_method_ids,
* method_encoding_21,method_encoding_22...,,class_id1,class_id2...
+ * startup/post startup bitmap,
* .....]
* The method_encoding is:
* method_id,number_of_inline_caches,inline_cache1,inline_cache2...
@@ -995,15 +998,6 @@
}
}
-void ProfileCompilationInfo::DexFileData::CreateBitmap() {
- const size_t num_bits = num_method_ids * kMethodBitCount;
- bitmap_storage.resize(RoundUp(num_bits, kBitsPerByte) / kBitsPerByte);
- if (!bitmap_storage.empty()) {
- method_bitmap =
- BitMemoryRegion(MemoryRegion(&bitmap_storage[0], bitmap_storage.size()), 0, num_bits);
- }
-}
-
// TODO(calin): fail fast if the dex checksums don't match.
ProfileCompilationInfo::ProfileLoadSatus ProfileCompilationInfo::LoadInternal(
int fd, std::string* error) {
diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h
index 2b89a41..ca204d8 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/runtime/jit/profile_compilation_info.h
@@ -343,7 +343,12 @@
class_set(std::less<dex::TypeIndex>(), arena->Adapter(kArenaAllocProfile)),
num_method_ids(num_methods),
bitmap_storage(arena->Adapter(kArenaAllocProfile)) {
- CreateBitmap();
+ const size_t num_bits = num_method_ids * kBitmapCount;
+ bitmap_storage.resize(RoundUp(num_bits, kBitsPerByte) / kBitsPerByte);
+ if (!bitmap_storage.empty()) {
+ method_bitmap =
+ BitMemoryRegion(MemoryRegion(&bitmap_storage[0], bitmap_storage.size()), 0, num_bits);
+ }
}
bool operator==(const DexFileData& other) const {
@@ -359,6 +364,13 @@
return method_bitmap.LoadBit(MethodBitIndex(startup, index));
}
+ void MergeBitmap(const DexFileData& other) {
+ DCHECK_EQ(bitmap_storage.size(), other.bitmap_storage.size());
+ for (size_t i = 0; i < bitmap_storage.size(); ++i) {
+ bitmap_storage[i] |= other.bitmap_storage[i];
+ }
+ }
+
// The arena used to allocate new inline cache maps.
ArenaAllocator* arena_;
// The profile key this data belongs to.
@@ -380,28 +392,21 @@
ArenaVector<uint8_t> bitmap_storage;
BitMemoryRegion method_bitmap;
- void CreateBitmap();
-
- void MergeBitmap(const DexFileData& other) {
- DCHECK_EQ(bitmap_storage.size(), other.bitmap_storage.size());
- for (size_t i = 0; i < bitmap_storage.size(); ++i) {
- bitmap_storage[i] |= other.bitmap_storage[i];
- }
- }
-
private:
- enum Bits {
- kMethodBitStartup,
- kMethodBitAfterStartup,
- kMethodBitCount,
+ enum BitmapIndex {
+ kBitmapStartup,
+ kBitmapPostStartup,
+ kBitmapCount,
};
size_t MethodBitIndex(bool startup, size_t index) const {
DCHECK_LT(index, num_method_ids);
- if (!startup) {
- index += num_method_ids;
- }
- return index;
+ // The format is [startup bitmap][post startup bitmap]
+ // This compresses better than ([startup bit][post statup bit])*
+
+ return index + (startup
+ ? kBitmapStartup * num_method_ids
+ : kBitmapPostStartup * num_method_ids);
}
};