[K/N] Handle permanent objects in new MM MemorySharedRefs ^KT-56233

Do not create a foreign ref to the permanent objects. There's no need to
do it, and, moreover, this ref would have leaked.
This commit is contained in:
Alexander Shabalin
2023-03-31 16:55:29 +02:00
committed by Space Team
parent 1f1b26f2a5
commit 8a8aeed998
4 changed files with 35 additions and 4 deletions
@@ -46,6 +46,7 @@ static_assert(std::is_trivially_destructible_v<KRefSharedHolder>, "KRefSharedHol
class BackRefFromAssociatedObject {
public:
void initForPermanentObject(ObjHeader* obj);
void initAndAddRef(ObjHeader* obj);
// Error if refCount is zero and it's called from the wrong worker with non-frozen obj_.
@@ -65,6 +66,8 @@ class BackRefFromAssociatedObject {
template <ErrorPolicy errorPolicy>
ObjHeader* ref() const;
ObjHeader* refPermanent() const;
private:
ObjHeader* obj_; // May be null before [initAndAddRef] or after [detach].
ForeignRefContext context_;