Changeset 12301 in project for chicken/trunk/runtime.c


Ignore:
Timestamp:
10/29/08 12:08:07 (13 years ago)
Author:
felix winkelmann
Message:

merged changes from cmi branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/runtime.c

    r12021 r12301  
    148148#if defined(C_NO_HACKED_APPLY) && defined(C_HACKED_APPLY)
    149149# undef C_HACKED_APPLY
    150 #endif
    151 
    152 #ifdef C_LOCK_TOSPACE
    153 #include <sys/mman.h>
    154150#endif
    155151
     
    529525static C_word get_unbound_variable_value(C_word sym);
    530526static LF_LIST *find_module_handle(C_char *name);
    531 static void lock_tospace(int lock);
    532527
    533528static C_ccall void call_cc_wrapper(C_word c, C_word closure, C_word k, C_word result) C_noret;
     
    658653    return 0;
    659654
    660 #ifdef C_LOCK_TOSPACE
    661   page_size = sysconf(_SC_PAGESIZE);
    662   assert(page_size > -1);
    663 #else
    664655  page_size = 0;
    665 #endif
    666656  stack_size = stack ? stack : DEFAULT_STACK_SIZE;
    667657  C_set_or_change_heap_size(heap ? heap : DEFAULT_HEAP_SIZE, 0);
     
    10371027/* Align memory to page boundary */
    10381028
    1039 #ifndef C_LOCK_TOSPACE
    10401029static void *align_to_page(void *mem)
    10411030{
    10421031  return (void *)C_align((C_uword)mem);
    10431032}
    1044 #endif
     1033
    10451034
    10461035static C_byte *
     
    10481037{
    10491038  C_byte *p;
    1050 #ifdef C_LOCK_TOSPACE
    1051   p = (C_byte *)mmap (NULL, size, (PROT_READ | PROT_WRITE),
    1052                       (MAP_PRIVATE | MAP_ANON), -1, 0);
    1053   if (p != NULL && page_aligned) *page_aligned = p;
    1054 #else
    10551039  p = (C_byte *)C_malloc (size + page_size);
     1040
    10561041  if (p != NULL && page_aligned) *page_aligned = align_to_page (p);
    1057 #endif
    1058 
    1059   /* . */
     1042
    10601043  return p;
    10611044}
     1045
    10621046
    10631047static void
    10641048heap_free (C_byte *ptr, size_t size)
    10651049{
    1066 #ifdef C_LOCK_TOSPACE
    1067   int r = munmap (ptr, size);
    1068   assert (r == 0);
    1069 #else
    10701050  C_free (ptr);
    1071 #endif
    1072   /* . */
    1073 }
     1051}
     1052
    10741053
    10751054static C_byte *
     
    10781057{
    10791058  C_byte *p;
    1080 #ifdef C_LOCK_TOSPACE
    1081   p = (C_byte *)mmap (NULL, new_size, (PROT_READ | PROT_WRITE),
    1082                       (MAP_PRIVATE | MAP_ANON), -1, 0);
    1083   if (ptr != NULL) {
    1084     memcpy (p, ptr, old_size);
    1085     heap_free (ptr, old_size);
    1086   }
    1087   if (p != NULL && page_aligned) *page_aligned = p;
    1088 #else
    10891059  p = (C_byte *)C_realloc (ptr, new_size + page_size);
     1060
    10901061  if (p != NULL && page_aligned) *page_aligned = align_to_page (p);
    1091 #endif
    1092 
    1093   /* . */
     1062
    10941063  return p;
    10951064}
     1065
    10961066
    10971067/* Modify heap size at runtime: */
     
    11271097  tospace_limit = tospace_start + size;
    11281098  mutation_stack_top = mutation_stack_bottom;
    1129   lock_tospace(1);
    11301099
    11311100  if(reintern) initialize_symbol_table();
     
    27082677
    27092678
    2710 static void lock_tospace(int lock)
    2711 {
    2712 #ifdef C_LOCK_TOSPACE
    2713   int r;
    2714 
    2715   r = mprotect(tospace_start, (heap_size / 2),
    2716                lock ? PROT_NONE : (PROT_READ | PROT_WRITE));
    2717 
    2718   if(r == -1) panic(strerror(errno));
    2719 #endif
    2720 }
    2721 
    2722 
    27232679C_regparm void C_fcall C_reclaim(void *trampoline, void *proc)
    27242680{
     
    27462702  if(C_pre_gc_hook != NULL) C_pre_gc_hook(GC_MINOR);
    27472703
    2748   lock_tospace(0);
    27492704  finalizers_checked = 0;
    27502705  C_restart_trampoline = (TRAMPOLINE)trampoline;
     
    30152970  if(C_post_gc_hook != NULL) C_post_gc_hook(gc_mode, tgc);
    30162971
    3017   lock_tospace(1);
    30182972  /* Jump from the Empire State Building... */
    30192973  C_longjmp(C_restart, 1);
     
    31953149  size_t  new_heapspace_size;
    31963150
    3197   lock_tospace(0);
    3198 
    31993151  if(C_pre_gc_hook != NULL) C_pre_gc_hook(GC_REALLOC);
    32003152
     
    33233275  C_fromspace_top = new_tospace_top;
    33243276  C_fromspace_limit = new_tospace_limit;
    3325   lock_tospace(1);
    33263277
    33273278  if(gc_report_flag) {
     
    41934144    return C_fix(C_MOST_POSITIVE_FIXNUM);
    41944145
    4195   case C_fix(22):
    4196 #ifdef C_LOCK_TOSPACE
    4197     return C_SCHEME_TRUE;
    4198 #else
    4199     return C_SCHEME_FALSE;
    4200 #endif
     4146    /* 22 */
    42014147
    42024148  case C_fix(23):
Note: See TracChangeset for help on using the changeset viewer.