[K/N] custom-alloc: handle finalizers
This commit adds finalizers to the custom allocator. Compared to the existing solution: * The finalizer queue is replaced by an AtomicStack<ExtraObjectData>. * All objects with finalizers get meta objects attached. This was not previously the case for CleanerImpl, but is now needed to link objects together in the finalization queue. * The finalizer queue is built during SweepExtraObjects, instead of during regular sweeping. * Cleaners are executed by the finalizer thread, and no longer by a separate worker thread. Co-authored-by: Troels Lund <troels@google.com> Merge-request: KOTLIN-MR-592 Merged-by: Alexander Shabalin <alexander.shabalin@jetbrains.com>
This commit is contained in:
committed by
Space
parent
5bd405856f
commit
7854b01473
@@ -86,8 +86,10 @@ void ObjHeader::destroyMetaObject(ObjHeader* object) {
|
||||
RuntimeAssert(object->has_meta_object(), "Object must have a meta object set");
|
||||
auto &extraObject = *mm::ExtraObjectData::Get(object);
|
||||
extraObject.Uninstall();
|
||||
#ifndef CUSTOM_ALLOCATOR
|
||||
auto *threadData = mm::ThreadRegistry::Instance().CurrentThreadData();
|
||||
mm::ExtraObjectDataFactory::Instance().DestroyExtraObjectData(threadData, extraObject);
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool isPermanentOrFrozen(const ObjHeader* obj) {
|
||||
|
||||
Reference in New Issue
Block a user