Identifying bound/free name in a FrameDescriptor

Adam Kovari kovariadam at
Tue Feb 5 20:03:11 UTC 2019


I have usecase concerning recursive calls (thus, as I noticed, one
instance of FrameDescriptor which is being reused for recursive calls)
and detecting whether a variable is bound or free within that
particular invocation.

For example, this simple recursive function:

factorial 1 = 1
factorial n = n * (factorial n - 1)


factorial 5

In the first invocation, this function's FrameDescriptor would not
contain "n", but in the next call to itself, it will, because it will
be written to local stack in the second line.
The situation is, when in second invocation of this recursive
function, the FrameSlot for "n" will exist, so something like:


will return true, however, the value will be null and code such as this one:

FrameUtil.getLongSafe(frame, getSlot())

will end up throwing an IllegalStateException.

That said, I think I understand that this is because the
FrameDescriptor is being reused here, my question is, how to
effectively decide whether a name is bound or not, that would not
involve findFrameSlot or catching IllegalStateException.

I hope my example can be understood, please let me know if it is
unclear. I will appreciate any feedback.


Adam Kovari(mailto:kovariadam at

More information about the graal-dev mailing list