Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: src/zone.cc

Issue 17827005: Get rid of ZoneScope completely. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Suggestions from danno Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/zone.h ('k') | src/zone-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone.cc
diff --git a/src/zone.cc b/src/zone.cc
index d3f1c6fce52d0b00e9feb86c0c253b5564937c51..0555f5da8ff88d3a593d71e3f9fee096ff44bf31 100644
--- a/src/zone.cc
+++ b/src/zone.cc
@@ -73,15 +73,37 @@ Zone::Zone(Isolate* isolate)
segment_bytes_allocated_(0),
position_(0),
limit_(0),
- scope_nesting_(0),
segment_head_(NULL),
isolate_(isolate) {
}
-ZoneScope::~ZoneScope() {
- if (ShouldDeleteOnExit()) zone_->DeleteAll();
- zone_->scope_nesting_--;
+Zone::~Zone() {
+#ifdef DEBUG
+ // Constant byte value used for zapping dead memory in debug mode.
+ static const unsigned char kZapDeadByte = 0xcd;
+#endif
+
+ // Traverse the chained list of segments, zapping
+ // (in debug mode) and freeing every segment
+ 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;
+ }
+
+ // We must clear the position and limit to force
+ // a new segment to be allocated on demand.
+ position_ = limit_ = 0;
+
+ // Update the head segment.
+ segment_head_ = NULL;
}
@@ -105,66 +127,6 @@ void Zone::DeleteSegment(Segment* segment, int size) {
}
-void Zone::DeleteAll() {
-#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_;
- while (keep != NULL && keep->size() > kMaximumKeptSegmentSize) {
- keep = keep->next();
- }
-
- // 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) {
- Segment* next = current->next();
- if (current == keep) {
- // Unlink the segment we wish to keep from the list.
- current->clear_next();
- } else {
- int size = current->size();
-#ifdef DEBUG
- // Zap the entire current segment (including the header).
- memset(current, kZapDeadByte, size);
-#endif
- DeleteSegment(current, size);
- }
- current = next;
- }
-
- // If we have found a segment we want to keep, we must recompute the
- // variables 'position' and 'limit' to prepare for future allocate
- // attempts. Otherwise, we must clear the position and limit to
- // force a new segment to be allocated on demand.
- if (keep != NULL) {
- Address start = keep->start();
- position_ = RoundUp(start, kAlignment);
- limit_ = keep->end();
-#ifdef DEBUG
- // Zap the contents of the kept segment (but not the header).
- memset(start, kZapDeadByte, keep->capacity());
-#endif
- } else {
- position_ = limit_ = 0;
- }
-
- // Update the head segment to be the kept segment (if any).
- segment_head_ = keep;
-}
-
-
-void Zone::DeleteKeptSegment() {
- if (segment_head_ != NULL) {
- DeleteSegment(segment_head_, segment_head_->size());
- segment_head_ = NULL;
- }
-}
-
-
Address Zone::NewExpand(int size) {
// Make sure the requested size is already properly aligned and that
// there isn't enough room in the Zone to satisfy the request.
« no previous file with comments | « src/zone.h ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698