IntInf _prims

Stephen Weeks MLton@sourcelight.com
Wed, 9 Aug 2000 08:41:18 -0700 (PDT)


> The original problem with making the primitives do allocation was that they
> then might have to do a GC.  I don't see any easy solution to that problem, and
> hence I think we are pretty much forced to solution #1.

Actually, I remembered another solution last night.  Matthew and I thought of it
and rejected it while he was here, but I've changed my mind.  We can just
declare the primitives as Functional instead of SideEffect.  We thought that
this was bad because the prims are getting an array and are side effecting it.
However, I now realize it's even worse than that.  The prims are destroying it.
That is, for correctness, the basis library IntInf code must be written in such
a way that the array passed to, say, IntInf_add, must be dead after the call
because the IntInf C code may have moved back the frontier and invalidated the
array.

So, my conclusion is that even the SideEffect annotation is really a lie.  We
are relying on very special properties of the use of the prim (like no
allocation between the array allocation and the prim call).  Since we're lying,
we mail as well lie and say Functional and get the optimization we want.  I
should probably put some asserts in the liveness pass to verify that the arrays
are dead after the primapp.