[MLton-commit] r6448
spoons at mlton.org
spoons at mlton.org
Mon Mar 3 07:33:03 PST 2008
Remaining changes in parallel runtime.
(These changes probably should have been in some previous commit.)
----------------------------------------------------------------------
U mlton/branches/shared-heap-multicore/runtime/gc/cheney-copy.c
U mlton/branches/shared-heap-multicore/runtime/gc/copy-thread.c
U mlton/branches/shared-heap-multicore/runtime/gc/foreach.c
U mlton/branches/shared-heap-multicore/runtime/gc/forward.c
U mlton/branches/shared-heap-multicore/runtime/gc/invariant.c
----------------------------------------------------------------------
Modified: mlton/branches/shared-heap-multicore/runtime/gc/cheney-copy.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/cheney-copy.c 2008-03-03 15:32:38 UTC (rev 6447)
+++ mlton/branches/shared-heap-multicore/runtime/gc/cheney-copy.c 2008-03-03 15:33:02 UTC (rev 6448)
@@ -37,12 +37,14 @@
}
void swapHeapsForCheneyCopy (GC_state s) {
- struct GC_heap tempHeap;
+ GC_heap tempHeap;
- tempHeap = s->secondaryHeap;
- s->secondaryHeap = s->heap;
- s->heap = tempHeap;
- setCardMapAbsolute (s);
+ for (int proc = 0; proc < s->numberOfProcs; proc++) {
+ tempHeap = s->procStates[proc].secondaryHeap;
+ s->procStates[proc].secondaryHeap = s->procStates[proc].heap;
+ s->procStates[proc].heap = tempHeap;
+ setCardMapAbsolute (&s->procStates[proc]);
+ }
}
void majorCheneyCopyGC (GC_state s) {
Modified: mlton/branches/shared-heap-multicore/runtime/gc/copy-thread.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/copy-thread.c 2008-03-03 15:32:38 UTC (rev 6447)
+++ mlton/branches/shared-heap-multicore/runtime/gc/copy-thread.c 2008-03-03 15:33:02 UTC (rev 6448)
@@ -9,7 +9,7 @@
GC_thread copyThread (GC_state s, GC_thread from, size_t size) {
GC_thread to;
- if (DEBUG_THREADS)
+ if (DEBUG_THREADS or s->controls->messages)
fprintf (stderr, "copyThread ("FMTPTR")\n", (uintptr_t)from);
/* newThread may do a GC, which invalidates from.
* Hence we need to stash from where the GC can find it.
@@ -65,11 +65,14 @@
*/
/* assert (fromStack->reserved == fromStack->used); */
assert (fromStack->reserved >= fromStack->used);
- leave (s);
+
+ /* Formerly: LEAVE1 (s, "toThread"); */
+
if (DEBUG_THREADS)
- fprintf (stderr, FMTPTR" = GC_copyCurrentThread\n", (uintptr_t)toThread);
+ fprintf (stderr, FMTPTR" = GC_copyCurrentThread [%d]\n",
+ (uintptr_t)toThread, Proc_processorNumber (s));
assert (s->savedThread == BOGUS_OBJPTR);
- s->savedThread = pointerToObjptr((pointer)toThread - offsetofThread (s), s->heap.start);
+ s->savedThread = pointerToObjptr((pointer)toThread - offsetofThread (s), s->heap->start);
}
pointer GC_copyThread (GC_state s, pointer p) {
Modified: mlton/branches/shared-heap-multicore/runtime/gc/foreach.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/foreach.c 2008-03-03 15:32:38 UTC (rev 6447)
+++ mlton/branches/shared-heap-multicore/runtime/gc/foreach.c 2008-03-03 15:33:02 UTC (rev 6448)
@@ -23,13 +23,30 @@
}
if (DEBUG_DETAILED)
fprintf (stderr, "foreachGlobal threads\n");
- callIfIsObjptr (s, f, &s->callFromCHandlerThread);
- callIfIsObjptr (s, f, &s->currentThread);
- callIfIsObjptr (s, f, &s->savedThread);
- callIfIsObjptr (s, f, &s->signalHandlerThread);
+ if (s->procStates) {
+ for (int proc = 0; proc < s->numberOfProcs; proc++) {
+ callIfIsObjptr (s, f, &s->procStates[proc].callFromCHandlerThread);
+ callIfIsObjptr (s, f, &s->procStates[proc].currentThread);
+ callIfIsObjptr (s, f, &s->procStates[proc].savedThread);
+ callIfIsObjptr (s, f, &s->procStates[proc].signalHandlerThread);
+
+ if (s->procStates[proc].roots) {
+ for (uint32_t i = 0; i < s->procStates[proc].rootsLength; i++) {
+ callIfIsObjptr (s, f, &s->procStates[proc].roots[i]);
+ }
+ }
+ }
+ }
+ else {
+ callIfIsObjptr (s, f, &s->callFromCHandlerThread);
+ callIfIsObjptr (s, f, &s->currentThread);
+ callIfIsObjptr (s, f, &s->savedThread);
+ callIfIsObjptr (s, f, &s->signalHandlerThread);
+ }
}
+
/* foreachObjptrInObject (s, p, f, skipWeaks)
*
* Applies f to each object pointer in the object pointed to by p.
Modified: mlton/branches/shared-heap-multicore/runtime/gc/forward.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/forward.c 2008-03-03 15:32:38 UTC (rev 6447)
+++ mlton/branches/shared-heap-multicore/runtime/gc/forward.c 2008-03-03 15:33:02 UTC (rev 6448)
@@ -60,12 +60,19 @@
skip = 0;
} else { /* Stack. */
GC_stack stack;
+ bool isCurrentStack = false;
assert (STACK_TAG == tag);
headerBytes = GC_STACK_HEADER_SIZE;
stack = (GC_stack)p;
- if (getStackCurrentObjptr(s) == op) {
+ /* Check if the pointer is the current stack of any processor. */
+ for (int proc = 0; proc < s->numberOfProcs; proc++) {
+ isCurrentStack |= (getStackCurrentObjptr(&s->procStates[proc]) == op
+ && not isStackEmpty(stack));
+ }
+
+ if (isCurrentStack) {
/* Shrink stacks that don't use a lot of their reserved space;
* but don't violate the stack invariant.
*/
@@ -91,7 +98,7 @@
/* Shrink heap stacks. */
stack->reserved =
alignStackReserved
- (s, max((size_t)(s->controls.ratios.threadShrink * stack->reserved),
+ (s, max((size_t)(s->controls->ratios.threadShrink * stack->reserved),
stack->used));
if (DEBUG_STACKS)
fprintf (stderr, "Shrinking stack to size %s.\n",
@@ -175,11 +182,11 @@
/* Constants. */
cardMap = s->generationalMaps.cardMap;
crossMap = s->generationalMaps.crossMap;
- maxCardIndex = sizeToCardMapIndex (align (s->heap.oldGenSize, CARD_SIZE));
- oldGenStart = s->heap.start;
- oldGenEnd = oldGenStart + s->heap.oldGenSize;
+ maxCardIndex = sizeToCardMapIndex (align (s->heap->oldGenSize, CARD_SIZE));
+ oldGenStart = s->heap->start;
+ oldGenEnd = oldGenStart + s->heap->oldGenSize;
/* Loop variables*/
- objectStart = alignFrontier (s, s->heap.start);
+ objectStart = alignFrontier (s, s->heap->start);
cardIndex = 0;
cardStart = oldGenStart;
checkAll:
Modified: mlton/branches/shared-heap-multicore/runtime/gc/invariant.c
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/gc/invariant.c 2008-03-03 15:32:38 UTC (rev 6447)
+++ mlton/branches/shared-heap-multicore/runtime/gc/invariant.c 2008-03-03 15:33:02 UTC (rev 6448)
@@ -30,6 +30,7 @@
#if ASSERT
bool invariantForGC (GC_state s) {
+ int proc;
if (DEBUG)
fprintf (stderr, "invariantForGC\n");
/* Frame layouts */
@@ -81,8 +82,24 @@
assertIsObjptrInFromSpace, FALSE);
if (DEBUG_DETAILED)
fprintf (stderr, "Checking nursery.\n");
- foreachObjptrInRange (s, s->heap.nursery, &s->frontier,
- assertIsObjptrInFromSpace, FALSE);
+ if (s->procStates) {
+ pointer firstStart = s->heap->frontier;
+ for (proc = 0; proc < s->numberOfProcs; proc++) {
+ foreachObjptrInRange (s, s->procStates[proc].start,
+ &s->procStates[proc].frontier,
+ assertIsObjptrInFromSpace, FALSE);
+ if (s->procStates[proc].start
+ and s->procStates[proc].start < firstStart)
+ firstStart = s->procStates[proc].start;
+ }
+ foreachObjptrInRange (s, s->heap->nursery,
+ &firstStart,
+ assertIsObjptrInFromSpace, FALSE);
+ }
+ else {
+ foreachObjptrInRange (s, s->start, &s->frontier,
+ assertIsObjptrInFromSpace, FALSE);
+ }
/* Current thread. */
GC_stack stack = getStackCurrent(s);
assert (isStackReservedAligned (s, stack->reserved));
More information about the MLton-commit
mailing list