Index: third_party/tcmalloc/chromium/src/central_freelist.cc |
diff --git a/third_party/tcmalloc/chromium/src/central_freelist.cc b/third_party/tcmalloc/chromium/src/central_freelist.cc |
index 87a1825c02b5011aec3166436d4e7ca16e013164..0f8a5c07eb6baf36b503208225219c96d9a87a7e 100644 |
--- a/third_party/tcmalloc/chromium/src/central_freelist.cc |
+++ b/third_party/tcmalloc/chromium/src/central_freelist.cc |
@@ -33,8 +33,8 @@ |
#include "config.h" |
#include <algorithm> |
#include "central_freelist.h" |
+#include "free_list.h" // for FL_Next, FL_Push, etc |
#include "internal_logging.h" // for ASSERT, MESSAGE |
-#include "linked_list.h" // for SLL_Next, SLL_Push, etc |
#include "page_heap.h" // for PageHeap |
#include "static_vars.h" // for Static |
@@ -80,7 +80,7 @@ void CentralFreeList::Init(size_t cl) { |
void CentralFreeList::ReleaseListToSpans(void* start) { |
while (start) { |
- void *next = SLL_Next(start); |
+ void *next = FL_Next(start); |
ReleaseToSpans(start); |
start = next; |
} |
@@ -116,7 +116,7 @@ void CentralFreeList::ReleaseToSpans(void* object) { |
if (false) { |
// Check that object does not occur in list |
int got = 0; |
- for (void* p = span->objects; p != NULL; p = *((void**) p)) { |
+ for (void* p = span->objects; p != NULL; p = FL_Next(p)){ |
ASSERT(p != object); |
got++; |
} |
@@ -142,8 +142,7 @@ void CentralFreeList::ReleaseToSpans(void* object) { |
} |
lock_.Lock(); |
} else { |
- *(reinterpret_cast<void**>(object)) = span->objects; |
- span->objects = object; |
+ FL_Push(&(span->objects), object); |
} |
} |
@@ -262,13 +261,12 @@ int CentralFreeList::RemoveRange(void **start, void **end, int N) { |
// TODO: Prefetch multiple TCEntries? |
tail = FetchFromSpansSafe(); |
if (tail != NULL) { |
- SLL_SetNext(tail, NULL); |
- head = tail; |
+ FL_Push(&head, tail); |
result = 1; |
while (result < N) { |
void *t = FetchFromSpans(); |
if (!t) break; |
- SLL_Push(&head, t); |
+ FL_Push(&head, t); |
result++; |
} |
} |
@@ -294,8 +292,7 @@ void* CentralFreeList::FetchFromSpans() { |
ASSERT(span->objects != NULL); |
span->refcount++; |
- void* result = span->objects; |
- span->objects = *(reinterpret_cast<void**>(result)); |
+ void *result = FL_Pop(&(span->objects)); |
if (span->objects == NULL) { |
// Move to empty list |
tcmalloc::DLL_Remove(span); |
@@ -334,19 +331,18 @@ void CentralFreeList::Populate() { |
// Split the block into pieces and add to the free-list |
// TODO: coloring of objects to avoid cache conflicts? |
- void** tail = &span->objects; |
+ void* list = NULL; |
char* ptr = reinterpret_cast<char*>(span->start << kPageShift); |
char* limit = ptr + (npages << kPageShift); |
const size_t size = Static::sizemap()->ByteSizeForClass(size_class_); |
int num = 0; |
while (ptr + size <= limit) { |
- *tail = ptr; |
- tail = reinterpret_cast<void**>(ptr); |
+ FL_Push(&list, ptr); |
ptr += size; |
num++; |
} |
ASSERT(ptr <= limit); |
- *tail = NULL; |
+ span->objects = list; |
span->refcount = 0; // No sub-object in use yet |
// Add span to list of non-empty spans |