Further improve of linker memory allocators
This includes:
- Blocks allocated by small object allocators are now aligned to
their block size.
- Remove redundant free_blocks_cnt and allocated_blocks_cnt, as they
sum up to a fixed number.
- Remove a redundant padding word in small_object_page_info on 32-bit
platform.
Test: Build and boot cuttlefish.
Change-Id: Ib922d7af739e3709e8a162c7f68e7f99bf95a914
diff --git a/linker/linker_allocator.h b/linker/linker_allocator.h
index 4619817..44a8b0d 100644
--- a/linker/linker_allocator.h
+++ b/linker/linker_allocator.h
@@ -55,7 +55,7 @@
// and allocator_addr for small ones.
LinkerSmallObjectAllocator* allocator_addr;
};
-} __attribute__((aligned(16)));
+};
struct small_object_block_record {
small_object_block_record* next;
@@ -77,9 +77,8 @@
// Linked list containing all free blocks in this page.
small_object_block_record* free_block_list;
- // Free/allocated blocks counter.
+ // Free blocks counter.
size_t free_blocks_cnt;
- size_t allocated_blocks_cnt;
};
class LinkerSmallObjectAllocator {
@@ -95,8 +94,9 @@
void add_to_page_list(small_object_page_info* page);
void remove_from_page_list(small_object_page_info* page);
- uint32_t type_;
- size_t block_size_;
+ const uint32_t type_;
+ const size_t block_size_;
+ const size_t blocks_per_page_;
size_t free_pages_cnt_;