Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 518

Show
Ignore:
Timestamp:
01/18/11 07:04:30 (14 years ago)
Author:
braddr
Message:

merge in some 64 bit fixes from the d1 gc

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/gc/gcx.d

    r517 r518  
    22042204        uint changes = 0; 
    22052205 
    22062206        //printf("marking range: %p -> %p\n", pbot, ptop); 
    22072207        for (; p1 < p2; p1++) 
    22082208        { 
    22092209            auto p = cast(byte *)(*p1); 
    22102210 
    22112211            //if (log) debug(PRINTF) printf("\tmark %p\n", p); 
    22122212            if (p >= minAddr && p < maxAddr) 
    22132213            { 
    2214                 if ((cast(size_t)p & ~(PAGESIZE-1)) == pcache) 
     2214                if ((cast(size_t)p & ~cast(size_t)(PAGESIZE-1)) == pcache) 
    22152215                    continue; 
    22162216 
    22172217        auto pool = findPool(p); 
    22182218                if (pool) 
    22192219                { 
    22202220                    size_t offset = cast(size_t)(p - pool.baseAddr); 
    22212221                    size_t biti = void; 
    22222222                    size_t pn = offset / PAGESIZE; 
    22232223                    Bins   bin = cast(Bins)pool.pagetable[pn]; 
    22242224 
     
    22282228                    if (bin < B_PAGE) 
    22292229                    { 
    22302230                        biti = (offset & notbinsize[bin]) >> 4; 
    22312231                        //debug(PRINTF) printf("\t\tbiti = x%x\n", biti); 
    22322232                    } 
    22332233                    else if (bin == B_PAGE) 
    22342234                    { 
    22352235                        biti = (offset & notbinsize[bin]) >> 4; 
    22362236                        //debug(PRINTF) printf("\t\tbiti = x%x\n", biti); 
    22372237 
    2238                         pcache = cast(size_t)p & ~(PAGESIZE-1); 
     2238                        pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1); 
    22392239                    } 
    22402240                    else if (bin == B_PAGEPLUS) 
    22412241                    { 
    22422242                        do 
    22432243                        {   --pn; 
    22442244                        } while (cast(Bins)pool.pagetable[pn] == B_PAGEPLUS); 
    22452245                        biti = pn * (PAGESIZE / 16); 
    22462246 
    2247                         pcache = cast(size_t)p & ~(PAGESIZE-1); 
     2247                        pcache = cast(size_t)p & ~cast(size_t)(PAGESIZE-1); 
    22482248                    } 
    22492249                    else 
    22502250                    { 
    22512251                        // Don't mark bits in B_FREE or B_UNCOMMITTED pages 
    22522252                        continue; 
    22532253                    } 
    22542254 
    22552255                    //debug(PRINTF) printf("\t\tmark(x%x) = %d\n", biti, pool.mark.test(biti)); 
    22562256                    if (!pool.mark.testSet(biti)) 
    22572257                    { 
     
    24452445        while (anychanges) 
    24462446        { 
    24472447            debug(COLLECT_PRINTF) printf("\t\tpass\n"); 
    24482448            anychanges = 0; 
    24492449            for (n = 0; n < npools; n++) 
    24502450            { 
    24512451                pool = pooltable[n]; 
    24522452 
    24532453                auto bbase = pool.scan.base(); 
    24542454                auto btop = bbase + pool.scan.nwords; 
     2455                //printf("\t\tn = %d, bbase = %p, btop = %p\n", n, bbase, btop); 
    24552456                for (auto b = bbase; b < btop;) 
    24562457                { 
    24572458                    auto bitm = *b; 
    24582459                    if (!bitm) 
    24592460                    {   b++; 
    24602461                        continue; 
    24612462                    } 
    24622463                    *b = 0; 
    24632464 
    2464                     auto o = pool.baseAddr + (b - bbase) * 32 * 16; 
     2465                    auto o = pool.baseAddr + (b - bbase) * (typeof(bitm).sizeof*8) * 16; 
    24652466                    if (!(bitm & 0xFFFF)) 
    24662467                    { 
    24672468                        bitm >>= 16; 
    24682469                        o += 16 * 16; 
    24692470                    } 
    24702471                    if (!(bitm & 0xFF)) 
    24712472                    { 
    24722473                        bitm >>= 8; 
    24732474                        o += 8 * 16; 
    24742475                    } 
     
    28052806            GC.file = null; 
    28062807 
    28072808            current.push(log); 
    28082809            //debug(PRINTF) printf("-log_malloc()\n"); 
    28092810        } 
    28102811 
    28112812 
    28122813        void log_free(void *p) 
    28132814        { 
    28142815            //debug(PRINTF) printf("+log_free(%p)\n", p); 
    2815             size_t i; 
    2816  
    2817             i = current.find(p); 
     2816            auto i = current.find(p); 
    28182817            if (i == OPFAIL) 
    28192818            { 
    28202819                debug(PRINTF) printf("free'ing unallocated memory %p\n", p); 
    28212820            } 
    28222821            else 
    28232822                current.remove(i); 
    28242823            //debug(PRINTF) printf("-log_free()\n"); 
    28252824        } 
    28262825 
    28272826 
    28282827        void log_collect() 
    28292828        { 
    28302829            //debug(PRINTF) printf("+log_collect()\n"); 
    28312830            // Print everything in current that is not in prev 
    28322831 
    28332832            debug(PRINTF) printf("New pointers this cycle: --------------------------------\n"); 
    28342833            size_t used = 0; 
    28352834            for (size_t i = 0; i < current.dim; i++) 
    28362835            { 
    2837                 size_t j; 
    2838  
    2839                 j = prev.find(current.data[i].p); 
     2836                auto j = prev.find(current.data[i].p); 
    28402837                if (j == OPFAIL) 
    28412838                    current.data[i].print(); 
    28422839                else 
    28432840                    used++; 
    28442841            } 
    28452842 
    28462843            debug(PRINTF) printf("All roots this cycle: --------------------------------\n"); 
    28472844            for (size_t i = 0; i < current.dim; i++) 
    28482845            { 
    2849                 void *p; 
    2850                 size_t j; 
    2851  
    2852                 p = current.data[i].p; 
     2846                void* p = current.data[i].p; 
    28532847                if (!findPool(current.data[i].parent)) 
    28542848                { 
    2855                     j = prev.find(current.data[i].p); 
     2849                    auto j = prev.find(current.data[i].p); 
    28562850                    if (j == OPFAIL) 
    28572851                        debug(PRINTF) printf("N"); 
    28582852                    else 
    28592853                        debug(PRINTF) printf(" ");; 
    28602854                    current.data[i].print(); 
    28612855                } 
    28622856            } 
    28632857 
    28642858            debug(PRINTF) printf("Used = %d-------------------------------------------------\n", used); 
    28652859            prev.copy(&current); 
    28662860 
    28672861            debug(PRINTF) printf("-log_collect()\n"); 
    28682862        } 
    28692863 
    28702864 
    28712865        void log_parent(void *p, void *parent) 
    28722866        { 
    28732867            //debug(PRINTF) printf("+log_parent()\n"); 
    2874             size_t i; 
    2875  
    2876             i = current.find(p); 
     2868            auto i = current.find(p); 
    28772869            if (i == OPFAIL) 
    28782870            { 
    28792871                debug(PRINTF) printf("parent'ing unallocated memory %p, parent = %p\n", p, parent); 
    28802872                Pool *pool; 
    28812873                pool = findPool(p); 
    28822874                assert(pool); 
    28832875                size_t offset = cast(size_t)(p - pool.baseAddr); 
    28842876                size_t biti; 
    28852877                size_t pn = offset / PAGESIZE; 
    28862878                Bins bin = cast(Bins)pool.pagetable[pn];