Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly account for foreign objects in GC #1842

Merged
merged 1 commit into from
Apr 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/libponyrt/gc/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ static void mark_remote_actor(pony_ctx_t* ctx, gc_t* gc, actorref_t* aref)
if(aref->mark == gc->mark)
return;

// Increase apparent used memory to provoke GC.
ponyint_heap_used(ponyint_actor_heap(ctx->current), GC_ACTOR_HEAP_EQUIV);

aref->mark = gc->mark;

if(aref->rc == 0)
Expand Down Expand Up @@ -335,7 +338,7 @@ static void recv_remote_object(pony_ctx_t* ctx, pony_actor_t* actor,
}

static void mark_remote_object(pony_ctx_t* ctx, pony_actor_t* actor,
void* p, pony_type_t* t, int mutability)
void* p, pony_type_t* t, int mutability, chunk_t* chunk)
{
gc_t* gc = ponyint_actor_gc(ctx->current);
actorref_t* aref = ponyint_actormap_getorput(&gc->foreign, actor, gc->mark);
Expand All @@ -344,6 +347,15 @@ static void mark_remote_object(pony_ctx_t* ctx, pony_actor_t* actor,
if(obj->mark == gc->mark)
return;

// Increase apparent used memory to provoke GC.
ponyint_heap_used(ponyint_actor_heap(ctx->current),
ponyint_heap_size(chunk));

// Increase apparent used memory further if the object is immutable, to
// account for memory that is reachable but not traced by this actor.
if(mutability == PONY_TRACE_IMMUTABLE)
ponyint_heap_used(ponyint_actor_heap(ctx->current), GC_IMMUT_HEAP_EQUIV);

// Implicitly mark the owner.
mark_remote_actor(ctx, gc, aref);

Expand Down Expand Up @@ -465,7 +477,7 @@ void ponyint_gc_markobject(pony_ctx_t* ctx, void* p, pony_type_t* t,
if(actor == ctx->current)
mark_local_object(ctx, chunk, p, t, mutability);
else
mark_remote_object(ctx, actor, p, t, mutability);
mark_remote_object(ctx, actor, p, t, mutability, chunk);
}

void ponyint_gc_acquireobject(pony_ctx_t* ctx, void* p, pony_type_t* t,
Expand Down