
use mem

@shared shared_dump: Bump (Bump.new())

fn dump_shared(shared_list: Bump) {
    let bytes = shared_list.index
    if bytes == 0 : return
    let dump = shared_dump
    let adr = dump.get(bytes)
    mem:copy(shared_list.data, adr, bytes)
}

fn check_shared_dump() {
    let list = shared_dump
    let data = list.data
    let adr = data
    let end = adr + list.index
    list.reset()

    while adr < end {
        let item = @ptrv(adr, ptr)
        let data = (@offset(item, u8, -8)).@cast(GcData)
        adr += size_of(ptr)

        if data.is_marked() {
            list.add_ptr(item)
            continue
        }

        free_shared_item(item)
    }
}
