Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: third_party/tcmalloc/chromium/src/free_list.h

Issue 7671034: doubly-linked free-lists for thread caches and page heaps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: enable doubly linked lists only in Debug builds Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 // ---
31 // Author: Rebecca Shapiro <bxx@google.com>
32 //
33 // This file contains declarations of functions that implement doubly
34 // linked lists and definitions of functions that implement singly
35 // linked lists. It also contains macros to tell the SizeMap class
36 // how much space a node in the freelist needs so that SizeMap can
37 // create large enough size classes.
38
39 #ifndef TCMALLOC_FREE_LIST_H_
40 #define TCMALLOC_FREE_LIST_H_
41
42 #include <stddef.h>
43 #include "linked_list.h"
44
45 namespace tcmalloc {
46
47 #ifdef TCMALLOC_USE_DOUBLYLINKED_FREELIST
48
49 // size class information for common.h.
50 static const bool kSupportsDoublyLinkedList = true;
51
52 void *FL_Next(void *t);
53 void FL_Init(void *t);
54 void FL_Push(void **list, void *element);
55 void *FL_Pop(void **list);
56 void FL_PopRange(void **head, int n, void **start, void **end);
57 void FL_PushRange(void **head, void *start, void *end);
58 size_t FL_Size(void *head);
59
60 #else // TCMALLOC_USE_DOUBLYLINKED_FREELIST not defined
61 static const bool kSupportsDoublyLinkedList = false;
62
63 inline void *FL_Next(void *t) {
64 return SLL_Next(t);
65 }
66
67 inline void FL_Init(void *t) {
68 SLL_SetNext(t, NULL);
69 }
70
71 inline void FL_Push(void **list, void *element) {
72 SLL_Push(list,element);
73 }
74
75 inline void *FL_Pop(void **list) {
76 return SLL_Pop(list);
77 }
78
79 // Removes |N| elements from a linked list to which |head| points.
80 // |head| will be modified to point to the new |head|. |start| and
81 // |end| will point to the first and last nodes of the range. Note
82 // that |end| will point to NULL after this function is called.
83 inline void FL_PopRange(void **head, int n, void **start, void **end) {
84 SLL_PopRange(head, n, start, end);
85 }
86
87 inline void FL_PushRange(void **head, void *start, void *end) {
88 SLL_PushRange(head,start,end);
89 }
90
91 inline size_t FL_Size(void *head) {
92 return SLL_Size(head);
93 }
94
95 #endif // TCMALLOC_USE_DOUBLYLINKED_FREELIST
96
97 } // namespace tcmalloc
98
99 #endif // TCMALLOC_FREE_LIST_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.cc ('k') | third_party/tcmalloc/chromium/src/free_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698