[MLton-commit] r6271

Matthew Fluet fluet at mlton.org
Fri Dec 14 21:17:36 PST 2007


Applied Wesley Terpstra's 'dumpable-core.patch', with some
modifications:
* drop extra "Out of memory." messages
* use 'may-page-heap' rather than 'dumpable-core' as option name.

Added runtime option 'may-page-heap {false|true}', to enable paging
the heap to disk when unable to grow the heap to a desired size.


----------------------------------------------------------------------

U   mlton/trunk/doc/changelog
U   mlton/trunk/man/mlton.1
U   mlton/trunk/runtime/gc/controls.h
U   mlton/trunk/runtime/gc/heap.c
U   mlton/trunk/runtime/gc/init.c

----------------------------------------------------------------------

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2007-12-15 03:10:38 UTC (rev 6270)
+++ mlton/trunk/doc/changelog	2007-12-15 05:17:34 UTC (rev 6271)
@@ -1,6 +1,12 @@
 Here are the changes from version 20070826 to version YYYYMMDD.
 
 * 2007-12-14
+   - Added runtime option 'may-page-heap {false|true}'.  By default,
+     MLton will not page the heap to disk when unable to grow the heap
+     to a desired size.  (Previously, this behavior was the default,
+     with no means to disable, with security and least-surprise
+     concerns.)  
+     Thanks to Wesley Terpstra for the patch.
    - Fixed bug the FFI visible representation of Int16.int ref (and
      references of other primitive types smaller than 32-bits) on
      big-endian platforms.

Modified: mlton/trunk/man/mlton.1
===================================================================
--- mlton/trunk/man/mlton.1	2007-12-15 03:10:38 UTC (rev 6270)
+++ mlton/trunk/man/mlton.1	2007-12-15 05:17:34 UTC (rev 6271)
@@ -352,6 +352,11 @@
 \fBfixed-heap\fP.
 
 .TP
+\fBmay-page-heap \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
+Enable paging the heap to disk when unable to grow the heap to a
+desired size.
+
+.TP
 \fBno-load-world\fP
 Disable \fBload-world\fP.  This can be used as an argument to the
 compiler via \fB-runtime no-load-world\fP to create executables that

Modified: mlton/trunk/runtime/gc/controls.h
===================================================================
--- mlton/trunk/runtime/gc/controls.h	2007-12-15 03:10:38 UTC (rev 6270)
+++ mlton/trunk/runtime/gc/controls.h	2007-12-15 05:17:34 UTC (rev 6271)
@@ -38,6 +38,7 @@
   size_t fixedHeap; /* If 0, then no fixed heap. */
   size_t maxHeap; /* if zero, then unlimited, else limit total heap */
   bool mayLoadWorld;
+  bool mayPageHeap; /* Permit paging heap to disk during GC */
   bool mayProcessAtMLton;
   bool messages; /* Print a message at the start and end of each gc. */
   size_t oldGenArraySize; /* Arrays larger are allocated in old gen, if possible. */

Modified: mlton/trunk/runtime/gc/heap.c
===================================================================
--- mlton/trunk/runtime/gc/heap.c	2007-12-15 03:10:38 UTC (rev 6270)
+++ mlton/trunk/runtime/gc/heap.c	2007-12-15 05:17:34 UTC (rev 6271)
@@ -316,8 +316,8 @@
     releaseHeap (s, curHeapp);
     newHeap.oldGenSize = size;
     *curHeapp = newHeap;
-  } else {
-    /* Write the heap to disk and try again. */
+  } else if (s->controls.mayPageHeap) {
+    /* Page the heap to disk and try again. */
     void *data;
 
     if (DEBUG or s->controls.messages) {
@@ -344,6 +344,9 @@
       die ("Out of memory.  Unable to allocate %s bytes.\n",
            uintmaxToCommaString(minSize));
     }
+  } else {
+    die ("Out of memory.  Unable to allocate %s bytes.\n",
+         uintmaxToCommaString(minSize));
   }
 done:
   unless (orig == s->heap.start) {

Modified: mlton/trunk/runtime/gc/init.c
===================================================================
--- mlton/trunk/runtime/gc/init.c	2007-12-15 03:10:38 UTC (rev 6270)
+++ mlton/trunk/runtime/gc/init.c	2007-12-15 05:17:34 UTC (rev 6271)
@@ -10,7 +10,6 @@
 /*                          Initialization                          */
 /* ---------------------------------------------------------------- */
 
-#if FALSE
 static bool stringToBool (char *s) {
   if (0 == strcmp (s, "false"))
     return FALSE;
@@ -18,7 +17,6 @@
     return TRUE;
   die ("Invalid @MLton bool: %s.", s);
 }
-#endif
 
 // From gdtoa/gdtoa.h.
 // Can't include the whole thing because it brings in too much junk.
@@ -181,6 +179,11 @@
           s->controls.ratios.nursery = stringToFloat (argv[i++]);
           unless (1.0 < s->controls.ratios.nursery)
             die ("@MLton nursery-ratio argument must be greater than 1.0.");
+        } else if (0 == strcmp (arg, "page-heap")) {
+          i++;
+          if (i == argc)
+            die ("@MLton may-page-heap missing argument.");
+          s->controls.mayPageHeap = stringToBool (argv[i++]);
         } else if (0 == strcmp (arg, "ram-slop")) {
           i++;
           if (i == argc)
@@ -233,6 +236,7 @@
   s->controls.fixedHeap = 0;
   s->controls.maxHeap = 0;
   s->controls.mayLoadWorld = TRUE;
+  s->controls.mayPageHeap = FALSE;
   s->controls.mayProcessAtMLton = TRUE;
   s->controls.messages = FALSE;
   s->controls.oldGenArraySize = 0x100000;




More information about the MLton-commit mailing list