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

Side by Side Diff: third_party/tcmalloc/chromium/src/page_heap.cc

Issue 11857007: TCMalloc: restrict maximum size of memory ranges (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't modify any system allocator, just GrowHeap. Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.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 (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 t->depth = GetStackTrace(t->stack, kMaxStackDepth-1, 3); 460 t->depth = GetStackTrace(t->stack, kMaxStackDepth-1, 3);
461 t->size = growth; 461 t->size = growth;
462 t->stack[kMaxStackDepth-1] = reinterpret_cast<void*>(Static::growth_stacks()); 462 t->stack[kMaxStackDepth-1] = reinterpret_cast<void*>(Static::growth_stacks());
463 Static::set_growth_stacks(t); 463 Static::set_growth_stacks(t);
464 } 464 }
465 465
466 bool PageHeap::GrowHeap(Length n) { 466 bool PageHeap::GrowHeap(Length n) {
467 ASSERT(kMaxPages >= kMinSystemAlloc); 467 ASSERT(kMaxPages >= kMinSystemAlloc);
468 if (n > kMaxValidPages) return false; 468 if (n > kMaxValidPages) return false;
469 Length ask = (n>kMinSystemAlloc) ? n : static_cast<Length>(kMinSystemAlloc); 469 Length ask = (n>kMinSystemAlloc) ? n : static_cast<Length>(kMinSystemAlloc);
470 // Check if it's ok to grow the heap for this much. This is a security
471 // measure to make sure that large allocations fail.
472 if (!IsContiguousAllocSizePermitted(n << kPageShift))
jar (doing other things) 2013/01/12 16:13:29 nit: test should come next to similar test in line
473 return false;
470 size_t actual_size; 474 size_t actual_size;
471 void* ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize); 475 void* ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize);
472 if (ptr == NULL) { 476 if (ptr == NULL) {
473 if (n < ask) { 477 if (n < ask) {
474 // Try growing just "n" pages 478 // Try growing just "n" pages
475 ask = n; 479 ask = n;
476 ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize); 480 ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize);
477 } 481 }
478 if (ptr == NULL) return false; 482 if (ptr == NULL) return false;
479 } 483 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 CHECK_CONDITION(s->location == freelist); // NORMAL or RETURNED 541 CHECK_CONDITION(s->location == freelist); // NORMAL or RETURNED
538 CHECK_CONDITION(s->length >= min_pages); 542 CHECK_CONDITION(s->length >= min_pages);
539 CHECK_CONDITION(s->length <= max_pages); 543 CHECK_CONDITION(s->length <= max_pages);
540 CHECK_CONDITION(GetDescriptor(s->start) == s); 544 CHECK_CONDITION(GetDescriptor(s->start) == s);
541 CHECK_CONDITION(GetDescriptor(s->start+s->length-1) == s); 545 CHECK_CONDITION(GetDescriptor(s->start+s->length-1) == s);
542 } 546 }
543 return true; 547 return true;
544 } 548 }
545 549
546 } // namespace tcmalloc 550 } // namespace tcmalloc
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698