| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // | 236 // |
| 237 // | HeapHeaderObject (4 byte) | object payload (8 * n byte) | padding (4 by
te) | | 237 // | HeapHeaderObject (4 byte) | object payload (8 * n byte) | padding (4 by
te) | |
| 238 // ^4 byte aligned ^8 byte aligned ^4 byte aligned | 238 // ^4 byte aligned ^8 byte aligned ^4 byte aligned |
| 239 // | 239 // |
| 240 // since the former layout aligns both header and payload to 8 byte. | 240 // since the former layout aligns both header and payload to 8 byte. |
| 241 #if !ENABLE(ASSERT) && !ENABLE(GC_PROFILING) && CPU(64BIT) | 241 #if !ENABLE(ASSERT) && !ENABLE(GC_PROFILING) && CPU(64BIT) |
| 242 uint32_t m_padding; | 242 uint32_t m_padding; |
| 243 #endif | 243 #endif |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 inline HeapObjectHeader* HeapObjectHeader::fromPayload(const void* payload) | |
| 247 { | |
| 248 Address addr = reinterpret_cast<Address>(const_cast<void*>(payload)); | |
| 249 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(addr - sizeof
(HeapObjectHeader)); | |
| 250 return header; | |
| 251 } | |
| 252 | |
| 253 class FreeListEntry final : public HeapObjectHeader { | 246 class FreeListEntry final : public HeapObjectHeader { |
| 254 public: | 247 public: |
| 255 NO_SANITIZE_ADDRESS | 248 NO_SANITIZE_ADDRESS |
| 256 explicit FreeListEntry(size_t size) | 249 explicit FreeListEntry(size_t size) |
| 257 : HeapObjectHeader(size, gcInfoIndexForFreeListHeader) | 250 : HeapObjectHeader(size, gcInfoIndexForFreeListHeader) |
| 258 , m_next(nullptr) | 251 , m_next(nullptr) |
| 259 { | 252 { |
| 260 #if ENABLE(ASSERT) && !defined(ADDRESS_SANITIZER) | 253 #if ENABLE(ASSERT) && !defined(ADDRESS_SANITIZER) |
| 261 // Zap free area with asterisks, aka 0x2a2a2a2a. | 254 // Zap free area with asterisks, aka 0x2a2a2a2a. |
| 262 // For ASan don't zap since we keep accounting in the freelist entry. | 255 // For ASan don't zap since we keep accounting in the freelist entry. |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 { | 1175 { |
| 1183 size_t size = m_encoded & headerSizeMask; | 1176 size_t size = m_encoded & headerSizeMask; |
| 1184 if (UNLIKELY(size == largeObjectSizeInHeader)) { | 1177 if (UNLIKELY(size == largeObjectSizeInHeader)) { |
| 1185 ASSERT(pageFromObject(this)->isLargeObjectPage()); | 1178 ASSERT(pageFromObject(this)->isLargeObjectPage()); |
| 1186 return static_cast<LargeObjectPage*>(pageFromObject(this))->payloadSize(
); | 1179 return static_cast<LargeObjectPage*>(pageFromObject(this))->payloadSize(
); |
| 1187 } | 1180 } |
| 1188 ASSERT(!pageFromObject(this)->isLargeObjectPage()); | 1181 ASSERT(!pageFromObject(this)->isLargeObjectPage()); |
| 1189 return size - sizeof(HeapObjectHeader); | 1182 return size - sizeof(HeapObjectHeader); |
| 1190 } | 1183 } |
| 1191 | 1184 |
| 1185 inline HeapObjectHeader* HeapObjectHeader::fromPayload(const void* payload) |
| 1186 { |
| 1187 Address addr = reinterpret_cast<Address>(const_cast<void*>(payload)); |
| 1188 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(addr - sizeof
(HeapObjectHeader)); |
| 1189 header->checkHeader(); |
| 1190 return header; |
| 1191 } |
| 1192 |
| 1192 NO_SANITIZE_ADDRESS inline | 1193 NO_SANITIZE_ADDRESS inline |
| 1193 bool HeapObjectHeader::isMarked() const | 1194 bool HeapObjectHeader::isMarked() const |
| 1194 { | 1195 { |
| 1195 checkHeader(); | 1196 checkHeader(); |
| 1196 return m_encoded & headerMarkBitMask; | 1197 return m_encoded & headerMarkBitMask; |
| 1197 } | 1198 } |
| 1198 | 1199 |
| 1199 NO_SANITIZE_ADDRESS inline | 1200 NO_SANITIZE_ADDRESS inline |
| 1200 void HeapObjectHeader::mark() | 1201 void HeapObjectHeader::mark() |
| 1201 { | 1202 { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 size_t copySize = previousHeader->payloadSize(); | 1294 size_t copySize = previousHeader->payloadSize(); |
| 1294 if (copySize > size) | 1295 if (copySize > size) |
| 1295 copySize = size; | 1296 copySize = size; |
| 1296 memcpy(address, previous, copySize); | 1297 memcpy(address, previous, copySize); |
| 1297 return address; | 1298 return address; |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 } // namespace blink | 1301 } // namespace blink |
| 1301 | 1302 |
| 1302 #endif // Heap_h | 1303 #endif // Heap_h |
| OLD | NEW |