X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fgc-common.c;h=b76dc55161a72389a7eede4c9250d5d6d9dceabf;hb=068cf4b55af3f8f8acf2c7c06869441612261cd4;hp=584f9d71ac259a12883f464f19e85b0406b47a66;hpb=5fffbb72d9871ab7c4b46306dc52dae68fb375ab;p=sbcl.git diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index 584f9d7..b76dc55 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -1638,7 +1638,7 @@ scav_hash_table_entries (struct hash_table *hash_table) unsigned long hash_vector_length; lispobj empty_symbol; lispobj weakness = hash_table->weakness; - long i; + unsigned long i; kv_vector = get_array_data(hash_table->table, SIMPLE_VECTOR_WIDETAG, &kv_length); @@ -1685,66 +1685,14 @@ scav_hash_table_entries (struct hash_table *hash_table) /* Scavenge the key and value. */ scavenge(&kv_vector[2*i],2); - /* Rehashing of EQ based keys. */ - if ((!hash_vector) || - (hash_vector[i] == MAGIC_HASH_VECTOR_VALUE)) { -#ifndef LISP_FEATURE_GENCGC - /* For GENCGC scav_hash_table_entries only rehashes - * the entries whose keys were moved. Cheneygc always - * moves the objects so here we let the lisp side know - * that rehashing is needed for the whole table. */ - *(kv_vector - 2) = (subtype_VectorMustRehash<needing_rehash); - hash_table->needing_rehash = make_fixnum(i); - /*SHOW("P2");*/ - } else { - unsigned long prior = index_vector[old_index]; - unsigned long next = next_vector[prior]; - - /*FSHOW((stderr, "/P3a %d %d\n", prior, next));*/ - - while (next != 0) { - /*FSHOW((stderr, "/P3b %d %d\n", prior, next));*/ - if (next == i) { - /* Unlink it. */ - next_vector[prior] = next_vector[next]; - /* Link it into the needing rehash - * chain. */ - next_vector[next] = - fixnum_value(hash_table->needing_rehash); - hash_table->needing_rehash = make_fixnum(next); - /*SHOW("/P3");*/ - break; - } - prior = next; - next = next_vector[next]; - } - } + + if (old_key != new_key && new_key != empty_symbol) { + hash_table->needs_rehash_p = T; } -#endif } } } @@ -1770,7 +1718,18 @@ scav_vector (lispobj *where, lispobj object) /* Scavenge element 0, which may be a hash-table structure. */ scavenge(where+2, 1); if (!is_lisp_pointer(where[2])) { - lose("no pointer at %x in hash table\n", where[2]); + /* This'll happen when REHASH clears the header of old-kv-vector + * and fills it with zero, but some other thread simulatenously + * sets the header in %%PUTHASH. + */ + fprintf(stderr, + "Warning: no pointer at %lx in hash table: this indicates " + "non-fatal corruption caused by concurrent access to a " + "hash-table from multiple threads. Any accesses to " + "hash-tables shared between threads should be protected " + "by locks.\n", (unsigned long)&where[2]); + // We've scavenged three words. + return 3; } hash_table = (struct hash_table *)native_pointer(where[2]); /*FSHOW((stderr,"/hash_table = %x\n", hash_table));*/ @@ -1868,7 +1827,7 @@ scan_weak_hash_table (struct hash_table *hash_table) lispobj *hash_vector; lispobj empty_symbol; lispobj weakness = hash_table->weakness; - long i; + unsigned long i; kv_vector = get_array_data(hash_table->table, SIMPLE_VECTOR_WIDETAG, NULL); @@ -1886,13 +1845,6 @@ scan_weak_hash_table (struct hash_table *hash_table) kv_vector, index_vector, next_vector, hash_vector, empty_symbol, weakness); } - { - lispobj first = fixnum_value(hash_table->needing_rehash); - scan_weak_hash_table_chain(hash_table, &first, - kv_vector, index_vector, next_vector, - hash_vector, empty_symbol, weakness); - hash_table->needing_rehash = make_fixnum(first); - } } /* Remove dead entries from weak hash tables. */ @@ -1951,7 +1903,7 @@ size_lose(lispobj *where) void gc_init_tables(void) { - long i; + unsigned long i; /* Set default value in all slots of scavenge table. FIXME * replace this gnarly sizeof with something based on @@ -2499,7 +2451,7 @@ maybe_gc(os_context_t *context) /* SIG_STOP_FOR_GC needs to be enabled before we can call lisp: * otherwise two threads racing here may deadlock: the other will * wait on the GC lock, and the other cannot stop the first one... */ - funcall0(SymbolFunction(SUB_GC)); + funcall0(StaticSymbolFunction(SUB_GC)); undo_fake_foreign_function_call(context); return 1; }