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

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

Issue 2835633002: Add more checks to diagnose MediaQuerySet issue (Closed)
Patch Set: added comment Created 3 years, 8 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 | « third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp ('k') | 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 void Finalize(Address, size_t); 235 void Finalize(Address, size_t);
236 static HeapObjectHeader* FromPayload(const void*); 236 static HeapObjectHeader* FromPayload(const void*);
237 237
238 // Some callers formerly called |fromPayload| only for its side-effect of 238 // Some callers formerly called |fromPayload| only for its side-effect of
239 // calling |checkHeader| (which is now private). This function does that, but 239 // calling |checkHeader| (which is now private). This function does that, but
240 // its explanatory name makes the intention at the call sites easier to 240 // its explanatory name makes the intention at the call sites easier to
241 // understand, and is public. 241 // understand, and is public.
242 static void CheckFromPayload(const void*); 242 static void CheckFromPayload(const void*);
243 243
244 // Returns true if magic number is valid.
245 bool IsValid() const;
246
244 static const uint32_t kZappedMagic = 0xDEAD4321; 247 static const uint32_t kZappedMagic = 0xDEAD4321;
245 248
246 protected: 249 protected:
247 #if DCHECK_IS_ON() && CPU(64BIT) 250 #if DCHECK_IS_ON() && CPU(64BIT)
248 // Zap |m_magic| with a new magic number that means there was once an object 251 // Zap |m_magic| with a new magic number that means there was once an object
249 // allocated here, but it was freed because nobody marked it during GC. 252 // allocated here, but it was freed because nobody marked it during GC.
250 void ZapMagic(); 253 void ZapMagic();
251 #endif 254 #endif
252 255
253 private: 256 private:
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 850
848 NO_SANITIZE_ADDRESS inline size_t HeapObjectHeader::size() const { 851 NO_SANITIZE_ADDRESS inline size_t HeapObjectHeader::size() const {
849 size_t result = encoded_ & kHeaderSizeMask; 852 size_t result = encoded_ & kHeaderSizeMask;
850 // Large objects should not refer to header->size(). The actual size of a 853 // Large objects should not refer to header->size(). The actual size of a
851 // large object is stored in |LargeObjectPage::m_payloadSize|. 854 // large object is stored in |LargeObjectPage::m_payloadSize|.
852 DCHECK(result != kLargeObjectSizeInHeader); 855 DCHECK(result != kLargeObjectSizeInHeader);
853 DCHECK(!PageFromObject(this)->IsLargeObjectPage()); 856 DCHECK(!PageFromObject(this)->IsLargeObjectPage());
854 return result; 857 return result;
855 } 858 }
856 859
860 NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::IsValid() const {
861 #if CPU(64BIT)
862 return GetMagic() == magic_;
863 #else
864 return true;
865 #endif
866 }
867
857 NO_SANITIZE_ADDRESS inline void HeapObjectHeader::CheckHeader() const { 868 NO_SANITIZE_ADDRESS inline void HeapObjectHeader::CheckHeader() const {
858 #if CPU(64BIT) 869 #if CPU(64BIT)
859 const bool good_magic = GetMagic() == magic_; 870 DCHECK(IsValid());
860 DCHECK(good_magic);
861 #endif 871 #endif
862 } 872 }
863 873
864 inline Address HeapObjectHeader::Payload() { 874 inline Address HeapObjectHeader::Payload() {
865 return reinterpret_cast<Address>(this) + sizeof(HeapObjectHeader); 875 return reinterpret_cast<Address>(this) + sizeof(HeapObjectHeader);
866 } 876 }
867 877
868 inline Address HeapObjectHeader::PayloadEnd() { 878 inline Address HeapObjectHeader::PayloadEnd() {
869 return reinterpret_cast<Address>(this) + size(); 879 return reinterpret_cast<Address>(this) + size();
870 } 880 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 return OutOfLineAllocate(allocation_size, gc_info_index); 1012 return OutOfLineAllocate(allocation_size, gc_info_index);
1003 } 1013 }
1004 1014
1005 inline NormalPageArena* NormalPage::ArenaForNormalPage() const { 1015 inline NormalPageArena* NormalPage::ArenaForNormalPage() const {
1006 return static_cast<NormalPageArena*>(Arena()); 1016 return static_cast<NormalPageArena*>(Arena());
1007 } 1017 }
1008 1018
1009 } // namespace blink 1019 } // namespace blink
1010 1020
1011 #endif // HeapPage_h 1021 #endif // HeapPage_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentStyleSheetCollection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698