From: Ivan Maidanski Date: Thu, 8 Dec 2016 23:41:54 +0000 (+0300) Subject: Remove page_was_dirty and remove_protection duplicate definitions X-Git-Tag: v8.0.0~1000 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be8ba30a0c0f4c962655a7741d8d53a2fd6cbae8;p=gc Remove page_was_dirty and remove_protection duplicate definitions * include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL] (GC_page_was_dirty): Refine comment (move the comment content from GC_page_was_dirty in os_dep.c). * os_dep.c [GWW_VDB && MPROTECT_VDB] (GC_gww_page_was_dirty): Remove. * os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB] (GC_page_was_dirty): Avoid code duplication (remove the functions of the identical implementation). * os_dep.c [(GWW_VDB || PROC_VDB) && !MPROTECT_VDB || MANUAL_VDB || DEFAULT_VDB] (GC_remove_protection): Likewise. * os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages): Remove nesting of #if. --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 0888be7f..3d80ac44 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2101,11 +2101,18 @@ GC_EXTERN GC_bool GC_print_back_height; /* Retrieve dirty bits. */ GC_INNER GC_bool GC_page_was_dirty(struct hblk *h); /* Read retrieved dirty bits. */ + GC_INNER void GC_remove_protection(struct hblk *h, word nblocks, GC_bool pointerfree); - /* h is about to be written or allocated. Ensure */ - /* that it's not write protected by the virtual */ - /* dirty bit implementation. */ + /* h is about to be written or allocated. Ensure that */ + /* it is not write protected by the virtual dirty bit */ + /* implementation. I.e., this is a call that: */ + /* - hints that [h, h+nblocks) is about to be written; */ + /* - guarantees that protection is removed; */ + /* - may speed up some dirty bit implementations; */ + /* - may be essential if we need to ensure that */ + /* pointer-free system call buffers in the heap are */ + /* not protected. */ GC_INNER void GC_dirty_init(void); #endif /* !GC_DISABLE_INCREMENTAL */ diff --git a/os_dep.c b/os_dep.c index 0c43ca77..8bceee5d 100644 --- a/os_dep.c +++ b/os_dep.c @@ -2713,21 +2713,24 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) GC_INNER GC_bool GC_dirty_maintained = FALSE; #endif -#if defined(PROC_VDB) || defined(GWW_VDB) -# ifdef MPROTECT_VDB - STATIC GC_bool GC_gww_page_was_dirty(struct hblk * h) -# else - GC_INNER GC_bool GC_page_was_dirty(struct hblk * h) -# endif +#if defined(GWW_VDB) || defined(MPROTECT_VDB) || defined(PROC_VDB) \ + || defined(MANUAL_VDB) + /* Is the HBLKSIZE sized page at h marked dirty in the local buffer? */ + /* If the actual page size is different, this returns TRUE if any */ + /* of the pages overlapping h are dirty. This routine may err on the */ + /* side of labeling pages as dirty (and this implementation does). */ + GC_INNER GC_bool GC_page_was_dirty(struct hblk * h) { register word index; + if (HDR(h) == 0) return TRUE; index = PHT_HASH(h); return get_pht_entry_from_index(GC_grungy_pages, index); } +#endif -# if defined(CHECKSUMS) || defined(PROC_VDB) +#if (defined(CHECKSUMS) && defined(GWW_VDB)) || defined(PROC_VDB) /* Add all pages in pht2 to pht1. */ STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2) { @@ -2748,16 +2751,15 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) index = PHT_HASH(h); return get_pht_entry_from_index(GC_written_pages, index); } -# endif /* CHECKSUMS || PROC_VDB */ +#endif /* CHECKSUMS && GWW_VDB || PROC_VDB */ -# ifndef MPROTECT_VDB +#if ((defined(GWW_VDB) || defined(PROC_VDB)) && !defined(MPROTECT_VDB)) \ + || defined(MANUAL_VDB) || defined(DEFAULT_VDB) /* Ignore write hints. They don't help us here. */ GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED, word nblocks GC_ATTR_UNUSED, GC_bool is_ptrfree GC_ATTR_UNUSED) {} -# endif - -#endif /* PROC_VDB || GWW_VDB */ +#endif #ifdef GWW_VDB @@ -2896,16 +2898,6 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) } # endif /* CHECKSUMS */ - /* A call that: */ - /* I) hints that [h, h+nblocks) is about to be written. */ - /* II) guarantees that protection is removed. */ - /* (I) may speed up some dirty bit implementations. */ - /* (II) may be essential if we need to ensure that */ - /* pointer-free system call buffers in the heap are */ - /* not protected. */ - GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED, - word nblocks GC_ATTR_UNUSED, - GC_bool is_ptrfree GC_ATTR_UNUSED) {} #endif /* DEFAULT_VDB */ #ifdef MANUAL_VDB @@ -2926,16 +2918,6 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) BZERO((word *)GC_dirty_pages, (sizeof GC_dirty_pages)); } - /* Is the HBLKSIZE sized page at h marked dirty in the local buffer? */ - /* If the actual page size is different, this returns TRUE if any */ - /* of the pages overlapping h are dirty. This routine may err on the */ - /* side of labeling pages as dirty (and this implementation does). */ - GC_INNER GC_bool GC_page_was_dirty(struct hblk *h) - { - register word index = PHT_HASH(h); - return(HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, index)); - } - # define async_set_pht_entry_from_index(db, index) \ set_pht_entry_from_index(db, index) /* for now */ @@ -2947,10 +2929,6 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) async_set_pht_entry_from_index(GC_dirty_pages, index); } - GC_INNER void GC_remove_protection(struct hblk * h GC_ATTR_UNUSED, - word nblocks GC_ATTR_UNUSED, - GC_bool is_ptrfree GC_ATTR_UNUSED) {} - # ifdef CHECKSUMS /* Could any valid GC heap pointer ever have been written to this page? */ GC_INNER GC_bool GC_page_was_ever_dirty(struct hblk * h GC_ATTR_UNUSED) @@ -3528,19 +3506,6 @@ GC_INNER void GC_read_dirty(void) GC_protect_heap(); } -GC_INNER GC_bool GC_page_was_dirty(struct hblk *h) -{ - register word index; - -# if defined(GWW_VDB) - if (GC_GWW_AVAILABLE()) - return GC_gww_page_was_dirty(h); -# endif - - index = PHT_HASH(h); - return(HDR(h) == 0 || get_pht_entry_from_index(GC_grungy_pages, index)); -} - /* * Acquiring the allocation lock here is dangerous, since this * can be called from within GC_call_with_alloc_lock, and the cord