Changeset 1889 for trunk/src


Ignore:
Timestamp:
Oct 20, 2008, 1:31:38 AM (17 years ago)
Author:
bird
Message:

kmk: cleaned out the VARIABLE_HASH code (was removed in favor of the a variable strcache).

Location:
trunk/src/kmk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/Makefile.am

    r1870 r1889  
    114114        -DKMK \
    115115        -DKMK_HELPERS \
    116         -DVARIABLE_HASH \
    117116        -DCONFIG_NO_DEFAULT_SUFFIXES \
    118117        -DCONFIG_NO_DEFAULT_PATTERN_RULES       \
  • trunk/src/kmk/make.h

    r1885 r1889  
    150150#endif
    151151
    152 #if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH) || defined (VARIABLE_HASH)
     152#if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH)
    153153# ifdef _MSC_VER
    154154#  define MY_INLINE     _inline static
  • trunk/src/kmk/variable.c

    r1888 r1889  
    110110/* Hash table of all global variable definitions.  */
    111111
    112 #if defined(VARIABLE_HASH) || defined(CONFIG_WITH_OPTIMIZATION_HACKS) || defined(CONFIG_WITH_STRCACHE2)
    113 MY_INLINE unsigned long variable_hash_2i(register const char *var, register int length)
    114 {
    115     /* all requests are served from the cache. */
    116     return strcache2_get_hash2 (&variable_strcache, var);
    117 }
    118 
    119 MY_INLINE unsigned long variable_hash_1i(register const char *var, register int length)
    120 {
    121     /* all requests are served from the cache. */
    122     return strcache2_get_hash1 (&variable_strcache, var);
    123 }
    124 #endif /* CONFIG_WITH_OPTIMIZATION_HACKS */
    125 
    126112static unsigned long
    127113variable_hash_1 (const void *keyv)
    128114{
    129115  struct variable const *key = (struct variable const *) keyv;
    130 #ifdef VARIABLE_HASH /* bird */
    131 # ifdef VARIABLE_HASH_STRICT
    132   if (key->hash1 != variable_hash_1i (key->name, key->length))
    133     __asm__("int3");
    134   if (key->hash2 && key->hash2 != variable_hash_2i (key->name, key->length))
    135     __asm__("int3");
    136 # endif
    137   return key->hash1;
    138 #else
    139 # if defined(CONFIG_WITH_STRCACHE2)
    140   return variable_hash_1i (key->name, key->length);
    141 # else
     116#ifndef CONFIG_WITH_STRCACHE2
    142117  return_STRING_N_HASH_1 (key->name, key->length);
    143 # endif
     118#else
     119  /* all requests are served from the cache. */
     120  return strcache2_get_hash1 (&variable_strcache, key->name);
    144121#endif
    145122}
     
    148125variable_hash_2 (const void *keyv)
    149126{
    150 #ifdef VARIABLE_HASH /* bird */
    151   struct variable *key = (struct variable *) keyv;
    152   if (!key->hash2)
    153     key->hash2 = variable_hash_2i (key->name, key->length);
    154   return key->hash2;
    155 #else
    156127  struct variable const *key = (struct variable const *) keyv;
    157 # ifdef CONFIG_WITH_STRCACHE2
    158   return variable_hash_2i (key->name, key->length);
    159 # else
     128#ifndef CONFIG_WITH_STRCACHE2
    160129  return_STRING_N_HASH_2 (key->name, key->length);
    161 # endif
     130#else
     131  /* all requests are served from the cache. */
     132  return strcache2_get_hash2 (&variable_strcache, key->name);
    162133#endif
    163134}
     
    253224  var_key.name = (char *) name;
    254225#else
    255   var_key.value = NULL; /* hack: name cached. (value != var) */
    256226  var_key.name = name = strcache2_add (&variable_strcache, name, length);
    257227#endif
    258228  var_key.length = length;
    259 #ifdef VARIABLE_HASH /* bird */
    260   var_key.hash1 = variable_hash_1i (name, length);
    261   var_key.hash2 = 0;
    262 #endif
    263229  var_slot = (struct variable **) hash_find_slot (&set->table, &var_key);
    264230
     
    330296#endif
    331297  v->length = length;
    332 #ifdef VARIABLE_HASH /* bird */
    333   v->hash1 = variable_hash_1i (name, length); /* FIXME: Unnecessary! */
    334   v->hash2 = 0;
    335 #endif
    336298  hash_insert_at (&set->table, v, var_slot);
    337299#ifdef CONFIG_WITH_VALUE_LENGTH
     
    487449  const struct variable_set_list *setlist;
    488450  struct variable var_key;
    489 #if defined(KMK) && !defined(VARIABLE_HASH)
     451#ifdef KMK
    490452  unsigned int hash_2 = 0;
    491453#endif
     
    503465  var_key.name = (char *) name;
    504466  var_key.length = length;
    505 #ifdef VARIABLE_HASH /* bird */
    506   var_key.hash1 = variable_hash_1i (name, length);
    507   var_key.hash2 = 0;
    508 #endif
    509467#ifdef CONFIG_WITH_STRCACHE2
    510468  var_key.value = (char *)&var_key; /* hack: name not cached */
     
    514472       setlist != 0; setlist = setlist->next)
    515473    {
    516 #if defined(KMK) /* bird: speed */
     474#ifdef KMK /* bird: speed */
    517475      struct hash_table *ht = &setlist->set->table;
    518 # ifdef VARIABLE_HASH
    519       unsigned int hash_1 = var_key.hash1;
    520 # else
    521476      unsigned int hash_1 = strcache2_get_hash1 (&variable_strcache, name);
    522 # endif
    523477      struct variable *v;
    524478
     
    535489              if (variable_hash_cmp(&var_key, v) == 0)
    536490                {
    537 # ifdef VARIABLE_HASH_STRICT /* bird */
     491# ifndef NDEBUG
    538492                  struct variable *v2 = (struct variable *) hash_find_item ((struct hash_table *) &setlist->set->table, &var_key);
    539493                  assert (v2 == v);
     
    543497              ht->ht_collisions++;
    544498            }
    545 # ifdef VARIABLE_HASH
    546           if (!var_key.hash2)
    547              var_key.hash2 = variable_hash_2i(name, length);
    548           hash_1 += (var_key.hash2 | 1);
    549 # else
    550499          if (!hash_2)
    551500            {
    552               hash_2 = strcache2_get_hash2 (&variable_strcache, name, length);
     501              hash_2 = strcache2_get_hash2 (&variable_strcache, name);
    553502              assert (hash_2 & 1);
    554503            }
    555504          hash_1 += hash_2;
    556 # endif
    557505        }
    558506
    559 #else /* !VARIABLE_HASH */
     507#else /* !KMK */
    560508      const struct variable_set *set = setlist->set;
    561509      struct variable *v;
     
    564512      if (v)
    565513        return v->special ? handle_special_var (v) : v;
    566 #endif /* !VARIABLE_HASH */
     514#endif /* !KMK */
    567515    }
    568516
     
    650598  var_key.name = (char *) name;
    651599  var_key.length = length;
    652 #ifdef VARIABLE_HASH /* bird */
    653   var_key.hash1 = variable_hash_1i (name, length);
    654   var_key.hash2 = 0;
    655 #endif
    656600#ifdef CONFIG_WITH_STRCACHE2
    657601  var_key.value = (char *)&var_key; /* hack: name not cached */
     
    13261270  char **result_0;
    13271271  char **result;
     1272#ifdef CONFIG_WITH_STRCACHE2
     1273  const char *cached_name;
     1274#endif
    13281275
    13291276  if (file == 0)
     
    14131360  makelevel_key.name = MAKELEVEL_NAME;
    14141361  makelevel_key.length = MAKELEVEL_LENGTH;
    1415 #ifdef VARIABLE_HASH /* bird */
    1416   makelevel_key.hash1 = variable_hash_1i (MAKELEVEL_NAME, MAKELEVEL_LENGTH);
    1417   makelevel_key.hash2 = 0;
    1418 #endif
    1419 #ifdef CONFIG_WITH_STRCACHE2
    1420   makelevel_key.value = (char *)&makelevel_key; /* hack: name not cached */
    1421 #endif
    14221362  hash_delete (&table, &makelevel_key);
    14231363#else  /* CONFIG_WITH_STRCACHE2 */
    14241364  /* lookup the name in the string case, if it's not there it won't
    14251365     be in any of the sets either. */
    1426   {
    1427     const char *cached_name = strcache2_lookup(&variable_strcache,
    1428                                                MAKELEVEL_NAME, MAKELEVEL_LENGTH);
    1429     if (cached_name)
    1430       {
    1431         makelevel_key.name = cached_name;
    1432         makelevel_key.length = MAKELEVEL_LENGTH;
    1433 #ifdef VARIABLE_HASH /* bird */
    1434         makelevel_key.hash1 = variable_hash_1i (MAKELEVEL_NAME, MAKELEVEL_LENGTH);
    1435         makelevel_key.hash2 = 0;
    1436 #endif
    1437         makelevel_key.value = NULL;
    1438         hash_delete (&table, &makelevel_key);
    1439       }
    1440   }
     1366  cached_name = strcache2_lookup(&variable_strcache,
     1367                                 MAKELEVEL_NAME, MAKELEVEL_LENGTH);
     1368  if (cached_name)
     1369    {
     1370      makelevel_key.name = cached_name;
     1371      makelevel_key.length = MAKELEVEL_LENGTH;
     1372      hash_delete (&table, &makelevel_key);
     1373    }
    14411374#endif /* CONFIG_WITH_STRCACHE2 */
    14421375
     
    20802013#endif
    20812014
     2015#ifndef CONFIG_WITH_STRCACHE2
    20822016  free (v.name);
     2017#else
     2018  free ((char *)v.name);
     2019#endif
    20832020
    20842021  return vp;
  • trunk/src/kmk/variable.h

    r1877 r1889  
    6060    char *name;                 /* Variable name.  */
    6161#else
    62     const char *name;           /* Variable name.  */
     62    const char *name;           /* Variable name (in varaible_strcache).  */
    6363#endif
    6464    int length;                 /* strlen (name) */
    65 #ifdef VARIABLE_HASH /* bird */
    66     int hash1;                  /* the primary hash */
    67     int hash2;                  /* the secondary hash */
    68 #endif
    6965#ifdef CONFIG_WITH_VALUE_LENGTH
    7066    int value_length;           /* The length of the value, usually unused.  */
Note: See TracChangeset for help on using the changeset viewer.