Chromium Code Reviews| Index: src/zone.cc |
| diff --git a/src/zone.cc b/src/zone.cc |
| index 42ce8c5cb7c2d72392c3f80cbbc92f42ac418cf4..2900f4aac0e83da31cbaaab3699f78125aa090fc 100644 |
| --- a/src/zone.cc |
| +++ b/src/zone.cc |
| @@ -34,24 +34,6 @@ namespace v8 { |
| namespace internal { |
| -Zone::Zone() |
| - : zone_excess_limit_(256 * MB), |
| - segment_bytes_allocated_(0), |
| - position_(0), |
| - limit_(0), |
| - scope_nesting_(0), |
| - segment_head_(NULL) { |
| -} |
| -unsigned Zone::allocation_size_ = 0; |
| - |
| - |
| -ZoneScope::~ZoneScope() { |
| - ASSERT_EQ(Isolate::Current(), isolate_); |
| - if (ShouldDeleteOnExit()) isolate_->zone()->DeleteAll(); |
| - isolate_->zone()->scope_nesting_--; |
| -} |
| - |
| - |
| // Segments represent chunks of memory: They have starting address |
| // (encoded in the this pointer) and a size in bytes. Segments are |
| // chained together forming a LIFO structure with the newest segment |
| @@ -60,6 +42,11 @@ ZoneScope::~ZoneScope() { |
| class Segment { |
| public: |
| + void Initialize(Segment* next, int size) { |
| + next_ = next; |
| + size_ = size; |
| + } |
| + |
| Segment* next() const { return next_; } |
| void clear_next() { next_ = NULL; } |
| @@ -77,19 +64,39 @@ class Segment { |
| Segment* next_; |
| int size_; |
| - |
| - friend class Zone; |
| }; |
| +Zone::Zone() |
| + : zone_excess_limit_(256 * MB), |
| + segment_bytes_allocated_(0), |
| + position_(0), |
| + limit_(0), |
| + scope_nesting_(0), |
| + segment_head_(NULL) { |
| +} |
| +unsigned Zone::allocation_size_ = 0; |
| + |
| +Zone::~Zone() { |
| + if (segment_head_ != NULL) { |
| + delete segment_head_; |
|
Vitaly Repeshko
2011/08/16 17:52:32
This should use DeleteSegment.
Jakob Kummerow
2011/08/17 08:47:30
Done.
This required putting the code into a separa
|
| + } |
| +} |
| + |
| +ZoneScope::~ZoneScope() { |
| + ASSERT_EQ(Isolate::Current(), isolate_); |
| + if (ShouldDeleteOnExit()) isolate_->zone()->DeleteAll(); |
| + isolate_->zone()->scope_nesting_--; |
| +} |
| + |
| + |
| // Creates a new segment, sets it size, and pushes it to the front |
| // of the segment chain. Returns the new segment. |
| Segment* Zone::NewSegment(int size) { |
| Segment* result = reinterpret_cast<Segment*>(Malloced::New(size)); |
| adjust_segment_bytes_allocated(size); |
| if (result != NULL) { |
| - result->next_ = segment_head_; |
| - result->size_ = size; |
| + result->Initialize(segment_head_, size); |
| segment_head_ = result; |
| } |
| return result; |