Home | History | Annotate | Download | only in src

Lines Matching refs:Zone

24 // The Zone supports very fast allocation of small chunks of
26 // the Zone supports deallocating all chunks in one fast
27 // operation. The Zone is used to hold temporary data structures like
30 // Note: There is no need to initialize the Zone; the first time an
36 class Zone final {
38 Zone();
39 ~Zone();
41 // Allocate 'size' bytes of memory in the Zone; expands the Zone by
51 // Deletes all objects and free all memory allocated in the Zone. Keeps one
56 // may no longer allocate in the Zone after a call to this method.
87 // Report zone excess when allocation exceeds this limit.
90 // The number of bytes allocated in this zone so far.
95 // the zone.
98 // Expand the Zone to hold at least 'size' more bytes and allocate
100 // memory in the Zone. Should only be called if there isn't enough
101 // room in the Zone already.
122 // allocated in the Zone. Use it as a base class; see ast.h.
125 // Allocate a new ZoneObject of 'size' bytes in the Zone.
126 void* operator new(size_t size, Zone* zone) { return zone->New(size); }
135 // Zone::DeleteAll() to delete all zone objects in one go.
137 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
142 // Zone when the ZoneScope is destroyed (i.e. goes out of scope)
145 explicit ZoneScope(Zone* zone) : zone_(zone) { }
148 Zone* zone() const { return zone_; }
151 Zone* zone_;
156 // structures to allocate themselves and their elements in the Zone.
159 explicit ZoneAllocationPolicy(Zone* zone) : zone_(zone) { }
160 void* New(size_t size) { return zone()->New(size); }
162 Zone* zone() const { return zone_; }
165 Zone* zone_;
171 // Zone. ZoneLists cannot be deleted individually; you can delete all
172 // objects in the Zone by calling Zone::DeleteAll().
178 ZoneList(int capacity, Zone* zone)
179 : List<T, ZoneAllocationPolicy>(capacity, ZoneAllocationPolicy(zone)) { }
181 void* operator new(size_t size, Zone* zone) { return zone->New(size); }
184 ZoneList(const ZoneList<T>& other, Zone* zone)
186 ZoneAllocationPolicy(zone)) {
187 AddAll(other, zone);
190 // We add some convenience wrappers so that we can pass in a Zone
192 void Add(const T& element, Zone* zone) {
193 List<T, ZoneAllocationPolicy>::Add(element, ZoneAllocationPolicy(zone));
195 void AddAll(const List<T, ZoneAllocationPolicy>& other, Zone* zone) {
196 List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
198 void AddAll(const Vector<T>& other, Zone* zone) {
199 List<T, ZoneAllocationPolicy>::AddAll(other, ZoneAllocationPolicy(zone));
201 void InsertAt(int index, const T& element, Zone* zone) {
203 ZoneAllocationPolicy(zone));
205 Vector<T> AddBlock(T value, int count, Zone* zone) {
207 ZoneAllocationPolicy(zone));
209 void Allocate(int length, Zone* zone) {
210 List<T, ZoneAllocationPolicy>::Allocate(length, ZoneAllocationPolicy(zone));
212 void Initialize(int capacity, Zone* zone) {
214 ZoneAllocationPolicy(zone));
218 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
222 // A zone splay tree. The config type parameter encapsulates the
224 // The tree itself and all its elements are allocated in the Zone.
228 explicit ZoneSplayTree(Zone* zone)
229 : SplayTree<Config, ZoneAllocationPolicy>(ZoneAllocationPolicy(zone)) {}
232 // in the destructor. For a zone-allocated tree, nodes will be
233 // freed by the Zone.
237 void* operator new(size_t size, Zone* zone) { return zone->New(size); }
240 void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }