Chromium Code Reviews| Index: src/zone.cc |
| diff --git a/src/zone.cc b/src/zone.cc |
| index d5d05ab95f21bb1f003e1a0334593df0de0dfcdd..7cfc7207d3e4738a376583abb627fd0fd173e8ec 100644 |
| --- a/src/zone.cc |
| +++ b/src/zone.cc |
| @@ -67,20 +67,20 @@ class Segment { |
| }; |
| -Zone::Zone() |
| +Zone::Zone(Isolate* isolate) |
| : zone_excess_limit_(256 * MB), |
| segment_bytes_allocated_(0), |
| position_(0), |
| limit_(0), |
| scope_nesting_(0), |
| - segment_head_(NULL) { |
| + segment_head_(NULL), |
| + isolate_(isolate) { |
| } |
| unsigned Zone::allocation_size_ = 0; |
| ZoneScope::~ZoneScope() { |
| - ASSERT_EQ(Isolate::Current(), isolate_); |
| - if (ShouldDeleteOnExit()) isolate_->zone()->DeleteAll(); |
| - isolate_->zone()->scope_nesting_--; |
| + if (ShouldDeleteOnExit()) zone_->Destroy(); |
| + zone_->scope_nesting_--; |
| } |
| @@ -104,11 +104,38 @@ void Zone::DeleteSegment(Segment* segment, int size) { |
| } |
| +void Zone::Destroy() { |
| + if (isolate_->runtime_zone() == this) |
|
danno
2012/06/14 14:22:19
Yikes! Please move the DeleteAll(DELETE_ALL_BLOCKS
sanjoy
2012/06/15 09:24:31
Moved deletion to the destructor.
|
| + DeleteAllButOne(); |
| + else |
| + DeleteAll(); |
| +} |
| + |
| + |
| void Zone::DeleteAll() { |
| #ifdef DEBUG |
| // Constant byte value used for zapping dead memory in debug mode. |
| static const unsigned char kZapDeadByte = 0xcd; |
| #endif |
| + Segment* current = segment_head_; |
| + while (current != NULL) { |
| + Segment* next = current->next(); |
| + int size = current->size(); |
| +#ifdef DEBUG |
| + // Zap the entire current segment (including the header). |
| + memset(current, kZapDeadByte, size); |
| +#endif |
| + DeleteSegment(current, size); |
| + current = next; |
| + } |
| +} |
| + |
| + |
| +void Zone::DeleteAllButOne() { |
|
danno
2012/06/14 14:22:19
Just add a enum flag to DeleteAll that handles the
sanjoy
2012/06/15 09:24:31
Moved deletion to the destructor.
|
| +#ifdef DEBUG |
| + // Constant byte value used for zapping dead memory in debug mode. |
| + static const unsigned char kZapDeadByte = 0xcd; |
| +#endif |
| // Find a segment with a suitable size to keep around. |
| Segment* keep = segment_head_; |