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

Unified Diff: src/zone.cc

Issue 12984: Partial fix for issue 173:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone.cc
===================================================================
--- src/zone.cc (revision 918)
+++ src/zone.cc (working copy)
@@ -163,8 +163,23 @@
// is to avoid excessive malloc() and free() overhead.
Segment* head = Segment::head();
int old_size = (head == NULL) ? 0 : head->size();
- int new_size = sizeof(Segment) + kAlignment + size + (old_size << 1);
- if (new_size < kMinimumSegmentSize) new_size = kMinimumSegmentSize;
+ int segment_overhead = sizeof(Segment) + kAlignment;
Kasper Lund 2008/12/05 08:36:49 This is a constant, right? Maybe make it 'static c
iposva 2008/12/05 17:25:13 Done.
+ int new_size = segment_overhead + size + (old_size << 1);
+ if (new_size < kMinimumSegmentSize) {
+ new_size = kMinimumSegmentSize;
+ } else if (new_size > kMaximumSegmentSize) {
+ // Limit the size of new segments to avoid growing the segment size
+ // exponentially, thus putting pressure on contiguous virtual address
+ // space.
+ if (size > (kMaximumSegmentSize - segment_overhead)) {
+ // Make sure to allocate a segment at least large enough to hold the
+ // requested size.
+ new_size = RoundUp(size + segment_overhead, kMinimumSegmentSize);
Kasper Lund 2008/12/05 08:36:49 Why do you round the result up? If it's a feature
iposva 2008/12/05 17:25:13 The idea was to round up to a size that is likely
+ } else {
+ // Allocate a new segment of maximum size.
+ new_size = kMaximumSegmentSize;
+ }
+ }
Segment* segment = Segment::New(new_size);
if (segment == NULL) V8::FatalProcessOutOfMemory("Zone");
« no previous file with comments | « src/zone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698