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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 months 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
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 void BaseArena::takeSnapshot(const String& dumpBaseName, 130 void BaseArena::takeSnapshot(const String& dumpBaseName,
131 ThreadState::GCSnapshotInfo& info) { 131 ThreadState::GCSnapshotInfo& info) {
132 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName" 132 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName"
133 base::trace_event::MemoryAllocatorDump* allocatorDump = 133 base::trace_event::MemoryAllocatorDump* allocatorDump =
134 BlinkGCMemoryDumpProvider::instance() 134 BlinkGCMemoryDumpProvider::instance()
135 ->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); 135 ->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
136 size_t pageCount = 0; 136 size_t pageCount = 0;
137 BasePage::HeapSnapshotInfo heapInfo; 137 BasePage::HeapSnapshotInfo heapInfo;
138 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 138 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
139 String dumpName = 139 String dumpName = dumpBaseName +
140 dumpBaseName + String::format("/pages/page_%lu", 140 String::format("/pages/page_%lu",
141 static_cast<unsigned long>(pageCount++)); 141 static_cast<unsigned long>(pageCount++));
142 base::trace_event::MemoryAllocatorDump* pageDump = 142 base::trace_event::MemoryAllocatorDump* pageDump =
143 BlinkGCMemoryDumpProvider::instance() 143 BlinkGCMemoryDumpProvider::instance()
144 ->createMemoryAllocatorDumpForCurrentGC(dumpName); 144 ->createMemoryAllocatorDumpForCurrentGC(dumpName);
145 145
146 page->takeSnapshot(pageDump, info, heapInfo); 146 page->takeSnapshot(pageDump, info, heapInfo);
147 } 147 }
148 allocatorDump->AddScalar("blink_page_count", "objects", pageCount); 148 allocatorDump->AddScalar("blink_page_count", "objects", pageCount);
149 149
150 // When taking a full dump (w/ freelist), both the /buckets and /pages 150 // When taking a full dump (w/ freelist), both the /buckets and /pages
151 // report their free size but they are not meant to be added together. 151 // report their free size but they are not meant to be added together.
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 CHECK_MEMORY_INACCESSIBLE(headerAddress, size); 692 CHECK_MEMORY_INACCESSIBLE(headerAddress, size);
693 freedSize += size; 693 freedSize += size;
694 headerAddress += size; 694 headerAddress += size;
695 continue; 695 continue;
696 } 696 }
697 if (header->isFree()) { 697 if (header->isFree()) {
698 // Zero the memory in the free list header to maintain the 698 // Zero the memory in the free list header to maintain the
699 // invariant that memory on the free list is zero filled. 699 // invariant that memory on the free list is zero filled.
700 // The rest of the memory is already on the free list and is 700 // The rest of the memory is already on the free list and is
701 // therefore already zero filled. 701 // therefore already zero filled.
702 SET_MEMORY_INACCESSIBLE(headerAddress, size < sizeof(FreeListEntry) 702 SET_MEMORY_INACCESSIBLE(
703 ? size 703 headerAddress,
704 : sizeof(FreeListEntry)); 704 size < sizeof(FreeListEntry) ? size : sizeof(FreeListEntry));
705 CHECK_MEMORY_INACCESSIBLE(headerAddress, size); 705 CHECK_MEMORY_INACCESSIBLE(headerAddress, size);
706 headerAddress += size; 706 headerAddress += size;
707 continue; 707 continue;
708 } 708 }
709 ASSERT(header->checkHeader()); 709 ASSERT(header->checkHeader());
710 if (startOfGap != headerAddress) 710 if (startOfGap != headerAddress)
711 addToFreeList(startOfGap, headerAddress - startOfGap); 711 addToFreeList(startOfGap, headerAddress - startOfGap);
712 712
713 headerAddress += size; 713 headerAddress += size;
714 startOfGap = headerAddress; 714 startOfGap = headerAddress;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 bool FreeList::takeSnapshot(const String& dumpBaseName) { 1210 bool FreeList::takeSnapshot(const String& dumpBaseName) {
1211 bool didDumpBucketStats = false; 1211 bool didDumpBucketStats = false;
1212 for (size_t i = 0; i < blinkPageSizeLog2; ++i) { 1212 for (size_t i = 0; i < blinkPageSizeLog2; ++i) {
1213 size_t entryCount = 0; 1213 size_t entryCount = 0;
1214 size_t freeSize = 0; 1214 size_t freeSize = 0;
1215 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next()) { 1215 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next()) {
1216 ++entryCount; 1216 ++entryCount;
1217 freeSize += entry->size(); 1217 freeSize += entry->size();
1218 } 1218 }
1219 1219
1220 String dumpName = 1220 String dumpName = dumpBaseName +
1221 dumpBaseName + String::format("/buckets/bucket_%lu", 1221 String::format("/buckets/bucket_%lu",
1222 static_cast<unsigned long>(1 << i)); 1222 static_cast<unsigned long>(1 << i));
1223 base::trace_event::MemoryAllocatorDump* bucketDump = 1223 base::trace_event::MemoryAllocatorDump* bucketDump =
1224 BlinkGCMemoryDumpProvider::instance() 1224 BlinkGCMemoryDumpProvider::instance()
1225 ->createMemoryAllocatorDumpForCurrentGC(dumpName); 1225 ->createMemoryAllocatorDumpForCurrentGC(dumpName);
1226 bucketDump->AddScalar("free_count", "objects", entryCount); 1226 bucketDump->AddScalar("free_count", "objects", entryCount);
1227 bucketDump->AddScalar("free_size", "bytes", freeSize); 1227 bucketDump->AddScalar("free_size", "bytes", freeSize);
1228 didDumpBucketStats = true; 1228 didDumpBucketStats = true;
1229 } 1229 }
1230 return didDumpBucketStats; 1230 return didDumpBucketStats;
1231 } 1231 }
1232 1232
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 ASSERT(size > 0); 1291 ASSERT(size > 0);
1292 ASSERT(size < blinkPagePayloadSize()); 1292 ASSERT(size < blinkPagePayloadSize());
1293 1293
1294 if (header->isPromptlyFreed()) 1294 if (header->isPromptlyFreed())
1295 pageArena->decreasePromptlyFreedSize(size); 1295 pageArena->decreasePromptlyFreedSize(size);
1296 if (header->isFree()) { 1296 if (header->isFree()) {
1297 // Zero the memory in the free list header to maintain the 1297 // Zero the memory in the free list header to maintain the
1298 // invariant that memory on the free list is zero filled. 1298 // invariant that memory on the free list is zero filled.
1299 // The rest of the memory is already on the free list and is 1299 // The rest of the memory is already on the free list and is
1300 // therefore already zero filled. 1300 // therefore already zero filled.
1301 SET_MEMORY_INACCESSIBLE(headerAddress, size < sizeof(FreeListEntry) 1301 SET_MEMORY_INACCESSIBLE(
1302 ? size 1302 headerAddress,
1303 : sizeof(FreeListEntry)); 1303 size < sizeof(FreeListEntry) ? size : sizeof(FreeListEntry));
1304 CHECK_MEMORY_INACCESSIBLE(headerAddress, size); 1304 CHECK_MEMORY_INACCESSIBLE(headerAddress, size);
1305 headerAddress += size; 1305 headerAddress += size;
1306 continue; 1306 continue;
1307 } 1307 }
1308 if (!header->isMarked()) { 1308 if (!header->isMarked()) {
1309 // This is a fast version of header->payloadSize(). 1309 // This is a fast version of header->payloadSize().
1310 size_t payloadSize = size - sizeof(HeapObjectHeader); 1310 size_t payloadSize = size - sizeof(HeapObjectHeader);
1311 Address payload = header->payload(); 1311 Address payload = header->payload();
1312 // For ASan, unpoison the object before calling the finalizer. The 1312 // For ASan, unpoison the object before calling the finalizer. The
1313 // finalized object will be zero-filled and poison'ed afterwards. 1313 // finalized object will be zero-filled and poison'ed afterwards.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 reinterpret_cast<HeapObjectHeader*>(headerAddress); 1463 reinterpret_cast<HeapObjectHeader*>(headerAddress);
1464 size_t size = header->size(); 1464 size_t size = header->size();
1465 ASSERT(size < blinkPagePayloadSize()); 1465 ASSERT(size < blinkPagePayloadSize());
1466 if (header->isPromptlyFreed()) 1466 if (header->isPromptlyFreed())
1467 arenaForNormalPage()->decreasePromptlyFreedSize(size); 1467 arenaForNormalPage()->decreasePromptlyFreedSize(size);
1468 if (header->isFree()) { 1468 if (header->isFree()) {
1469 // Zero the memory in the free list header to maintain the 1469 // Zero the memory in the free list header to maintain the
1470 // invariant that memory on the free list is zero filled. 1470 // invariant that memory on the free list is zero filled.
1471 // The rest of the memory is already on the free list and is 1471 // The rest of the memory is already on the free list and is
1472 // therefore already zero filled. 1472 // therefore already zero filled.
1473 SET_MEMORY_INACCESSIBLE(headerAddress, size < sizeof(FreeListEntry) 1473 SET_MEMORY_INACCESSIBLE(
1474 ? size 1474 headerAddress,
1475 : sizeof(FreeListEntry)); 1475 size < sizeof(FreeListEntry) ? size : sizeof(FreeListEntry));
1476 CHECK_MEMORY_INACCESSIBLE(headerAddress, size); 1476 CHECK_MEMORY_INACCESSIBLE(headerAddress, size);
1477 headerAddress += size; 1477 headerAddress += size;
1478 continue; 1478 continue;
1479 } 1479 }
1480 if (startOfGap != headerAddress) 1480 if (startOfGap != headerAddress)
1481 normalArena->addToFreeList(startOfGap, headerAddress - startOfGap); 1481 normalArena->addToFreeList(startOfGap, headerAddress - startOfGap);
1482 if (header->isMarked()) 1482 if (header->isMarked())
1483 header->unmark(); 1483 header->unmark();
1484 headerAddress += size; 1484 headerAddress += size;
1485 startOfGap = headerAddress; 1485 startOfGap = headerAddress;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 1814
1815 m_hasEntries = true; 1815 m_hasEntries = true;
1816 size_t index = hash(address); 1816 size_t index = hash(address);
1817 ASSERT(!(index & 1)); 1817 ASSERT(!(index & 1));
1818 Address cachePage = roundToBlinkPageStart(address); 1818 Address cachePage = roundToBlinkPageStart(address);
1819 m_entries[index + 1] = m_entries[index]; 1819 m_entries[index + 1] = m_entries[index];
1820 m_entries[index] = cachePage; 1820 m_entries[index] = cachePage;
1821 } 1821 }
1822 1822
1823 } // namespace blink 1823 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapCompact.cpp ('k') | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698