+2009-06-20 Hans Boehm <Hans.Boehm@hp.com>
+
+ * allchblk.c (GC_allochblk_nth): Add assertion.
+ * checksums.c: Add GC_record_fault, GC_was_faulted,
+ CC_n_faulted_dirty_errors.
+ (GC_check_dirty): Remove register declarations, print
+ dirty bit errors on faulted pages.
+ * os_dep.c (GC_write_fault_handler): Call GC_record_fault().
+ * os_dep.c (GC_remove_protection): Compute index correctly.
+
2009-06-12 Hans Boehm <Hans.Boehm@hp.com>
* include/gc_version.h, configure.ac, doc/README:
/* Notify virtual dirty bit implementation that we are about to write. */
/* Ensure that pointerfree objects are not protected if it's avoidable. */
+ /* This also ensures that newly allocated blocks are treated as dirty. */
+ /* Necessary since we don't protect free blocks. */
+ GC_ASSERT((size_needed & (HBLKSIZE-1)) == 0);
GC_remove_protection(hbp, divHBLKSZ(size_needed),
(hhdr -> hb_descr == 0) /* pointer-free */);
page_entry GC_sums [NSUMS];
+STATIC word GC_faulted[NSUMS]; /* Record of pages on which we saw a write */
+ /* fault. */
+STATIC size_t GC_n_faulted = 0;
+
+void GC_record_fault(struct hblk * h)
+{
+ word page = (word)h;
+
+ page += GC_page_size - 1;
+ page &= ~(GC_page_size - 1);
+ if (GC_n_faulted >= NSUMS) ABORT("write fault log overflowed");
+ GC_faulted[GC_n_faulted++] = page;
+}
+
+STATIC GC_bool GC_was_faulted(struct hblk *h)
+{
+ size_t i;
+ word page = (word)h;
+
+ page += GC_page_size - 1;
+ page &= ~(GC_page_size - 1);
+ for (i = 0; i < GC_n_faulted; ++i) {
+ if (GC_faulted[i] == page) return TRUE;
+ }
+ return FALSE;
+}
+
STATIC word GC_checksum(struct hblk *h)
{
register word *p = (word *)h;
# endif
int GC_n_dirty_errors;
+int GC_n_faulted_dirty_errors;
int GC_n_changed_errors;
int GC_n_clean;
int GC_n_dirty;
&& hhdr != 0 && hhdr -> hb_descr != 0 /* may contain pointers */
&& pe -> old_sum != pe -> new_sum) {
if (!GC_page_was_dirty(h) || !GC_page_was_ever_dirty(h)) {
+ GC_bool was_faulted = GC_was_faulted(h);
/* Set breakpoint here */GC_n_dirty_errors++;
+ if (was_faulted) GC_n_faulted_dirty_errors++;
}
# ifdef STUBBORN_ALLOC
if (!HBLK_IS_FREE(hhdr)
/* Should be called immediately after GC_read_dirty and GC_read_changed. */
void GC_check_dirty(void)
{
- register int index;
- register unsigned i;
- register struct hblk *h;
- register ptr_t start;
+ int index;
+ unsigned i;
+ struct hblk *h;
+ ptr_t start;
GC_check_blocks();
GC_n_dirty_errors = 0;
+ GC_n_faulted_dirty_errors = 0;
GC_n_changed_errors = 0;
GC_n_clean = 0;
GC_n_dirty = 0;
GC_printf("Checked %lu clean and %lu dirty pages\n",
(unsigned long) GC_n_clean, (unsigned long) GC_n_dirty);
if (GC_n_dirty_errors > 0) {
- GC_printf("Found %lu dirty bit errors\n",
- (unsigned long)GC_n_dirty_errors);
+ GC_printf("Found %d dirty bit errors (%d were faulted)\n",
+ GC_n_dirty_errors, GC_n_faulted_dirty_errors);
}
if (GC_n_changed_errors > 0) {
GC_printf("Found %lu changed bit errors\n",
"Also expect 1 per thread currently allocating a stubborn obj.\n");
# endif
}
+ for (i = 0; i < GC_n_faulted; ++i) {
+ GC_faulted[i] = 0; /* Don't expose block pointers to GC */
+ }
+ GC_n_faulted = 0;
}
# else
set_pht_entry_from_index(db, index)
#endif /* !THREADS */
+#ifdef CHECKSUMS
+ void GC_record_fault(struct hblk * h);
+ /* From checksums.c */
+#endif
+
#if !defined(DARWIN)
# include <errno.h>
# if defined(FREEBSD)
register struct hblk * h =
(struct hblk *)((word)addr & ~(GC_page_size-1));
GC_bool in_allocd_block;
+# ifdef CHECKSUMS
+ GC_record_fault(h);
+# endif /* CHECKSUMS */
# ifdef SUNOS5SIGS
/* Address is only within the correct physical page. */
return;
}
for (current = h_trunc; current < h_end; ++current) {
- size_t index = PHT_HASH(h_trunc);
+ size_t index = PHT_HASH(current);
if (!is_ptrfree || current < h || current >= h + nblocks) {
async_set_pht_entry_from_index(GC_dirty_pages, index);
}