OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 size_t i; | 289 size_t i; |
290 for (i = 0; i < kGenericNumBucketedOrders * kGenericNumBucketsPerOrder; ++i) { | 290 for (i = 0; i < kGenericNumBucketedOrders * kGenericNumBucketsPerOrder; ++i) { |
291 PartitionBucket* bucket = &root->buckets[i]; | 291 PartitionBucket* bucket = &root->buckets[i]; |
292 if (!partitionAllocShutdownBucket(bucket)) | 292 if (!partitionAllocShutdownBucket(bucket)) |
293 noLeaks = false; | 293 noLeaks = false; |
294 } | 294 } |
295 partitionAllocBaseShutdown(root); | 295 partitionAllocBaseShutdown(root); |
296 return noLeaks; | 296 return noLeaks; |
297 } | 297 } |
298 | 298 |
299 static NEVER_INLINE void partitionOutOfMemory() | 299 static NEVER_INLINE void partitionOutOfMemory(const PartitionRootBase* root) |
300 { | 300 { |
301 if ((uint64_t)root->totalSizeOfSuperPages - (uint64_t)root->totalSizeOfCommi ttedPages > kReasonableSizeOfUnusedPages) { | |
Tom Sepez
2014/11/06 17:32:51
why this promotion to unit64_t? Also, are we sure
Chris Evans
2014/11/06 20:43:22
I don't think this condition will ever give more a
Chris Evans
2014/11/06 20:43:22
I also don't like the look of these casts. Hopeful
Jens Widell
2014/11/07 08:31:21
Since we now include direct mapped allocations in
hiroshige
2014/11/07 08:57:00
I expect there are no out-of-virtual-address-space
hiroshige
2014/11/07 08:57:00
Added assertions, and removed casts.
hiroshige
2014/11/07 08:57:00
Yes, and I added totalSizeOfDirectMappedPages in P
| |
302 // OOMs where a lot of super pages are allocated but not committed, | |
303 // probably due to http://crbug.com/421387. | |
304 // Crash at a special address (0x9b) | |
305 // to be easily distinguished on crash reports. | |
306 ((void(*)())0x0000009b)(); | |
Tom Sepez
2014/11/06 17:32:51
Maybe we need IMMEDIATE_CRASH_WITH_FLAG(0x9b) macr
Chris Evans
2014/11/06 20:43:22
I don't like this, it's a bit arbitrary and doesn'
hiroshige
2014/11/07 08:56:59
cevans@, Agree, I also prefer what you suggested,
hiroshige
2014/11/07 10:28:17
Added IMMEDIATE_CRASH_WITH_FLAG and partitionOutOf
| |
307 } | |
308 // Ordinary OOMs (where super pages are consumed and mostly committed). | |
301 IMMEDIATE_CRASH(); | 309 IMMEDIATE_CRASH(); |
302 } | 310 } |
303 | 311 |
304 static ALWAYS_INLINE void partitionDecommitSystemPages(PartitionRootBase* root, void* addr, size_t len) | 312 static ALWAYS_INLINE void partitionDecommitSystemPages(PartitionRootBase* root, void* addr, size_t len) |
305 { | 313 { |
306 decommitSystemPages(addr, len); | 314 decommitSystemPages(addr, len); |
307 ASSERT(root->totalSizeOfCommittedPages > len); | 315 ASSERT(root->totalSizeOfCommittedPages > len); |
308 root->totalSizeOfCommittedPages -= len; | 316 root->totalSizeOfCommittedPages -= len; |
309 } | 317 } |
310 | 318 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 newPage = partitionPointerToPageNoAlignmentCheck(rawNewPage); | 702 newPage = partitionPointerToPageNoAlignmentCheck(rawNewPage); |
695 } | 703 } |
696 | 704 |
697 partitionPageReset(newPage, bucket); | 705 partitionPageReset(newPage, bucket); |
698 bucket->activePagesHead = newPage; | 706 bucket->activePagesHead = newPage; |
699 return partitionPageAllocAndFillFreelist(newPage); | 707 return partitionPageAllocAndFillFreelist(newPage); |
700 | 708 |
701 partitionAllocSlowPathFailed: | 709 partitionAllocSlowPathFailed: |
702 if (returnNull) | 710 if (returnNull) |
703 return nullptr; | 711 return nullptr; |
704 partitionOutOfMemory(); | 712 partitionOutOfMemory(root); |
705 return nullptr; | 713 return nullptr; |
706 } | 714 } |
707 | 715 |
708 static ALWAYS_INLINE void partitionFreePage(PartitionRootBase* root, PartitionPa ge* page) | 716 static ALWAYS_INLINE void partitionFreePage(PartitionRootBase* root, PartitionPa ge* page) |
709 { | 717 { |
710 ASSERT(page->freelistHead); | 718 ASSERT(page->freelistHead); |
711 ASSERT(!page->numAllocatedSlots); | 719 ASSERT(!page->numAllocatedSlots); |
712 partitionUnusePage(root, page); | 720 partitionUnusePage(root, page); |
713 // We actually leave the freed page in the active list. We'll sweep it on | 721 // We actually leave the freed page in the active list. We'll sweep it on |
714 // to the free page list when we next walk the active page list. Pulling | 722 // to the free page list when we next walk the active page list. Pulling |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 printf("total live: %zu bytes\n", totalLive); | 981 printf("total live: %zu bytes\n", totalLive); |
974 printf("total resident: %zu bytes\n", totalResident); | 982 printf("total resident: %zu bytes\n", totalResident); |
975 printf("total freeable: %zu bytes\n", totalFreeable); | 983 printf("total freeable: %zu bytes\n", totalFreeable); |
976 fflush(stdout); | 984 fflush(stdout); |
977 } | 985 } |
978 | 986 |
979 #endif // !NDEBUG | 987 #endif // !NDEBUG |
980 | 988 |
981 } // namespace WTF | 989 } // namespace WTF |
982 | 990 |
OLD | NEW |