pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:680:   #endif /* DEBUG_MALLOC */      #ifdef PIKE_DEBUG   void debug_check_type_string(struct pike_type *s)   {    /* FIXME: Add verification code here */   }      #endif /* PIKE_DEBUG */    - struct pike_type *type_stack[PIKE_TYPE_STACK_SIZE]; - struct pike_type **pike_type_mark_stack[PIKE_TYPE_STACK_SIZE/4]; + struct pike_type **type_stack; + struct pike_type ***pike_type_mark_stack;      ptrdiff_t pop_stack_mark(void)   {    Pike_compiler->pike_type_mark_stackp--;    if(Pike_compiler->pike_type_mark_stackp<pike_type_mark_stack)    Pike_fatal("Type mark stack underflow\n");       TYPE_STACK_DEBUG("pop_stack_mark");       return Pike_compiler->type_stackp - *Pike_compiler->pike_type_mark_stackp;
pike.git/src/pike_types.c:714:   struct pike_type *debug_peek_type_stack(void)   {    return *(Pike_compiler->type_stackp);   }      void debug_push_int_type(INT_TYPE min, INT_TYPE max)   {   #if SIZEOF_INT_TYPE > 4   /* a bit kludgy: should maybe really allow 64 bit INT_TYPE */   /* see also extract_type_int */ -  +     if (min<MIN_INT32) min=MIN_INT32;    else if (min>MAX_INT32) min=MAX_INT32;    if (max<MIN_INT32) max=MIN_INT32;    else if (max>MAX_INT32) max=MAX_INT32; -  - #if 0 -  if (min!=(INT32)min || -  max!=(INT32)max) -  Pike_fatal("push_int_type(): int outside INT32 range (sorry)" -  " (%"PRINTPIKEINT"d..%"PRINTPIKEINT"d)\n", -  min,max); +    #endif - #endif +       #ifdef PIKE_DEBUG    if (min > max)    Pike_fatal("push_int_type(): Bad integer range:"    " min:%"PRINTPIKEINT"d, max:%"PRINTPIKEINT"d.\n",    min, max);   #endif /* PIKE_DEBUG */       if (!min && !max) {    /* Special case... */
pike.git/src/pike_types.c:8447: Inside #if defined(PIKE_DEBUG)
   }   #ifdef PIKE_DEBUG    default:    Pike_fatal("compile_type_string(): Error in type string %d.\n", type);    /* NOT_REACHED */    break;   #endif    }   }    + void type_stack_mark() + { +  if(UNLIKELY(Pike_compiler->pike_type_mark_stackp >= pike_type_mark_stack + (PIKE_TYPE_STACK_SIZE>>4))) +  Pike_fatal("Type mark stack overflow.\n"); +  *Pike_compiler->pike_type_mark_stackp=Pike_compiler->type_stackp; +  Pike_compiler->pike_type_mark_stackp++; +  TYPE_STACK_DEBUG("type_stack_mark"); + } +    /* Make a pike-type from a serialized (old-style) type. */   struct pike_type *debug_make_pike_type(const char *serialized_type)   {    unsigned char *dummy;    type_stack_mark();    low_make_pike_type((unsigned char *)serialized_type, &dummy);   #if 1    if ((Pike_compiler->type_stackp[0]->flags &    (PT_FLAG_MARKER|PT_FLAG_ASSIGN)) ||    (((Pike_compiler->type_stackp[0]->type == T_OR) ||
pike.git/src/pike_types.c:8675:    low_type_to_string(t);    UNSET_ONERROR(err);    return free_buf(&save_buf);   }      #ifdef PIKE_DEBUG   static void gc_mark_external_types(struct callback *cb, void *a, void *b);   static struct callback *pike_type_gc_callback = NULL;   #endif /* PIKE_DEBUG */    + #ifdef HAVE_SYS_MMAN_H + #include <sys/mman.h> + #endif +  + #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) + #define MAP_ANONYMOUS MAP_ANON + static int type_stack_mmap, type_mark_stack_mmap; + #endif /* !MAP_ANONYMOUS && MAP_ANON */ +    void init_types(void)   {    /* Initialize hashtable here. */    pike_type_hash = xcalloc(sizeof(struct pike_type *),    (PIKE_TYPE_HASH_SIZE+1));    pike_type_hash_size = PIKE_TYPE_HASH_SIZE;    -  +  /* if possible, use mmap with on-demand allocation */ + #if defined(MAP_ANONYMOUS) +  type_stack = mmap( NULL, sizeof(struct pike_type *)*PIKE_TYPE_STACK_SIZE, +  PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE,0,0); +  if( type_stack ) +  type_stack_mmap = 1; +  pike_type_mark_stack = mmap( NULL, sizeof(struct pike_type **)*PIKE_TYPE_STACK_SIZE>>2, +  PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0, 0); +  if( pike_type_mark_stack ) +  type_mark_stack_mmap = 1; + #endif +  if( !type_stack ) +  type_stack = xalloc(sizeof(struct pike_type *)*PIKE_TYPE_STACK_SIZE); +  if( !pike_type_mark_stack ) +  pike_type_mark_stack = xalloc(sizeof(struct pike_type *)*PIKE_TYPE_STACK_SIZE); +  +  Pike_compiler->type_stackp = type_stack; +  Pike_compiler->pike_type_mark_stackp = pike_type_mark_stack; +     int_type_string = CONSTTYPE(tInt); /* MUST come before string! */    string0_type_string = CONSTTYPE(tStr0);    string_type_string = CONSTTYPE(tStr32);    object_type_string = CONSTTYPE(tObj);    program_type_string = CONSTTYPE(tPrg(tObj));    float_type_string = CONSTTYPE(tFloat);    mixed_type_string = CONSTTYPE(tMix);    array_type_string = CONSTTYPE(tArray);    multiset_type_string = CONSTTYPE(tMultiset);    mapping_type_string = CONSTTYPE(tMapping);
pike.git/src/pike_types.c:8725:   #endif   }      void cleanup_pike_types(void)   {   #ifdef DO_PIKE_CLEANUP    while (all_pike_type_locations) {    free_type(all_pike_type_locations->t);    all_pike_type_locations = all_pike_type_locations->next;    } + #ifdef MAP_ANONYMOUS +  if( type_stack_mmap ) +  { +  munmap( type_stack, sizeof(struct pike_type *)*PIKE_TYPE_STACK_SIZE); +  type_stack = NULL; +  } +  if( pike_type_mark_stack_mmap ) +  { +  munmap( pike_type_mark_stack, sizeof(struct pike_type *)*PIKE_TYPE_STACK_SIZE>>2); +  pike_type_mark_stack = NULL; +  } + #endif +  free( type_stack ); +  free( pike_type_mark_stack );   #endif /* DO_PIKE_CLEANUP */       clear_markers();       free_type(string0_type_string);    string0_type_string = NULL;    free_type(string_type_string);    string_type_string = NULL;    free_type(int_type_string);    int_type_string = NULL;