Changeset 554


Ignore:
Timestamp:
Apr 29, 2011, 1:39:32 AM (7 years ago)
Author:
Sam Hocevar
Message:

lisp: if the Lisp permanent space grows out of memory, grow the space
during GCs instead of dying.

Location:
abuse/trunk/src
Files:
4 edited

Legend:

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

    r544 r554  
    24682468
    24692469        game_net_init(argc, argv);
    2470         lisp_init(0x80000, 0x94000);
     2470        lisp_init(0x8000, 0x94000);
    24712471
    24722472        dev_init(argc, argv);
  • abuse/trunk/src/lisp/lisp.cpp

    r524 r554  
    188188    {
    189189        if (which_space == PERM_SPACE || which_space == TMP_SPACE)
    190             collect_space(which_space);
     190            collect_space(which_space, 0);
     191
     192        if (size > get_free_size(which_space))
     193            collect_space(which_space, 1);
    191194
    192195        if (size > get_free_size(which_space))
     
    28182821    }
    28192822    case SYS_FUNC_GC:
    2820         collect_space(current_space);
     2823        collect_space(current_space, 0);
    28212824        break;
    28222825    case SYS_FUNC_SCHAR:
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r553 r554  
    233233}
    234234
    235 void collect_space(int which_space) // should be tmp or permanent
     235void collect_space(int which_space, int grow) // should be tmp or permanent
    236236{
    237237  int old_space = current_space;
     
    240240
    241241  space_size[GC_SPACE] = space_size[which_space];
     242  if (grow)
     243  {
     244    space_size[GC_SPACE] += space_size[which_space] >> 1;
     245    space_size[GC_SPACE] -= (space_size[GC_SPACE] & 7);
     246  }
    242247  uint8_t *new_space = (uint8_t *)malloc(space_size[GC_SPACE]);
    243248  current_space = GC_SPACE;
     
    255260
    256261  space[which_space] = new_space;
     262  space_size[which_space] = space_size[GC_SPACE];
    257263  free_space[which_space] = new_space
    258264                          + (free_space[GC_SPACE] - space[GC_SPACE]);
  • abuse/trunk/src/lisp/lisp_gc.h

    r496 r554  
    1515extern grow_stack<void> l_user_stack;       // stack user progs can push data and have it GCed
    1616
    17 void collect_space(int which_space); // should be tmp or permenant
     17void collect_space(int which_space, int grow); // should be tmp or permenant
    1818
    1919void register_pointer(void *&addr);
Note: See TracChangeset for help on using the changeset viewer.