void ram_diag()
{
    AJ_Printf("SRAM usage (stack, heap, static): %d, %d, %d\n",
              stack_used(),
              heap_used(),
              static_used());
}
Esempio n. 2
0
File: gc.c Progetto: ozra/ponyc
void gc_markobject(pony_actor_t* current, heap_t* heap, gc_t* gc,
                   void* p, pony_trace_fn f)
{
    chunk_t* chunk = (chunk_t*)pagemap_get(p);

    // don't gc memory that wasn't pony_allocated
    if(chunk == NULL)
        return;

    pony_actor_t* actor = heap_owner(chunk);
    size_t objsize = heap_base(chunk, &p);

    if(actor == current)
    {
        if(f != NULL)
        {
            // mark in our heap and recurse if it wasn't already marked
            if(!heap_mark(chunk, p))
            {
                stack = gcstack_push(stack, p);
                stack = gcstack_push(stack, f);
            }
        } else {
            // no recurse function, so do a shallow mark. if the same address is
            // later marked with a recurse function, it will recurse.
            heap_mark_shallow(chunk, p);
        }
    } else {
        // mark the owner
        actorref_t* aref = actormap_getactor(&gc->foreign, actor);

        // we've reached this by tracing a tag through a union
        if(aref == NULL)
            return;

        // get the object
        object_t* obj = actorref_getobject(aref, p);

        // we've reached this by tracing a tag through a union
        if(obj == NULL)
            return;

        actorref_mark(aref, gc->mark);

        if(!object_marked(obj, gc->mark))
        {
            // add to heap used size
            heap_used(heap, objsize);

            // mark and recurse
            object_mark(obj, gc->mark);

            if(f != NULL)
            {
                stack = gcstack_push(stack, p);
                stack = gcstack_push(stack, f);
            }
        }
    }
}
Esempio n. 3
0
File: gc.c Progetto: ozra/ponyc
void gc_createactor(heap_t* heap, gc_t* gc, pony_actor_t* actor)
{
    actorref_t* aref = actormap_getorput(&gc->foreign, actor, gc->mark);
    actorref_inc_more(aref);
    gc->delta = deltamap_update(gc->delta,
                                actorref_actor(aref), actorref_rc(aref));
    heap_used(heap, GC_ACTOR_HEAP_EQUIV);
}
Esempio n. 4
0
File: gc.c Progetto: ozra/ponyc
void gc_markactor(pony_actor_t* current, heap_t* heap, gc_t* gc,
                  pony_actor_t* actor)
{
    if(actor == current)
        return;

    actorref_t* aref = actormap_getactor(&gc->foreign, actor);

    // we've reached this by tracing a tag through a union
    if(aref == NULL)
        return;

    if(actorref_marked(aref, gc->mark))
        return;

    actorref_mark(aref, gc->mark);
    heap_used(heap, GC_ACTOR_HEAP_EQUIV);
}
Esempio n. 5
0
File: gc.c Progetto: ozra/ponyc
void gc_recvactor(pony_actor_t* current, heap_t* heap, gc_t* gc,
                  pony_actor_t* actor)
{
    if(actor == current)
    {
        current_actor_dec(gc);
    } else {
        actorref_t* aref = actormap_getorput(&gc->foreign, actor, gc->mark);

        if(!actorref_marked(aref, gc->mark))
        {
            actorref_inc(aref);
            actorref_mark(aref, gc->mark);
            gc->delta = deltamap_update(gc->delta,
                                        actorref_actor(aref), actorref_rc(aref));
            heap_used(heap, GC_ACTOR_HEAP_EQUIV);
        }
    }
}
Esempio n. 6
0
File: gc.c Progetto: ozra/ponyc
void gc_recvobject(pony_actor_t* current, heap_t* heap, gc_t* gc,
                   void* p, pony_trace_fn f)
{
    chunk_t* chunk = (chunk_t*)pagemap_get(p);

    // don't gc memory that wasn't pony_allocated
    if(chunk == NULL)
        return;

    pony_actor_t* actor = heap_owner(chunk);
    size_t objsize = heap_base(chunk, &p);

    if(actor == current)
    {
        current_actor_dec(gc);

        // get the object
        object_t* obj = objectmap_getobject(&gc->local, p);
        assert(obj != NULL);

        if(!object_marked(obj, gc->mark))
        {
            // dec, mark and recurse
            object_dec(obj);
            object_mark(obj, gc->mark);

            if(f != NULL)
            {
                stack = gcstack_push(stack, p);
                stack = gcstack_push(stack, f);
            }
        }
    } else {
        // get the actor
        actorref_t* aref = actormap_getorput(&gc->foreign, actor, gc->mark);

        if(!actorref_marked(aref, gc->mark))
        {
            // inc and mark
            actorref_inc(aref);
            actorref_mark(aref, gc->mark);
            gc->delta = deltamap_update(gc->delta,
                                        actorref_actor(aref), actorref_rc(aref));
        }

        // get the object
        object_t* obj = actorref_getorput(aref, p, gc->mark);

        if(!object_marked(obj, gc->mark))
        {
            // if this is our first reference, add to our heap used size
            if(object_rc(obj) == 0)
                heap_used(heap, objsize);

            // inc, mark and recurse
            object_inc(obj);
            object_mark(obj, gc->mark);

            if(f != NULL)
            {
                stack = gcstack_push(stack, p);
                stack = gcstack_push(stack, f);
            }
        }
    }
}