Ignore:
Timestamp:
May 11, 2011, 1:26:11 AM (11 years ago)
Author:
Sam Hocevar
Message:

lisp: refactor Lisp spaces so that they are real objects, and get rid
of the unused USER_SPACE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r630 r635  
    205205}
    206206
    207 void LispGC::CollectSpace(int which_space, int grow)
    208 {
    209     int old_space = current_space;
    210     cstart = space[which_space];
    211     cend = free_space[which_space];
    212 
    213     space_size[GC_SPACE] = space_size[which_space];
     207void LispGC::CollectSpace(LSpace *which_space, int grow)
     208{
     209    LSpace *old_space = LSpace::Current;
     210    cstart = which_space->m_data;
     211    cend = which_space->m_free;
     212
     213    LSpace::Gc.m_size = which_space->m_size;
    214214    if (grow)
    215215    {
    216         space_size[GC_SPACE] += space_size[which_space] >> 1;
    217         space_size[GC_SPACE] -= (space_size[GC_SPACE] & 7);
    218     }
    219     uint8_t *new_space = (uint8_t *)malloc(space_size[GC_SPACE]);
    220     current_space = GC_SPACE;
    221     free_space[GC_SPACE] = space[GC_SPACE] = new_space;
    222 
    223     collected_start = new_space;
    224     collected_end = new_space + space_size[GC_SPACE];
     216        LSpace::Gc.m_size += which_space->m_size >> 1;
     217        LSpace::Gc.m_size -= (LSpace::Gc.m_size & 7);
     218    }
     219    uint8_t *new_data = (uint8_t *)malloc(LSpace::Gc.m_size);
     220    LSpace::Current = &LSpace::Gc;
     221    LSpace::Gc.m_free = LSpace::Gc.m_data = new_data;
     222
     223    collected_start = new_data;
     224    collected_end = new_data + LSpace::Gc.m_size;
    225225
    226226    CollectSymbols(LSymbol::root);
     
    228228
    229229    // for debuging clear it out
    230     memset(space[which_space], 0, space_size[which_space]);
    231     free(space[which_space]);
    232 
    233     space[which_space] = new_space;
    234     space_size[which_space] = space_size[GC_SPACE];
    235     free_space[which_space] = new_space
    236                             + (free_space[GC_SPACE] - space[GC_SPACE]);
    237     current_space = old_space;
    238 }
    239 
     230    memset(which_space->m_data, 0, which_space->m_size);
     231    free(which_space->m_data);
     232
     233    which_space->m_data = new_data;
     234    which_space->m_size = LSpace::Gc.m_size;
     235    which_space->m_free = new_data + (LSpace::Gc.m_free - LSpace::Gc.m_data);
     236    LSpace::Current = old_space;
     237}
     238
Note: See TracChangeset for help on using the changeset viewer.