How "mandatory" is PolyglotEngine?

Jaroslav Tulach jaroslav.tulach at oracle.com
Tue Apr 26 14:53:35 UTC 2016


Hello Peter, Stefan.

### Monday 25 of April 2016, 21:12:59 @ Stefan Marr ###
> > On 25 Apr 2016, at 20:58, Peter Niederwieser <peter at pniederw.com> wrote:
> > 
> > 1. Is it OK to interact directly with `MyTruffleLanguage` (which extends
> > `TruffleLanguage`), or do I always have to go through `PolyglotEngine`?
> > (The latter seems more complicated, less flexible, and seems to do a lot
> > of wrapping.)
> If you don’t want to use any other Truffle-based languages, I would expect
> it to be fine. 

Yes, that is true. People playing with their own language only are usually 
fine.

> My understanding is that the PolyglotEngine is not supposed
> to be mandatory.

My goal/vision is to make PolyglotEngine mandatory. Even in case of a single 
language PolyglotEngine offers interfaces that other services can benefit 
from. For example if you go through PolyglotEngine, your language can be 
debugged like any other Truffle one. Without PolyglotEngine you are out of 
luck.

> Could you give examples for what you like to do, and were you found it to be
> insufficient? The design is somewhat driven by the know use cases.

Yes, knowing the observed limitations would be good. Please note that in new 
version of Truffle @ 0.13 many limitations are removed.

> 
> > 2. Say I get back an instance of `MyTruffleObject` (which implements
> > `TruffleObject`) from `PolyglotEngine`. Is it OK to get a `CallTarget`
> > from that instance (assuming it offers an API for that), and call that
> > directly? Or do I always have to go through a `TruffleObject` message
> > send instead?

Please note that all the overhead of initial 'message' has been removed in 
Truffle @ 0.13 release. Hopefully there is no reason why not use it and try 
the CallTarget shortcut.

> It depends on what you want to do.
> If this is for interactions at the boundary of Java and Truffle, it should
> be fine. Otherwise, the messages are better, because they are meant to
> allow the partial evaluation to compile out their overhead.

If you find a case where PolyglotEngine.Value.execute isn't as fast as direct 
CallTarget call please report a bug with steps to reproduce.

> > If `PolyglotEngine` is not mandatory, are there nevertheless good reasons
> > to use it when all I want is to interact with my own language?
> If you want to use the REPL, the debugger, the Truffle profiler, or any of
> the other things built on the Instrumentation API, you’ll have to use the
> PolyglotEngine at the moment.

PolyglotEngine glues everything together. If you bypass PolyglotEngine you:
- either don't need to glue anything together
- have to glue things together yourself

-jt



More information about the graal-dev mailing list