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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // a bunch of system pages more than "size": | 571 // a bunch of system pages more than "size": |
572 // - The first few system pages are the partition page in which the super | 572 // - The first few system pages are the partition page in which the super |
573 // page metadata is stored. We fault just one system page out of a partition | 573 // page metadata is stored. We fault just one system page out of a partition |
574 // page sized clump. | 574 // page sized clump. |
575 // - We add a trailing guard page. | 575 // - We add a trailing guard page. |
576 size_t mapSize = size + kPartitionPageSize + kSystemPageSize; | 576 size_t mapSize = size + kPartitionPageSize + kSystemPageSize; |
577 // Round up to the allocation granularity. | 577 // Round up to the allocation granularity. |
578 mapSize += kPageAllocationGranularityOffsetMask; | 578 mapSize += kPageAllocationGranularityOffsetMask; |
579 mapSize &= kPageAllocationGranularityBaseMask; | 579 mapSize &= kPageAllocationGranularityBaseMask; |
580 | 580 |
| 581 root->totalSizeOfCommittedPages += size + kSystemPageSize; |
| 582 |
581 // TODO: we may want to let the operating system place these allocations | 583 // TODO: we may want to let the operating system place these allocations |
582 // where it pleases. On 32-bit, this might limit address space | 584 // where it pleases. On 32-bit, this might limit address space |
583 // fragmentation and on 64-bit, this might have useful savings for TLB | 585 // fragmentation and on 64-bit, this might have useful savings for TLB |
584 // and page table overhead. | 586 // and page table overhead. |
585 // TODO: if upsizing realloc()s are common on large sizes, we could | 587 // TODO: if upsizing realloc()s are common on large sizes, we could |
586 // consider over-allocating address space on 64-bit, "just in case". | 588 // consider over-allocating address space on 64-bit, "just in case". |
587 // TODO: consider pre-populating page tables (e.g. MAP_POPULATE on Linux, | 589 // TODO: consider pre-populating page tables (e.g. MAP_POPULATE on Linux, |
588 // MADV_WILLNEED on POSIX). | 590 // MADV_WILLNEED on POSIX). |
589 // TODO: these pages will be zero-filled. Consider internalizing an | 591 // TODO: these pages will be zero-filled. Consider internalizing an |
590 // allocZeroed() API so we can avoid a memset() entirely in this case. | 592 // allocZeroed() API so we can avoid a memset() entirely in this case. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 } | 629 } |
628 | 630 |
629 static ALWAYS_INLINE void partitionDirectUnmap(PartitionPage* page) | 631 static ALWAYS_INLINE void partitionDirectUnmap(PartitionPage* page) |
630 { | 632 { |
631 size_t unmapSize = partitionPageToDirectMapExtent(page)->mapSize; | 633 size_t unmapSize = partitionPageToDirectMapExtent(page)->mapSize; |
632 | 634 |
633 // Add on the size of the trailing guard page and preceeding partition | 635 // Add on the size of the trailing guard page and preceeding partition |
634 // page. | 636 // page. |
635 unmapSize += kPartitionPageSize + kSystemPageSize; | 637 unmapSize += kPartitionPageSize + kSystemPageSize; |
636 | 638 |
| 639 PartitionRootBase* root = partitionPageToRoot(page); |
| 640 root->totalSizeOfCommittedPages -= page->bucket->slotSize + kSystemPageSize; |
| 641 |
637 ASSERT(!(unmapSize & kPageAllocationGranularityOffsetMask)); | 642 ASSERT(!(unmapSize & kPageAllocationGranularityOffsetMask)); |
638 | 643 |
639 char* ptr = reinterpret_cast<char*>(partitionPageToPointer(page)); | 644 char* ptr = reinterpret_cast<char*>(partitionPageToPointer(page)); |
640 // Account for the mapping starting a partition page before the actual | 645 // Account for the mapping starting a partition page before the actual |
641 // allocation address. | 646 // allocation address. |
642 ptr -= kPartitionPageSize; | 647 ptr -= kPartitionPageSize; |
643 | 648 |
644 freePages(ptr, unmapSize); | 649 freePages(ptr, unmapSize); |
645 } | 650 } |
646 | 651 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 printf("total live: %zu bytes\n", totalLive); | 980 printf("total live: %zu bytes\n", totalLive); |
976 printf("total resident: %zu bytes\n", totalResident); | 981 printf("total resident: %zu bytes\n", totalResident); |
977 printf("total freeable: %zu bytes\n", totalFreeable); | 982 printf("total freeable: %zu bytes\n", totalFreeable); |
978 fflush(stdout); | 983 fflush(stdout); |
979 } | 984 } |
980 | 985 |
981 #endif // !NDEBUG | 986 #endif // !NDEBUG |
982 | 987 |
983 } // namespace WTF | 988 } // namespace WTF |
984 | 989 |
OLD | NEW |