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

Side by Side Diff: src/vm/object_memory.h

Issue 1263043007: Add ImmutableHeap class consisting of parts (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Addressed comments, merged other CL about allocation budget in space Created 5 years, 4 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
OLDNEW
1 // Copyright (c) 2014, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #ifndef SRC_VM_OBJECT_MEMORY_H_ 5 #ifndef SRC_VM_OBJECT_MEMORY_H_
6 #define SRC_VM_OBJECT_MEMORY_H_ 6 #define SRC_VM_OBJECT_MEMORY_H_
7 7
8 #include "src/shared/globals.h" 8 #include "src/shared/globals.h"
9 #include "src/shared/platform.h" 9 #include "src/shared/platform.h"
10 #include "src/shared/utils.h" 10 #include "src/shared/utils.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void set_owner(Space* value) { owner_ = value; } 65 void set_owner(Space* value) { owner_ = value; }
66 66
67 friend class ObjectMemory; 67 friend class ObjectMemory;
68 friend class PageTable; 68 friend class PageTable;
69 friend class Space; 69 friend class Space;
70 }; 70 };
71 71
72 // Space is a chain of chunks. It supports allocation and traversal. 72 // Space is a chain of chunks. It supports allocation and traversal.
73 class Space { 73 class Space {
74 public: 74 public:
75 static const int kDefaultChunkSize = 128 * KB;
76
75 explicit Space(int maximum_initial_size = 0); 77 explicit Space(int maximum_initial_size = 0);
76 78
77 ~Space(); 79 ~Space();
78 80
79 // Allocate raw object. 81 // Allocate raw object.
80 uword Allocate(int size); 82 uword Allocate(int size);
81 83
82 // Rewind allocation top by size bytes if location is equal to current 84 // Rewind allocation top by size bytes if location is equal to current
83 // allocation top. 85 // allocation top.
84 void TryDealloc(uword location, int size); 86 void TryDealloc(uword location, int size);
(...skipping 19 matching lines...) Expand all
104 106
105 // Schema change support. 107 // Schema change support.
106 void CompleteTransformations(PointerVisitor* visitor, Process* process); 108 void CompleteTransformations(PointerVisitor* visitor, Process* process);
107 109
108 // Returns true if the address is inside this space. 110 // Returns true if the address is inside this space.
109 inline bool Includes(uword address) const; 111 inline bool Includes(uword address) const;
110 112
111 // Adjust the allocation budget based on the current heap size. 113 // Adjust the allocation budget based on the current heap size.
112 void AdjustAllocationBudget(); 114 void AdjustAllocationBudget();
113 115
116 void SetAllocationBudget(int new_budget);
117
114 // Tells whether garbage collection is needed. 118 // Tells whether garbage collection is needed.
115 bool needs_garbage_collection() { return allocation_budget_ <= 0; } 119 bool needs_garbage_collection() { return allocation_budget_ <= 0; }
116 120
117 bool in_no_allocation_failure_scope() { return no_allocation_nesting_ != 0; } 121 bool in_no_allocation_failure_scope() { return no_allocation_nesting_ != 0; }
118 122
119 // TODO(kasperl): This seems like a bad interface. 123 // TODO(kasperl): This seems like a bad interface.
120 void AppendProgramChunk(Chunk* chunk, uword top) { 124 void AppendProgramChunk(Chunk* chunk, uword top) {
121 Append(chunk); 125 Append(chunk);
122 top_ = top; 126 top_ = top;
123 limit_ = chunk->limit_; 127 limit_ = chunk->limit_;
124 } 128 }
125 129
126 // Takes all chunks inside [space] and prepends it to this space. 130 // Takes all chunks inside [space] and prepends it to this space.
127 // The given [space] will be deleted. 131 // The given [space] will be deleted.
128 void PrependSpace(Space* space); 132 void PrependSpace(Space* space);
129 133
130 bool is_empty() const { return first_ == NULL; } 134 bool is_empty() const { return first_ == NULL; }
131 135
132 private: 136 private:
133 friend class NoAllocationFailureScope; 137 friend class NoAllocationFailureScope;
134 138
135 static const int kDefaultChunkSize = 128 * KB;
136
137 uword TryAllocate(int size); 139 uword TryAllocate(int size);
138 uword AllocateInNewChunk(int size); 140 uword AllocateInNewChunk(int size);
139 141
140 void Append(Chunk* chunk); 142 void Append(Chunk* chunk);
141 143
142 Chunk* first() { return first_; } 144 Chunk* first() { return first_; }
143 Chunk* last() { return last_; } 145 Chunk* last() { return last_; }
144 uword top() { return top_; } 146 uword top() { return top_; }
145 147
146 void IncrementNoAllocationNesting() { ++no_allocation_nesting_; } 148 void IncrementNoAllocationNesting() { ++no_allocation_nesting_; }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 friend class Space; 240 friend class Space;
239 }; 241 };
240 242
241 inline bool Space::Includes(uword address) const { 243 inline bool Space::Includes(uword address) const {
242 return ObjectMemory::IsAddressInSpace(address, this); 244 return ObjectMemory::IsAddressInSpace(address, this);
243 } 245 }
244 246
245 } // namespace fletch 247 } // namespace fletch
246 248
247 #endif // SRC_VM_OBJECT_MEMORY_H_ 249 #endif // SRC_VM_OBJECT_MEMORY_H_
OLDNEW
« src/vm/immutable_heap.h ('K') | « src/vm/immutable_heap.cc ('k') | src/vm/object_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698