pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:69:      /*    * Flags used as flag_method to mk_type()    */   #define PT_COPY_CAR 1   #define PT_COPY_CDR 2   #define PT_COPY_BOTH 3   #define PT_IS_MARKER 4 /* The node is a marker. */      /* Number of entries in the struct pike_type hash-table. */ - #define PIKE_TYPE_HASH_SIZE 32768 + #define PIKE_TYPE_HASH_SIZE 65535         #ifdef PIKE_TYPE_DEBUG   static int indent=0;   #endif      int max_correct_args;      PMOD_EXPORT struct pike_type *string0_type_string;   PMOD_EXPORT struct pike_type *string_type_string;
pike.git/src/pike_types.c:285:      void debug_free_type(struct pike_type *t)   {   #ifdef DEBUG_MALLOC    if (t == (struct pike_type *)(size_t)0x55555555) {    Pike_fatal("Freeing dead type.\n");    }   #endif /* DEBUG_MALLOC */    loop:    if (!sub_ref(t)) { -  unsigned INT32 hash = t->hash % pike_type_hash_size; +  unsigned INT32 hash = t->hash & pike_type_hash_size;    struct pike_type **t2 = pike_type_hash + hash;    struct pike_type *car, *cdr;    unsigned INT32 type; -  + #ifdef PIKE_DEBUG    /* PIKE_DEBUG code */ -  if (hash >= pike_type_hash_size) { +  if (hash > pike_type_hash_size) {    Pike_fatal("Modulo operation failed for hash:%u, index:%u, size:%u.\n",    t->hash, hash, pike_type_hash_size);    }    /* End PIKE_DEBUG code */ -  + #endif    while (*t2) {    if (*t2 == t) {    *t2 = t->next;    break;    }    t2 = &((*t2)->next);    }       car = t->car;    cdr = t->cdr;
pike.git/src/pike_types.c:387:   }      static inline struct pike_type *debug_mk_type(unsigned INT32 type,    struct pike_type *car,    struct pike_type *cdr,    int flag_method)   {    /* FIXME: The hash ought to be based on the tree contents, regardless    * of what the adresses of the type nodes are.    */ -  unsigned INT32 hash = DO_NOT_WARN((unsigned INT32) +  struct pike_type *t; +  unsigned INT32 index, +  hash = DO_NOT_WARN((unsigned INT32)    ((ptrdiff_t)type*0x10204081)^    (0x8003*PTR_TO_INT(car))^    ~(0x10001*PTR_TO_INT(cdr))); -  unsigned INT32 index = hash % pike_type_hash_size; -  struct pike_type *t; +  +  hash ^= (hash >> 20) ^ (hash >> 12); +  hash ^= (hash >> 7) ^ (hash >> 4); +  +  index = hash & pike_type_hash_size;   #ifdef PIKE_EXTRA_DEBUG    static unsigned INT32 extra_debug_index = (unsigned INT32)~0;   #endif /* PIKE_EXTRA_DEBUG */ -  + #ifdef PIKE_DEBUG    /* PIKE_DEBUG code */    if (type & ~255) {    /* The bad type node on OSF/1 seems to be:    *    * type: 0xffff    * car: valid pointer.    * cdr: 0x400000000    * next: 0x100000000    */    Pike_fatal("Attempt to create an invalid type node: %d(%s)\n"    " car: %p\n"    " cdr: %p\n",    type, get_name_of_type(type),    car, cdr);    } -  if (index >= pike_type_hash_size) { +  if (index > pike_type_hash_size) {    Pike_fatal("Modulo operation failed for hash:%u, index:%u, "    "size:%"PRINTSIZET"d.\n",    hash, index, pike_type_hash_size);    }    /* End PIKE_DEBUG code */ -  + #endif   #ifdef PIKE_EXTRA_DEBUG    if ((!~extra_debug_index) &&    (type == T_FUNCTION) &&    (car->type == T_STRING) &&    (cdr->type == T_FUNCTION) &&    (cdr->car->type == T_STRING) &&    (cdr->cdr->type == T_MANY) &&    (cdr->cdr->car->type == T_VOID) &&    (cdr->cdr->cdr->type == T_STRING)) {    /* Attempt to detect why we get a core-dump on OSF/1
pike.git/src/pike_types.c:510:    case T_ASSIGN:    /* Free cdr */    free_type((struct pike_type *)debug_malloc_pass(cdr));    break;       case PIKE_T_ATTRIBUTE:    case PIKE_T_NAME:    free_string((struct pike_string *)debug_malloc_pass(car));    free_type((struct pike_type *)debug_malloc_pass(cdr));    break; -  +    #ifdef PIKE_DEBUG    case '0':    case '1':    case '2':    case '3':    case '4':    case '5':    case '6':    case '7':    case '8':
pike.git/src/pike_types.c:8413: Inside #if defined(PIKE_DEBUG)
     #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 */      void init_types(void)   {    /* Initialize hashtable here. */    pike_type_hash = (struct pike_type **)xalloc(sizeof(struct pike_type *) * -  PIKE_TYPE_HASH_SIZE); -  MEMSET(pike_type_hash, 0, sizeof(struct pike_type *) * PIKE_TYPE_HASH_SIZE); +  (PIKE_TYPE_HASH_SIZE+1)); +  MEMSET(pike_type_hash, 0, sizeof(struct pike_type *) * (PIKE_TYPE_HASH_SIZE+1));    pike_type_hash_size = PIKE_TYPE_HASH_SIZE;    init_pike_type_blocks();       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);