Commit 61ddb1b9 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* src/lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.

* src/fns.c (hashfn_eq, hashfn_eql, sxhash):
* src/profiler.c (hashfn_profiler): Don't use XUINT on non-integers.
* src/buffer.c (compare_overlays): Use XLI rather than XHASH.
parent 04a2d0d3
2012-11-08 Stefan Monnier <monnier@iro.umontreal.ca>
* lisp.h (XHASH): Redefine to be imperfect and fit in a Lisp int.
* fns.c (hashfn_eq, hashfn_eql, sxhash):
* profiler.c (hashfn_profiler): Don't use XUINT on non-integers.
* buffer.c (compare_overlays): Use XLI rather than XHASH.
2012-11-08 Paul Eggert <eggert@cs.ucla.edu>
 
Use same hash function for hashfn_profiler as for hash_string etc.
......
......@@ -3132,8 +3132,8 @@ compare_overlays (const void *v1, const void *v2)
between "equal" overlays. The result can still change between
invocations of Emacs, but it won't change in the middle of
`find_field' (bug#6830). */
if (XHASH (s1->overlay) != XHASH (s2->overlay))
return XHASH (s1->overlay) < XHASH (s2->overlay) ? -1 : 1;
if (!EQ (s1->overlay, s2->overlay))
return XLI (s1->overlay) < XLI (s2->overlay) ? -1 : 1;
return 0;
}
......
......@@ -3479,7 +3479,7 @@ cmpfn_user_defined (struct hash_table_test *ht,
static EMACS_UINT
hashfn_eq (struct hash_table_test *ht, Lisp_Object key)
{
EMACS_UINT hash = XUINT (key) ^ XTYPE (key);
EMACS_UINT hash = XHASH (key) ^ XTYPE (key);
return hash;
}
......@@ -3494,7 +3494,7 @@ hashfn_eql (struct hash_table_test *ht, Lisp_Object key)
if (FLOATP (key))
hash = sxhash (key, 0);
else
hash = XUINT (key) ^ XTYPE (key);
hash = XHASH (key) ^ XTYPE (key);
return hash;
}
......@@ -4173,7 +4173,7 @@ sxhash (Lisp_Object obj, int depth)
break;
case Lisp_Misc:
hash = XUINT (obj);
hash = XHASH (obj);
break;
case Lisp_Symbol:
......@@ -4197,7 +4197,7 @@ sxhash (Lisp_Object obj, int depth)
else
/* Others are `equal' if they are `eq', so let's take their
address as hash. */
hash = XUINT (obj);
hash = XHASH (obj);
break;
case Lisp_Cons:
......
......@@ -454,9 +454,6 @@ enum More_Lisp_Bits
For example, if tem is a Lisp_Object whose type is Lisp_Cons,
XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
/* Return a perfect hash of the Lisp_Object representation. */
#define XHASH(a) XLI (a)
#if USE_LSB_TAG
enum lsb_bits
......@@ -509,6 +506,11 @@ static EMACS_INT const VALMASK
#endif /* not USE_LSB_TAG */
/* Return a (Lisp-integer sized) hash of the Lisp_Object value. Happens to be
like XUINT right now, but XUINT should only be applied to objects we know
are integers. */
#define XHASH(a) XUINT (a)
/* For integers known to be positive, XFASTINT sometimes provides
faster retrieval and XSETFASTINT provides faster storage.
If not, fallback on the non-accelerated path. */
......@@ -524,7 +526,7 @@ static EMACS_INT const VALMASK
# define XUNTAG(a, type) XPNTR (a)
#endif
#define EQ(x, y) (XHASH (x) == XHASH (y))
#define EQ(x, y) (XLI (x) == XLI (y))
/* Largest and smallest representable fixnum values. These are the C
values. They are macros for use in static initializers. */
......
......@@ -798,7 +798,7 @@ safe_debug_print (Lisp_Object arg)
else
fprintf (stderr, "#<%s_LISP_OBJECT 0x%08"pI"x>\r\n",
!valid ? "INVALID" : "SOME",
XHASH (arg));
XLI (arg));
}
......
......@@ -555,15 +555,15 @@ hashfn_profiler (struct hash_table_test *ht, Lisp_Object bt)
{
Lisp_Object f = AREF (bt, i);
EMACS_UINT hash1
= (COMPILEDP (f) ? XUINT (AREF (f, COMPILED_BYTECODE))
= (COMPILEDP (f) ? XHASH (AREF (f, COMPILED_BYTECODE))
: (CONSP (f) && CONSP (XCDR (f)) && EQ (Qclosure, XCAR (f)))
? XUINT (XCDR (XCDR (f))) : XUINT (f));
? XHASH (XCDR (XCDR (f))) : XHASH (f));
hash = sxhash_combine (hash, hash1);
}
return (hash & INTMASK);
}
else
return XUINT (bt);
return XHASH (bt);
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment