diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-19 00:36:25 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-19 00:36:25 -0400 |
commit | 29228d6ea14fe216ee7eaf8ee141085257aaf589 (patch) | |
tree | 89e0852febc4e09f787817b7a077653481226e71 | |
parent | 81dac06e17f6cef9217fafa28285a65f6d093014 (diff) | |
download | txr-29228d6ea14fe216ee7eaf8ee141085257aaf589.tar.gz txr-29228d6ea14fe216ee7eaf8ee141085257aaf589.tar.bz2 txr-29228d6ea14fe216ee7eaf8ee141085257aaf589.zip |
* hash.c (ll_hash): Hashing of pointers should take into
account alignment, otherwise only values divisible by the
alignment occur. This patch takes into considerations that
val values are pointers to object descriptors in a heap which
are four words wide, and so most likely aligned to 16 byte
boundaries (32 bit systems) or 32 byte boundaries (64 bit).
We need to shift.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | hash.c | 7 |
2 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,13 @@ +2011-10-19 Kaz Kylheku <kaz@kylheku.com> + + * hash.c (ll_hash): Hashing of pointers should take into + account alignment, otherwise only values divisible by the + alignment occur. This patch takes into considerations that + val values are pointers to object descriptors in a heap which + are four words wide, and so most likely aligned to 16 byte + boundaries (32 bit systems) or 32 byte boundaries (64 bit). + We need to shift. + 2011-10-18 Kaz Kylheku <kaz@kylheku.com> Task #11425 @@ -102,7 +102,12 @@ static cnum ll_hash(val obj) return c_num(obj) & NUM_MAX; case SYM: case PKG: - return ((cnum) obj) & NUM_MAX; + switch (sizeof (mem_t *)) { + case 4: + return (((cnum) obj) & NUM_MAX) >> 4; + case 8: default: + return (((cnum) obj) & NUM_MAX) >> 5; + } case FUN: return ((cnum) obj->f.f.interp_fun + ll_hash(obj->f.env)) & NUM_MAX; case VEC: |