Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] Generate invokedynamic

Hi Jasper,

Thank you very much for pinpointing. I managed to exchange all relevant parts in the JDT compiler to come up with my solution for ObjectTeams.

I have extended the bootstrap generation and also the MessageSend is generated into an invokedynamic. It’s also not that pretty ;-)

However, I have a problem to generate the right class attributes. For u2 num_bootstrap_methods it says that there need to be a type attribute etc. for every argument to the bootstrap method. I was copying the approach taken for MetaFactory. 
My bootstrap looks like (MethodType, String, MethodHandle, int, int)CallSite. So I need to add 2 bootstrap arguments. I tried something like 

int idx = this.constantPool.literalIndexForType(TypeBinding.INT);
this.contents[localContentsOffset++] = (byte) (idx >> 8);
this.contents[localContentsOffset++] = (byte) idx;

But when running the code it says Exception in thread "main" java.lang.NoClassDefFoundError: I

The whole adaptions to generateBootstrapMethods can be seen https://gist.github.com/lschuetze/c97ff013a1a3b69c1cedecfdee7b688c

Your help is appreciated. I think I am still not understanding the whole picture of JVM spec, the JDT code generation and everything that is expected here.

Cheers,
Lars

Hi Lars

At the moment, both the invokedynamic call and the bootstrap code generation is part of lambda code generation, and has no API as such, since it's specific to LambdaMetafactory. For instance, the bootstrap methods are emitted inside org.eclipse.jdt.internal.compiler.ClassFile.generateBootstrapMethods(List). It's not that pretty.

In general, JDT's top priority is remaining compatible to JLS, so I wouldn't expect us making a language extension to call indy. However, at the (internal) API level, we could probably clean up the code generation a bit, and make the bootstrap and indy calls cleaner (especially now that we have the ConstantDynamic in Java 11, which could lead the way to a number of improvements in the generated code down the road.

Hope that it explains the current situation.

-Jesper

-- 

On 8 Oct 2018, at 12.52, Lars Schuetze <lars.schuetze@xxxxxxxxxxxxx> wrote:

Hello developers,

I was already posting to the Object Teams development mailing list [1], but got no reaction after reasonable time, so because of the similar topic I also post here. Thanks, for your understanding.

I am working with the JDT core version as of Photon branch R4_8_maintenance. I have a runtime which implements a bootstrap method (static CallSite bootstrap(â)) to be used in conjunction with invokedynamic.
ObjectTeams is an extension that is deeply coupled and intermingled with the EJC and also has specific changes to the JDT core plugin. I worked already all my changes into the compiler.
However, it currently just calls the bootstrap method as static method. I want it to be treated as invokedynamic callsite. Looking into the JDT how such a callsite is created (i.e., in CodeStream class etc) I just find references w.r.t. lambdas. 

Is there any facility in the JDT already in place to create invokedynamic callsites? Maybe you can point me to the right JDT API to generate an invokedynamic from the MessageSend?

Best regards,
Lars SchÃtze


- -
M.Sc. Lars SchÃtze
Research Assistant

Technische UniversitÃt Dresden
Chair for Compiler Construction
Helmholtzstrasse 18, 01069 Dresden, BAR III57
www: https://cfaed.tu-dresden.de/ccc-staff-schuetze
www: https://wwwdb.inf.tu-dresden.de/grk/team/lars-schuetze/
Mail: lars.schuetze@xxxxxxxxxxxxx
Phone: +49 (351) 463-43733
Fax: +49 (351) 463-39995

_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jdt-core-dev

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Back to the top