[MLton] refs in ssa

Lukasz S Ziarek lziarek@cs.purdue.edu
Sun, 7 Mar 2004 13:27:43 -0500 (EST)


On Sat, 6 Mar 2004, Matthew Fluet wrote:

>
> > So I assumed that ref_ref would just take a variable.
>
> That would seem to be a reasonable assumption.
>
> > This is not always the case. For
> > instance, when I try to snag the first variable of the args field for a
> > ref_ref prim op sometimes it is not there, IE we have a length zero arg
> > vector.
>
> Can you post some code that demonstrates this?  I'd be very surprised if
> this were the case.

 | PrimApp{prim, targs, args} =>
        (case var of
               SOME var' => ...
           (case Prim.name prim
              of Ref_ref =>
                  let val i = Vector.length(args)
                      val _ = print(Int.toString i)
                      val _ = if i = 0 then ()
                              else setRefEnv(var', {var = Vector.sub(args, 0)})
                      val _ = print("\n")
                  in [stmt]
                  end
             | _ => [stmt])


outputs:
I omited the new line for the sake of readability as well as shrunk the
output.
skavena 107 $ ./mlton -flatten true zebra.batch.sml
1 1 1 1 2 2 2 1 2 2 2 1 2 2 1 2 2 2 2 2 1 1 1 2 2 2 1 2
...
2 1 4 2 1 1 2 0 1 2 2 2
...
1 4 2 1 1 2 0 1
...

etc

I would have expected to see only 1s, but the ref_ref arg vector has
lengths of 0,1,2, or 4. I am not sure why, could anyone explain? My code
at this point does nothing with refs, I am looking to create an
association between x and y, in a stmt like x = ref y.

thank you,
Luke

>
> > This occurs when we reference a variable which is null.
>
> Not sure what you mean by this.

I should have said Unit =)

>
> > In general is the first argument to ref_ref going
> > to be the ssa variable that was referenced?
>
> Well, the first (and I would think only) argument to Ref_ref would be the
> SSA variable whose value should be allocated in a ref cell.



>
> _______________________________________________
> MLton mailing list
> MLton@mlton.org
> http://www.mlton.org/mailman/listinfo/mlton
>