hg: valhalla/valhalla: 8222711: [lworld] Initial skeletal implementation of inline class instance construction via <init>

Remi Forax forax at univ-mlv.fr
Sat Apr 20 21:29:31 UTC 2019


There is maybe a way to generate those static factories and be binary backward compatible i.e. support the new L + dup + init L dance,

the idea can be decomposed in two rewritings:
- new L should be equivalent to calling Q.default if its an inline class
- invokespecial L <init>(params)V should be equivalent to calling top_of_stack = invokestatic <init>(top_of_stack, params) if its an inline class

obviously the later rewriting seems like a red herring but because of the side effect is on the top of the stack, it may be possible.

Rémi

----- Mail original -----
> De: "John Rose" <john.r.rose at oracle.com>
> À: "Srikanth" <srikanth.adayapalam at oracle.com>
> Cc: "valhalla-dev" <valhalla-dev at openjdk.java.net>
> Envoyé: Samedi 20 Avril 2019 20:48:09
> Objet: Re: hg: valhalla/valhalla: 8222711: [lworld] Initial skeletal implementation of inline class instance
> construction via <init>

> I've been wanting to do this for some time.  I'll take a crack at it.
> 
>> On Apr 20, 2019, at 8:19 AM, Srikanth <srikanth.adayapalam at oracle.com> wrote:
>> 
>> JVM folk:
>> 
>> I have raised https://bugs.openjdk.java.net/browse/JDK-8222787 ([lworld] JVM
>> should be enhanced to work with static <init> factory methods for inline types)
>> in connection with this.
>> 
>> I have pushed an initial implementation for JDK-8222711 that alters the way code
>> is generated by javac for inline classes. Rather than emit synthetic
>> $makeValue$ methods that embody the construction, now with the option
>> -XDstaticInitValueFactory emits source level constructors into class file level
>> static factories that
>> 
>>     - have the name <init>
>>     - are static methods
>>     - have a return type that matches the class
>>     - are invoked via invokestatic at the new V() construction site.
>> 
>> All 4 are potential irritants to the JVM and need to be addressed before
>> JDK-8222711 can be tested at all.
>> 
>> I have eyeballed the code generated by this changeset and it passes muster, but
>> real testing is possible only after the VM stops choking with:
>> 
>> Error: LinkageError occurred while loading main class X
>>     java.lang.ClassFormatError: Method "<init>" in class X has illegal signature
>>     "(Ljava/lang/String;)QX;"
>> 
>> Thanks for looking into this.
>> Srikanth
>> 
>> 
>> On 20/04/19 8:35 PM, srikanth.adayapalam at oracle.com wrote:
>>> Changeset: cc473d393abf
>>> Author:    sadayapalam
>>> Date:      2019-04-20 20:35 +0530
>>> URL:       http://hg.openjdk.java.net/valhalla/valhalla/rev/cc473d393abf
>>> 
>>> 8222711: [lworld] Initial skeletal implementation of inline class instance
>>> construction via <init>
>>> 
>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java
>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
>>> ! src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/TransValues.java
>>> ! src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java
>>> 



More information about the valhalla-dev mailing list