| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } else { | 310 } else { |
| 311 // Fully used page became partially used. It must be put back on the | 311 // Fully used page became partially used. It must be put back on the |
| 312 // non-full page list. | 312 // non-full page list. |
| 313 partitionLinkPage(page, bucket->currPage); | 313 partitionLinkPage(page, bucket->currPage); |
| 314 page->numAllocatedSlots = -page->numAllocatedSlots - 2; | 314 page->numAllocatedSlots = -page->numAllocatedSlots - 2; |
| 315 ASSERT(page->numAllocatedSlots == partitionBucketSlots(bucket) - 1); | 315 ASSERT(page->numAllocatedSlots == partitionBucketSlots(bucket) - 1); |
| 316 --bucket->numFullPages; | 316 --bucket->numFullPages; |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 size_t partitionAllocGetUsedPagesSize(const PartitionRoot& root) |
| 321 { |
| 322 size_t total = 0; |
| 323 size_t i; |
| 324 for (i = 0; i < kNumBuckets; ++i) { |
| 325 const PartitionBucket& bucket = root.buckets[i]; |
| 326 total += bucket.numFullPages * kPartitionPageSize; |
| 327 const PartitionPageHeader* page = bucket.currPage; |
| 328 do { |
| 329 if (page != &bucket.root->seedPage) |
| 330 total += kPartitionPageSize; |
| 331 page = page->next; |
| 332 } while (page != bucket.currPage); |
| 333 } |
| 334 return total; |
| 335 } |
| 336 |
| 320 #ifndef NDEBUG | 337 #ifndef NDEBUG |
| 321 | 338 |
| 322 void partitionDumpStats(const PartitionRoot& root) | 339 void partitionDumpStats(const PartitionRoot& root) |
| 323 { | 340 { |
| 324 size_t i; | 341 size_t i; |
| 325 for (i = 0; i < kNumBuckets; ++i) { | 342 for (i = 0; i < kNumBuckets; ++i) { |
| 326 const PartitionBucket& bucket = root.buckets[i]; | 343 const PartitionBucket& bucket = root.buckets[i]; |
| 327 if (bucket.currPage == &bucket.root->seedPage && !bucket.freePages) { | 344 if (bucket.currPage == &bucket.root->seedPage && !bucket.freePages) { |
| 328 // Empty bucket with no freelist pages. Skip reporting it. | 345 // Empty bucket with no freelist pages. Skip reporting it. |
| 329 continue; | 346 continue; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 346 } | 363 } |
| 347 page = page->next; | 364 page = page->next; |
| 348 } while (page != bucket.currPage); | 365 } while (page != bucket.currPage); |
| 349 printf("bucket size %ld: %ld/%ld bytes, %ld free pages\n", bucketSlotSiz
e, numActiveBytes, numActivePages * kPartitionPageSize, numFreePages); | 366 printf("bucket size %ld: %ld/%ld bytes, %ld free pages\n", bucketSlotSiz
e, numActiveBytes, numActivePages * kPartitionPageSize, numFreePages); |
| 350 } | 367 } |
| 351 } | 368 } |
| 352 #endif // !NDEBUG | 369 #endif // !NDEBUG |
| 353 | 370 |
| 354 } // namespace WTF | 371 } // namespace WTF |
| 355 | 372 |
| OLD | NEW |