[MLton-commit] r7387
Wesley Terpstra
wesley at mlton.org
Mon Dec 14 09:37:44 PST 2009
As discussed on the mailing list, try to resize in-place first.
----------------------------------------------------------------------
U mlton/trunk/runtime/platform/mremap.c
----------------------------------------------------------------------
Modified: mlton/trunk/runtime/platform/mremap.c
===================================================================
--- mlton/trunk/runtime/platform/mremap.c 2009-12-14 14:36:53 UTC (rev 7386)
+++ mlton/trunk/runtime/platform/mremap.c 2009-12-14 17:37:41 UTC (rev 7387)
@@ -29,14 +29,6 @@
return base;
}
- /* Prefer a moving remap -> it results in less mmapped regions */
- alloc = GC_mmapAnon(0, newLength);
- if (alloc != (void*)-1) {
- memcpy(alloc, base, oldLength);
- GC_release(base, oldLength);
- return alloc;
- }
-
growth = newLength-oldLength;
if (cacheAddress == base &&
@@ -103,6 +95,14 @@
/* Is there enough free space? */
if (cacheTailSize + cacheHeadSize < growth) {
+ /* No, there's not. Try to move it instead. */
+ alloc = GC_mmapAnon(0, newLength);
+ if (alloc != (void*)-1) {
+ memcpy(alloc, base, oldLength);
+ GC_release(base, oldLength);
+ return alloc;
+ }
+ /* Failed even to move it */
return (void*)-1;
}
@@ -115,6 +115,7 @@
tail = (char*)base + oldLength;
alloc = GC_extendTail(tail, growth);
if (alloc != tail) {
+ /* This shouldn't happen; we tested for the memory! */
if (alloc != (void*)-1)
GC_release(alloc, growth);
return (void*)-1;
@@ -126,6 +127,7 @@
tail = (char*)base + oldLength;
alloc = GC_extendTail(tail, cacheTailSize);
if (alloc != tail) {
+ /* This shouldn't happen; we tested for the memory! */
if (alloc != (void*)-1)
GC_release(alloc, cacheTailSize);
return (void*)-1;
@@ -137,6 +139,7 @@
head = (char*)base - (growth-cacheTailSize);
alloc = GC_extendHead(head, growth-cacheTailSize);
if (alloc != head) {
+ /* This shouldn't happen; we tested for the memory! */
if (alloc != (void*)-1)
GC_release(alloc, growth-cacheTailSize);
if (cacheTailSize > 0)
More information about the MLton-commit
mailing list