From fa3ceb0a75bcab7750c1eab32405d64f61c61808 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 11 Jul 2008 19:26:46 -0600 Subject: [PATCH] add assertions to hashMapResize and hashMapRemove to help debug rare infinite loop --- src/util.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index a929c9e153..aeb6593f46 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -321,6 +321,7 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object), unsigned index = hash(t, k) & (newLength - 1); + expect(t, p != arrayBody(t, newArray, index)); set(t, p, TripleThird, arrayBody(t, newArray, index)); set(t, newArray, ArrayBody + (index * BytesPerWord), p); } @@ -333,7 +334,7 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object), void hashMapInsert(Thread* t, object map, object key, object value, - uint32_t (*hash)(Thread*, object)) + uint32_t (*hash)(Thread*, object)) { // note that we reinitialize the array and index variables whenever // an allocation (and thus possibly a collection) occurs, in case @@ -387,6 +388,7 @@ object hashMapRemoveNode(Thread* t, object map, unsigned index, object p, object n) { if (p) { + expect(t, p != tripleThird(t, n)); set(t, p, TripleThird, tripleThird(t, n)); } else { set(t, hashMapArray(t, map), ArrayBody + (index * BytesPerWord),