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

Unified Diff: src/zone.cc

Issue 7631020: Version 3.5.6. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 4 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') | test/cctest/test-api.cc » ('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 42ce8c5cb7c2d72392c3f80cbbc92f42ac418cf4..7574778f539acb9db63f73e79218a9fa0a3cd9ee 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,33 @@ 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;
+
+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;
@@ -155,6 +156,14 @@ void Zone::DeleteAll() {
}
+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') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698