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

Side by Side Diff: src/zone.cc

Issue 897213003: Remove obsolete Malloced::FatalProcessOutOfMemory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/serialize.cc ('k') | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/zone.h" 5 #include "src/zone.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "src/v8.h"
10
9 #ifdef V8_USE_ADDRESS_SANITIZER 11 #ifdef V8_USE_ADDRESS_SANITIZER
10 #include <sanitizer/asan_interface.h> 12 #include <sanitizer/asan_interface.h>
11 #endif // V8_USE_ADDRESS_SANITIZER 13 #endif // V8_USE_ADDRESS_SANITIZER
12 14
13 namespace v8 { 15 namespace v8 {
14 namespace internal { 16 namespace internal {
15 17
16 namespace { 18 namespace {
17 19
18 #if V8_USE_ADDRESS_SANITIZER 20 #if V8_USE_ADDRESS_SANITIZER
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // is to avoid excessive malloc() and free() overhead. 232 // is to avoid excessive malloc() and free() overhead.
231 Segment* head = segment_head_; 233 Segment* head = segment_head_;
232 const size_t old_size = (head == nullptr) ? 0 : head->size(); 234 const size_t old_size = (head == nullptr) ? 0 : head->size();
233 static const size_t kSegmentOverhead = sizeof(Segment) + kAlignment; 235 static const size_t kSegmentOverhead = sizeof(Segment) + kAlignment;
234 const size_t new_size_no_overhead = size + (old_size << 1); 236 const size_t new_size_no_overhead = size + (old_size << 1);
235 size_t new_size = kSegmentOverhead + new_size_no_overhead; 237 size_t new_size = kSegmentOverhead + new_size_no_overhead;
236 const size_t min_new_size = kSegmentOverhead + static_cast<size_t>(size); 238 const size_t min_new_size = kSegmentOverhead + static_cast<size_t>(size);
237 // Guard against integer overflow. 239 // Guard against integer overflow.
238 if (new_size_no_overhead < static_cast<size_t>(size) || 240 if (new_size_no_overhead < static_cast<size_t>(size) ||
239 new_size < static_cast<size_t>(kSegmentOverhead)) { 241 new_size < static_cast<size_t>(kSegmentOverhead)) {
240 FatalProcessOutOfMemory("Zone"); 242 V8::FatalProcessOutOfMemory("Zone");
241 return nullptr; 243 return nullptr;
242 } 244 }
243 if (new_size < static_cast<size_t>(kMinimumSegmentSize)) { 245 if (new_size < static_cast<size_t>(kMinimumSegmentSize)) {
244 new_size = kMinimumSegmentSize; 246 new_size = kMinimumSegmentSize;
245 } else if (new_size > static_cast<size_t>(kMaximumSegmentSize)) { 247 } else if (new_size > static_cast<size_t>(kMaximumSegmentSize)) {
246 // Limit the size of new segments to avoid growing the segment size 248 // Limit the size of new segments to avoid growing the segment size
247 // exponentially, thus putting pressure on contiguous virtual address space. 249 // exponentially, thus putting pressure on contiguous virtual address space.
248 // All the while making sure to allocate a segment large enough to hold the 250 // All the while making sure to allocate a segment large enough to hold the
249 // requested size. 251 // requested size.
250 new_size = Max(min_new_size, static_cast<size_t>(kMaximumSegmentSize)); 252 new_size = Max(min_new_size, static_cast<size_t>(kMaximumSegmentSize));
251 } 253 }
252 if (new_size > INT_MAX) { 254 if (new_size > INT_MAX) {
253 FatalProcessOutOfMemory("Zone"); 255 V8::FatalProcessOutOfMemory("Zone");
254 return nullptr; 256 return nullptr;
255 } 257 }
256 Segment* segment = NewSegment(static_cast<int>(new_size)); 258 Segment* segment = NewSegment(static_cast<int>(new_size));
257 if (segment == nullptr) { 259 if (segment == nullptr) {
258 FatalProcessOutOfMemory("Zone"); 260 V8::FatalProcessOutOfMemory("Zone");
259 return nullptr; 261 return nullptr;
260 } 262 }
261 263
262 // Recompute 'top' and 'limit' based on the new segment. 264 // Recompute 'top' and 'limit' based on the new segment.
263 Address result = RoundUp(segment->start(), kAlignment); 265 Address result = RoundUp(segment->start(), kAlignment);
264 position_ = result + size; 266 position_ = result + size;
265 // Check for address overflow. 267 // Check for address overflow.
266 // (Should not happen since the segment is guaranteed to accomodate 268 // (Should not happen since the segment is guaranteed to accomodate
267 // size bytes + header and alignment padding) 269 // size bytes + header and alignment padding)
268 DCHECK_GE(reinterpret_cast<uintptr_t>(position_), 270 DCHECK_GE(reinterpret_cast<uintptr_t>(position_),
269 reinterpret_cast<uintptr_t>(result)); 271 reinterpret_cast<uintptr_t>(result));
270 limit_ = segment->end(); 272 limit_ = segment->end();
271 DCHECK(position_ <= limit_); 273 DCHECK(position_ <= limit_);
272 return result; 274 return result;
273 } 275 }
274 276
275 } // namespace internal 277 } // namespace internal
276 } // namespace v8 278 } // namespace v8
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698