pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: las.c,v 1.223 2000/11/25 16:45:02 grubba Exp $"); + RCSID("$Id: las.c,v 1.224 2000/11/26 14:20:24 grubba Exp $");      #include "language.h"   #include "interpret.h"   #include "las.h"   #include "array.h"   #include "object.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "lex.h"   #include "pike_types.h"
pike.git/src/las.c:420: Inside #if defined(SHARED_NODES)
   if (!prior) {    return;    }    prior->next = n->next;    }    n->next = NULL;   }      static node *freeze_node(node *orig)   { -  size_t hash = hash_node(orig); +  size_t hash;    node *n;    int found = 0;    -  /* free_node() wants a correct hash */ -  orig->hash = hash; -  +     if (orig->tree_info & OPT_NOT_SHARED) {    /* No need to have this node in the hash-table. */    /* add_node(orig); */    return check_node_hash(dmalloc_touch(node *, orig));    }    -  +  /* free_node() wants a correct hash */ +  orig->hash = hash = hash_node(orig); +     /* Mark this node as a possible duplicate */    orig->node_info |= OPT_DEFROSTED;    /* Make sure we don't find ourselves */    /* sub_node(orig); */       n = node_hash.table[hash % node_hash.size];       while (n) {    if (n == orig) {    found = 1;
pike.git/src/las.c:559: Inside #if defined(SHARED_NODES)
   /* Free the node and be happy */   #ifdef SHARED_NODES    /* Force the hashtable to be cleared. */    tmp->next = NULL;    sub_node(tmp);   #endif /* SHARED_NODES */    /* Make sure we don't free any nodes twice */    if(car_is_node(tmp)) _CAR(tmp)=0;    if(cdr_is_node(tmp)) _CDR(tmp)=0;   #ifdef SHARED_NODES +  if (!(tmp->tree_info & OPT_NOT_SHARED)) {    tmp->hash = hash_node(tmp); -  +  }   #ifdef PIKE_DEBUG    if (l_flag > 3) {    fprintf(stderr, "Freeing node that had %d refs.\n",    tmp->refs);    }   #endif /* PIKE_DEBUG */    /* Force the node to be freed. */    tmp->refs = 1;   #endif /* SHARED_NODES */    debug_malloc_touch(tmp->type);
pike.git/src/las.c:602:   void debug_free_node(node *n)   {    if(!n) return;      #ifdef SHARED_NODES    if (--n->refs) {   #ifdef PIKE_DEBUG    if(l_flag>9)    print_tree(n);    -  { +  if (!(n->tree_info & OPT_NOT_SHARED)) {    size_t hash;    if ((hash = hash_node(n)) != n->hash) {    fprintf(stderr, "Hash-value is bad 0x%08lx != 0x%08lx\n",    DO_NOT_WARN((unsigned long)hash),    DO_NOT_WARN((unsigned long)n->hash));    print_tree(n);    fatal("token:%d, car:%p cdr:%p file:%s line:%d\n",    n->token, _CAR(n), _CDR(n), n->current_file->str, n->line_number);    }    }
pike.git/src/las.c:626:   #endif /* SHARED_NODES */       n->parent = NULL;       do {   #ifdef PIKE_DEBUG    if(l_flag>9)    print_tree(n);      #ifdef SHARED_NODES -  { +  if (!(n->tree_info & OPT_NOT_SHARED)) {    size_t hash;    if ((hash = hash_node(n)) != n->hash) {    fprintf(stderr, "Hash-value is bad 0x%08lx != 0x%08lx\n",    DO_NOT_WARN((unsigned long)hash),    DO_NOT_WARN((unsigned long)n->hash));    print_tree(n);    fatal("token:%d, car:%p cdr:%p file:%s line:%d\n",    n->token, _CAR(n), _CDR(n), n->current_file->str, n->line_number);    }    }
pike.git/src/las.c:773:    n->token=USHRT_MAX;    really_free_node_s(n);    break;    } while (n->parent);   }         node *debug_check_node_hash(node *n)   {   #if defined(PIKE_DEBUG) && defined(SHARED_NODES) -  if (n && (n->hash != hash_node(n))) { +  if (n && !(n->tree_info & OPT_NOT_SHARED) && (n->hash != hash_node(n))) {    fprintf(stderr,"Bad node hash at %p, (%s:%d) (token=%d).\n",    n, n->current_file->str, n->line_number,    n->token);    debug_malloc_dump_references(n,0,0,0);    print_tree(n);    fatal("Bad node hash!\n");    }   #endif /* PIKE_DEBUG && SHARED_NODES */    return n;   }
pike.git/src/las.c:1065:    node *res = mkemptynode();    res->token = F_CONSTANT;    res->node_info = OPT_NOT_SHARED;    res->tree_info = OPT_NOT_SHARED;    res->u.sval.type = T_INT;    res->u.sval.subtype = NUMBER_NUMBER;    res->u.sval.u.integer = nr;    res->type=get_type_of_svalue( & res->u.sval);   #ifdef SHARED_NODES    res->refs = 1; -  res->hash = hash_node(res); +  /* res->hash = hash_node(res); */   #endif /* SHARED_NODES */       return res;   }      node *debug_mkfloatnode(FLOAT_TYPE foo)   {    node *res = mkemptynode();    res->token = F_CONSTANT;    copy_shared_string(res->type, float_type_string);
pike.git/src/las.c:3216:    case F_RETURN:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yywarning("Returning a void expression.");    if (!CAR(n)) {   #ifdef SHARED_NODES    sub_node(n);   #endif /* SHARED_NODES */    _CAR(n) = mkintnode(0);    copy_shared_string(n->type, CAR(n)->type);   #ifdef SHARED_NODES +  if (!(n->tree_info & OPT_NOT_SHARED)) {    n->hash = hash_node(n); -  +  }    n->node_info |= OPT_DEFROSTED;    add_node(n);   #endif /* SHARED_NODES */    break;    }    } else if(Pike_compiler->compiler_frame && Pike_compiler->compiler_frame->current_return_type) {    if (!pike_types_le(CAR(n)->type, Pike_compiler->compiler_frame->current_return_type) &&    !(    Pike_compiler->compiler_frame->current_return_type==void_type_string &&    CAR(n)->token == F_CONSTANT &&
pike.git/src/las.c:4284:    OPT_ASSIGNMENT|    OPT_RETURN)) &&    (CAR(n)->tree_info & OPT_TRY_OPTIMIZE) &&    CAR(n)->token != ':')    {   #ifdef SHARED_NODES    sub_node(n);   #endif /* SHARED_NODES */    _CAR(n) = eval(CAR(n));   #ifdef SHARED_NODES -  n->hash = hash_node(n); +     n->node_info |= OPT_DEFROSTED; -  +  if (!(n->tree_info & OPT_NOT_SHARED)) { +  n->hash = hash_node(n);    add_node(n); -  +  }   #endif /* SHARED_NODES */    if(CAR(n)) CAR(n)->parent = n;    zapp_try_optimize(CAR(n)); /* avoid infinite loops */    continue;    }    if(cdr_is_node(n) &&    !(CDR(n)->tree_info & (OPT_NOT_CONST|    OPT_SIDE_EFFECT|    OPT_EXTERNAL_DEPEND|    OPT_ASSIGNMENT|    OPT_RETURN)) &&    (CDR(n)->tree_info & OPT_TRY_OPTIMIZE) &&    CDR(n)->token != ':')    {   #ifdef SHARED_NODES    sub_node(n);   #endif /* SHARED_NODES */    _CDR(n) = eval(CDR(n));   #ifdef SHARED_NODES -  n->hash = hash_node(n); +     n->node_info |= OPT_DEFROSTED; -  +  if (!(n->tree_info & OPT_NOT_SHARED)) { +  n->hash = hash_node(n);    add_node(n); -  +  }   #endif /* SHARED_NODES */    if(CDR(n)) CDR(n)->parent = n;    zapp_try_optimize(CDR(n)); /* avoid infinite loops */    continue;    }    }    if (!n->type || (n->node_info & OPT_TYPE_NOT_FIXED)) {    fix_type_field(n);    }    debug_malloc_touch(n->type);
pike.git/src/las.c:4368:    if(CAR(n->parent) == n)    _CAR(n->parent) = tmp1;    else    _CDR(n->parent) = tmp1;       if (!tmp1 || (tmp1->type != n->type)) {    n->parent->node_info |= OPT_TYPE_NOT_FIXED;    }      #ifdef SHARED_NODES +  n->parent->node_info |= OPT_DEFROSTED; +  if (!(n->tree_info & OPT_NOT_SHARED)) {    n->parent->hash = hash_node(n->parent);    add_node(n->parent); -  n->parent->node_info |= OPT_DEFROSTED; +  }   #endif /* SHARED_NODES */       if(tmp1)    tmp1->parent = n->parent;    else    tmp1 = n->parent;       free_node(n);    n = tmp1;