am e057b9fc: Merge "Introduce size-based r/w allocators"
				
					
				
			* commit 'e057b9fc82e1674198738ff2fdd4eb70c645bf9e': Introduce size-based r/w allocators
This commit is contained in:
		@@ -627,10 +627,42 @@ done:
 | 
				
			|||||||
    return nullptr;
 | 
					    return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Each size has it's own allocator.
 | 
				
			||||||
 | 
					template<size_t size>
 | 
				
			||||||
 | 
					class SizeBasedAllocator {
 | 
				
			||||||
 | 
					 public:
 | 
				
			||||||
 | 
					  static void* alloc() {
 | 
				
			||||||
 | 
					    return allocator_.alloc();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void free(void* ptr) {
 | 
				
			||||||
 | 
					    allocator_.free(ptr);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 private:
 | 
				
			||||||
 | 
					  static LinkerBlockAllocator allocator_;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<size_t size>
 | 
				
			||||||
 | 
					LinkerBlockAllocator SizeBasedAllocator<size>::allocator_(size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template<typename T>
 | 
				
			||||||
 | 
					class TypeBasedAllocator {
 | 
				
			||||||
 | 
					 public:
 | 
				
			||||||
 | 
					  static T* alloc() {
 | 
				
			||||||
 | 
					    return reinterpret_cast<T*>(SizeBasedAllocator<sizeof(T)>::alloc());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void free(T* ptr) {
 | 
				
			||||||
 | 
					    SizeBasedAllocator<sizeof(T)>::free(ptr);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					using linked_list_t = LinkedList<T, TypeBasedAllocator<LinkedListEntry<T>>>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef linked_list_t<soinfo> SoinfoLinkedList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Another soinfo list allocator to use in dlsym. We don't reuse
 | 
					 | 
				
			||||||
// SoinfoListAllocator because it is write-protected most of the time.
 | 
					 | 
				
			||||||
static LinkerAllocator<LinkedListEntry<soinfo>> g_soinfo_list_allocator_rw;
 | 
					static LinkerAllocator<LinkedListEntry<soinfo>> g_soinfo_list_allocator_rw;
 | 
				
			||||||
class SoinfoListAllocatorRW {
 | 
					class SoinfoListAllocatorRW {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
@@ -646,8 +678,9 @@ class SoinfoListAllocatorRW {
 | 
				
			|||||||
// This is used by dlsym(3).  It performs symbol lookup only within the
 | 
					// This is used by dlsym(3).  It performs symbol lookup only within the
 | 
				
			||||||
// specified soinfo object and its dependencies in breadth first order.
 | 
					// specified soinfo object and its dependencies in breadth first order.
 | 
				
			||||||
ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name) {
 | 
					ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name) {
 | 
				
			||||||
  LinkedList<soinfo, SoinfoListAllocatorRW> visit_list;
 | 
					  SoinfoLinkedList visit_list;
 | 
				
			||||||
  LinkedList<soinfo, SoinfoListAllocatorRW> visited;
 | 
					  SoinfoLinkedList visited;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  visit_list.push_back(si);
 | 
					  visit_list.push_back(si);
 | 
				
			||||||
  soinfo* current_soinfo;
 | 
					  soinfo* current_soinfo;
 | 
				
			||||||
  while ((current_soinfo = visit_list.pop_front()) != nullptr) {
 | 
					  while ((current_soinfo = visit_list.pop_front()) != nullptr) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user