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

Side by Side Diff: src/zone.cc

Issue 13210: - Simplify the code slightly by using Max(). (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // except that we employ a maximum segment size when we delete. This 162 // except that we employ a maximum segment size when we delete. This
163 // is to avoid excessive malloc() and free() overhead. 163 // is to avoid excessive malloc() and free() overhead.
164 Segment* head = Segment::head(); 164 Segment* head = Segment::head();
165 int old_size = (head == NULL) ? 0 : head->size(); 165 int old_size = (head == NULL) ? 0 : head->size();
166 static const int kSegmentOverhead = sizeof(Segment) + kAlignment; 166 static const int kSegmentOverhead = sizeof(Segment) + kAlignment;
167 int new_size = kSegmentOverhead + size + (old_size << 1); 167 int new_size = kSegmentOverhead + size + (old_size << 1);
168 if (new_size < kMinimumSegmentSize) { 168 if (new_size < kMinimumSegmentSize) {
169 new_size = kMinimumSegmentSize; 169 new_size = kMinimumSegmentSize;
170 } else if (new_size > kMaximumSegmentSize) { 170 } else if (new_size > kMaximumSegmentSize) {
171 // Limit the size of new segments to avoid growing the segment size 171 // Limit the size of new segments to avoid growing the segment size
172 // exponentially, thus putting pressure on contiguous virtual address 172 // exponentially, thus putting pressure on contiguous virtual address space.
173 // space. 173 // All the while making sure to allocate a segment large enough to hold the
174 if (size > (kMaximumSegmentSize - kSegmentOverhead)) { 174 // requested size.
175 // Make sure to allocate a segment at large enough to hold the requested 175 new_size = Max(kSegmentOverhead + size, kMaximumSegmentSize);
176 // size.
177 new_size = kSegmentOverhead + size;
178 } else {
179 // Allocate a new segment of maximum size.
180 new_size = kMaximumSegmentSize;
181 }
182 } 176 }
183 Segment* segment = Segment::New(new_size); 177 Segment* segment = Segment::New(new_size);
184 if (segment == NULL) V8::FatalProcessOutOfMemory("Zone"); 178 if (segment == NULL) V8::FatalProcessOutOfMemory("Zone");
185 179
186 // Recompute 'top' and 'limit' based on the new segment. 180 // Recompute 'top' and 'limit' based on the new segment.
187 Address result = RoundUp(segment->start(), kAlignment); 181 Address result = RoundUp(segment->start(), kAlignment);
188 position_ = result + size; 182 position_ = result + size;
189 limit_ = segment->end(); 183 limit_ = segment->end();
190 ASSERT(position_ <= limit_); 184 ASSERT(position_ <= limit_);
191 return result; 185 return result;
192 } 186 }
193 187
194 188
195 } } // namespace v8::internal 189 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698