Changeset 301 for trunk/thune/gc.c
- Timestamp:
- 10/23/06 04:19:31 (2 years ago)
- Files:
-
- 1 modified
-
trunk/thune/gc.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gc.c
r300 r301 145 145 146 146 147 static void _freeBuffer( UrlanEnv* env, UGCArray* agc, UBuffer* buf ) 148 { 149 int idx = ((int) buf->dataType) - UT_BI_COUNT; 150 if( idx >= 0 ) 151 env->customDT[ idx ].gcDestroyBuffer( buf ); 152 153 // Flag as unused. 154 buf->dataType = UT_UNSET; 155 156 // Link to free list. 157 buf->link = agc->freeList; 158 agc->freeList = buf - ((UBuffer*) agc->arr.ptr.v); 159 160 agc->freeCount += 1; 161 } 162 163 164 #define FREE_BUFFER(buf) \ 165 btmp = buf; \ 166 if( btmp->dataType != UT_UNSET ) \ 167 _freeBuffer( env, agc, btmp ); 168 169 static void _sweepBuffers( UrlanEnv* env, UArray* mark, UGCArray* agc ) 170 { 171 UBuffer* btmp; 172 UBuffer* ait = (UBuffer*) agc->arr.ptr.v; 173 uint8_t* it = mark->ptr.b; 174 uint8_t* end = it + mark->used; 175 176 177 // Mark padding bits at end as used. 178 { 179 int padBits = agc->arr.used & 7; 180 if( padBits ) 181 end[-1] |= 0xff << padBits; 182 } 183 184 // Check mark bitset for unused elements. 185 while( it != end ) 186 { 187 if( *it != 0xff ) 188 { 189 int mask = *it; 190 191 if( (mask & 0x0f) != 0x0f ) 192 { 193 if( (mask & 0x01) == 0 ) { FREE_BUFFER( ait ) } 194 if( (mask & 0x02) == 0 ) { FREE_BUFFER( ait + 1 ) } 195 if( (mask & 0x04) == 0 ) { FREE_BUFFER( ait + 2 ) } 196 if( (mask & 0x08) == 0 ) { FREE_BUFFER( ait + 3 ) } 197 } 198 199 if( (mask & 0xf0) != 0xf0 ) 200 { 201 if( (mask & 0x10) == 0 ) { FREE_BUFFER( ait + 4 ) } 202 if( (mask & 0x20) == 0 ) { FREE_BUFFER( ait + 5 ) } 203 if( (mask & 0x40) == 0 ) { FREE_BUFFER( ait + 6 ) } 204 if( (mask & 0x80) == 0 ) { FREE_BUFFER( ait + 7 ) } 205 } 206 } 207 ++it; 208 ait += 8; 209 } 210 } 211 147 212 148 213 static UCollector _gc; 149 150 #define bsBlk _gc.bsBlock151 #define bsStr _gc.bsBin152 214 153 215 … … 156 218 #define SET_BIT_BLOCK(bn) \ 157 219 idx = bn - env->blocks.sweepStart; \ 158 if( idx >= 0 ) ur_setBit( bsBlk.ptr.b, idx );220 if( idx >= 0 ) ur_setBit( _gc.bsBlock.ptr.b, idx ); 159 221 160 222 #define SET_BIT_BIN(bn) \ 161 223 idx = bn - env->bin.sweepStart; \ 162 if( idx >= 0 ) ur_setBit( bsStr.ptr.b, idx );224 if( idx >= 0 ) ur_setBit( _gc.bsBin.ptr.b, idx ); 163 225 164 226 #define SWEEP_START_BLOCK env->blocks.sweepStart … … 168 230 169 231 #define SET_BIT_BLOCK(bn) \ 170 idx = bn; ur_setBit( bsBlk.ptr.b, idx );232 idx = bn; ur_setBit( _gc.bsBlock.ptr.b, idx ); 171 233 172 234 #define SET_BIT_BIN(bn) \ 173 idx = bn; ur_setBit( bsStr.ptr.b, idx );235 idx = bn; ur_setBit( _gc.bsBin.ptr.b, idx ); 174 236 175 237 #define SWEEP_START_BLOCK 0 … … 188 250 { 189 251 ur_setBit( gc->bsBlock.ptr.b, idx ); 252 } 253 254 255 void ur_gcMarkBuffer( UCollector* gc, UIndex idx ) 256 { 257 ur_setBit( gc->bsBuf.ptr.b, idx ); 190 258 } 191 259 … … 261 329 int ai = idx >> 3; 262 330 int bitm = 1 << (idx & 7); 263 bsBlk.ptr.b[ ai ] |= bitm;331 _gc.bsBlock.ptr.b[ ai ] |= bitm; 264 332 _gc.blkChecked.ptr.b[ ai ] |= bitm; 265 333 } … … 273 341 idx = it->func.closureN; 274 342 if( idx ) 275 ur_setBit( bsBlk.ptr.b, idx );343 ur_setBit( _gc.bsBlock.ptr.b, idx ); 276 344 277 345 idx = it->func.sigN; 278 346 if( idx ) 279 ur_setBit( bsBlk.ptr.b, idx );347 ur_setBit( _gc.bsBlock.ptr.b, idx ); 280 348 break; 281 349 … … 293 361 int ai = idx >> 3; 294 362 int bitm = 1 << (idx & 7); 295 bsBlk.ptr.b[ ai ] |= bitm;363 _gc.bsBlock.ptr.b[ ai ] |= bitm; 296 364 if( ! (_gc.blkChecked.ptr.b[ ai ] & bitm) ) 297 365 { … … 319 387 idx = it->err.messageStr; 320 388 if( idx ) 321 ur_setBit( bsStr.ptr.b, idx );389 ur_setBit( _gc.bsBin.ptr.b, idx ); 322 390 323 391 idx = it->err.traceBlk; 324 392 if( idx ) 325 ur_setBit( bsBlk.ptr.b, idx );393 ur_setBit( _gc.bsBlock.ptr.b, idx ); 326 394 break; 327 395 … … 399 467 idx = it->func.sigN; 400 468 if( idx ) 401 ur_setBit( bsBlk.ptr.b, idx );469 ur_setBit( _gc.bsBlock.ptr.b, idx ); 402 470 it -= CC_LEN_FUNC; 403 471 break; … … 548 616 GC_BITSET( _gc.blkChecked, env->blocks, SWEEP_START_BLOCK ); 549 617 550 GC_BITSET( bsBlk, env->blocks, SWEEP_START_BLOCK ); 551 GC_BITSET( bsStr, env->bin, SWEEP_START_BIN ); 618 GC_BITSET( _gc.bsBlock, env->blocks, SWEEP_START_BLOCK ); 619 GC_BITSET( _gc.bsBin, env->bin, SWEEP_START_BIN ); 620 GC_BITSET( _gc.bsBuf, env->buffers, 0 ); 552 621 553 622 #ifdef PAIRPOOL_H … … 585 654 ur_setBit( doneset, GLOBAL_WORD_BLKN ); 586 655 587 ur_setBit( bsBlk.ptr.b, GLOBAL_VAL_BLKN );588 ur_setBit( bsBlk.ptr.b, GLOBAL_WORD_BLKN );589 590 591 ur_setBit( bsStr.ptr.b, BIN_ATOM_NAMES );656 ur_setBit( _gc.bsBlock.ptr.b, GLOBAL_VAL_BLKN ); 657 ur_setBit( _gc.bsBlock.ptr.b, GLOBAL_WORD_BLKN ); 658 659 660 ur_setBit( _gc.bsBin.ptr.b, BIN_ATOM_NAMES ); 592 661 593 662 … … 627 696 628 697 i = 0; 629 markset = bsBlk.ptr.b;698 markset = _gc.bsBlock.ptr.b; 630 699 doneset = _gc.blkChecked.ptr.b; 631 700 … … 674 743 #endif 675 744 676 _sweepArray( &bsBlk, &env->blocks ); 677 _sweepArray( &bsStr, &env->bin ); 745 _sweepBuffers( env, &_gc.bsBuf, &env->buffers ); 746 _sweepArray( &_gc.bsBlock, &env->blocks ); 747 _sweepArray( &_gc.bsBin, &env->bin ); 678 748 679 749 ur_arrayFree( &_gc.blkChecked ); 680 750 681 ur_arrayFree( &bsBlk ); 682 ur_arrayFree( &bsStr ); 751 ur_arrayFree( &_gc.bsBuf ); 752 ur_arrayFree( &_gc.bsBlock ); 753 ur_arrayFree( &_gc.bsBin ); 683 754 684 755 #ifdef GC_TIME
