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 21 matching lines...) Expand all Loading... |
32 #include "wtf/PartitionAlloc.h" | 32 #include "wtf/PartitionAlloc.h" |
33 | 33 |
34 #include <string.h> | 34 #include <string.h> |
35 | 35 |
36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
37 #include <stdio.h> | 37 #include <stdio.h> |
38 #endif | 38 #endif |
39 | 39 |
40 // Two partition pages are used as guard / metadata page so make sure the super | 40 // Two partition pages are used as guard / metadata page so make sure the super |
41 // page size is bigger. | 41 // page size is bigger. |
42 COMPILE_ASSERT(WTF::kPartitionPageSize * 4 <= WTF::kSuperPageSize, ok_super_page
_size); | 42 static_assert(WTF::kPartitionPageSize * 4 <= WTF::kSuperPageSize, "ok super page
size"); |
43 COMPILE_ASSERT(!(WTF::kSuperPageSize % WTF::kPartitionPageSize), ok_super_page_m
ultiple); | 43 static_assert(!(WTF::kSuperPageSize % WTF::kPartitionPageSize), "ok super page m
ultiple"); |
44 // Four system pages gives us room to hack out a still-guard-paged piece | 44 // Four system pages gives us room to hack out a still-guard-paged piece |
45 // of metadata in the middle of a guard partition page. | 45 // of metadata in the middle of a guard partition page. |
46 COMPILE_ASSERT(WTF::kSystemPageSize * 4 <= WTF::kPartitionPageSize, ok_partition
_page_size); | 46 static_assert(WTF::kSystemPageSize * 4 <= WTF::kPartitionPageSize, "ok partition
page size"); |
47 COMPILE_ASSERT(!(WTF::kPartitionPageSize % WTF::kSystemPageSize), ok_partition_p
age_multiple); | 47 static_assert(!(WTF::kPartitionPageSize % WTF::kSystemPageSize), "ok partition p
age multiple"); |
48 COMPILE_ASSERT(sizeof(WTF::PartitionPage) <= WTF::kPageMetadataSize, PartitionPa
ge_not_too_big); | 48 static_assert(sizeof(WTF::PartitionPage) <= WTF::kPageMetadataSize, "PartitionPa
ge should not be too big"); |
49 COMPILE_ASSERT(sizeof(WTF::PartitionBucket) <= WTF::kPageMetadataSize, Partition
Bucket_not_too_big); | 49 static_assert(sizeof(WTF::PartitionBucket) <= WTF::kPageMetadataSize, "Partition
Bucket should not be too big"); |
50 COMPILE_ASSERT(sizeof(WTF::PartitionSuperPageExtentEntry) <= WTF::kPageMetadataS
ize, PartitionSuperPageExtentEntry_not_too_big); | 50 static_assert(sizeof(WTF::PartitionSuperPageExtentEntry) <= WTF::kPageMetadataSi
ze, "PartitionSuperPageExtentEntry should not be too big"); |
51 COMPILE_ASSERT(WTF::kPageMetadataSize * WTF::kNumPartitionPagesPerSuperPage <= W
TF::kSystemPageSize, page_metadata_fits_in_hole); | 51 static_assert(WTF::kPageMetadataSize * WTF::kNumPartitionPagesPerSuperPage <= WT
F::kSystemPageSize, "page metadata fits in hole"); |
52 // Check that some of our zanier calculations worked out as expected. | 52 // Check that some of our zanier calculations worked out as expected. |
53 COMPILE_ASSERT(WTF::kGenericSmallestBucket == 8, generic_smallest_bucket); | 53 static_assert(WTF::kGenericSmallestBucket == 8, "generic smallest bucket"); |
54 COMPILE_ASSERT(WTF::kGenericMaxBucketed == 983040, generic_max_bucketed); | 54 static_assert(WTF::kGenericMaxBucketed == 983040, "generic max bucketed"); |
55 | 55 |
56 namespace WTF { | 56 namespace WTF { |
57 | 57 |
58 int PartitionRootBase::gInitializedLock = 0; | 58 int PartitionRootBase::gInitializedLock = 0; |
59 bool PartitionRootBase::gInitialized = false; | 59 bool PartitionRootBase::gInitialized = false; |
60 PartitionPage PartitionRootBase::gSeedPage; | 60 PartitionPage PartitionRootBase::gSeedPage; |
61 PartitionBucket PartitionRootBase::gPagedBucket; | 61 PartitionBucket PartitionRootBase::gPagedBucket; |
62 | 62 |
63 static uint16_t partitionBucketNumSystemPages(size_t size) | 63 static uint16_t partitionBucketNumSystemPages(size_t size) |
64 { | 64 { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 printf("total live: %zu bytes\n", totalLive); | 1020 printf("total live: %zu bytes\n", totalLive); |
1021 printf("total resident: %zu bytes\n", totalResident); | 1021 printf("total resident: %zu bytes\n", totalResident); |
1022 printf("total freeable: %zu bytes\n", totalFreeable); | 1022 printf("total freeable: %zu bytes\n", totalFreeable); |
1023 fflush(stdout); | 1023 fflush(stdout); |
1024 } | 1024 } |
1025 | 1025 |
1026 #endif // !NDEBUG | 1026 #endif // !NDEBUG |
1027 | 1027 |
1028 } // namespace WTF | 1028 } // namespace WTF |
1029 | 1029 |
OLD | NEW |