Index: src/zone.h |
diff --git a/src/zone.h b/src/zone.h |
index 1bc4984aa2520b0b8d84831290741252e189ee69..761c38f495e8c46676c4d635a1a2295e02c39c0d 100644 |
--- a/src/zone.h |
+++ b/src/zone.h |
@@ -64,6 +64,7 @@ class Isolate; |
class Zone { |
public: |
+ explicit Zone(Isolate* isolate); |
// Allocate 'size' bytes of memory in the Zone; expands the Zone by |
// allocating new segments of memory on demand using malloc(). |
inline void* New(int size); |
@@ -71,9 +72,10 @@ class Zone { |
template <typename T> |
inline T* NewArray(int length); |
- // Deletes all objects and free all memory allocated in the Zone. Keeps one |
- // small (size <= kMaximumKeptSegmentSize) segment around if it finds one. |
- void DeleteAll(); |
+ // This method dispatches to either DeleteAll or to DeleteAllButOne |
+ // depending on whether this is the singleton Zone in the isolate or |
+ // not. |
+ void Destroy(); |
danno
2012/06/14 14:22:19
Why not just make sure that the destructor of the
sanjoy
2012/06/15 09:24:31
Yes, that is much cleaner. Done.
|
// Deletes the last small segment kept around by DeleteAll(). |
void DeleteKeptSegment(); |
@@ -92,6 +94,13 @@ class Zone { |
friend class Isolate; |
friend class ZoneScope; |
+ // Frees all memory allocated to this Zone. |
+ void DeleteAll(); |
+ |
+ // Deletes all objects and free all memory allocated in the Zone. Keeps one |
+ // small (size <= kMaximumKeptSegmentSize) segment around if it finds one. |
+ void DeleteAllButOne(); |
+ |
// All pointers returned from New() have this alignment. In addition, if the |
// object being allocated has a size that is divisible by 8 then its alignment |
// will be 8. |
@@ -114,9 +123,6 @@ class Zone { |
// the zone. |
int segment_bytes_allocated_; |
- // Each isolate gets its own zone. |
- Zone(); |
- |
// Expand the Zone to hold at least 'size' more bytes and allocate |
// the bytes. Returns the address of the newly allocated chunk of |
// memory in the Zone. Should only be called if there isn't enough |
@@ -157,7 +163,7 @@ class ZoneObject { |
// operator to be public. |
// ZoneObjects should never be deleted individually; use |
- // Zone::DeleteAll() to delete all zone objects in one go. |
+ // Zone::Destroy() to delete all zone objects in one go. |
void operator delete(void*, size_t) { UNREACHABLE(); } |
void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); } |
}; |
@@ -179,7 +185,7 @@ struct ZoneAllocationPolicy { |
// ZoneLists are growable lists with constant-time access to the |
// elements. The list itself and all its elements are allocated in the |
// Zone. ZoneLists cannot be deleted individually; you can delete all |
-// objects in the Zone by calling Zone::DeleteAll(). |
+// objects in the Zone by calling Zone::Destroy(). |
template<typename T> |
class ZoneList: public List<T, ZoneAllocationPolicy> { |
public: |
@@ -235,7 +241,7 @@ class ZoneList: public List<T, ZoneAllocationPolicy> { |
// outer-most scope. |
class ZoneScope BASE_EMBEDDED { |
public: |
- INLINE(ZoneScope(Isolate* isolate, ZoneScopeMode mode)); |
+ INLINE(ZoneScope(Zone* zone, ZoneScopeMode mode)); |
virtual ~ZoneScope(); |
@@ -250,7 +256,7 @@ class ZoneScope BASE_EMBEDDED { |
inline static int nesting(); |
private: |
- Isolate* isolate_; |
+ Zone* zone_; |
ZoneScopeMode mode_; |
}; |