diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2017-06-29 10:47:50 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2017-06-29 10:47:50 +0300 |
commit | 922c747f558a220c8a87359c2abd6b6e0d991b6b (patch) | |
tree | f4ae86b7deb31795c8319d68a271a649299c7e85 /allchblk.c | |
parent | 6bfc8404c23dd74996967ff4d38266b30983ea60 (diff) | |
download | bdwgc-922c747f558a220c8a87359c2abd6b6e0d991b6b.tar.gz |
Decide between memory unmapping and mprotect-based dirty bits at runtime
* allchblk.c [USE_MUNMAP && MPROTECT_VDB] (GC_has_unmapped_memory): New
function.
* include/private/gcconfig.h [USE_MUNMAP] (MPROTECT_VDB): Do not
undefine unless GWW_VDB; update comment.
* os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory,
GC_mprotect_dirty_init): Declare function.
* os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_dirty_init): Ensure
mprotect-based virtual dirty bits and memory unmapping are not both
turned on (disable on of them and call WARN with the appropriate
message), and call GC_mprotect_dirty_init (unless memory unmapping is
requested or some pages are already unmapped).
* os_dep.c [MPROTECT_VDB && !USE_MUNMAP] (GC_mprotect_dirty_init):
Define as a macro (to GC_dirty_init).
* os_dep.c [MPROTECT_VDB] (GC_dirty_init): Rename to
GC_mprotect_dirty_init.
Diffstat (limited to 'allchblk.c')
-rw-r--r-- | allchblk.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -417,6 +417,24 @@ GC_INNER void GC_unmap_old(void) } } +# ifdef MPROTECT_VDB + GC_INNER GC_bool GC_has_unmapped_memory(void) + { + int i; + + for (i = 0; i <= N_HBLK_FLS; ++i) { + struct hblk * h; + hdr * hhdr; + + for (h = GC_hblkfreelist[i]; h != NULL; h = hhdr -> hb_next) { + hhdr = HDR(h); + if (!IS_MAPPED(hhdr)) return TRUE; + } + } + return FALSE; + } +# endif /* MPROTECT_VDB */ + /* Merge all unmapped blocks that are adjacent to other free */ /* blocks. This may involve remapping, since all blocks are either */ /* fully mapped or fully unmapped. */ |