diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-02 17:11:31 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-06 16:53:06 +0200 |
commit | 704fd8f3745527fc080f96e54e5ec1857c505399 (patch) | |
tree | bff68e8a731f3618d3e8f1708aa9de194bc1f612 /deps/v8/src/zone.cc | |
parent | eec43351c44c0bec31a83e1a28be15e30722936a (diff) | |
download | node-new-704fd8f3745527fc080f96e54e5ec1857c505399.tar.gz |
v8: upgrade to v3.20.2
Diffstat (limited to 'deps/v8/src/zone.cc')
-rw-r--r-- | deps/v8/src/zone.cc | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/deps/v8/src/zone.cc b/deps/v8/src/zone.cc index 51b8113a0d..2a0a0e2846 100644 --- a/deps/v8/src/zone.cc +++ b/deps/v8/src/zone.cc @@ -68,39 +68,20 @@ class Segment { Zone::Zone(Isolate* isolate) - : zone_excess_limit_(256 * MB), + : allocation_size_(0), segment_bytes_allocated_(0), position_(0), limit_(0), - scope_nesting_(0), segment_head_(NULL), isolate_(isolate) { } -unsigned Zone::allocation_size_ = 0; -ZoneScope::~ZoneScope() { - if (ShouldDeleteOnExit()) zone_->DeleteAll(); - zone_->scope_nesting_--; -} +Zone::~Zone() { + DeleteAll(); + DeleteKeptSegment(); -// 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->Initialize(segment_head_, size); - segment_head_ = result; - } - return result; -} - - -// Deletes the given segment. Does not touch the segment chain. -void Zone::DeleteSegment(Segment* segment, int size) { - adjust_segment_bytes_allocated(-size); - Malloced::Delete(segment); + ASSERT(segment_bytes_allocated_ == 0); } @@ -118,8 +99,7 @@ void Zone::DeleteAll() { // Traverse the chained list of segments, zapping (in debug mode) // and freeing every segment except the one we wish to keep. - Segment* current = segment_head_; - while (current != NULL) { + for (Segment* current = segment_head_; current != NULL; ) { Segment* next = current->next(); if (current == keep) { // Unlink the segment we wish to keep from the list. @@ -157,10 +137,43 @@ void Zone::DeleteAll() { void Zone::DeleteKeptSegment() { +#ifdef DEBUG + // Constant byte value used for zapping dead memory in debug mode. + static const unsigned char kZapDeadByte = 0xcd; +#endif + + ASSERT(segment_head_ == NULL || segment_head_->next() == NULL); if (segment_head_ != NULL) { - DeleteSegment(segment_head_, segment_head_->size()); + int size = segment_head_->size(); +#ifdef DEBUG + // Zap the entire kept segment (including the header). + memset(segment_head_, kZapDeadByte, size); +#endif + DeleteSegment(segment_head_, size); segment_head_ = NULL; } + + ASSERT(segment_bytes_allocated_ == 0); +} + + +// 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->Initialize(segment_head_, size); + segment_head_ = result; + } + return result; +} + + +// Deletes the given segment. Does not touch the segment chain. +void Zone::DeleteSegment(Segment* segment, int size) { + adjust_segment_bytes_allocated(-size); + Malloced::Delete(segment); } |