+static inline uintptr_t *actually_valid_pair(const struct htable *ht)
+{
+ return ht->table + ((size_t)1 << ht->bits);
+}
+
+/* We have have two entries which look deleted, but we remember
+ * they are not! */
+static inline bool entry_actually_valid(const struct htable *ht, size_t off)
+{
+ const uintptr_t *valid = actually_valid_pair(ht);
+ /* Empty table looks like this! */
+ if (valid == &ht->common_bits + 1)
+ return false;
+ return valid[0] == off || valid[1] == off;
+}
+
+/* Initialize the "actually valid" pair. */
+static inline void init_actually_valid(struct htable *ht)
+{
+ uintptr_t *valid = actually_valid_pair(ht);
+ valid[0] = valid[1] = ((size_t)1 << ht->bits);
+}
+
+/* Add to the "actually valid" pair: there can only ever be two! */
+static COLD void add_actually_valid(struct htable *ht, size_t off)
+{
+ uintptr_t *valid = actually_valid_pair(ht);
+ if (valid[0] == ((size_t)1 << ht->bits))
+ valid[0] = off;
+ else {
+ assert(valid[1] == ((size_t)1 << ht->bits));
+ valid[1] = off;
+ }
+}
+
+static COLD void del_actually_valid(struct htable *ht, size_t off)
+{
+ uintptr_t *validpair = actually_valid_pair(ht);
+ if (validpair[0] == off)
+ validpair[0] = ((size_t)1 << ht->bits);
+ else {
+ assert(validpair[1] == off);
+ validpair[1] = ((size_t)1 << ht->bits);
+ }
+}
+
+/* If this entry looks invalid, check entry_actually_valid! */
+static inline bool entry_looks_invalid(const struct htable *ht, size_t off)
+{
+ return ht->table[off] <= HTABLE_DELETED;
+}
+
+static inline bool entry_is_valid(const struct htable *ht, size_t off)
+{
+ if (!entry_looks_invalid(ht, off))
+ return true;
+ return entry_actually_valid(ht, off);
+}
+
+static inline bool entry_is_deleted(const struct htable *ht, size_t off)