Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3439

Show
Ignore:
Timestamp:
04/17/08 01:28:00 (8 months ago)
Author:
sean
Message:

Added TypeInfo? for key to associative array and fixed primitive detection of value type. It had been treating the value type as if it had pointers if value.sizeof == void.sizeof, and this is only true for pointers (ie. void arrays). An associative array would have its value type be a void array reference, not a single element of a void array itself. All of this should improve GC efficiency a bit in apps using GCs. Please let me know if there are any problems. This closes #1037

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/compiler/dmd/aaA.d

    r2974 r3439  
    8888    aaA*[] b; 
    8989    size_t nodes;       // total number of aaA nodes 
     90    TypeInfo keyti;     // TODO: replace this with TypeInfo_AssociativeArray when available in _aaGet() 
    9091} 
    9192 
     
    255256    if (!aa.a) 
    256257        aa.a = new BB(); 
     258    aa.a.keyti = keyti; 
    257259 
    258260    if (!aa.a.b.length) 
     
    284286    //printf("create new one\n"); 
    285287    size_t size = aaA.sizeof + keysize + valuesize; 
    286     uint   bits = keysize   < (void*).sizeof && 
    287                   keysize   > (void).sizeof  && 
    288                   valuesize < (void*).sizeof && 
    289                   valuesize > (void).sizeof  ? BlkAttr.NO_SCAN : 0; 
     288    uint   bits = !(aa.a.keyti.flags() & 1) && 
     289                  valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0; 
    290290    e = cast(aaA *) gc_calloc(size, bits); 
    291291    memcpy(e + 1, pkey, keysize); 
     
    491491        a.length = _aaLen(aa); 
    492492        a.ptr = cast(byte*) gc_malloc(a.length * valuesize, 
    493                                       valuesize < (void*).sizeof && 
    494                                       valuesize > (void).sizeof  ? BlkAttr.NO_SCAN : 0); 
     493                                      valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0); 
    495494        resi = 0; 
    496495        foreach (e; aa.a.b) 
     
    628627        return 0; 
    629628    res = (cast(byte*) gc_malloc(len * keysize, 
    630                                  keysize < (void*).sizeof && 
    631                                  keysize > (void).sizeof  ? BlkAttr.NO_SCAN : 0))[0 .. len * keysize]; 
     629                                 !(aa.a.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0))[0 .. len * keysize]; 
    632630    resi = 0; 
    633631    foreach (e; aa.a.b) 
     
    781779 
    782780        result = new BB(); 
     781        result.keyti = keyti; 
    783782        size_t i; 
    784783 
  • trunk/lib/compiler/gdc/aaA.d

    r2974 r3439  
    9393    aaA*[] b; 
    9494    size_t nodes;       // total number of aaA nodes 
     95    TypeInfo keyti;     // TODO: replace this with TypeInfo_AssociativeArray when available in _aaGet() 
    9596} 
    9697 
     
    259260    if (!aa.a) 
    260261        aa.a = new BB(); 
     262    aa.a.keyti = keyti; 
    261263 
    262264    if (!aa.a.b.length) 
     
    288290    //printf("create new one\n"); 
    289291    size_t size = aaA.sizeof + keysize + valuesize; 
    290     uint   bits = keysize   < (void*).sizeof && 
    291                   keysize   > (void).sizeof  && 
    292                   valuesize < (void*).sizeof && 
    293                   valuesize > (void).sizeof  ? BlkAttr.NO_SCAN : 0; 
     292    uint   bits = !(aa.a.keyti.flags() & 1) && 
     293                  valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0; 
    294294    e = cast(aaA *) gc_calloc(size, bits); 
    295295    memcpy(e + 1, pkey, keysize); 
     
    492492        a.length = _aaLen(aa); 
    493493        a.ptr = cast(byte*) gc_malloc(a.length * valuesize, 
    494                                       valuesize < (void*).sizeof && 
    495                                       valuesize > (void).sizeof  ? BlkAttr.NO_SCAN : 0); 
     494                                      valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0); 
    496495        resi = 0; 
    497496        foreach (e; aa.a.b) 
     
    630629        return a; 
    631630    res = (cast(byte*) gc_malloc(len * keysize, 
    632                                  keysize < (void*).sizeof && 
    633                                  keysize > (void).sizeof  ? BlkAttr.NO_SCAN : 0))[0 .. len * keysize]; 
     631                                 !(aa.a.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0))[0 .. len * keysize]; 
    634632    resi = 0; 
    635633    foreach (e; aa.a.b) 
     
    784782 
    785783        result = new BB(); 
     784        result.keyti = keyti; 
    786785        size_t i; 
    787786