Snippets and programmatically creating new classes
Thomas Wuerthinger
thomas.wuerthinger at oracle.com
Thu Apr 26 01:55:40 PDT 2012
Tiark,
the currently available way for an application or library to actively
register snippets is to call the Snippets.install(...) method. There are
three parameters:
- A reference to the runtime where the snippet definition should replace
existing method definitions.
- A reference to the description of the target architecture.
- An instance of the class that contains the snippet definitions.
You can retrieve pointers to the former two by calling
CompilerImpl.getGraalRuntime() and CompilerImpl.getInstance().getTarget().
We do not (yet) have a way to create an interface implementation by only
using Graal IR. The closest you can get to this is by using the
"RiCompiledMethod" class that allows you to directly call installed
machine code. In combination with an InvocationHandler implementation
you can create an interface proxy without generating bytecodes. Calls to
installed methods are restricted to three object parameters. We are
working on relaxing that restriction.
- thomas
On 25.04.2012 09:14, Tiark Rompf wrote:
> Hi all,
>
> I've been playing with Graal a little since you guys came visiting EPFL in March.
> I like the idea of Snippets and I was wondering, what is the preferred way of adding and
> deploying custom Snippets that are specific to a particular application or library?
>
> Also, is there a suggested way of programmatically creating new classes or methods?
> For example, I would like to implement something similar to
> java.lang.reflect.Proxy.newProxyInstance, creating an object on the fly that
> implements a bunch of interfaces, where the method bodies are created directly using
> Graal IR. Is there an API for this or would I still need to produce some byte code
> and pass it through a class loader?
>
> Cheers,
> - Tiark
More information about the graal-dev
mailing list