Changeset 500


Ignore:
Timestamp:
Apr 18, 2011, 3:22:21 AM (6 years ago)
Author:
sam
Message:

cache: get rid of the lisp cache code, it cannot be used properly as
it conflicts with the garbage collector: cached data contains pointers
that would need to be updated at each collect.

Location:
abuse/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/cache.cpp

    r497 r500  
    857857}
    858858
    859 
    860 
    861859int32_t CacheList::reg_lisp_block(Cell *block)
    862860{
    863   uint32_t s;
    864   if (lcache_number==-1)
    865     lcache_number=crc_manager.get_filenumber(lfname);
    866 
    867   if (can_cache_lisp())
    868   {
    869     if (!cache_file)
    870     {
    871       if (cache_read_file)
    872       {
    873     delete cache_read_file;
    874     cache_read_file=NULL;
    875 
    876     cache_file=new jFILE(lfname,"ab");
    877       } else cache_file=new jFILE(lfname,"wb");     // first time we opened
    878     }
    879     if (cache_file->open_failure())
    880     {
    881       delete cache_file;
    882       ((LObject *)block)->Print();
    883       fprintf(stderr,"Unable to open lisp cache file name %s\n",lfname);
    884       exit(0);
    885     }
    886   }
    887   int id=alloc_id(),fn=crc_manager.get_filenumber(lfname);
    888   CacheItem *ci=list+id;
    889   CHECK(id<total && list[id].file_number<0);
    890 
    891   ci->file_number=fn;
    892   ci->last_access=-1;
    893   ci->type=SPEC_EXTERNAL_LCACHE;
    894   if (!can_cache_lisp())
    895   {
    896     ci->data=(void *)block;                // we can't cache it out so it must be in memory
     861    if (lcache_number == -1)
     862        lcache_number = crc_manager.get_filenumber(lfname);
     863
     864    int id = alloc_id(), fn = crc_manager.get_filenumber(lfname);
     865    CacheItem *ci = list + id;
     866    CHECK(id < total && list[id].file_number < 0);
     867
     868    ci->file_number = fn;
     869    ci->last_access = -1;
     870    ci->type = SPEC_EXTERNAL_LCACHE;
     871    ci->data = (void *)block; // we can't cache it out so it must be in memory
    897872    return id;
    898   }
    899   ci->data=NULL;                  // assume that it is in tmp memory, need to cache in on access
    900   ci->offset=cache_file->tell();
    901 
    902   s = block_size((LObject *)block);
    903   cache_file->write_uint32(s);
    904   write_level(cache_file, (LObject *)block);
    905   return id;
    906873}
    907874
     
    11441111  CacheItem *me=list+id;
    11451112  CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
    1146   if (!can_cache_lisp()) return (Cell *)me->data;
    1147   if (me->last_access>=0)
    1148   {
    1149     touch(me);
    1150     return (Cell *)me->data;
    1151   }
    1152   else
    1153   {
    1154     if (cache_file)
    1155     {
    1156       delete cache_file;
    1157       cache_file=NULL;
    1158     }
    1159     touch(me);
    1160 
    1161     if (!cache_read_file)
    1162     {
    1163       cache_read_file=new jFILE(crc_manager.get_filename(me->file_number),"rb");
    1164 
    1165       int cache_size=80*1024;                   // 80K
    1166       cache_read_file->set_read_buffer_size(cache_size);
    1167       uint8_t mini_buf;
    1168       cache_read_file->read(&mini_buf,1);       // prime the buffer
    1169     }
    1170 
    1171     cache_read_file->seek(me->offset,0);
    1172 
    1173     uint32_t size=cache_read_file->read_uint32();
    1174     void *space;
    1175 
    1176     if (size)
    1177       space=malloc(size);
    1178     else space=NULL;
    1179 
    1180     int cs=current_space;
    1181     use_user_space(space,size);
    1182     load_block(cache_read_file);
    1183     current_space=cs;
    1184 
    1185     if (size)
    1186       me->data=(Cell *)space;
    1187     else me->data=NULL;
    1188     return (Cell *)me->data;
    1189   }
     1113  return (Cell *)me->data;
    11901114}
    11911115
     
    12491173}
    12501174
    1251 
    12521175int CacheList::loaded(int id)
    12531176{
     
    12591182}
    12601183
    1261 
    1262 
    12631184char_tint *CacheList::ctint(int id)
    12641185{
     
    12801201}
    12811202
    1282 
    1283 
    1284 
  • abuse/trunk/src/lcache.h

    r495 r500  
    1313#include "lisp.h"
    1414
    15 #ifdef SCADALISP
    16 #define can_cache_lisp() 0
    17 #else
    18 #define can_cache_lisp() 0 /* XXX */
    19 #endif
    20 
    2115// return number of bytes to save this block of code
    2216size_t block_size(LObject *level);
Note: See TracChangeset for help on using the changeset viewer.