[m-rev.] for review: revert boehm gc munmap customisations
Peter Wang
novalazy at gmail.com
Mon Mar 1 12:06:49 AEDT 2010
Branches: main
The version of Boehm GC that we recently upgraded to already contains support
for enabling or disabling munmap() support at runtime.
boehm_gc/allchblk.c:
boehm_gc/alloc.c:
boehm_gc/include/gc.h:
boehm_gc/include/private/gc_priv.h:
boehm_gc/malloc.c:
Back out our customisations related to munmap.
doc/user_guide.texi:
runtime/mercury_wrapper.c:
Delete the `--boehm-gc-munmap' MERCURY_OPTIONS variable. Unmapping
will be enabled by default (if compiled in). To disable it at runtime
you can set an environment variable `GC_MUNMAP_THRESHOLD=0'.
diff --git a/boehm_gc/allchblk.c b/boehm_gc/allchblk.c
index 789f343..d6a1437 100644
--- a/boehm_gc/allchblk.c
+++ b/boehm_gc/allchblk.c
@@ -20,11 +20,6 @@
GC_bool GC_use_entire_heap = 0;
-/* For Mercury: this is a hack to control use of munmap() when */
-/* USE_MUNMAP is enabled. Use GC_MERCURY_USE_MUNMAP when checking */
-/* the value of this variable. */
-GC_bool GC_mercury_use_munmap = 0;
-
/*
* Free heap blocks are kept on one of several free lists,
* depending on the size of the block. Each free list is doubly linked.
@@ -55,7 +50,7 @@ STATIC struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 };
/* header structure associated with */
/* block. */
-#if !defined(USE_MUNMAP) || 1 /* GC_MERCURY_USE_MUNMAP */
+#ifndef USE_MUNMAP
STATIC word GC_free_bytes[N_HBLK_FLS+1] = { 0 };
/* Number of free bytes on each list. */
@@ -77,10 +72,7 @@ STATIC struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 };
return 0;
}
-# define INCR_FREE_BYTES(n, b) \
- do { \
- if (!GC_MERCURY_USE_MUNMAP) GC_free_bytes[n] += (b); \
- } while (0)
+# define INCR_FREE_BYTES(n, b) GC_free_bytes[n] += (b);
# define FREE_ASSERT(e) GC_ASSERT(e)
@@ -292,28 +284,24 @@ STATIC void GC_remove_from_fl(hdr *hhdr, int n)
int index;
GC_ASSERT(((hhdr -> hb_sz) & (HBLKSIZE-1)) == 0);
-# if !defined(USE_MUNMAP) || 1 /* GC_MERCURY_USE_MUNMAP */
- if (!GC_MERCURY_USE_MUNMAP) {
- /* We always need index to mainatin free counts. */
+# ifndef USE_MUNMAP
+ /* We always need index to mainatin free counts. */
if (FL_UNKNOWN == n) {
index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
} else {
index = n;
}
- }
# endif
if (hhdr -> hb_prev == 0) {
-# ifdef USE_MUNMAP
- if (GC_MERCURY_USE_MUNMAP) {
- if (FL_UNKNOWN == n) {
+# ifdef USE_MUNMAP
+ if (FL_UNKNOWN == n) {
index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
- } else {
- index = n;
- }
- }
-# endif
- GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr);
- GC_hblkfreelist[index] = hhdr -> hb_next;
+ } else {
+ index = n;
+ }
+# endif
+ GC_ASSERT(HDR(GC_hblkfreelist[index]) == hhdr);
+ GC_hblkfreelist[index] = hhdr -> hb_next;
} else {
hdr *phdr;
GET_HDR(hhdr -> hb_prev, phdr);
@@ -673,10 +661,6 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n,
if (size_avail != size_needed) {
signed_word next_size;
-# ifdef USE_MUNMAP
- if (GC_MERCURY_USE_MUNMAP) continue;
-# endif /* USE_MUNMAP */
-
if (!may_split) continue;
/* If the next heap block is obviously better, go on. */
/* This prevents us from disassembling a single large block */
diff --git a/boehm_gc/alloc.c b/boehm_gc/alloc.c
index f59cf01..e181301 100644
--- a/boehm_gc/alloc.c
+++ b/boehm_gc/alloc.c
@@ -929,9 +929,7 @@ STATIC void GC_finish_collection(void)
GC_finalizer_bytes_freed = 0;
# ifdef USE_MUNMAP
- if (GC_MERCURY_USE_MUNMAP) {
- GC_unmap_old();
- }
+ GC_unmap_old();
# endif
# ifndef SMALL_CONFIG
diff --git a/boehm_gc/include/gc.h b/boehm_gc/include/gc.h
index 24503b1..52ebed9 100644
--- a/boehm_gc/include/gc.h
+++ b/boehm_gc/include/gc.h
@@ -326,9 +326,6 @@ GC_API unsigned long GC_time_limit;
GC_API void GC_CALL GC_set_time_limit(unsigned long);
GC_API unsigned long GC_CALL GC_get_time_limit(void);
-GC_API int GC_mercury_use_munmap;
- /* Whether to use munmap(). Only */
- /* effective if USE_MUNMAP is defined. */
GC_API int GC_mercury_calc_gc_time;
/* Whether to calculate the time taken */
/* by garbage collections. If yes, the */
diff --git a/boehm_gc/include/private/gc_priv.h b/boehm_gc/include/private/gc_priv.h
index 387adfb..56e7458 100644
--- a/boehm_gc/include/private/gc_priv.h
+++ b/boehm_gc/include/private/gc_priv.h
@@ -1894,9 +1894,6 @@ GC_EXTERN GC_bool GC_print_back_height;
GC_INNER void GC_remap(ptr_t start, size_t bytes);
GC_INNER void GC_unmap_gap(ptr_t start1, size_t bytes1, ptr_t start2,
size_t bytes2);
- #define GC_MERCURY_USE_MUNMAP GC_mercury_use_munmap
-#else
- #define GC_MERCURY_USE_MUNMAP 0
#endif
/* Virtual dirty bit implementation: */
diff --git a/boehm_gc/malloc.c b/boehm_gc/malloc.c
index 790def6..f6a3f3f 100644
--- a/boehm_gc/malloc.c
+++ b/boehm_gc/malloc.c
@@ -60,10 +60,10 @@ GC_INNER ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)
GC_collect_a_little_inner((int)n_blocks);
h = GC_allochblk(lb, k, flags);
# ifdef USE_MUNMAP
- if (0 == h && GC_MERCURY_USE_MUNMAP) {
- GC_merge_unmapped();
- h = GC_allochblk(lb, k, flags);
- }
+ if (0 == h) {
+ GC_merge_unmapped();
+ h = GC_allochblk(lb, k, flags);
+ }
# endif
while (0 == h && GC_collect_or_expand(n_blocks, flags != 0, retry)) {
h = GC_allochblk(lb, k, flags);
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 3ccf2ca..ede8edb 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -10185,14 +10185,6 @@ The default maximum value of @var{N} is 20.
@c testing the code writing out deep profiling data).
@sp 1
- at item --boehm-gc-munmap
- at findex --boehm-gc-munmap
-This option enables code in the Boehm garbage collector to return unused memory
-pages back to the operating system. It is meaningful only when using the Boehm
-garbage collector, and requires @samp{--enable-gc-munmap} to be passed to
- at samp{configure}. (This may not work with all platforms).
-
- at sp 1
@item --boehm-gc-free-space-divisor=@var{N}
@findex --boehm-gc-free-space-divisor=@var{N}
This option sets the value of the free space divisor in the Boehm garbage
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index c827cc3..1a302f3 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -1287,7 +1287,6 @@ enum MR_long_option {
MR_COVERAGE_TEST_IF_EXEC_OPT,
MR_TRACE_COUNT_FILE,
MR_MEM_USAGE_REPORT,
- MR_BOEHM_GC_MUNMAP,
MR_BOEHM_GC_FREE_SPACE_DIVISOR,
MR_BOEHM_GC_CALC_TIME,
MR_FP_ROUNDING_MODE
@@ -1399,7 +1398,6 @@ struct MR_option MR_long_opts[] = {
{ "tc-summary-max", 1, 0, MR_TRACE_COUNT_SUMMARY_MAX_OPT },
{ "trace-count-summary-max", 1, 0, MR_TRACE_COUNT_SUMMARY_MAX_OPT },
{ "mem-usage-report", 1, 0, MR_MEM_USAGE_REPORT },
- { "boehm-gc-munmap", 0, 0, MR_BOEHM_GC_MUNMAP },
{ "boehm-gc-free-space-divisor", 1, 0, MR_BOEHM_GC_FREE_SPACE_DIVISOR },
{ "boehm-gc-calc-time", 0, 0, MR_BOEHM_GC_CALC_TIME },
{ "fp-rounding-mode", 1, 0, MR_FP_ROUNDING_MODE },
@@ -1979,12 +1977,6 @@ MR_process_options(int argc, char **argv)
MR_mem_usage_report_prefix = MR_copy_string(MR_optarg);
break;
- case MR_BOEHM_GC_MUNMAP:
-#ifdef MR_BOEHM_GC
- GC_mercury_use_munmap = MR_TRUE;
-#endif
- break;
-
case MR_BOEHM_GC_FREE_SPACE_DIVISOR:
if (sscanf(MR_optarg, "%lu", &size) != 1) {
MR_usage();
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list