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

Unified Diff: third_party/WebKit/Source/platform/heap/HeapPage.h

Issue 2786843002: Make HeapObjectHeader::checkHeader private. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/HeapPage.h
diff --git a/third_party/WebKit/Source/platform/heap/HeapPage.h b/third_party/WebKit/Source/platform/heap/HeapPage.h
index 1130f79ce35b3577a87d158f5b4e8317a19b905b..cd6f113e7f5ec1b6528c67c47f523621a4b76484 100644
--- a/third_party/WebKit/Source/platform/heap/HeapPage.h
+++ b/third_party/WebKit/Source/platform/heap/HeapPage.h
@@ -195,26 +195,31 @@ class PLATFORM_EXPORT HeapObjectHeader {
(gcInfoIndex == gcInfoIndexForFreeListHeader ? headerFreedBitMask : 0));
}
- NO_SANITIZE_ADDRESS
- bool isFree() const { return m_encoded & headerFreedBitMask; }
- NO_SANITIZE_ADDRESS
- bool isPromptlyFreed() const {
+ NO_SANITIZE_ADDRESS bool isFree() const {
+ return m_encoded & headerFreedBitMask;
+ }
+
+ NO_SANITIZE_ADDRESS bool isPromptlyFreed() const {
return (m_encoded & headerPromptlyFreedBitMask) ==
headerPromptlyFreedBitMask;
}
- NO_SANITIZE_ADDRESS
- void markPromptlyFreed() { m_encoded |= headerPromptlyFreedBitMask; }
+
+ NO_SANITIZE_ADDRESS void markPromptlyFreed() {
+ m_encoded |= headerPromptlyFreedBitMask;
+ }
+
size_t size() const;
- NO_SANITIZE_ADDRESS
- size_t gcInfoIndex() const {
+ NO_SANITIZE_ADDRESS size_t gcInfoIndex() const {
return (m_encoded & headerGCInfoIndexMask) >> headerGCInfoIndexShift;
}
- NO_SANITIZE_ADDRESS
- void setSize(size_t size) {
+
+ NO_SANITIZE_ADDRESS void setSize(size_t size) {
ASSERT(size < nonLargeObjectPageSizeMax);
+ checkHeader();
m_encoded = static_cast<uint32_t>(size) | (m_encoded & ~headerSizeMask);
}
+
bool isWrapperHeaderMarked() const;
void markWrapperHeader();
void unmarkWrapperHeader();
@@ -226,23 +231,21 @@ class PLATFORM_EXPORT HeapObjectHeader {
size_t payloadSize();
Address payloadEnd();
- // TODO(633030): Make |checkHeader| and |zapMagic| private. This class should
- // manage its integrity on its own, without requiring outside callers to
- // explicitly check.
- void checkHeader() const;
+ void finalize(Address, size_t);
+ static HeapObjectHeader* fromPayload(const void*);
+
+ static const uint32_t zappedMagic = 0xDEAD4321;
+ protected:
#if DCHECK_IS_ON() && CPU(64BIT)
// Zap |m_magic| with a new magic number that means there was once an object
// allocated here, but it was freed because nobody marked it during GC.
void zapMagic();
#endif
- void finalize(Address, size_t);
- static HeapObjectHeader* fromPayload(const void*);
-
- static const uint32_t zappedMagic = 0xDEAD4321;
-
private:
+ void checkHeader() const;
+
#if CPU(64BIT)
// Returns a random value.
//
@@ -254,7 +257,7 @@ class PLATFORM_EXPORT HeapObjectHeader {
// arbitrary infoleak bug (used twice).
uint32_t getMagic() const;
uint32_t m_magic;
-#endif
+#endif // CPU(64BIT)
uint32_t m_encoded;
};
@@ -840,8 +843,8 @@ NO_SANITIZE_ADDRESS inline size_t HeapObjectHeader::size() const {
NO_SANITIZE_ADDRESS inline void HeapObjectHeader::checkHeader() const {
#if CPU(64BIT)
- const bool good = getMagic() == m_magic;
- DCHECK(good);
+ const bool goodMagic = getMagic() == m_magic;
+ CHECK(goodMagic);
haraken 2017/03/30 14:12:46 What's a performance implication for the DCHECK =>
#endif
}
@@ -854,6 +857,7 @@ inline Address HeapObjectHeader::payloadEnd() {
}
NO_SANITIZE_ADDRESS inline size_t HeapObjectHeader::payloadSize() {
+ checkHeader();
size_t size = m_encoded & headerSizeMask;
if (UNLIKELY(size == largeObjectSizeInHeader)) {
ASSERT(pageFromObject(this)->isLargeObjectPage());

Powered by Google App Engine
This is Rietveld 408576698