diff options
-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: |