| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void registerWeakTable(void* containerObject, EphemeronCallback, EphemeronCa
llback); | 329 void registerWeakTable(void* containerObject, EphemeronCallback, EphemeronCa
llback); |
| 330 #if ENABLE(ASSERT) | 330 #if ENABLE(ASSERT) |
| 331 bool weakTableRegistered(const void*); | 331 bool weakTableRegistered(const void*); |
| 332 #endif | 332 #endif |
| 333 | 333 |
| 334 BlinkGC::GCReason lastGCReason() { return m_lastGCReason; } | 334 BlinkGC::GCReason lastGCReason() { return m_lastGCReason; } |
| 335 RegionTree* getRegionTree() { return m_regionTree.get(); } | 335 RegionTree* getRegionTree() { return m_regionTree.get(); } |
| 336 | 336 |
| 337 static inline size_t allocationSizeFromSize(size_t size) | 337 static inline size_t allocationSizeFromSize(size_t size) |
| 338 { | 338 { |
| 339 // Check the size before computing the actual allocation size. The | |
| 340 // allocation size calculation can overflow for large sizes and the chec
k | |
| 341 // therefore has to happen before any calculation on the size. | |
| 342 RELEASE_ASSERT(size < maxHeapObjectSize); | |
| 343 | |
| 344 // Add space for header. | 339 // Add space for header. |
| 345 size_t allocationSize = size + sizeof(HeapObjectHeader); | 340 size_t allocationSize = size + sizeof(HeapObjectHeader); |
| 341 // The allocation size calculation can overflow for large sizes. |
| 342 RELEASE_ASSERT(allocationSize > size); |
| 346 // Align size with allocation granularity. | 343 // Align size with allocation granularity. |
| 347 allocationSize = (allocationSize + allocationMask) & ~allocationMask; | 344 allocationSize = (allocationSize + allocationMask) & ~allocationMask; |
| 348 return allocationSize; | 345 return allocationSize; |
| 349 } | 346 } |
| 350 static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, si
ze_t gcInfoIndex, const char* typeName); | 347 static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, si
ze_t gcInfoIndex, const char* typeName); |
| 351 template<typename T> static Address allocate(size_t, bool eagerlySweep = fal
se); | 348 template<typename T> static Address allocate(size_t, bool eagerlySweep = fal
se); |
| 352 template<typename T> static Address reallocate(void* previous, size_t); | 349 template<typename T> static Address reallocate(void* previous, size_t); |
| 353 | 350 |
| 354 static const char* gcReasonString(BlinkGC::GCReason); | 351 static const char* gcReasonString(BlinkGC::GCReason); |
| 355 static void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GC
Reason); | 352 static void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GC
Reason); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) | 619 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) |
| 623 { | 620 { |
| 624 T** cell = reinterpret_cast<T**>(object); | 621 T** cell = reinterpret_cast<T**>(object); |
| 625 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 622 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
| 626 *cell = nullptr; | 623 *cell = nullptr; |
| 627 } | 624 } |
| 628 | 625 |
| 629 } // namespace blink | 626 } // namespace blink |
| 630 | 627 |
| 631 #endif // Heap_h | 628 #endif // Heap_h |
| OLD | NEW |