aboutsummaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2019-01-28 23:04:40 +0000
committerVic Yang <victoryang@google.com>2019-01-29 20:21:41 -0800
commit7bb60fcbcd29f4e18865aa657cb3929ecb872b77 (patch)
tree2d6fd1790134178a652369c8cc05124e414df164 /linker
parentd7873cf94ee3c7a7b0fa24e1e932694c78416cd4 (diff)
downloadandroid_bionic-7bb60fcbcd29f4e18865aa657cb3929ecb872b77.tar.gz
android_bionic-7bb60fcbcd29f4e18865aa657cb3929ecb872b77.tar.bz2
android_bionic-7bb60fcbcd29f4e18865aa657cb3929ecb872b77.zip
Revert "linker: Purge block allocator memory when possible"
This reverts commit fb78a4ac1b93218f59aa44089ae5f4dbfababf0d. Reason for revert: Performance regression. Change-Id: Ib12335fc7478dad933da00b8bc525366c9330a17
Diffstat (limited to 'linker')
-rw-r--r--linker/linker_block_allocator.cpp25
-rw-r--r--linker/linker_block_allocator.h5
2 files changed, 2 insertions, 28 deletions
diff --git a/linker/linker_block_allocator.cpp b/linker/linker_block_allocator.cpp
index 27f1e3800..d72cad3d6 100644
--- a/linker/linker_block_allocator.cpp
+++ b/linker/linker_block_allocator.cpp
@@ -55,8 +55,7 @@ LinkerBlockAllocator::LinkerBlockAllocator(size_t block_size)
: block_size_(
round_up(block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size, 16)),
page_list_(nullptr),
- free_block_list_(nullptr),
- allocated_(0)
+ free_block_list_(nullptr)
{}
void* LinkerBlockAllocator::alloc() {
@@ -77,8 +76,6 @@ void* LinkerBlockAllocator::alloc() {
memset(block_info, 0, block_size_);
- ++allocated_;
-
return block_info;
}
@@ -107,11 +104,6 @@ void LinkerBlockAllocator::free(void* block) {
block_info->num_free_blocks = 1;
free_block_list_ = block_info;
-
- --allocated_;
- if (allocated_ == 0) {
- free_all_pages();
- }
}
void LinkerBlockAllocator::protect_all(int prot) {
@@ -162,18 +154,3 @@ LinkerBlockAllocatorPage* LinkerBlockAllocator::find_page(void* block) {
abort();
}
-
-void LinkerBlockAllocator::free_all_pages() {
- if (allocated_) {
- abort();
- }
-
- LinkerBlockAllocatorPage* page = page_list_;
- while (page) {
- LinkerBlockAllocatorPage* next = page->next;
- munmap(page, kAllocateSize);
- page = next;
- }
- page_list_ = nullptr;
- free_block_list_ = nullptr;
-}
diff --git a/linker/linker_block_allocator.h b/linker/linker_block_allocator.h
index 458d092cf..0c54b93fa 100644
--- a/linker/linker_block_allocator.h
+++ b/linker/linker_block_allocator.h
@@ -53,12 +53,10 @@ class LinkerBlockAllocator {
private:
void create_new_page();
LinkerBlockAllocatorPage* find_page(void* block);
- void free_all_pages();
size_t block_size_;
LinkerBlockAllocatorPage* page_list_;
void* free_block_list_;
- size_t allocated_;
DISALLOW_COPY_AND_ASSIGN(LinkerBlockAllocator);
};
@@ -75,8 +73,7 @@ class LinkerBlockAllocator {
* 513 this allocator will use 516 (520 for lp64) bytes of data where
* generalized implementation is going to use 1024 sized blocks.
*
- * 2. Unless all allocated memory is freed, this allocator does not munmap
- * allocated memory, where BionicAllocator does.
+ * 2. This allocator does not munmap allocated memory, where BionicAllocator does.
*
* 3. This allocator provides mprotect services to the user, where BionicAllocator
* always treats its memory as READ|WRITE.