| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 static bool popAndInvokeGlobalWeakCallback(Visitor*); | 209 static bool popAndInvokeGlobalWeakCallback(Visitor*); |
| 210 | 210 |
| 211 // Register an ephemeron table for fixed-point iteration. | 211 // Register an ephemeron table for fixed-point iteration. |
| 212 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); | 212 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe
meronCallback); |
| 213 #if ENABLE(ASSERT) | 213 #if ENABLE(ASSERT) |
| 214 static bool weakTableRegistered(const void*); | 214 static bool weakTableRegistered(const void*); |
| 215 #endif | 215 #endif |
| 216 | 216 |
| 217 static inline size_t allocationSizeFromSize(size_t size) | 217 static inline size_t allocationSizeFromSize(size_t size) |
| 218 { | 218 { |
| 219 // Check the size before computing the actual allocation size. The |
| 220 // allocation size calculation can overflow for large sizes and the chec
k |
| 221 // therefore has to happen before any calculation on the size. |
| 222 RELEASE_ASSERT(size < maxHeapObjectSize); |
| 223 |
| 219 // Add space for header. | 224 // Add space for header. |
| 220 size_t allocationSize = size + sizeof(HeapObjectHeader); | 225 size_t allocationSize = size + sizeof(HeapObjectHeader); |
| 221 // The allocation size calculation can overflow for large sizes. | |
| 222 RELEASE_ASSERT(allocationSize > size); | |
| 223 // Align size with allocation granularity. | 226 // Align size with allocation granularity. |
| 224 allocationSize = (allocationSize + allocationMask) & ~allocationMask; | 227 allocationSize = (allocationSize + allocationMask) & ~allocationMask; |
| 225 return allocationSize; | 228 return allocationSize; |
| 226 } | 229 } |
| 227 static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, si
ze_t gcInfoIndex, const char* typeName); | 230 static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, si
ze_t gcInfoIndex, const char* typeName); |
| 228 template<typename T> static Address allocate(size_t, bool eagerlySweep = fal
se); | 231 template<typename T> static Address allocate(size_t, bool eagerlySweep = fal
se); |
| 229 template<typename T> static Address reallocate(void* previous, size_t); | 232 template<typename T> static Address reallocate(void* previous, size_t); |
| 230 | 233 |
| 231 static const char* gcReasonString(BlinkGC::GCReason); | 234 static const char* gcReasonString(BlinkGC::GCReason); |
| 232 static void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GC
Reason); | 235 static void collectGarbage(BlinkGC::StackState, BlinkGC::GCType, BlinkGC::GC
Reason); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) | 530 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) |
| 528 { | 531 { |
| 529 T** cell = reinterpret_cast<T**>(object); | 532 T** cell = reinterpret_cast<T**>(object); |
| 530 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 533 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
| 531 *cell = nullptr; | 534 *cell = nullptr; |
| 532 } | 535 } |
| 533 | 536 |
| 534 } // namespace blink | 537 } // namespace blink |
| 535 | 538 |
| 536 #endif // Heap_h | 539 #endif // Heap_h |
| OLD | NEW |