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

Side by Side Diff: Source/wtf/PartitionAlloc.cpp

Issue 710963002: PartitionAlloc: Update totalSizeOf.* counters when allocation succeeds (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | 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 /* 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 recommitSystemPages(addr, len); 313 recommitSystemPages(addr, len);
314 root->totalSizeOfCommittedPages += len; 314 root->totalSizeOfCommittedPages += len;
315 } 315 }
316 316
317 static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root, int flags, uint16_t numPartitionPages) 317 static ALWAYS_INLINE void* partitionAllocPartitionPages(PartitionRootBase* root, int flags, uint16_t numPartitionPages)
318 { 318 {
319 ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPage) % kPartitionPa geSize)); 319 ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPage) % kPartitionPa geSize));
320 ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPageEnd) % kPartitio nPageSize)); 320 ASSERT(!(reinterpret_cast<uintptr_t>(root->nextPartitionPageEnd) % kPartitio nPageSize));
321 RELEASE_ASSERT(numPartitionPages <= kNumPartitionPagesPerSuperPage); 321 RELEASE_ASSERT(numPartitionPages <= kNumPartitionPagesPerSuperPage);
322 size_t totalSize = kPartitionPageSize * numPartitionPages; 322 size_t totalSize = kPartitionPageSize * numPartitionPages;
323 root->totalSizeOfCommittedPages += totalSize;
324 size_t numPartitionPagesLeft = (root->nextPartitionPageEnd - root->nextParti tionPage) >> kPartitionPageShift; 323 size_t numPartitionPagesLeft = (root->nextPartitionPageEnd - root->nextParti tionPage) >> kPartitionPageShift;
325 if (LIKELY(numPartitionPagesLeft >= numPartitionPages)) { 324 if (LIKELY(numPartitionPagesLeft >= numPartitionPages)) {
326 // In this case, we can still hand out pages from the current super page 325 // In this case, we can still hand out pages from the current super page
327 // allocation. 326 // allocation.
328 char* ret = root->nextPartitionPage; 327 char* ret = root->nextPartitionPage;
329 root->nextPartitionPage += totalSize; 328 root->nextPartitionPage += totalSize;
329 root->totalSizeOfCommittedPages += totalSize;
330 return ret; 330 return ret;
331 } 331 }
332 332
333 // Need a new super page. 333 // Need a new super page.
334 root->totalSizeOfSuperPages += kSuperPageSize;
335 char* requestedAddress = root->nextSuperPage; 334 char* requestedAddress = root->nextSuperPage;
336 char* superPage = reinterpret_cast<char*>(allocPages(requestedAddress, kSupe rPageSize, kSuperPageSize)); 335 char* superPage = reinterpret_cast<char*>(allocPages(requestedAddress, kSupe rPageSize, kSuperPageSize));
337 if (UNLIKELY(!superPage)) 336 if (UNLIKELY(!superPage))
338 return 0; 337 return 0;
338
339 root->totalSizeOfSuperPages += kSuperPageSize;
340 root->totalSizeOfCommittedPages += totalSize;
341
339 root->nextSuperPage = superPage + kSuperPageSize; 342 root->nextSuperPage = superPage + kSuperPageSize;
340 char* ret = superPage + kPartitionPageSize; 343 char* ret = superPage + kPartitionPageSize;
341 root->nextPartitionPage = ret + totalSize; 344 root->nextPartitionPage = ret + totalSize;
342 root->nextPartitionPageEnd = root->nextSuperPage - kPartitionPageSize; 345 root->nextPartitionPageEnd = root->nextSuperPage - kPartitionPageSize;
343 // Make the first partition page in the super page a guard page, but leave a 346 // Make the first partition page in the super page a guard page, but leave a
344 // hole in the middle. 347 // hole in the middle.
345 // This is where we put page metadata and also a tiny amount of extent 348 // This is where we put page metadata and also a tiny amount of extent
346 // metadata. 349 // metadata.
347 setSystemPagesInaccessible(superPage, kSystemPageSize); 350 setSystemPagesInaccessible(superPage, kSystemPageSize);
348 setSystemPagesInaccessible(superPage + (kSystemPageSize * 2), kPartitionPage Size - (kSystemPageSize * 2)); 351 setSystemPagesInaccessible(superPage + (kSystemPageSize * 2), kPartitionPage Size - (kSystemPageSize * 2));
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 printf("total live: %zu bytes\n", totalLive); 983 printf("total live: %zu bytes\n", totalLive);
981 printf("total resident: %zu bytes\n", totalResident); 984 printf("total resident: %zu bytes\n", totalResident);
982 printf("total freeable: %zu bytes\n", totalFreeable); 985 printf("total freeable: %zu bytes\n", totalFreeable);
983 fflush(stdout); 986 fflush(stdout);
984 } 987 }
985 988
986 #endif // !NDEBUG 989 #endif // !NDEBUG
987 990
988 } // namespace WTF 991 } // namespace WTF
989 992
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698