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

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

Issue 10810048: Revert "Revert "Favor free list allocation to bump pointer allocation."" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « runtime/vm/bit_set.h ('k') | 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 "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bit_set.h"
10 #include "vm/raw_object.h" 11 #include "vm/raw_object.h"
11 12
12 namespace dart { 13 namespace dart {
13 14
14 // FreeListElement describes a freelist element. Smallest FreeListElement is 15 // 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_ 16 // 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 17 // 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 18 // object size encodable in tags field, the size of the element is embedded in
18 // the element at the address following the next_ field. 19 // the element at the address following the next_ field.
19 class FreeListElement { 20 class FreeListElement {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class FreeList { 72 class FreeList {
72 public: 73 public:
73 FreeList(); 74 FreeList();
74 ~FreeList(); 75 ~FreeList();
75 76
76 uword TryAllocate(intptr_t size); 77 uword TryAllocate(intptr_t size);
77 void Free(uword addr, intptr_t size); 78 void Free(uword addr, intptr_t size);
78 79
79 void Reset(); 80 void Reset();
80 81
82 intptr_t Length(int index) const;
83
84 void Print() const;
85
81 private: 86 private:
82 static const int kNumLists = 128; 87 static const int kNumLists = 128;
83 88
84 static intptr_t IndexForSize(intptr_t size); 89 static intptr_t IndexForSize(intptr_t size);
85 90
86 void EnqueueElement(FreeListElement* element, intptr_t index); 91 void EnqueueElement(FreeListElement* element, intptr_t index);
87 FreeListElement* DequeueElement(intptr_t index); 92 FreeListElement* DequeueElement(intptr_t index);
88 93
89 void SplitElementAfterAndEnqueue(FreeListElement* element, intptr_t size); 94 void SplitElementAfterAndEnqueue(FreeListElement* element, intptr_t size);
90 95
96 BitSet<kNumLists + 1> free_map_;
97
91 FreeListElement* free_lists_[kNumLists + 1]; 98 FreeListElement* free_lists_[kNumLists + 1];
92 99
93 DISALLOW_COPY_AND_ASSIGN(FreeList); 100 DISALLOW_COPY_AND_ASSIGN(FreeList);
94 }; 101 };
95 102
96 } // namespace dart 103 } // namespace dart
97 104
98 #endif // VM_FREELIST_H_ 105 #endif // VM_FREELIST_H_
OLDNEW
« no previous file with comments | « runtime/vm/bit_set.h ('k') | runtime/vm/freelist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698