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

Side by Side Diff: runtime/vm/freelist.h

Issue 10807031: Favor free list allocation to bump pointer allocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 5 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
« no previous file with comments | « no previous file | runtime/vm/freelist.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FREELIST_H_ 5 #ifndef VM_FREELIST_H_
6 #define VM_FREELIST_H_ 6 #define VM_FREELIST_H_
7 7
8 #include <bitset>
9
8 #include "platform/assert.h" 10 #include "platform/assert.h"
9 #include "vm/allocation.h" 11 #include "vm/allocation.h"
10 #include "vm/raw_object.h" 12 #include "vm/raw_object.h"
11 13
12 namespace dart { 14 namespace dart {
13 15
14 // FreeListElement describes a freelist element. Smallest FreeListElement is 16 // FreeListElement describes a freelist element. Smallest FreeListElement is
15 // two words in size. Second word of the raw object is used to keep a next_ 17 // two words in size. Second word of the raw object is used to keep a next_
16 // pointer to chain elements of the list together. For objects larger than the 18 // pointer to chain elements of the list together. For objects larger than the
17 // object size encodable in tags field, the size of the element is embedded in 19 // object size encodable in tags field, the size of the element is embedded in
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class FreeList { 73 class FreeList {
72 public: 74 public:
73 FreeList(); 75 FreeList();
74 ~FreeList(); 76 ~FreeList();
75 77
76 uword TryAllocate(intptr_t size); 78 uword TryAllocate(intptr_t size);
77 void Free(uword addr, intptr_t size); 79 void Free(uword addr, intptr_t size);
78 80
79 void Reset(); 81 void Reset();
80 82
83 intptr_t Length(int index) const;
84
85 void Print() const;
86
81 private: 87 private:
82 static const int kNumLists = 128; 88 static const int kNumLists = 128;
83 89
84 static intptr_t IndexForSize(intptr_t size); 90 static intptr_t IndexForSize(intptr_t size);
85 91
86 void EnqueueElement(FreeListElement* element, intptr_t index); 92 void EnqueueElement(FreeListElement* element, intptr_t index);
87 FreeListElement* DequeueElement(intptr_t index); 93 FreeListElement* DequeueElement(intptr_t index);
88 94
89 void SplitElementAfterAndEnqueue(FreeListElement* element, intptr_t size); 95 void SplitElementAfterAndEnqueue(FreeListElement* element, intptr_t size);
90 96
97 std::bitset<kNumLists + 1> free_map_;
98
91 FreeListElement* free_lists_[kNumLists + 1]; 99 FreeListElement* free_lists_[kNumLists + 1];
92 100
93 DISALLOW_COPY_AND_ASSIGN(FreeList); 101 DISALLOW_COPY_AND_ASSIGN(FreeList);
94 }; 102 };
95 103
96 } // namespace dart 104 } // namespace dart
97 105
98 #endif // VM_FREELIST_H_ 106 #endif // VM_FREELIST_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/freelist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698