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

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

Issue 1700723002: Tidy heap snapshotting implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: zero initialize Created 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapPage.cpp » ('j') | 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 #else 122 #else
123 #define USE_4BYTE_HEADER_PADDING 0 123 #define USE_4BYTE_HEADER_PADDING 0
124 #endif 124 #endif
125 125
126 class CallbackStack; 126 class CallbackStack;
127 class FreePagePool; 127 class FreePagePool;
128 class NormalPageHeap; 128 class NormalPageHeap;
129 class OrphanedPagePool; 129 class OrphanedPagePool;
130 class PageMemory; 130 class PageMemory;
131 class PageMemoryRegion; 131 class PageMemoryRegion;
132 class WebProcessMemoryDump; 132 class WebMemoryAllocatorDump;
133 133
134 // HeapObjectHeader is 4 byte (32 bit) that has the following layout: 134 // HeapObjectHeader is 4 byte (32 bit) that has the following layout:
135 // 135 //
136 // | gcInfoIndex (14 bit) | DOM mark bit (1 bit) | size (14 bit) | dead bit (1 b it) | freed bit (1 bit) | mark bit (1 bit) | 136 // | gcInfoIndex (14 bit) | DOM mark bit (1 bit) | size (14 bit) | dead bit (1 b it) | freed bit (1 bit) | mark bit (1 bit) |
137 // 137 //
138 // - For non-large objects, 14 bit is enough for |size| because the blink 138 // - For non-large objects, 14 bit is enough for |size| because the blink
139 // page size is 2^17 byte and each object is guaranteed to be aligned with 139 // page size is 2^17 byte and each object is guaranteed to be aligned with
140 // 2^3 byte. 140 // 2^3 byte.
141 // - For large objects, |size| is 0. The actual size of a large object is 141 // - For large objects, |size| is 0. The actual size of a large object is
142 // stored in LargeObjectPage::m_payloadSize. 142 // stored in LargeObjectPage::m_payloadSize.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // heap page. If so, find the start of that object and mark it 385 // heap page. If so, find the start of that object and mark it
386 // using the given Visitor. Otherwise do nothing. The pointer must 386 // using the given Visitor. Otherwise do nothing. The pointer must
387 // be within the same aligned blinkPageSize as the this-pointer. 387 // be within the same aligned blinkPageSize as the this-pointer.
388 // 388 //
389 // This is used during conservative stack scanning to 389 // This is used during conservative stack scanning to
390 // conservatively mark all objects that could be referenced from 390 // conservatively mark all objects that could be referenced from
391 // the stack. 391 // the stack.
392 virtual void checkAndMarkPointer(Visitor*, Address) = 0; 392 virtual void checkAndMarkPointer(Visitor*, Address) = 0;
393 virtual void markOrphaned(); 393 virtual void markOrphaned();
394 394
395 virtual void takeSnapshot(String dumpBaseName, size_t pageIndex, ThreadState ::GCSnapshotInfo&, size_t* outFreeSize, size_t* outFreeCount) = 0; 395 class HeapSnapshotInfo {
396 STACK_ALLOCATED();
397 public:
398 size_t freeCount = 0;
399 size_t freeSize = 0;
400 };
401
402 virtual void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotIn fo&, HeapSnapshotInfo&) = 0;
396 #if ENABLE(ASSERT) 403 #if ENABLE(ASSERT)
397 virtual bool contains(Address) = 0; 404 virtual bool contains(Address) = 0;
398 #endif 405 #endif
399 virtual size_t size() = 0; 406 virtual size_t size() = 0;
400 virtual bool isLargeObjectPage() { return false; } 407 virtual bool isLargeObjectPage() { return false; }
401 408
402 Address address() { return reinterpret_cast<Address>(this); } 409 Address address() { return reinterpret_cast<Address>(this); }
403 PageMemory* storage() const { return m_storage; } 410 PageMemory* storage() const { return m_storage; }
404 BaseHeap* heap() const { return m_heap; } 411 BaseHeap* heap() const { return m_heap; }
405 bool orphaned() { return !m_heap; } 412 bool orphaned() { return !m_heap; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 void sweep() override; 468 void sweep() override;
462 void makeConsistentForGC() override; 469 void makeConsistentForGC() override;
463 void makeConsistentForMutator() override; 470 void makeConsistentForMutator() override;
464 void invalidateObjectStartBitmap() override { m_objectStartBitMapComputed = false; } 471 void invalidateObjectStartBitmap() override { m_objectStartBitMapComputed = false; }
465 #if defined(ADDRESS_SANITIZER) 472 #if defined(ADDRESS_SANITIZER)
466 void poisonObjects(BlinkGC::ObjectsToPoison, BlinkGC::Poisoning) override; 473 void poisonObjects(BlinkGC::ObjectsToPoison, BlinkGC::Poisoning) override;
467 #endif 474 #endif
468 void checkAndMarkPointer(Visitor*, Address) override; 475 void checkAndMarkPointer(Visitor*, Address) override;
469 void markOrphaned() override; 476 void markOrphaned() override;
470 477
471 void takeSnapshot(String dumpBaseName, size_t pageIndex, ThreadState::GCSnap shotInfo&, size_t* outFreeSize, size_t* outFreeCount) override; 478 void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotInfo&, Hea pSnapshotInfo&) override;
472 #if ENABLE(ASSERT) 479 #if ENABLE(ASSERT)
473 // Returns true for the whole blinkPageSize page that the page is on, even 480 // Returns true for the whole blinkPageSize page that the page is on, even
474 // for the header, and the unmapped guard page at the start. That ensures 481 // for the header, and the unmapped guard page at the start. That ensures
475 // the result can be used to populate the negative page cache. 482 // the result can be used to populate the negative page cache.
476 bool contains(Address) override; 483 bool contains(Address) override;
477 #endif 484 #endif
478 size_t size() override { return blinkPageSize; } 485 size_t size() override { return blinkPageSize; }
479 static size_t pageHeaderSize() 486 static size_t pageHeaderSize()
480 { 487 {
481 // Compute the amount of padding we have to add to a header to make 488 // Compute the amount of padding we have to add to a header to make
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 void sweep() override; 525 void sweep() override;
519 void makeConsistentForGC() override; 526 void makeConsistentForGC() override;
520 void makeConsistentForMutator() override; 527 void makeConsistentForMutator() override;
521 void invalidateObjectStartBitmap() override { } 528 void invalidateObjectStartBitmap() override { }
522 #if defined(ADDRESS_SANITIZER) 529 #if defined(ADDRESS_SANITIZER)
523 void poisonObjects(BlinkGC::ObjectsToPoison, BlinkGC::Poisoning) override; 530 void poisonObjects(BlinkGC::ObjectsToPoison, BlinkGC::Poisoning) override;
524 #endif 531 #endif
525 void checkAndMarkPointer(Visitor*, Address) override; 532 void checkAndMarkPointer(Visitor*, Address) override;
526 void markOrphaned() override; 533 void markOrphaned() override;
527 534
528 void takeSnapshot(String dumpBaseName, size_t pageIndex, ThreadState::GCSnap shotInfo&, size_t* outFreeSize, size_t* outFreeCount) override; 535 void takeSnapshot(WebMemoryAllocatorDump*, ThreadState::GCSnapshotInfo&, Hea pSnapshotInfo&) override;
529 #if ENABLE(ASSERT) 536 #if ENABLE(ASSERT)
530 // Returns true for any address that is on one of the pages that this 537 // Returns true for any address that is on one of the pages that this
531 // large object uses. That ensures that we can use a negative result to 538 // large object uses. That ensures that we can use a negative result to
532 // populate the negative page cache. 539 // populate the negative page cache.
533 bool contains(Address) override; 540 bool contains(Address) override;
534 #endif 541 #endif
535 virtual size_t size() 542 virtual size_t size()
536 { 543 {
537 return pageHeaderSize() + sizeof(HeapObjectHeader) + m_payloadSize; 544 return pageHeaderSize() + sizeof(HeapObjectHeader) + m_payloadSize;
538 } 545 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ; 886 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ;
880 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); 887 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1));
881 return result; 888 return result;
882 } 889 }
883 return outOfLineAllocate(allocationSize, gcInfoIndex); 890 return outOfLineAllocate(allocationSize, gcInfoIndex);
884 } 891 }
885 892
886 } // namespace blink 893 } // namespace blink
887 894
888 #endif // HeapPage_h 895 #endif // HeapPage_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapPage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698