On Apr 20, 2021, at 9:40 AM, Remi Forax <fo...@univ-mlv.fr> wrote: > > Hi all, > at least as an exercise to understand the proposed class file format for the > parametric VM, i will update ASM soon (in a branch) to see how things work.
Thank you! > As usual with ASM, there is the question of sharing the same index in the > constant pool, > i.e. should two anchors (SpecializationAnchor) that have the same kind and > the same BSM + constant arguments share the same constant pool index ? Yes, I don’t see why not. For a Class-level SA it would be a bug if there were two of them in one classfile. > And same question with two linkages (SpecializationLinkage). Definitely. Just like you’d want to unique-ify CONSTANT_Class items. > I believe the answer is yes for both, the index is shared. > > The other questions are about "ldc Linkage", first, why do we need a ldc > Linkage with a Linkage that reference a class given that we already have > Condy ? Condy can do a lot of this stuff, but it shouldn’t duplicate work that the JVM is already likely to have done. If you have code using a C_Linkage[C_Class,] the JVM has probably resolved it to a species. In that case, a condy is wasted work. We did without ldc C_Class for a while but added it for similar reasons. Once we added it we had no desire to go back to the workarounds. I predict the same for “C_Species” which is C_Linkage[C_Class,]. > And second question, is there a ldc Linkage with the linkage referencing > something else than a class ? No! It would be possible to find a meaning for such a thing, but it would probably interfere with ldc of C_Linkage[C_Class,]. (I tried.) The workaround is not bad: Just wrap the C_Linkage[C_Methodref] in a C_MethodHandle, et voilà. An earlier draft made ldc of a C_Linkage recover the SpecializationAnchor object, with the theory that from there condy gets you everything. But I turned away from that design because (a) it was clunky to use, and (b) it exposed SA objects which, as I came to understand, should really be encapsulated and private to their defining class. — John