X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/b802e8fe709f22ad56f8a43bc9675c114c2fc21f..b5e1601adc7b579e9d2366aa2529b07ee6f47fe3:/rt/gc/cdgc/gc.d?ds=inline diff --git a/rt/gc/cdgc/gc.d b/rt/gc/cdgc/gc.d index b8008f1..267b42f 100644 --- a/rt/gc/cdgc/gc.d +++ b/rt/gc/cdgc/gc.d @@ -295,66 +295,15 @@ Pool *findPool(void *p) BlkInfo getInfo(void* p) { assert (p !is null); - - Pool* pool; + Pool* pool = findPool(p); + if (pool is null) + return BlkInfo.init; BlkInfo info; - - pool = findPool(p); - if (pool) - { - size_t offset = cast(size_t)(p - pool.baseAddr); - size_t pn = offset / PAGESIZE; - Bins bin = cast(Bins)pool.pagetable[pn]; - - //////////////////////////////////////////////////////////////////// - // findAddr - //////////////////////////////////////////////////////////////////// - - if (bin <= B_PAGE) - { - info.base = pool.baseAddr + (offset & notbinsize[bin]); - } - else if (bin == B_PAGEPLUS) - { - do - { - --pn, offset -= PAGESIZE; - } - while (cast(Bins)pool.pagetable[pn] == B_PAGEPLUS); - - info.base = pool.baseAddr + (offset & (offset.max ^ (PAGESIZE-1))); - - // fix bin for use by size calc below - bin = cast(Bins)pool.pagetable[pn]; - } - - //////////////////////////////////////////////////////////////////// - // findSize - //////////////////////////////////////////////////////////////////// - - info.size = binsize[bin]; - if (bin == B_PAGE) - { - ubyte* pt; - size_t i; - - pt = &pool.pagetable[0]; - for (i = pn + 1; i < pool.npages; i++) - { - if (pt[i] != B_PAGEPLUS) - break; - } - info.size = (i - pn) * PAGESIZE; - } - - //////////////////////////////////////////////////////////////////// - // getAttr - //////////////////////////////////////////////////////////////////// - - info.attr = getAttr(pool, cast(size_t)(offset / 16)); - if (!(info.attr & BlkAttr.NO_SCAN)) - info.size -= (size_t*).sizeof; // bitmask - } + info.base = pool.findBase(p); + info.size = pool.findSize(info.base); + info.attr = getAttr(pool, cast(size_t)(info.base - pool.baseAddr) / 16u); + if (!opts.options.conservative && !(info.attr & BlkAttr.NO_SCAN)) + info.size -= size_t.sizeof; // PointerMap bitmask return info; }