Ejemplo n.º 1
0
/* Runs the mark-sweep garbage collector */
PmReturn_t
heap_gcRun(void)
{
    PmReturn_t retval;

    C_DEBUG_PRINT(VERBOSITY_LOW, "heap_gcRun()\n");

    /*
     * Prevent the GC from running twice during one session of native code.
     * Corruption can occur from collecting objects that were allocated
     * during the native code session and are not yet reachable from the
     * roots list.  Running the GC once is acceptable, a special case was
     * created in the allocator to handle that situation.
     * See #104 for greater detail.
     */
    if (gVmGlobal.nativeframe.nf_active)
    {
        if (++gVmGlobal.nativeframe.nf_gcCount >= 2)
        {
            /*PM_RAISE(retval, PM_RET_EX_MEM); TODO: change back to error here rather than later?*/
            retval = PM_RET_OK;
            return retval;
        }
    }

    retval = heap_gcMarkRoots();
    PM_RETURN_IF_ERROR(retval);
    retval = heap_gcSweep();

    return retval;
}
Ejemplo n.º 2
0
/* Runs the mark-sweep garbage collector */
PmReturn_t
heap_gcRun(void)
{
    PmReturn_t retval;

    /* #239: Fix GC when 2+ unlinked allocs occur */
    /* This assertion fails when there are too many objects on the temporary
     * root stack and a GC occurs; consider increasing PM_HEAP_NUM_TEMP_ROOTS
     */
    C_ASSERT(pmHeap.temp_root_index < HEAP_NUM_TEMP_ROOTS);

    C_DEBUG_PRINT(VERBOSITY_LOW, "heap_gcRun()\n");
    /*heap_dump();*/

    retval = heap_gcMarkRoots();
    PM_RETURN_IF_ERROR(retval);

    retval = heap_gcSweep();
    /*heap_dump();*/
    return retval;
}