Truffle multithreaded language

Thomas Wuerthinger thomas.wuerthinger at oracle.com
Fri Oct 4 08:47:19 PDT 2013


OK, sounds good. Changes to the AST during compilation should in the current design of your Truffle interpreter not cause problems. We plan to add code that is cancelling currently running compilations in case of AST changes.

- thomas

On Oct 4, 2013, at 5:42 PM, Timothy Baldridge <tbaldridge at gmail.com> wrote:

> After some more testing yesterday, I was able to fix the problem by wrapping the call to .compile(this) in a global lock. That seemed to fix the problem. Although it seems that we could this issue again if a AST node decides to modify the tree while compilation is happening in a different thread.  
> Timothy,
> 
> The problem below comes from multiple compilations running concurrently. We'll fix the issue and push the changes asap.
> 
> - thomas
> 
> On Oct 4, 2013, at 1:14 AM, Timothy Baldridge <tbaldridge at gmail.com> wrote:
> 
> > Or perhaps there is a "pre compilation" hook? That way I could lock the AST
> > before the JIT kicks in. I don't mind a global lock like that, I just don't
> > want to have to run under a GIL the entire time.
> >
> > Timothy
> >
> >
> > On Thu, Oct 3, 2013 at 4:38 PM, Timothy Baldridge <tbaldridge at gmail.com>wrote:
> >
> >> In my continued investigations of Truffle I decided to see what happened
> >> when I threw multiple threads at my AST.
> >>
> >> What I have is a simple BF language with no specialization (we pass around
> >> Objects and cast to ints/bytes as needed).
> >>
> >> For this test, I parse the source code once, and then have 3 threads
> >> execute the code over and over again. However when truffle kicks in (after
> >> 1000 total invocations of the function), I get the following error:
> >>
> >> [thread:8] scope:
> >>  [thread:8] scope: Truffle
> >>    [thread:8] scope: Truffle.createGraph
> >>      [thread:8] scope: Truffle.createGraph.InterceptException
> >>      Exception occurred in scope: Truffle.createGraph.InterceptException
> >>      Context obj java.lang.IllegalStateException: Inlined graph is in
> >> invalid state
> >>      Context obj
> >> StructuredGraph:4{HotSpotMethod<OptimizedCallTarget.executeHelper(PackedFrame,
> >> Arguments)>}
> >>      Use -G:+DumpOnError to enable dumping of graphs on this error
> >>      Context obj DebugDumpScope[Truffle: MainNode at 333bee49]
> >> [truffle] opt failed MainNode at 333bee49
> >> java.lang.IllegalStateException: Inlined graph is in invalid state
> >> java.lang.IllegalStateException: Inlined graph is in invalid state
> >>
> >> I create a CallTarget per thread, but I do share the AST between all
> >> threads.
> >>
> >> How is this supposed to work in a large language? Am I expected to
> >> duplicate the AST for every thread? And if so, how would I get something
> >> like that to work with thread pools.
> >>
> >> Thanks for the help,
> >>
> >> Timothy Baldridge
> >>
> >
> >
> >
> > --
> > “One of the main causes of the fall of the Roman Empire was that–lacking
> > zero–they had no way to indicate successful termination of their C
> > programs.”
> > (Robert Firth)
> 



More information about the graal-dev mailing list