[MLton] cvs commit: critical sections during thread switch

Stephen Weeks MLton@mlton.org
Mon, 5 Apr 2004 08:47:33 -0700


> Here's a revised gc.c.  It seems to pass the regressions (with the slow
> GC_switchToThread), but I don't want to check it in without someone else
> taking a look at it.

It looks great to me -- a lot cleaner than what's there now.

> My big question is whether or not the stack resizing in forward is correct
> given the new invariants.

Since we now ensureMutatorInvariant, which ensures
mutatorStackInvariant, before returning to the mutator, it seems to me
that the only invariant that we need for stacks in the heap is that
stack->used <= stack->reserved.  So, I don't see any problem with the
stack shrinking in forward.  In fact, with the new weaker invariant we
can change stackNeedsReserved to return stack->used.  Also, I think we
can drop stackTopIsOk, which is now only used in GC_copyThread.

One other thing.  I think we can drop the stackIsEmpty test in
mutatorStackInvariant, since mutator stacks will always be nonempty
(they will have at least the frame that called the runtime).