| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 372                                     MovingObjectCallback, | 372                                     MovingObjectCallback, | 
| 373                                     void* callback_data); | 373                                     void* callback_data); | 
| 374 | 374 | 
| 375   BlinkGC::GCReason LastGCReason() { return last_gc_reason_; } | 375   BlinkGC::GCReason LastGCReason() { return last_gc_reason_; } | 
| 376   RegionTree* GetRegionTree() { return region_tree_.get(); } | 376   RegionTree* GetRegionTree() { return region_tree_.get(); } | 
| 377 | 377 | 
| 378   static inline size_t AllocationSizeFromSize(size_t size) { | 378   static inline size_t AllocationSizeFromSize(size_t size) { | 
| 379     // Add space for header. | 379     // Add space for header. | 
| 380     size_t allocation_size = size + sizeof(HeapObjectHeader); | 380     size_t allocation_size = size + sizeof(HeapObjectHeader); | 
| 381     // The allocation size calculation can overflow for large sizes. | 381     // The allocation size calculation can overflow for large sizes. | 
| 382     RELEASE_ASSERT(allocation_size > size); | 382     CHECK_GT(allocation_size, size); | 
| 383     // Align size with allocation granularity. | 383     // Align size with allocation granularity. | 
| 384     allocation_size = (allocation_size + kAllocationMask) & ~kAllocationMask; | 384     allocation_size = (allocation_size + kAllocationMask) & ~kAllocationMask; | 
| 385     return allocation_size; | 385     return allocation_size; | 
| 386   } | 386   } | 
| 387   static Address AllocateOnArenaIndex(ThreadState*, | 387   static Address AllocateOnArenaIndex(ThreadState*, | 
| 388                                       size_t, | 388                                       size_t, | 
| 389                                       int arena_index, | 389                                       int arena_index, | 
| 390                                       size_t gc_info_index, | 390                                       size_t gc_info_index, | 
| 391                                       const char* type_name); | 391                                       const char* type_name); | 
| 392   template <typename T> | 392   template <typename T> | 
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 486   WTF_MAKE_NONCOPYABLE(GarbageCollected); | 486   WTF_MAKE_NONCOPYABLE(GarbageCollected); | 
| 487 | 487 | 
| 488   // For now direct allocation of arrays on the heap is not allowed. | 488   // For now direct allocation of arrays on the heap is not allowed. | 
| 489   void* operator new[](size_t size); | 489   void* operator new[](size_t size); | 
| 490 | 490 | 
| 491 #if OS(WIN) && COMPILER(MSVC) | 491 #if OS(WIN) && COMPILER(MSVC) | 
| 492   // Due to some quirkiness in the MSVC compiler we have to provide | 492   // Due to some quirkiness in the MSVC compiler we have to provide | 
| 493   // the delete[] operator in the GarbageCollected subclasses as it | 493   // the delete[] operator in the GarbageCollected subclasses as it | 
| 494   // is called when a class is exported in a DLL. | 494   // is called when a class is exported in a DLL. | 
| 495  protected: | 495  protected: | 
| 496   void operator delete[](void* p) { ASSERT_NOT_REACHED(); } | 496   void operator delete[](void* p) { NOTREACHED(); } | 
| 497 #else | 497 #else | 
| 498   void operator delete[](void* p); | 498   void operator delete[](void* p); | 
| 499 #endif | 499 #endif | 
| 500 | 500 | 
| 501  public: | 501  public: | 
| 502   using GarbageCollectedType = T; | 502   using GarbageCollectedType = T; | 
| 503 | 503 | 
| 504   void* operator new(size_t size) { | 504   void* operator new(size_t size) { | 
| 505     return AllocateObject(size, IsEagerlyFinalizedType<T>::value); | 505     return AllocateObject(size, IsEagerlyFinalizedType<T>::value); | 
| 506   } | 506   } | 
| 507 | 507 | 
| 508   static void* AllocateObject(size_t size, bool eagerly_sweep) { | 508   static void* AllocateObject(size_t size, bool eagerly_sweep) { | 
| 509     return ThreadHeap::Allocate<T>(size, eagerly_sweep); | 509     return ThreadHeap::Allocate<T>(size, eagerly_sweep); | 
| 510   } | 510   } | 
| 511 | 511 | 
| 512   void operator delete(void* p) { ASSERT_NOT_REACHED(); } | 512   void operator delete(void* p) { NOTREACHED(); } | 
| 513 | 513 | 
| 514  protected: | 514  protected: | 
| 515   GarbageCollected() {} | 515   GarbageCollected() {} | 
| 516 }; | 516 }; | 
| 517 | 517 | 
| 518 // Assigning class types to their arenas. | 518 // Assigning class types to their arenas. | 
| 519 // | 519 // | 
| 520 // We use sized arenas for most 'normal' objects to improve memory locality. | 520 // We use sized arenas for most 'normal' objects to improve memory locality. | 
| 521 // It seems that the same type of objects are likely to be accessed together, | 521 // It seems that the same type of objects are likely to be accessed together, | 
| 522 // which means that we want to group objects by type. That's one reason | 522 // which means that we want to group objects by type. That's one reason | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 666   T** cell = reinterpret_cast<T**>(object); | 666   T** cell = reinterpret_cast<T**>(object); | 
| 667   if (*cell && !ObjectAliveTrait<T>::IsHeapObjectAlive(*cell)) | 667   if (*cell && !ObjectAliveTrait<T>::IsHeapObjectAlive(*cell)) | 
| 668     *cell = nullptr; | 668     *cell = nullptr; | 
| 669 } | 669 } | 
| 670 | 670 | 
| 671 }  // namespace blink | 671 }  // namespace blink | 
| 672 | 672 | 
| 673 #include "platform/heap/VisitorImpl.h" | 673 #include "platform/heap/VisitorImpl.h" | 
| 674 | 674 | 
| 675 #endif  // Heap_h | 675 #endif  // Heap_h | 
| OLD | NEW | 
|---|