Indirect specialized calls
Jan Lahoda
jan.lahoda at oracle.com
Wed Sep 24 20:52:07 UTC 2014
Maurizio, Brian,
Thanks a lot for your comments and explanations.
Jan
On 23.9.2014 19:49, Brian Goetz wrote:
> So, I've got an incomplete patch in progress that helps slightly, it
> rewrites the invocation signature for the indy call but not yet the
> static arguments. I hope to clean this up and get it put back soon.
>
> We're still a bit away for i) instance generic methods, ii)
> specialization of inner classes, iii) specialization of local classes.
> But we should soon get to where static generic methods can be cleanly
> specialized.
>
> I recently pushed support for specialization to long/double, which had
> been victim of the classic "two stack slots" problem.
>
> Remi made a point about lambdas -- can you elucidate what will go wrong
> here?
>
> On 9/23/2014 9:09 AM, Jan Lahoda wrote:
>> Hello,
>>
>> While experimenting with accessors to private specialized fields, I ran
>> across a case where javac produces a classfile that crashes at runtime
>> (on a custom build from valhalla forest). I apologize if this is a known
>> problem, or if I am doing something wrong.
>>
>> The code is like this:
>> ---
>> public class SpecializationTest<any T> {
>>
>> public T i;
>>
>> public static <any TT> TT get(SpecializationTest<TT> t) {
>> return t.i;
>> }
>>
>> public static void main(String[] args) {
>> Nested.main(args);
>> }
>>
>> public static class Nested<any TT> {
>> public static void main(String[] args) {
>> SpecializationTest<int> v = new SpecializationTest<>();
>>
>> new Nested<int>().call(v);
>> }
>> public TT call(SpecializationTest<TT> v) {
>> return get(v);
>> }
>> }
>> }
>> ---
>>
>> The output of javap for the compiled classes is attached.
>>
>> Running the compiled class leads to:
>> ---
>> Specializing SpecializationTest${0=I}; searching for
>> SpecializationTest.class (not found)
>> Specializing SpecializationTest${0=I}; searching for
>> SpecializationTest.class (found)
>> Specializing SpecializationTest$Nested${0=I}; searching for
>> SpecializationTest$Nested.class (not found)
>> Specializing SpecializationTest$Nested${0=I}; searching for
>> SpecializationTest$Nested.class (found)
>> Specializing (LSpecializationTest;)Ljava/lang/Object; to
>> (LSpecializationTest${0=I};)I
>> Exception in thread "main" java.lang.VerifyError: Bad type on operand
>> stack
>> Exception Details:
>> Location:
>> SpecializationTest$Nested${0=I}.call(LSpecializationTest${0=I};)I
>> @1: invokedynamic
>> Reason:
>> Type 'SpecializationTest${0=I}' (current frame, stack[0]) is not
>> assignable to 'SpecializationTest'
>> Current Frame:
>> bci: @1
>> flags: { }
>> locals: { 'SpecializationTest$Nested${0=I}',
>> 'SpecializationTest${0=I}' }
>> stack: { 'SpecializationTest${0=I}' }
>> Bytecode:
>> 0000000: 2bba 002e 0000 ac
>>
>> at SpecializationTest$Nested.main(SpecializationTest.java:17)
>> at SpecializationTest.main(SpecializationTest.java:10)
>> ---
>>
>> Any idea what is wrong?
>>
>> Thanks,
>> Jan
More information about the valhalla-dev
mailing list