From 18e578687b025e38731b28c88c9f518c84a0b6a8 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Tue, 29 Sep 2020 11:10:17 -0700 Subject: [PATCH] Clean up allocLongLived in GenGC and MallocGC Summary: Remove allocLongLived APIs from GenGC and MallocGC. Reviewed By: dulinriley Differential Revision: D23833526 fbshipit-source-id: d8422dd92b1a0ab7f1b1e011842c8a629d09d8f3 --- include/hermes/VM/GCBase.h | 7 ------- include/hermes/VM/GenGCNC.h | 12 ++++++------ include/hermes/VM/MallocGC.h | 20 +++----------------- lib/VM/gcs/MallocGC.cpp | 2 -- 4 files changed, 9 insertions(+), 32 deletions(-) diff --git a/include/hermes/VM/GCBase.h b/include/hermes/VM/GCBase.h index 1c243cc6e65..5de70f2ac83 100644 --- a/include/hermes/VM/GCBase.h +++ b/include/hermes/VM/GCBase.h @@ -79,13 +79,6 @@ class Deserializer; /// HasFinalizer hasFinalizer = HasFinalizer::No> /// CallResult alloc(const VTable *vt, uint32_t size); /// -/// Like the above, but if the GC makes a distinction between short- and -/// long-lived objects, allocates an object that is expected to be -/// long-lived. Does not allow specification of fixed-sizeness. -/// -/// template -/// CallResult allocLongLived(const VTable *vt, uint32_t size); -/// /// Allocate a new cell of type \p T and size \p size using the APIs above. /// Instantiate an object of type \p T in the newly allocated cell, using /// \p args as the arguments to its constructor. diff --git a/include/hermes/VM/GenGCNC.h b/include/hermes/VM/GenGCNC.h index 33b0c9d01d2..9cd9dec7c37 100644 --- a/include/hermes/VM/GenGCNC.h +++ b/include/hermes/VM/GenGCNC.h @@ -142,12 +142,6 @@ class GenGC final : public GCBase { debugAllocRandomize(uint32_t sz, HasFinalizer hasFinalizer, bool fixedSize); #endif - /// Like alloc above, but the resulting object is expected to be long-lived. - /// Allocate directly in the old generation (doing a full collection if - /// necessary to create room). - template - inline void *allocLongLived(uint32_t size); - /// Allocate a new cell of the specified size \p size by calling alloc. /// Instantiate an object of type T with constructor arguments \p args in the /// newly allocated cell. @@ -519,6 +513,12 @@ class GenGC final : public GCBase { /// arguments. void *allocSlow(uint32_t sz, bool fixedSize, HasFinalizer hasFinalizer); + /// Like alloc above, but the resulting object is expected to be long-lived. + /// Allocate directly in the old generation (doing a full collection if + /// necessary to create room). + template + inline void *allocLongLived(uint32_t size); + /// The given pointer value is being written at the given loc (required to /// be in the heap). The value is may be null. Execute a write /// barrier. The \p hv argument indicates whether this is being diff --git a/include/hermes/VM/MallocGC.h b/include/hermes/VM/MallocGC.h index 029ebbbd71b..35586c6daa3 100644 --- a/include/hermes/VM/MallocGC.h +++ b/include/hermes/VM/MallocGC.h @@ -170,12 +170,6 @@ class MallocGC final : public GCBase { /// declared. void collectBeforeAlloc(std::string cause, uint32_t size); - /// Same as above, but tries to allocate in a long lived area of the heap. - /// Use this when the object is known to last for a long period of time. - /// NOTE: this does nothing different for MallocGC, but does for GenGC. - template - inline void *allocLongLived(uint32_t size); - /// Allocate a new cell of the specified size \p size by calling alloc. /// Instantiate an object of type T with constructor arguments \p args in the /// newly allocated cell. @@ -370,13 +364,6 @@ inline void *MallocGC::alloc(uint32_t size) { return mem; } -template -inline void *MallocGC::allocLongLived(uint32_t size) { - // Since there is no old generation in this collector, forward to the normal - // allocation. - return alloc(size); -} - inline bool MallocGC::canAllocExternalMemory(uint32_t size) { return size <= maxSize_; } @@ -388,10 +375,9 @@ template < LongLived longLived, class... Args> inline T *MallocGC::makeA(uint32_t size, Args &&... args) { - // TODO: Once all callers are using makeA, remove allocLongLived. - void *mem = longLived == LongLived::Yes - ? allocLongLived(size) - : alloc(size); + // Since there is no old generation in this collector, always forward to the + // normal allocation. + void *mem = alloc(size); return new (mem) T(std::forward(args)...); } diff --git a/lib/VM/gcs/MallocGC.cpp b/lib/VM/gcs/MallocGC.cpp index c986736836d..a3348fa4668 100644 --- a/lib/VM/gcs/MallocGC.cpp +++ b/lib/VM/gcs/MallocGC.cpp @@ -620,8 +620,6 @@ template void *MallocGC::alloc( uint32_t size); template void *MallocGC::alloc( uint32_t size); -template void *MallocGC::allocLongLived(uint32_t size); -template void *MallocGC::allocLongLived(uint32_t size); /// @} } // namespace vm