Implementing lexical scope for local variables

Stefan Marr java at
Wed Jul 27 14:46:47 UTC 2016

Hi Gerard:

> On 27 Jul 2016, at 16:35, Gerard Krol <gerard at> wrote:
> I now created a workaround where use a single FrameDescriptor. I just
> rename the variables inside the block if they have the same name as one in
> the outer scope, but I'm not sure that's such a good solution. Perhaps it
> would be better to just create a new frame,

I’d assume that a single frame descriptor per method is the best way to go.
Otherwise, you’d need multiple truffle methods (root nodes) for a single conceptual method. This is structurally a little harder to handle (you need proper non-local variable access, potentially traversing truffle frames).

Variable names can be objects, if I recall correctly, so perhaps, you don’t need to use strings, which might give you also a little more info during debugging.

Generally, I’d avoid manually creating truffle frames, especially if that is not based on any performance issues you actually see on programs/benchmarks.
You might wonder about lifeness of values, for object slots, you might want to set them to null explicitly at the end of a scope, but this is also an optimization I would not worry about before getting things running on Graal.

Best regards

Stefan Marr
Johannes Kepler Universität Linz

More information about the graal-dev mailing list