Skip to content

Commit

Permalink
Clean up allocLongLived in GenGC and MallocGC
Browse files Browse the repository at this point in the history
Summary: Remove allocLongLived APIs from GenGC and MallocGC.

Reviewed By: dulinriley

Differential Revision: D23833526

fbshipit-source-id: d8422dd92b1a0ab7f1b1e011842c8a629d09d8f3
  • Loading branch information
neildhar authored and facebook-github-bot committed Sep 29, 2020
1 parent c62e8e0 commit 18e5786
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 32 deletions.
7 changes: 0 additions & 7 deletions include/hermes/VM/GCBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ class Deserializer;
/// HasFinalizer hasFinalizer = HasFinalizer::No>
/// CallResult<GCCell *> 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 <HasFinalizer hasFinalizer = HasFinalizer::No>
/// CallResult<GCCell *> 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.
Expand Down
12 changes: 6 additions & 6 deletions include/hermes/VM/GenGCNC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <HasFinalizer hasFinalizer = HasFinalizer::No>
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.
Expand Down Expand Up @@ -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 <HasFinalizer hasFinalizer = HasFinalizer::No>
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
Expand Down
20 changes: 3 additions & 17 deletions include/hermes/VM/MallocGC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <HasFinalizer hasFinalizer = HasFinalizer::No>
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.
Expand Down Expand Up @@ -370,13 +364,6 @@ inline void *MallocGC::alloc(uint32_t size) {
return mem;
}

template <HasFinalizer hasFinalizer>
inline void *MallocGC::allocLongLived(uint32_t size) {
// Since there is no old generation in this collector, forward to the normal
// allocation.
return alloc<true, hasFinalizer>(size);
}

inline bool MallocGC::canAllocExternalMemory(uint32_t size) {
return size <= maxSize_;
}
Expand All @@ -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<hasFinalizer>(size)
: alloc<fixedSize, hasFinalizer>(size);
// Since there is no old generation in this collector, always forward to the
// normal allocation.
void *mem = alloc<fixedSize, hasFinalizer>(size);
return new (mem) T(std::forward<Args>(args)...);
}

Expand Down
2 changes: 0 additions & 2 deletions lib/VM/gcs/MallocGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,6 @@ template void *MallocGC::alloc</*FixedSize*/ true, HasFinalizer::No>(
uint32_t size);
template void *MallocGC::alloc</*FixedSize*/ false, HasFinalizer::No>(
uint32_t size);
template void *MallocGC::allocLongLived<HasFinalizer::Yes>(uint32_t size);
template void *MallocGC::allocLongLived<HasFinalizer::No>(uint32_t size);
/// @}

} // namespace vm
Expand Down

0 comments on commit 18e5786

Please sign in to comment.