Calling methods on guest language objects from host language

Peter Niederwieser peter at pniederw.com
Tue Sep 1 17:13:58 UTC 2015


Hello,

I’m trying to make the following interaction between host language and my own guest language work: Call TruffleVM.eval(), which returns a guest language object, call a method on that object that returns another object, call a method on that object, etc. This is effectively traversing a guest language object graph that is computed lazily, which is a main way of interacting with my guest language (i.e. I’m going to have lots of such calls).

The problem I’m facing is that calling from the host language into the guest language, either by invoking a CallTarget or sending a TruffleObject message, doesn’t re-establish the VM context. The only way I found to do that is to invoke a Symbol obtained with TruffleVM.findGlobalSymbol(). However, my guest language objects aren’t global symbols, but dynamically computed along the way.

For now, I hacked around this by manually creating a TruffleVM.Symbol using reflection (the constructor is non-public). Is there a better way, or can one be added? Am I using Truffle in an unanticipated way, or in a way that does not make much sense? Ideally, I’d like for calls from host language to guest language to be as lightweight as possible.

Thanks,
Peter


More information about the graal-dev mailing list