Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 // | gcInfoIndex (14 bit) | DOM mark bit (1 bit) | size (14 bit) | dead bit (1 b it) | freed bit (1 bit) | mark bit (1 bit) | | 135 // | 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 // | 136 // |
| 137 // - For non-large objects, 14 bit is enough for |size| because the blink | 137 // - For non-large objects, 14 bit is enough for |size| because the blink |
| 138 // page size is 2^17 byte and each object is guaranteed to be aligned with | 138 // page size is 2^17 byte and each object is guaranteed to be aligned with |
| 139 // 2^3 byte. | 139 // 2^3 byte. |
| 140 // - For large objects, |size| is 0. The actual size of a large object is | 140 // - For large objects, |size| is 0. The actual size of a large object is |
| 141 // stored in LargeObjectPage::m_payloadSize. | 141 // stored in LargeObjectPage::m_payloadSize. |
| 142 // - 1 bit used to mark DOM trees for V8. | 142 // - 1 bit used to mark DOM trees for V8. |
| 143 // - 14 bit is enough for gcInfoIndex because there are less than 2^14 types | 143 // - 14 bit is enough for gcInfoIndex because there are less than 2^14 types |
| 144 // in Blink. | 144 // in Blink. |
| 145 const size_t headerDOMMarkBitMask = 1u << 17; | 145 const size_t headerWrapperMarkBitMast = 1u << 17; |
|
Hannes Payer (out of office)
2016/04/19 07:44:33
headerWrapperMarkBitMask
Marcel Hlopko
2016/04/19 12:40:30
Done.
| |
| 146 const size_t headerGCInfoIndexShift = 18; | 146 const size_t headerGCInfoIndexShift = 18; |
| 147 const size_t headerGCInfoIndexMask = (static_cast<size_t>((1 << 14) - 1)) << hea derGCInfoIndexShift; | 147 const size_t headerGCInfoIndexMask = (static_cast<size_t>((1 << 14) - 1)) << hea derGCInfoIndexShift; |
| 148 const size_t headerSizeMask = (static_cast<size_t>((1 << 14) - 1)) << 3; | 148 const size_t headerSizeMask = (static_cast<size_t>((1 << 14) - 1)) << 3; |
| 149 const size_t headerMarkBitMask = 1; | 149 const size_t headerMarkBitMask = 1; |
| 150 const size_t headerFreedBitMask = 2; | 150 const size_t headerFreedBitMask = 2; |
| 151 // The dead bit is used for objects that have gone through a GC marking, but did | 151 // The dead bit is used for objects that have gone through a GC marking, but did |
| 152 // not get swept before a new GC started. In that case we set the dead bit on | 152 // not get swept before a new GC started. In that case we set the dead bit on |
| 153 // objects that were not marked in the previous GC to ensure we are not tracing | 153 // objects that were not marked in the previous GC to ensure we are not tracing |
| 154 // them via a conservatively found pointer. Tracing dead objects could lead to | 154 // them via a conservatively found pointer. Tracing dead objects could lead to |
| 155 // tracing of already finalized objects in another thread's heap which is a | 155 // tracing of already finalized objects in another thread's heap which is a |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 size_t size() const; | 198 size_t size() const; |
| 199 | 199 |
| 200 NO_SANITIZE_ADDRESS | 200 NO_SANITIZE_ADDRESS |
| 201 size_t gcInfoIndex() const { return (m_encoded & headerGCInfoIndexMask) >> h eaderGCInfoIndexShift; } | 201 size_t gcInfoIndex() const { return (m_encoded & headerGCInfoIndexMask) >> h eaderGCInfoIndexShift; } |
| 202 NO_SANITIZE_ADDRESS | 202 NO_SANITIZE_ADDRESS |
| 203 void setSize(size_t size) | 203 void setSize(size_t size) |
| 204 { | 204 { |
| 205 ASSERT(size < nonLargeObjectPageSizeMax); | 205 ASSERT(size < nonLargeObjectPageSizeMax); |
| 206 m_encoded = static_cast<uint32_t>(size) | (m_encoded & ~headerSizeMask); | 206 m_encoded = static_cast<uint32_t>(size) | (m_encoded & ~headerSizeMask); |
| 207 } | 207 } |
| 208 bool isWrapperMarked() const; | |
| 209 void markWrapper(); | |
| 210 void unmarkWrapper(); | |
|
haraken
2016/04/19 04:58:31
isWrapperHeaderMarked
markWrapperHeader
unmarkWrap
Marcel Hlopko
2016/04/19 12:40:30
Done.
Marcel Hlopko
2016/04/19 12:40:30
Done.
| |
| 208 bool isMarked() const; | 211 bool isMarked() const; |
| 209 void mark(); | 212 void mark(); |
| 210 void unmark(); | 213 void unmark(); |
| 211 void markDead(); | 214 void markDead(); |
| 212 bool isDead() const; | 215 bool isDead() const; |
| 213 | 216 |
| 214 Address payload(); | 217 Address payload(); |
| 215 size_t payloadSize(); | 218 size_t payloadSize(); |
| 216 Address payloadEnd(); | 219 Address payloadEnd(); |
| 217 | 220 |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 | 831 |
| 829 inline HeapObjectHeader* HeapObjectHeader::fromPayload(const void* payload) | 832 inline HeapObjectHeader* HeapObjectHeader::fromPayload(const void* payload) |
| 830 { | 833 { |
| 831 Address addr = reinterpret_cast<Address>(const_cast<void*>(payload)); | 834 Address addr = reinterpret_cast<Address>(const_cast<void*>(payload)); |
| 832 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(addr - sizeof (HeapObjectHeader)); | 835 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(addr - sizeof (HeapObjectHeader)); |
| 833 ASSERT(header->checkHeader()); | 836 ASSERT(header->checkHeader()); |
| 834 return header; | 837 return header; |
| 835 } | 838 } |
| 836 | 839 |
| 837 NO_SANITIZE_ADDRESS inline | 840 NO_SANITIZE_ADDRESS inline |
| 841 bool HeapObjectHeader::isWrapperMarked() const | |
| 842 { | |
| 843 ASSERT(checkHeader()); | |
| 844 return m_encoded & headerWrapperMarkBitMast; | |
| 845 } | |
| 846 | |
| 847 NO_SANITIZE_ADDRESS inline | |
| 848 void HeapObjectHeader::markWrapper() | |
| 849 { | |
| 850 ASSERT(checkHeader()); | |
| 851 ASSERT(!isWrapperMarked()); | |
| 852 m_encoded |= headerWrapperMarkBitMast; | |
| 853 } | |
| 854 | |
| 855 NO_SANITIZE_ADDRESS inline | |
| 856 void HeapObjectHeader::unmarkWrapper() | |
| 857 { | |
| 858 ASSERT(checkHeader()); | |
| 859 ASSERT(isWrapperMarked()); | |
| 860 m_encoded &= ~headerWrapperMarkBitMast; | |
| 861 } | |
| 862 | |
| 863 NO_SANITIZE_ADDRESS inline | |
| 838 bool HeapObjectHeader::isMarked() const | 864 bool HeapObjectHeader::isMarked() const |
| 839 { | 865 { |
| 840 ASSERT(checkHeader()); | 866 ASSERT(checkHeader()); |
| 841 return m_encoded & headerMarkBitMask; | 867 return m_encoded & headerMarkBitMask; |
| 842 } | 868 } |
| 843 | 869 |
| 844 NO_SANITIZE_ADDRESS inline | 870 NO_SANITIZE_ADDRESS inline |
| 845 void HeapObjectHeader::mark() | 871 void HeapObjectHeader::mark() |
| 846 { | 872 { |
| 847 ASSERT(checkHeader()); | 873 ASSERT(checkHeader()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 886 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ; | 912 SET_MEMORY_ACCESSIBLE(result, allocationSize - sizeof(HeapObjectHeader)) ; |
| 887 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); | 913 ASSERT(findPageFromAddress(headerAddress + allocationSize - 1)); |
| 888 return result; | 914 return result; |
| 889 } | 915 } |
| 890 return outOfLineAllocate(allocationSize, gcInfoIndex); | 916 return outOfLineAllocate(allocationSize, gcInfoIndex); |
| 891 } | 917 } |
| 892 | 918 |
| 893 } // namespace blink | 919 } // namespace blink |
| 894 | 920 |
| 895 #endif // HeapPage_h | 921 #endif // HeapPage_h |
| OLD | NEW |