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

Unified Diff: src/zone.cc

Issue 10534139: One Zone per CompilationInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
« src/zone.h ('K') | « 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 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_;
« src/zone.h ('K') | « src/zone.h ('k') | src/zone-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698