Test Interface for Truffle: Good for PE tests?

Jaroslav Tulach jaroslav.tulach at oracle.com
Tue Apr 4 10:24:12 UTC 2017


On úterý 4. dubna 2017 11:30:57 CEST Doug Simon wrote:
> Roland,
> 
> You may want to consider adding a FAQ section to the javadoc of
> TruffleRunner to capture some of this.

+1

Or rather add the FAQ to the tutorial: 
http://graalvm.github.io/truffle/javadoc/com/oracle/truffle/tutorial/newlanguage/
package-summary.html
that's where people seek for FAQ like info more likely than in a class 
javadoc.

In any case having FAQ somewhere is better than no FAQ.
-jt

> > On 4 Apr 2017, at 10:55, Roland Schatz <roland.schatz at oracle.com> wrote:
> > 
> > Hi Stefan,
> > 
> > On 03/31/2017 01:16 PM, Stefan Marr wrote:
> >> Hi:
> >> 
> >> I just saw that a recent commit [1] introduced a test interface for
> >> Truffle.
> >> 
> >> What exactly is this good for? Can I use this to easily check for
> >> instance that specific operations properly constant fold?> 
> > Yes, the idea of that interface is that you can use it to unit-test the
> > partial evaluation and compilation of individual nodes or small AST
> > snippets. You can combine that with CompilerDirectives to explicitly test
> > for constant folding.> 
> >> I looked a little at the documentation. Does the warmup annotation imply
> >> that after the given number of iterations, compilation is forced for me?
> >> This isn’t quite clear to me from the javadoc.> 
> > If there is a Truffle compiler in the system (i.e. you're running with
> > Graal), then compilation is forced for the final execution of the test
> > AST. This is essentially saving you the need to write a manual warmup
> > loop in the hope of eventually triggering compilation.> 
> >> If this can be used to build checks that code constant folds, I am also
> >> wondering how the tests can be ignored/skipped when unit tests are
> >> executed without Graal. Are there now facilities, to test explicitly
> >> that the TruffleRuntime supports compilation? There has been a long
> >> standing feature request for such an API [2].> 
> > CompilerDirectives.isCompilationConstant will return true if called from
> > the interpreter, so if you're writing a test that's asserting that
> > something is constant, it should at least not fail if there is no
> > compiler available (but of course it also won't actually test anything).
> > You could also just put a big "if (CompilerDirectives.inCompiledCode())"
> > around the code in the test root node, but that would of course also
> > effectively disable your warmup (which may be totally fine, depending on
> > how you build your test AST).
> > 
> > 
> > - Roland
> > 
> >> Thanks
> >> Stefan
> >> 
> >> [1]:
> >> https://github.com/graalvm/truffle/commit/1dce7adb2833abc2aa3f3a4bcd0e0c
> >> 288a472faf [2]: https://github.com/graalvm/truffle/issues/47




More information about the graal-dev mailing list