summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-19 00:36:25 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-19 00:36:25 -0400
commit29228d6ea14fe216ee7eaf8ee141085257aaf589 (patch)
tree89e0852febc4e09f787817b7a077653481226e71
parent81dac06e17f6cef9217fafa28285a65f6d093014 (diff)
downloadtxr-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--ChangeLog10
-rw-r--r--hash.c7
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e5573ec5..d6bf9bbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/hash.c b/hash.c
index ece2fa46..7dbabacd 100644
--- a/hash.c
+++ b/hash.c
@@ -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: