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 6b3be0644090bb19034c6d99cb10d6808699e0b5..fff12600a7d040a7b7867ed28ff9d11763ff681d 100644 |
--- a/third_party/tcmalloc/chromium/src/central_freelist.cc |
+++ b/third_party/tcmalloc/chromium/src/central_freelist.cc |
@@ -32,9 +32,8 @@ |
#include "config.h" |
#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 |
@@ -58,7 +57,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; |
} |
@@ -94,7 +93,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++; |
} |
@@ -119,8 +118,7 @@ void CentralFreeList::ReleaseToSpans(void* object) { |
} |
lock_.Lock(); |
} else { |
- *(reinterpret_cast<void**>(object)) = span->objects; |
- span->objects = object; |
+ FL_Push(&(span->objects), object); |
} |
} |
@@ -239,13 +237,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++; |
} |
} |
@@ -271,8 +268,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); |
@@ -310,19 +306,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 |