Unset a slot in a frame

Stefan Marr java at stefan-marr.de
Wed Sep 28 09:51:31 UTC 2016


Let’s imagine a code snippet like this, but assume a bit specific semantics close to my language.

The `var` declaration ensures that there is a frame slot, and that it should contain a `nil` value.
So, the following code should always print 0.

for (int i = 0; i < 10; i++) {
  var local;
  if (local == nil) { local := 0 }
  else { local += 1; }

Further, the variables `i` and `local` are allocated as frame slots in the frame of the surrounding method.
And, I would like to make sure that both frame slots can specialize themselves properly to integers.

To realize that, I was thinking that the frame would need an `unset()` operation, which it currently does not have.
I think, it could be sufficient to realize my semantics if the tag stored in the frame is reverted to `Illegal`.

So, I am wondering whether there are any assumptions in Truffle/Graal that would prevent the introduction of an `unset()`.
Perhaps some parts cannot handle the transition from an initialized state back to `Illegal`?

My assumption is that the `tags` in a frame do not have to be stable, because there is already the transition from the initial state to the typed state. And, I also assume that reverting back to `Illegal` does not mess with the FrameDescriptor, because I don’t want to change the type specialization there either.

I just want to ensure that the first read of `local` in each loop iteration is correctly in the `uninitialized` state.

Would it be possible to add an `unset(slot)` to Frame?


Stefan Marr
Johannes Kepler Universität Linz

More information about the graal-dev mailing list