From karen.kinnear at oracle.com Wed Jul 5 13:07:06 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 5 Jul 2017 09:07:06 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <4bce389e-3342-bcfa-0174-140ef4313134@cs.oswego.edu> References: <4bce389e-3342-bcfa-0174-140ef4313134@cs.oswego.edu> Message-ID: Doug, Thank you. I suspect we will dance together on specific performance improvements - so getting your use cases may identify optimizations we have not yet done - and that would be helpful to both of us. Ian - any feedback? thanks, Karen > On Jun 25, 2017, at 6:08 PM, Doug Lea
wrote: > > > I missed this meeting (out at PLDI/ISMM/ECOOP) but ... > > On 06/23/2017 04:33 PM, Karen Kinnear wrote: >> >> Hotspot and IBM: >> what could be available for early access for early adopters to >> experiment with? >> revisit early access timing - if we were to set expectations that >> - model would be to deliver binaries and periodic binary updates to >> match the source builds. This is not a one shot delivery. >> - limit functionality (platforms, reflection behavior unspecified, >> no JVMTI, ?) >> - performance improvements are not yet there, expect to come in >> incrementally >> - maybe verifier isn?t ready? >> - stability issues >> >> *Potential early adopters: Ian Graves? Doug Lea? Others?* >> * So - would you be willing to start experimenting with minimal value >> types even with the restrictions above?* >> > > Yes. This should be enough to try out some useful experiments. > At least if "not there yet" doesn't mean "dreadful" performance. > For example, trying out techniques for parallel sorting of values > seems possible, and is likely to be informative about other possible > concurrent/parallel library improvements. > > -Doug > > > > From karen.kinnear at oracle.com Wed Jul 5 14:12:30 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 5 Jul 2017 10:12:30 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: Message-ID: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> Bjorn, Thank you for the corrections. > On Jul 5, 2017, at 5:10 AM, Bjorn B Vardal wrote: > > > Bjorn: single representation for both value capable class and derived value class > > We basically rely on single class data structure for the VCC and DVT, but we still expose these as separate java/lang/Class objects. > > > > I think you said ?treat ;Q? as the name for the derived value class rather than as an escape character (feel free to correct my notes) > > I meant to say the opposite of that: Since our DVT and VCC have the same name (because they rely on the same class data structure), > we would simply treat ";Q" as an escape character that switches to DVT mode, instead of as part of the name of the value class. That makes more sense. > > > > Bjorn: could hack using the different name as two views of the same thing > > e.g. vbox/vunbox would need to swap names > > (ed. note - please let us know if this is doable without heroic efforts) > > I can make this work as long as there's a predictable prefix and suffix, so ";Q$value" works. Thank you - very much appreciated. > > > > Dan S: class loading in the proposed JVMS: if you see $Value > > 1) first derive the VCC name and see if already resolved > > 2) if not - load the VCC, check properties and derive > > (ed. note - if see VCC - lazily derive derived value class on touch) > > It's not a requirement that the value class derivation is lazy, correct? Let?s double-check with Dan Smith at today?s meeting. The way I read 5.3 Creation and Loading in http://cr.openjdk.java.net/~dlsmith/values.html it appears to allow lazy derivation as well as eager derivation, which I think is what we both want since it allows implementations to optimize. Our current derivation is also eager. thanks, Karen > > > > ----- Original message ----- > From: Karen Kinnear > Sent by: "valhalla-spec-experts" > To: valhalla-spec-experts at openjdk.java.net > Cc: > Subject: Valhalla EG minutes 6/21/17 > Date: Fri, Jun 23, 2017 10:33 PM > > attendees: Remi, Bjorn, Dan H, Dan S, John, Maurizio, Frederic, Lois, Karen > > AIs: > All: review Dan Smith?s proposals > MVT JVMS: Specification for Value Classes: http://cr.openjdk.java.net/~dlsmith/values.html - initial proposal > *** let?s pin this down ASAP so we - Remi for ASM, IBM and Oracle can deliver early binaries for early adopters to try > > incremental proposals for post early access (or maybe post - MVT TBD) > Direct Value Class: Specification for Value Classes with Explicit Declarations: http://cr.openjdk.java.net/~dlsmith/values-declaration.html > Specification for Value Classes with CONSTANT_ClassType: http://cr.openjdk.java.net/~dlsmith/values-classtype.html#values-classtype-4.1 > All: review John Rose?s proposals: > ConstantDynamic JVMS changes: http://cr.openjdk.java.net/~jrose/jvm/condy-jvms-2017-0620.html > note: this is orthogonal to MVT > java/lang/Class.java makeSecondaryClass: http://mail.openjdk.java.net/pipermail/valhalla-spec-experts/2017-June/000286.html > post EA > > Hotspot and IBM: > what could be available for early access for early adopters to experiment with? > revisit early access timing - if we were to set expectations that > - model would be to deliver binaries and periodic binary updates to match the source builds. This is not a one shot delivery. > - limit functionality (platforms, reflection behavior unspecified, no JVMTI, ?) > - performance improvements are not yet there, expect to come in incrementally > - maybe verifier isn?t ready? > - stability issues > > Potential early adopters: Ian Graves? Doug Lea? Others? > So - would you be willing to start experimenting with minimal value types even with the restrictions above? > > We would find it helpful to get your feedback on > - the basic conceptual model > - usage model > - use cases - so we can optimize what you care about > - required features we missed > - so that when we ship this experimentally it is much closer to what you need > > Model of usage: > 1) Value-capable-class: created in java with annotation, javac generates a regular classfile with no new constant pool entries > or bytecodes > 2) MethodHandles and ValueType APIs > - this is the default model of usage > 3) generated byte codes > - you can generate your own byte codes to work on value types > - at this point you can?t generate your own value type class this way (until we get to Direct Value Class support) > > Constant Pool changes for Early Access: > 1) proposal for a value class is: > part I: CONSTANT_Class_info: UTF8: ?;Q;? // i.e. this would be a descriptor using a UTF8 string to speed up implementation > part II: hotspot requests that we use a different name for the value type than for the value capable class > implementation request - today we need unique strings to identify unique runtime types and this is baked in multiple places > > So propose: CONSTANT_Class_info: UTF8:?QFoo$ > > Where is the name exposed? > in the constant pool when you generate your own bytecodes - in descriptors and class names > > Dan S: Longer term: will declare a value class directly. The box first is a temporary approach in which we derive the value class. > Propose we not spend a lot of time here blurring the difference and needing to hide the derived value class. > > Bjorn: single representation for both value capable class and derived value class > I think you said ?treat ;Q? as the name for the derived value class rather than as an escape character (feel free to correct my notes) > > Dan S. Longer term: we do want one declaration and two views based on the value class. > > John: prefers Bjorn?s approach > > Bjorn: could hack using the different name as two views of the same thing > e.g. vbox/vunbox would need to swap names > (ed. note - please let us know if this is doable without heroic efforts) > > John: for hotspot - part of condy refactoring did part of the loaded class cache lookup changes that could be used here. > > Dan S: class loading in the proposed JVMS: if you see $Value > 1) first derive the VCC name and see if already resolved > 2) if not - load the VCC, check properties and derive > (ed. note - if see VCC - lazily derive derived value class on touch) > > ---- > > John sent out a proposed API for a secondary mirror (see email link above) > note: not for EA > > Dan H: if ask for the same name for the secondary mirror what happens? > John: only libraries can use the proposed API and library is responsible for interning the name - not the VM. > > Remi: need ?nest? automatically for secondary mirror > John: yes eventually > Karen: not EA - need to check if time during MVT > > Remi: dynamic language implementor will want the same name - e.g. to get to shared static methods > today - because you can?t re-open a class folks generate ancillary classes to add static methods later > note: for printing purposes it would be helpful to have a different way to represent the name > > John: model on primitive type vs. wrapper type > > VWithfield - propose for MVT - allow package private access - since there are no methods on the derived value class > and the value capable class can?t have any methods with vbytecodes since generated by javac > - plan to make private when we add factory methods to value classes with a compiler (and we have nest support) > > Discussion of work needed to get to early access from various parties. See question above for early adopters > on potential restrictions to get this to you sooner. > > Teams need to re-assess timing assuming we want to make this available before we cross all the t?s and dot the i?s > (you just have to recognize this goes against the grain for any virtual machine engineer), but we do appreciate > that our first adopters would like to get this this summer while they have time to experiment and have shown > lots of willingness to work with us) > > Good news is: With the current JVMS (let?s get that reviewed and stamped), Remi is looking at modifying > ASM so folks will find it easier to generate byte codes. Many thanks! > > ASM needs: > 1) new opcodes and overloaded opcodes > 2) descriptor support > > note: this is independent of condy > > Maurizio - we would like to use that ASM internally whenever it is ready - that would make the MethodHandle API > able to take advantage of existing optimizations for references that we haven?t done yet > > So - goal is to have a binary snapshot available ASAP. > > Maurizio suggested we look at the JVMLS workshop time separately - need to discuss that next meeting. > > ?? > > Exposure of java/lang/__Value? > > Hotspot uses this today internally for MethodHandle LambdaForms - generating e.g. vreturn for __Value > (which is derived value class top type) . This is internal implementation magic - we pretend this is a marker class. > > Note: instanceof and checkcast do NOT work with value types in MVT. > > John: Longer-term: exploring QObject equivalent and a UObject which is at least a reference or value type > When we support interfaces and generics for value types we will need a user story users can trust > > Concern: ASM verification > John proposed: use invokeBasic model - wormhole from untyped to typed which is ignored by the verifier > > thanks, > Karen > > > > > > > > > > From karen.kinnear at oracle.com Wed Jul 5 14:26:03 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 5 Jul 2017 10:26:03 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> Message-ID: <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> Paul, What we were discussing was the ability to use the byte code itself - not the ValueType.findWither API. John?s longer term plan is that ultimately the byte code can only be executed in the value class itself, and since the derived value class has no methods, we need a temporary approach. Did I misunderstand what you were saying? thanks, Karen > On Jun 26, 2017, at 2:52 PM, Paul Sandoz wrote: > > >> On 23 Jun 2017, at 13:33, Karen Kinnear wrote: > >> VWithfield - propose for MVT - allow package private access - since there are no methods on the derived value class >> and the value capable class can?t have any methods with vbytecodes since generated by javac >> - plan to make private when we add factory methods to value classes with a compiler (and we have nest support) >> > > I am unsure if it?s necessary for MVT purposes to dial back the accessibility then dial it up again later on. > > ValueType.findWither can be used in conjunction with MethodHandle.privateLookupIn. It?s a little odd but works. What am i missing? > > Paul. > > > > From john.r.rose at oracle.com Wed Jul 5 16:11:51 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 5 Jul 2017 09:11:51 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> Message-ID: On Jul 5, 2017, at 7:26 AM, Karen Kinnear wrote: > > John?s longer term plan is that ultimately the byte code can only be executed in the value class itself Slight correction: ultimately the byte code requires private access to the value class itself. This means that nestmates can use that bytecode also. Access rules are as if it were a private method. We don't want to require bridge methods to use withers within a compilation unit. From paul.sandoz at oracle.com Wed Jul 5 16:28:22 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 5 Jul 2017 09:28:22 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> Message-ID: > On 5 Jul 2017, at 07:26, Karen Kinnear wrote: > > Paul, > > What we were discussing was the ability to use the byte code itself - not the ValueType.findWither API. > John?s longer term plan is that ultimately the byte code can only be executed in the value class itself, and > since the derived value class has no methods, we need a temporary approach. > > Did I misunderstand what you were saying? > No, i was missing aspect that you were referring to byte code generation. What if we added a safe replacement for: Unsafe.defineAnonymousClass https://bugs.openjdk.java.net/browse/JDK-8171335 (Which we anyway have to do.) ? Then the VCC or DVT could be used as the host class. However, i dunno if that would be sufficient to cover the use-cases of byte code generation. Paul. > thanks, > Karen > >> On Jun 26, 2017, at 2:52 PM, Paul Sandoz wrote: >> >> >>> On 23 Jun 2017, at 13:33, Karen Kinnear wrote: >> >>> VWithfield - propose for MVT - allow package private access - since there are no methods on the derived value class >>> and the value capable class can?t have any methods with vbytecodes since generated by javac >>> - plan to make private when we add factory methods to value classes with a compiler (and we have nest support) >>> >> >> I am unsure if it?s necessary for MVT purposes to dial back the accessibility then dial it up again later on. >> >> ValueType.findWither can be used in conjunction with MethodHandle.privateLookupIn. It?s a little odd but works. What am i missing? >> >> Paul. >> >> >> >> > From karen.kinnear at oracle.com Wed Jul 5 17:48:15 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 5 Jul 2017 13:48:15 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> Message-ID: <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> Agree with John?s clarification - yes we are planning longterm for nest mate access. And your proposal of using a safe replacement for Unsafe.defineAnonymousClass with appropriate access to add into the nest makes sense. At this time we are building an Early Access that needs to go out sooner than nest mates. We should re-evaluate adding a nest mate dependency when we get closer to deadlines and see if that works for our partners and our own timing. thanks, Karen > On Jul 5, 2017, at 12:28 PM, Paul Sandoz wrote: > > >> On 5 Jul 2017, at 07:26, Karen Kinnear wrote: >> >> Paul, >> >> What we were discussing was the ability to use the byte code itself - not the ValueType.findWither API. >> John?s longer term plan is that ultimately the byte code can only be executed in the value class itself, and >> since the derived value class has no methods, we need a temporary approach. >> >> Did I misunderstand what you were saying? >> > > No, i was missing aspect that you were referring to byte code generation. > > What if we added a safe replacement for: > > Unsafe.defineAnonymousClass > https://bugs.openjdk.java.net/browse/JDK-8171335 > > (Which we anyway have to do.) > > ? > > Then the VCC or DVT could be used as the host class. However, i dunno if that would be sufficient to cover the use-cases of byte code generation. > > Paul. > >> thanks, >> Karen >> >>> On Jun 26, 2017, at 2:52 PM, Paul Sandoz wrote: >>> >>> >>>> On 23 Jun 2017, at 13:33, Karen Kinnear wrote: >>> >>>> VWithfield - propose for MVT - allow package private access - since there are no methods on the derived value class >>>> and the value capable class can?t have any methods with vbytecodes since generated by javac >>>> - plan to make private when we add factory methods to value classes with a compiler (and we have nest support) >>>> >>> >>> I am unsure if it?s necessary for MVT purposes to dial back the accessibility then dial it up again later on. >>> >>> ValueType.findWither can be used in conjunction with MethodHandle.privateLookupIn. It?s a little odd but works. What am i missing? >>> >>> Paul. >>> >>> >>> >>> >> > From paul.sandoz at oracle.com Wed Jul 5 17:59:29 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 5 Jul 2017 10:59:29 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> Message-ID: I strongly suspect we can specify a safe version of Unsafe.defineAnonymousClass (minus constant pool patching) independent of nest mates. I believe that is desirable on it?s own as part of the replace unsafe functionality and if that can help MVT then even better! Paul. > On 5 Jul 2017, at 10:48, Karen Kinnear wrote: > > Agree with John?s clarification - yes we are planning longterm for nest mate access. > And your proposal of using a safe replacement for Unsafe.defineAnonymousClass with > appropriate access to add into the nest makes sense. > > At this time we are building an Early Access that needs to go out sooner than nest mates. > We should re-evaluate adding a nest mate dependency when we get closer to deadlines and > see if that works for our partners and our own timing. > > thanks, > Karen > >> On Jul 5, 2017, at 12:28 PM, Paul Sandoz wrote: >> >> >>> On 5 Jul 2017, at 07:26, Karen Kinnear wrote: >>> >>> Paul, >>> >>> What we were discussing was the ability to use the byte code itself - not the ValueType.findWither API. >>> John?s longer term plan is that ultimately the byte code can only be executed in the value class itself, and >>> since the derived value class has no methods, we need a temporary approach. >>> >>> Did I misunderstand what you were saying? >>> >> >> No, i was missing aspect that you were referring to byte code generation. >> >> What if we added a safe replacement for: >> >> Unsafe.defineAnonymousClass >> https://bugs.openjdk.java.net/browse/JDK-8171335 >> >> (Which we anyway have to do.) >> >> ? > >> >> Then the VCC or DVT could be used as the host class. However, i dunno if that would be sufficient to cover the use-cases of byte code generation. > >> >> Paul. >> >>> thanks, >>> Karen >>> >>>> On Jun 26, 2017, at 2:52 PM, Paul Sandoz wrote: >>>> >>>> >>>>> On 23 Jun 2017, at 13:33, Karen Kinnear wrote: >>>> >>>>> VWithfield - propose for MVT - allow package private access - since there are no methods on the derived value class >>>>> and the value capable class can?t have any methods with vbytecodes since generated by javac >>>>> - plan to make private when we add factory methods to value classes with a compiler (and we have nest support) >>>>> >>>> >>>> I am unsure if it?s necessary for MVT purposes to dial back the accessibility then dial it up again later on. >>>> >>>> ValueType.findWither can be used in conjunction with MethodHandle.privateLookupIn. It?s a little odd but works. What am i missing? >>>> >>>> Paul. >>>> >>>> >>>> >>>> >>> >> > From john.r.rose at oracle.com Wed Jul 5 18:06:33 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 5 Jul 2017 11:06:33 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> Message-ID: <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> On Jul 5, 2017, at 10:59 AM, Paul Sandoz wrote: > > I strongly suspect we can specify a safe version of Unsafe.defineAnonymousClass (minus constant pool patching) independent of nest mates. I believe that is desirable on it?s own as part of the replace unsafe functionality and if that can help MVT then even better! We have an API point already for this, with a pre-planned "hole" for the functionality you want. If the VCC says "L=MethodHandles.lookup().in(DVT.class)" the Lookup should retain the PRIVATE access mode. Then, L.defineClass(...) is specified to throw an exception when it sees the PRIVATE access mode, but what is supposed to happen in the future is that the newly defined class is inserted into the nest of the Lookup.lookupClass. In the very specific case of a DVT, it would be reasonable to allow the injection you want, Paul, without throwing the required exception. After all, the DVT's are going away, so there's no compatibility risk for future changes to the API. The challenge to provide this for general use is to specify what happens when the Lookup has PRIVATE access mode. The best way to spec. this (IMO) is as a forcible injection into the nest of the Lookup.lookupClass. That requires nestmates to be specified *first*, and *then* we can specify what it means to inject a new (dynamically defined) nestmate. ? John From paul.sandoz at oracle.com Wed Jul 5 18:39:03 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 5 Jul 2017 11:39:03 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> Message-ID: <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> > On 5 Jul 2017, at 11:06, John Rose wrote: > > On Jul 5, 2017, at 10:59 AM, Paul Sandoz > wrote: >> >> I strongly suspect we can specify a safe version of Unsafe.defineAnonymousClass (minus constant pool patching) independent of nest mates. I believe that is desirable on it?s own as part of the replace unsafe functionality and if that can help MVT then even better! > > We have an API point already for this, with a pre-planned "hole" for the functionality you want. > > If the VCC says "L=MethodHandles.lookup().in(DVT.class)" the Lookup should retain the PRIVATE access mode. > Yes. > Then, L.defineClass(...) is specified to throw an exception when it sees the PRIVATE access mode, Right, i was just looking at that, currently scoped for package access. > but what is supposed to happen in the future is that the newly defined class is inserted into the nest of the Lookup.lookupClass. > I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. Paul. > In the very specific case of a DVT, it would be reasonable to allow the injection you want, Paul, without throwing the required exception. After all, the DVT's are going away, so there's no compatibility risk for future changes to the API. > > The challenge to provide this for general use is to specify what happens when the Lookup has PRIVATE access mode. The best way to spec. this (IMO) is as a forcible injection into the nest of the Lookup.lookupClass. That requires nestmates to be specified *first*, and *then* we can specify what it means to inject a new (dynamically defined) nestmate. > > ? John From john.r.rose at oracle.com Wed Jul 5 18:43:51 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 5 Jul 2017 11:43:51 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> Message-ID: <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> On Jul 5, 2017, at 11:39 AM, Paul Sandoz wrote: > > > I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. > Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). For MVT we can just generate a throwaway name, like DVT.getName()+":29348". ? John From brian.goetz at oracle.com Wed Jul 5 18:57:40 2017 From: brian.goetz at oracle.com (Brian Goetz) Date: Wed, 5 Jul 2017 14:57:40 -0400 Subject: constant-dynamic specification, updated In-Reply-To: References: Message-ID: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> This is very nice. One thing that readers will wonder (doesn't belong in JVMS, but belongs somewhere) is what suggested practice are for using invocation name / constant name. I don't see the name widely used in indy, but I could imagine it more widely used in condy, because constants often have names (like Pi.) For a BSM that effectively has a single String parameter, I think we'll get more compact classfiles if we use the name and a shared no-arg BootstrapMethods entry, but is that a good reason? For example, for a primitive-class bootstrap, would this be a good use of the name? I don't understand this sentence: "A bootstrap specifier gives a method or fielddescriptor,/TD/." On the API: - The type parameter T to BCI is "dangling", in that there is nothing to constrain it. However, IIUC, it can only be MethodType or Class. In an ideal world, T would be bounded by the common supertype of these two things (NominalConstantRepresentingMemberDescriptor). We generally advise against use of unconstrained tvars like this in APIs, since it provides only the illusion of type safety, though I understand why you went this way -- you can have a BSM Foo bsm(Lookup lookup, BootstrapCallInfo bci) { ... } and just proceed without casting, and it's both convenient and self-documenting. If we had a common supertype in the future, we'd not be able to add this as a bound in a binary-compatible manner, because invocationType()Object would be burned into client classfiles. So it's kind of a dead-end. In any case, I'd add a stronger note about the range of T here. THere's room to put javadoc on tvars with "@param "; you could say "Must be Class or MethodType." - In ConstantGroup, do you want to clarify that constants described by multiple CGs might be the same constant, and therefore might share the one-time transition to resolved? Readers could think that the one-transition lifecycle is a property of "entry #3 in CG at 234098", not the constant that CG at 234098 happens to refer to in slot 3. I'd like to see some guidance about what a constant is. Condy will happily serve up mutable objects in the guise of dynamic constants, and the VM will have no regrets. However, this is likely to lead to pain (or security issues) for the user. Some sort of guidance here would be good, perhaps in the package javadoc. Also, related: what sort of facilities might we want to provide for caching/interning of equivalent constants across classes? I could easily imagine a BSM wanting to preserve the invariant that any LDC with a given set of args from any class results in the same object. On 6/24/2017 7:52 PM, John Rose wrote: > I have updated the javadoc API that is relevant to the proposed > JVM features for dynamic constants and more powerful bootstrap > methods. > > http://cr.openjdk.java.net/~jrose/jvm/condy-jvms-2017-0620.html > > Here is a rough draft of the corresponding JVMS changes: > > http://cr.openjdk.java.net/~jrose/jvm/specdiff-condy-2017-0624.zip > > Please enjoy and comment. > > ? John From daniel.smith at oracle.com Wed Jul 5 19:13:22 2017 From: daniel.smith at oracle.com (Dan Smith) Date: Wed, 5 Jul 2017 13:13:22 -0600 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> References: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> Message-ID: > On Jul 5, 2017, at 8:12 AM, Karen Kinnear wrote: > >> > Dan S: class loading in the proposed JVMS: if you see $Value >> > 1) first derive the VCC name and see if already resolved >> > 2) if not - load the VCC, check properties and derive >> > (ed. note - if see VCC - lazily derive derived value class on touch) >> >> It's not a requirement that the value class derivation is lazy, correct? > Let?s double-check with Dan Smith at today?s meeting. > > The way I read 5.3 Creation and Loading in > http://cr.openjdk.java.net/~dlsmith/values.html > it appears to allow lazy derivation as well as eager derivation, which I think is what we both want > since it allows implementations to optimize. > Our current derivation is also eager. Summary of today's discussion, supplemented with some reflection on what I see as the requirements: - The specification shouldn't care when the class is derived (though it must occur, naturally, no later than resolution of "Foo$Value"); the specification *might* care when error checking occurs, because that's observable. - Current specification draft says error checking occurs when Foo$Value is loaded (5.3), and that "Class or interface creation is triggered by another class or interface D, which references C through its run-time constant pool." So, as a test case: if my program has no references to Foo$Value (direct or reflective), no VCC-related errors would occur. - We could redesign this so that the VCC properties are checked during loading/verification of Foo. I am concerned that, where Foo is version 54.0 and has attribute ValueCapableClass, this sort of error checking will violate the Java SE 10 spec. Elaborating: we're presenting values as an optional feature of Java SE 10. For a JVM that does not implement the optional feature, JVMS 10 says that a ValueCapableClass attribute on a version 54.0 class file will be ignored. JVMS 4.7.1: "any attribute not defined as part of the class file specification must not affect the semantics of the class file. Java Virtual Machine implementations are required to silently ignore attributes they do not recognize." My interpretation of our mission, in adding an optional feature, is to provide new capabilities while having no impact on existing behavior. We can do new things where JVMS 10 specifies an error; we can't generate new errors where JVMS 10 specifies none. - We could limit usage/interpretation of "ValueCapableClass" to 54.1 class files. Then eager error checks when loading Foo would be fine. But the ability to work with 54.0 ValueCapableClass class files is an important use case. - Actually, examining that use case more closely, we discussed how attributes are not the right tool at all. We want clients of MVT to be able to generate interesting programs using a vanilla Java SE 10 compiler. The best mechanism to communicate "I'm a value-capable class" using a vanilla Java compiler is annotations, not attributes. Tentatively, the spec should be revised so that: - The "ValueCapableClass" attribute no longer exists. Delete changes to 4.7 and delete new section 4.7.25. - A "value capable class" is a class whose RuntimeVisibleAnnotations includes a ValueCapableClass annotation (package TBD; whether the referenced class must be loaded TBD) - As usual, this annotation doesn't impact behavior of class Foo - When loading Foo$Value, as specified in 5.3, we'll check that Foo is a value capable class and that it has the right properties ?Dan From john.r.rose at oracle.com Wed Jul 5 19:51:18 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 5 Jul 2017 12:51:18 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> Message-ID: <0EA0F802-333E-40F7-B344-3739C8082933@oracle.com> On Jul 5, 2017, at 12:13 PM, Dan Smith wrote: > Summary of today's discussion, supplemented with some reflection on what I see as the requirements: Thanks! > - The specification shouldn't care when the class is derived (though it must occur, naturally, no later than resolution of "Foo$Value"); the specification *might* care when error checking occurs, because that's observable. Even more specifically: "when errors are reported". Checking can happen long before reporting. > - Current specification draft says error checking occurs when Foo$Value is loaded (5.3), and that "Class or interface creation is triggered by another class or interface D, which references C through its run-time constant pool." So, as a test case: if my program has no references to Foo$Value (direct or reflective), no VCC-related errors would occur. I would prefer this in MVT, but it's not a showstopper. In the long term this might be a good move, relative to operations that resolve Q-Foo (not Foo$Value), if Foo is supposed to be "merely an object" until suddenly its value aspect comes into play. In the usual case where some ACC_VALUE bit is present in the class file, there is no cause to delay error processing. > - We could redesign this so that the VCC properties are checked during loading/verification of Foo. I am concerned that, where Foo is version 54.0 and has attribute ValueCapableClass, this sort of error checking will violate the Java SE 10 spec. > > Elaborating: we're presenting values as an optional feature of Java SE 10. For a JVM that does not implement the optional feature, JVMS 10 says that a ValueCapableClass attribute on a version 54.0 class file will be ignored. JVMS 4.7.1: "any attribute not defined as part of the class file specification must not affect the semantics of the class file. Java Virtual Machine implementations are required to silently ignore attributes they do not recognize." My interpretation of our mission, in adding an optional feature, is to provide new capabilities while having no impact on existing behavior. We can do new things where JVMS 10 specifies an error; we can't generate new errors where JVMS 10 specifies none. This is a good point. It's the right way to manage the spec. OTOH, it's hard to construct examples where this matters for MVT. If I forget to use a VM that supports DVTs (or forget to flip the On switch), I am practically certain to get an error if I run my example MVT code. The error should occur as soon as the DVT is extracted. But it might also occur if the JVM falls over (due to some bug) when it loads the VCC and asks itself a premature question. Practically speaking, I will never expect (in MVT) to use a VCC as a POJO with DVTs turned off. > > - We could limit usage/interpretation of "ValueCapableClass" to 54.1 class files. Then eager error checks when loading Foo would be fine. But the ability to work with 54.0 ValueCapableClass class files is an important use case. Confirmed. This is why "Shady" speaks of mainly of an annotation to enable VCCs. (Over-cautiously, it also says "perhaps an attribute".) I should have mentioned this earlier. > - Actually, examining that use case more closely, we discussed how attributes are not the right tool at all. We want clients of MVT to be able to generate interesting programs using a vanilla Java SE 10 compiler. The best mechanism to communicate "I'm a value-capable class" using a vanilla Java compiler is annotations, not attributes. > > Tentatively, the spec should be revised so that: > - The "ValueCapableClass" attribute no longer exists. Delete changes to 4.7 and delete new section 4.7.25. > - A "value capable class" is a class whose RuntimeVisibleAnnotations includes a ValueCapableClass annotation (package TBD; whether the referenced class must be loaded TBD) > - As usual, this annotation doesn't impact behavior of class Foo > - When loading Foo$Value, as specified in 5.3, we'll check that Foo is a value capable class and that it has the right properties Also: - The annotation is ignored if the VCC does not have permission to access the annotation. (It's filtered like @Contended, which is not in the spec.) This check is complex to implement in general, since it interacts with the bootstrapping of the module system runtime. But in fact it only needs to work for the specific @ValueCapableClass annotation. That means a hardwired check to is likely to work, by embedded into the JVM which modules have access to the @VCC annotation. For @Contended it works because the JVM "just knows" that @Contended lives in an unexported package of java.base. ? John From paul.sandoz at oracle.com Wed Jul 5 20:08:26 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 5 Jul 2017 13:08:26 -0700 Subject: constant-dynamic specification, updated In-Reply-To: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> References: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> Message-ID: <957B7AE8-9DFA-46D1-A065-AD94E4BE6612@oracle.com> > On 5 Jul 2017, at 11:57, Brian Goetz wrote: > > This is very nice. > > One thing that readers will wonder (doesn't belong in JVMS, but belongs somewhere) is what suggested practice are for using invocation name / constant name. I don't see the name widely used in indy, but I could imagine it more widely used in condy, because constants often have names (like Pi.) For a BSM that effectively has a single String parameter, I think we'll get more compact classfiles if we use the name and a shared no-arg BootstrapMethods entry, but is that a good reason? For example, for a primitive-class bootstrap, would this be a good use of the name? > That?s how it?s applied by javac and the BSM (j.l.i.DynamicConstants.primitiveClassBootstrap) in the amber branch. For a VarHandle to a field, the name corresponds to the field name (for an array it is redundant). (FWIW the StringConcatFactory BSM could of used the name for the recipe encoding. Arguably with condy a richer recipe description could be used as a BSM argument rather than encoding it all into a string.) > I don't understand this sentence: "A bootstrap specifier gives a method or field descriptor, TD." > > On the API: > > - The type parameter T to BCI is "dangling", in that there is nothing to constrain it. However, IIUC, it can only be MethodType or Class. In an ideal world, T would be bounded by the common supertype of these two things (NominalConstantRepresentingMemberDescriptor). We generally advise against use of unconstrained tvars like this in APIs, since it provides only the illusion of type safety, though I understand why you went this way -- you can have a BSM > > Foo bsm(Lookup lookup, BootstrapCallInfo bci) { ... } > > and just proceed without casting, and it's both convenient and self-documenting. > > If we had a common supertype in the future, we'd not be able to add this as a bound in a binary-compatible manner, because invocationType()Object would be burned into client classfiles. So it's kind of a dead-end. In any case, I'd add a stronger note about the range of T here. THere's room to put javadoc on tvars with "@param "; you could say "Must be Class or MethodType." > > - In ConstantGroup, do you want to clarify that constants described by multiple CGs might be the same constant, and therefore might share the one-time transition to resolved? Readers could think that the one-transition lifecycle is a property of "entry #3 in CG at 234098", not the constant that CG at 234098 happens to refer to in slot 3. > > > I'd like to see some guidance about what a constant is. Condy will happily serve up mutable objects in the guise of dynamic constants, and the VM will have no regrets. However, this is likely to lead to pain (or security issues) for the user. Some sort of guidance here would be good, perhaps in the package javadoc. > > Also, related: what sort of facilities might we want to provide for caching/interning of equivalent constants across classes? I could easily imagine a BSM wanting to preserve the invariant that any LDC with a given set of args from any class results in the same object. > And also that the constant returned from a condy might store a ConstantGroup for later resolution of further values, namely the scope of resolution can exceed that of the BSM invocation (which is what i suspect might happen for pattern matching). Paul. From paul.sandoz at oracle.com Thu Jul 6 20:02:39 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 6 Jul 2017 13:02:39 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: In terms of what we have today we could easily do: // lookup must have private access to the lookup class, which becomes the ?host? class Class defineAnonymousClass(byte[] data) is that ending gaining too much? That still leaves the possibility of another method in the future say: Class defineClass(boolean isAnon, byte[] data, Object constant) That?s a little fuzzy since it?s not clear to me how the generated class locates the constant (synthetic static final field of known name? substitute the last entry in the CP if appropriately defined in the class bytes as substitutable?). Paul. > On 5 Jul 2017, at 11:43, John Rose wrote: > > On Jul 5, 2017, at 11:39 AM, Paul Sandoz wrote: >> >> >> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >> > > Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. > > At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), > 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). > > For MVT we can just generate a throwaway name, like DVT.getName()+":29348". > > ? John From forax at univ-mlv.fr Thu Jul 6 20:12:30 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Thu, 6 Jul 2017 22:12:30 +0200 (CEST) Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: <432349830.2490944.1499371950101.JavaMail.zimbra@u-pem.fr> ----- Mail original ----- > De: "Paul Sandoz" > ?: "John Rose" > Cc: valhalla-spec-experts at openjdk.java.net > Envoy?: Jeudi 6 Juillet 2017 22:02:39 > Objet: Re: Valhalla EG minutes 6/21/17 > In terms of what we have today we could easily do: > > // lookup must have private access to the lookup class, which becomes the ?host? > class > Class defineAnonymousClass(byte[] data) > > is that ending gaining too much? > > That still leaves the possibility of another method in the future say: > > Class defineClass(boolean isAnon, byte[] data, Object constant) > > That?s a little fuzzy since it?s not clear to me how the generated class locates > the constant (synthetic static final field of known name? substitute the last > entry in the CP if appropriately defined in the class bytes as substitutable?). Lookup.getConstant() with a private Lookup ? > > Paul. R?mi > >> On 5 Jul 2017, at 11:43, John Rose wrote: >> >> On Jul 5, 2017, at 11:39 AM, Paul Sandoz wrote: >>> >>> >>> I was unsure if we require a new method L.defineAnonClass or could leverage the >>> existing L.defineClass. IIUC for expediency the current hooks in the VM lean >>> towards anon classes, since there is already code to defer to the host class, >>> whereas the general defineClass case will likely require more work, although i >>> can potentially see some short cuts if we focus on VCC/DVT. >>> >> >> Good point. Yes, that part isn't designed yet. It may manifest as an extra >> argument or two to the L.dC. >> >> At least two degrees of freedom apply there: 1. suppressing the name (no system >> dictionary update), >> 2. providing some sort of "user data" to bind to the class (can be a single >> ref., replaces CP patching). >> >> For MVT we can just generate a throwaway name, like DVT.getName()+":29348". >> > > ? John From john.r.rose at oracle.com Thu Jul 6 22:58:08 2017 From: john.r.rose at oracle.com (John Rose) Date: Thu, 6 Jul 2017 15:58:08 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: On Jul 6, 2017, at 1:02 PM, Paul Sandoz wrote: > > In terms of what we have today we could easily do: > > // lookup must have private access to the lookup class, which becomes the ?host? class > Class defineAnonymousClass(byte[] data) > > is that ending gaining too much? Sure, that's OK, or else an 'isAnonymous' optional argument. The difficult part here is specifying exactly what is a "host class". > That still leaves the possibility of another method in the future say: > > Class defineClass(boolean isAnon, byte[] data, Object constant) > > That?s a little fuzzy since it?s not clear to me how the generated class locates the constant (synthetic static final field of known name? substitute the last entry in the CP if appropriately defined in the class bytes as substitutable?). On Jul 6, 2017, at 1:12 PM, Remi Forax wrote: > > Lookup.getConstant() with a private Lookup ? Exactly, an ad hoc API point like that. Would fit nicely with a BSM and CONSTANT_ConstantDynamic and ldc. Or a private static final and code in . If you need several of them, a Map would be your friend. This doesn't need to be baked into the Lookup API, just a design pattern, supported nicely by a slightly different BSM. ? John From john.r.rose at oracle.com Thu Jul 6 23:34:48 2017 From: john.r.rose at oracle.com (John Rose) Date: Thu, 6 Jul 2017 16:34:48 -0700 Subject: constant-dynamic specification, updated In-Reply-To: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> References: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> Message-ID: <2441BC64-0D14-453D-9AD0-26235F85C344@oracle.com> On Jul 5, 2017, at 11:57 AM, Brian Goetz wrote: > > This is very nice. > > One thing that readers will wonder (doesn't belong in JVMS, but belongs somewhere) is what suggested practice are for using invocation name / constant name. I don't see the name widely used in indy, but I could imagine it more widely used in condy, because constants often have names (like Pi.) For a BSM that effectively has a single String parameter, I think we'll get more compact classfiles if we use the name and a shared no-arg BootstrapMethods entry, but is that a good reason? Combined with one other reason it is good enough. The other reason is that invokedynamic BSMs already take a method name. It is helpful to keep indy and condy BSMs similar, where possible. The similarity allows similar parts to be factored together, in both spec. and implementation. The similarity, in brief, condy:indy :: Fieldref:Methodref. In all cases, you have a NameAndType (field or method) accompanied by either a Class or a BSM. > For example, for a primitive-class bootstrap, would this be a good use of the name? Here FTR are some use cases for constants with very simple names: - enums (all enums can use *one* BSM in common) - other ad hoc manifest constants (Math.PI; BSM must be told which class) - primitives (really, ad hoc access to "W.TYPE" constants, but "I" is more compact) - simple extended numerics ("2/3", "1i2") - dates, times ("12:30am") - any other naming system (encodings? locales? timezones? geos?) - format specifiers (like the 'recipe' of StringConcatFactory) The overall effect is to keep the length of the BootstrapMethods attribute small even if there are large numbers of simple constants floating around. (Also, Note that integer constants divide into small?aconst_2, bipush, sipush?and large?ldc CONSTANT_Integer. Similarly, small numerics might be well served by using name strings when they are short, and component-wise BSMs otherwise.) If indy had not already set the pattern, these (taken all together) are IMO barely enough to motivate allowing this extra-compact way of defining constants, but only after a close accounting of the exact number of CP and BSM indexes consumed by each proposed translation strategy. (I should say that indy set this pattern because of a similar analysis for method names. So the StringConcatFactory could use this trick to implement all concatenations with one BSM. The DynaLink API can make good use of the method names, allowing one BSM to serve all invocation instructions.) > I don't understand this sentence: "A bootstrap specifier gives a method or field descriptor, TD." The vague phrase "a foo specifier gives a bar" appears a lot. It could be super-explicit: "A bootstrap specifier gives a CONSTANT_Utf8 string which encodes a method descriptor or field descriptor; call it TD." Or: "A bootstrap specifier gives a method descriptor or a field descriptor; call it TD." > > On the API: > > - The type parameter T to BCI is "dangling", in that there is nothing to constrain it. However, IIUC, it can only be MethodType or Class. In an ideal world, T would be bounded by the common supertype of these two things (NominalConstantRepresentingMemberDescriptor). We generally advise against use of unconstrained tvars like this in APIs, since it provides only the illusion of type safety, though I understand why you went this way -- you can have a BSM > > Foo bsm(Lookup lookup, BootstrapCallInfo bci) { ... } > > and just proceed without casting, and it's both convenient and self-documenting. Yep. And I uses BootstrapCallInfo for generic uses, knowing that Object is the bound type. I don't think the types will cooperate with anything cleaner. (Should I try BootstrapCallInfo maybe? That might work. Nice wildcard? nice wildcard? ouch, down boy!) > If we had a common supertype in the future, we'd not be able to add this as a bound in a binary-compatible manner, because invocationType()Object would be burned into client classfiles. So it's kind of a dead-end. In any case, I'd add a stronger note about the range of T here. THere's room to put javadoc on tvars with "@param "; you could say "Must be Class or MethodType." Will do. > - In ConstantGroup, do you want to clarify that constants described by multiple CGs might be the same constant, and therefore might share the one-time transition to resolved? Readers could think that the one-transition lifecycle is a property of "entry #3 in CG at 234098", not the constant that CG at 234098 happens to refer to in slot 3. Will do. I was being cagey. > I'd like to see some guidance about what a constant is. Condy will happily serve up mutable objects in the guise of dynamic constants, and the VM will have no regrets. However, this is likely to lead to pain (or security issues) for the user. Some sort of guidance here would be good, perhaps in the package javadoc. OK, will add. This is not something the system can check or enforce, of course. > > Also, related: what sort of facilities might we want to provide for caching/interning of equivalent constants across classes? I could easily imagine a BSM wanting to preserve the invariant that any LDC with a given set of args from any class results in the same object. I was going to leave that up to the user. But I'll add a note, since String sets the standard by making the interning behavior clear, as a reliable across compilation units. ? John > On 6/24/2017 7:52 PM, John Rose wrote: >> I have updated the javadoc API that is relevant to the proposed >> JVM features for dynamic constants and more powerful bootstrap >> methods. >> >> >> http://cr.openjdk.java.net/~jrose/jvm/condy-jvms-2017-0620.html >> >> >> Here is a rough draft of the corresponding JVMS changes: >> >> >> http://cr.openjdk.java.net/~jrose/jvm/specdiff-condy-2017-0624.zip >> >> >> Please enjoy and comment. >> >> ? John >> > From brian.goetz at oracle.com Fri Jul 7 00:13:24 2017 From: brian.goetz at oracle.com (Brian Goetz) Date: Thu, 6 Jul 2017 20:13:24 -0400 Subject: constant-dynamic specification, updated In-Reply-To: <2441BC64-0D14-453D-9AD0-26235F85C344@oracle.com> References: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> <2441BC64-0D14-453D-9AD0-26235F85C344@oracle.com> Message-ID: <7775DF14-929F-49C9-9AEE-3826F523179C@oracle.com> >> One thing that readers will wonder (doesn't belong in JVMS, but belongs somewhere) is what suggested practice are for using invocation name / constant name. I don't see the name widely used in indy, but I could imagine it more widely used in condy, because constants often have names (like Pi.) For a BSM that effectively has a single String parameter, I think we'll get more compact classfiles if we use the name and a shared no-arg BootstrapMethods entry, but is that a good reason? > > Combined with one other reason it is good enough. The other reason is that invokedynamic > BSMs already take a method name. It is helpful to keep indy and condy BSMs similar, where > possible. The similarity allows similar parts to be factored together, in both spec. and > implementation. The similarity, in brief, condy:indy :: Fieldref:Methodref. In all cases, > you have a NameAndType (field or method) accompanied by either a Class or a BSM. I was asking a slightly different question; not ?why should condy support an invocation name?, but, ?given that condy supports an invocation name, how and when should a bootstrap writer choose to use it vs one (or more) String parameters?? From john.r.rose at oracle.com Fri Jul 7 00:18:13 2017 From: john.r.rose at oracle.com (John Rose) Date: Thu, 6 Jul 2017 17:18:13 -0700 Subject: constant-dynamic specification, updated In-Reply-To: <7775DF14-929F-49C9-9AEE-3826F523179C@oracle.com> References: <4a909f99-6074-6977-77c3-85ea493c7783@oracle.com> <2441BC64-0D14-453D-9AD0-26235F85C344@oracle.com> <7775DF14-929F-49C9-9AEE-3826F523179C@oracle.com> Message-ID: <0DF5609B-22BB-4134-9130-5E96D9F63223@oracle.com> On Jul 6, 2017, at 5:13 PM, Brian Goetz wrote: > > I was asking a slightly different question Ok, thanks. (D'oh.) I'll put in some guidance. From paul.sandoz at oracle.com Fri Jul 7 00:37:57 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Thu, 6 Jul 2017 17:37:57 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: <3CFEE8CF-D24B-4258-B5BE-6DC9A775E597@oracle.com> > On 6 Jul 2017, at 15:58, John Rose wrote: > > On Jul 6, 2017, at 1:02 PM, Paul Sandoz > wrote: >> >> In terms of what we have today we could easily do: >> >> // lookup must have private access to the lookup class, which becomes the ?host? class >> Class defineAnonymousClass(byte[] data) >> >> is that ending gaining too much? > > Sure, that's OK, or else an 'isAnonymous' optional argument. > The difficult part here is specifying exactly what is a "host class". > Agreed, that?s the tricky bit. >> That still leaves the possibility of another method in the future say: >> >> Class defineClass(boolean isAnon, byte[] data, Object constant) >> >> That?s a little fuzzy since it?s not clear to me how the generated class locates the constant (synthetic static final field of known name? substitute the last entry in the CP if appropriately defined in the class bytes as substitutable?). > > On Jul 6, 2017, at 1:12 PM, Remi Forax > wrote: >> >> Lookup.getConstant() with a private Lookup ? > > Exactly, an ad hoc API point like that. Would fit nicely with a BSM and > CONSTANT_ConstantDynamic and ldc. Or a private static final and > code in . I like that. Perhaps those associated constants could be squirrelled away in a ClassValue, and any class could participate and receive an ad-hoc constant. > > If you need several of them, a Map would be your > friend. This doesn't need to be baked into the Lookup API, just a > design pattern, supported nicely by a slightly different BSM. > And there could be a condy for extracting a value for a given key from the Map constant. Paul. From karen.kinnear at oracle.com Tue Jul 11 21:42:59 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Tue, 11 Jul 2017 17:42:59 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: Paul, We are working hard on getting the nest mates requirements clarified. I would like to use that to support the Lookup.defineClass and not do a Quick&Dirty in advance for MVT . I think we should stick with the reduced restrictions for withfield for early access. I think we should put our energy into getting nest mates and Lookup.defineClass ready. We have three parts to Lookup.defineClass. 1) PRIVATE mode handling - which we believe we can support with nest mates - we do not want to do any versions of this based on unsafe.DAC current behavior, - we are looking at cleaner behavior for nestmates 2) ?temporary? name - i.e. find doesn?t work 3) CP patching/user data My mental model is that we don?t have to add all of these at the same time, although we will want user feedback on when to remove unsafe.DefineAnonymousClass. In fact, we would love more examples of current use cases, to help guide our design. thanks, Karen > On Jul 5, 2017, at 2:43 PM, John Rose wrote: > > On Jul 5, 2017, at 11:39 AM, Paul Sandoz > wrote: >> >> >> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >> > > Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. > > At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), > 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). > > For MVT we can just generate a throwaway name, like DVT.getName()+":29348". > > ? John From paul.sandoz at oracle.com Tue Jul 11 23:10:11 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 11 Jul 2017 16:10:11 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> Hi Karen, Thanks, i understand the need for being conservative here in case we get things wrong. The pragmatic relaxation is entirely reasonable, although i would still prefer to go through a lookup mechanism if we could pull it off :-) Paul. > On 11 Jul 2017, at 14:42, Karen Kinnear wrote: > > Paul, > > We are working hard on getting the nest mates requirements clarified. > I would like to use that to support the Lookup.defineClass and not do a Quick&Dirty > in advance for MVT . I think we should stick with the reduced restrictions > for withfield for early access. I think we should put our energy into getting > nest mates and Lookup.defineClass ready. > > We have three parts to Lookup.defineClass. > 1) PRIVATE mode handling - which we believe we can support with nest mates > - we do not want to do any versions of this based on unsafe.DAC current behavior, > - we are looking at cleaner behavior for nestmates > 2) ?temporary? name - i.e. find doesn?t work > 3) CP patching/user data > > My mental model is that we don?t have to add all of these at the same time, > although we will want user feedback on when to remove unsafe.DefineAnonymousClass. > In fact, we would love more examples of current use cases, to help guide our > design. > > thanks, > Karen > >> On Jul 5, 2017, at 2:43 PM, John Rose > wrote: >> >> On Jul 5, 2017, at 11:39 AM, Paul Sandoz > wrote: >>> >>> >>> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >>> >> >> Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. >> >> At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), >> 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). >> >> For MVT we can just generate a throwaway name, like DVT.getName()+":29348". >> >> ? John > From paul.sandoz at oracle.com Tue Jul 11 23:34:10 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 11 Jul 2017 16:34:10 -0700 Subject: off-list Re: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> Message-ID: <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> Hi, Off-list as i am not sure i wanna commit to this publicly :-) In the interest of moving this forward independent of MVT i can prototype some of this if you like and use the three usages of U.DAC in the JDK as use-cases (see also [1]) Perhaps surprisingly grepcode.com reports no external usages of U.DAC. Some use-cases for U.DAC could be replaced by an isolated method feature, which makes me wonder if that is really the actual public feature we really want rather than anon/nameless classes? My gut feeling is 2) can be implemented straightforwardly on top of Unsafe.DAC with appropriate checks, if we are ok with the current HS implementation at least as a starting point. To me the tricky bit is the spec gymnastics, it would have to be subset of the eventual behaviour and that can only expand in scope with refinement of terms. Is that a reasonably accurate assessment? I believe we can also prototype the constant pool patching in an indirect manner as indicated by John and Remi. That leaves the more general nested named class support which requires more fundamental hotspot work. So in terms of progress order it could be: 2), 3), 1). But if we throw isolated methods into the mix then the plot thickens. Paul. [1] https://bugs.openjdk.java.net/browse/JDK-8078602 Support j.l.i.BoundMethodHandle$Species_* classes unloading https://bugs.openjdk.java.net/browse/JDK-8168848 Too many anonymous classes that aren't unloaded > On 11 Jul 2017, at 14:42, Karen Kinnear wrote: > > Paul, > > We are working hard on getting the nest mates requirements clarified. > I would like to use that to support the Lookup.defineClass and not do a Quick&Dirty > in advance for MVT . I think we should stick with the reduced restrictions > for withfield for early access. I think we should put our energy into getting > nest mates and Lookup.defineClass ready. > > We have three parts to Lookup.defineClass. > 1) PRIVATE mode handling - which we believe we can support with nest mates > - we do not want to do any versions of this based on unsafe.DAC current behavior, > - we are looking at cleaner behavior for nestmates > 2) ?temporary? name - i.e. find doesn?t work > 3) CP patching/user data > > My mental model is that we don?t have to add all of these at the same time, > although we will want user feedback on when to remove unsafe.DefineAnonymousClass. > In fact, we would love more examples of current use cases, to help guide our > design. > > thanks, > Karen > >> On Jul 5, 2017, at 2:43 PM, John Rose wrote: >> >> On Jul 5, 2017, at 11:39 AM, Paul Sandoz wrote: >>> >>> >>> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >>> >> >> Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. >> >> At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), >> 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). >> >> For MVT we can just generate a throwaway name, like DVT.getName()+":29348". >> >> ? John > From paul.sandoz at oracle.com Tue Jul 11 23:36:10 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Tue, 11 Jul 2017 16:36:10 -0700 Subject: off-list Re: Valhalla EG minutes 6/21/17 In-Reply-To: <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> Message-ID: > On 11 Jul 2017, at 16:34, Paul Sandoz wrote: > > Hi, > > Off-list as i am not sure i wanna commit to this publicly :-) > Sigh, email fail, looks like i just have :-) Paul. > In the interest of moving this forward independent of MVT i can prototype some of this if you like and use the three usages of U.DAC in the JDK as use-cases (see also [1]) Perhaps surprisingly grepcode.com reports no external usages of U.DAC. > > Some use-cases for U.DAC could be replaced by an isolated method feature, which makes me wonder if that is really the actual public feature we really want rather than anon/nameless classes? > > My gut feeling is 2) can be implemented straightforwardly on top of Unsafe.DAC with appropriate checks, if we are ok with the current HS implementation at least as a starting point. To me the tricky bit is the spec gymnastics, it would have to be subset of the eventual behaviour and that can only expand in scope with refinement of terms. Is that a reasonably accurate assessment? > > I believe we can also prototype the constant pool patching in an indirect manner as indicated by John and Remi. > > That leaves the more general nested named class support which requires more fundamental hotspot work. > > So in terms of progress order it could be: 2), 3), 1). But if we throw isolated methods into the mix then the plot thickens. > > Paul. > > [1] > https://bugs.openjdk.java.net/browse/JDK-8078602 > Support j.l.i.BoundMethodHandle$Species_* classes unloading > https://bugs.openjdk.java.net/browse/JDK-8168848 > Too many anonymous classes that aren't unloaded > > >> On 11 Jul 2017, at 14:42, Karen Kinnear wrote: >> >> Paul, >> >> We are working hard on getting the nest mates requirements clarified. >> I would like to use that to support the Lookup.defineClass and not do a Quick&Dirty >> in advance for MVT . I think we should stick with the reduced restrictions >> for withfield for early access. I think we should put our energy into getting >> nest mates and Lookup.defineClass ready. >> >> We have three parts to Lookup.defineClass. >> 1) PRIVATE mode handling - which we believe we can support with nest mates >> - we do not want to do any versions of this based on unsafe.DAC current behavior, >> - we are looking at cleaner behavior for nestmates >> 2) ?temporary? name - i.e. find doesn?t work >> 3) CP patching/user data >> >> My mental model is that we don?t have to add all of these at the same time, >> although we will want user feedback on when to remove unsafe.DefineAnonymousClass. >> In fact, we would love more examples of current use cases, to help guide our >> design. >> >> thanks, >> Karen >> >>> On Jul 5, 2017, at 2:43 PM, John Rose wrote: >>> >>> On Jul 5, 2017, at 11:39 AM, Paul Sandoz wrote: >>>> >>>> >>>> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >>>> >>> >>> Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. >>> >>> At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), >>> 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). >>> >>> For MVT we can just generate a throwaway name, like DVT.getName()+":29348". >>> >>> ? John >> > From john.r.rose at oracle.com Tue Jul 11 23:58:51 2017 From: john.r.rose at oracle.com (John Rose) Date: Tue, 11 Jul 2017 16:58:51 -0700 Subject: off-list Re: Valhalla EG minutes 6/21/17 In-Reply-To: References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> Message-ID: On Jul 11, 2017, at 4:36 PM, Paul Sandoz wrote: > > Sigh, email fail, looks like i just have :-) Well played, sir! From john.r.rose at oracle.com Wed Jul 12 00:03:47 2017 From: john.r.rose at oracle.com (John Rose) Date: Tue, 11 Jul 2017 17:03:47 -0700 Subject: off-list Re: Valhalla EG minutes 6/21/17 In-Reply-To: <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <17C8C4A6-F650-4D51-88E5-0090918FC651@oracle.com> Message-ID: <7C3469DE-B091-4D91-9E78-5069A72949CA@oracle.com> On Jul 11, 2017, at 4:34 PM, Paul Sandoz wrote: > > That leaves the more general nested named class support which requires more fundamental hotspot work. > > So in terms of progress order it could be: 2), 3), 1). But if we throw isolated methods into the mix then the plot thickens. I think we should get the nestmate stuff nailed down first, then we can see more clearly how to do the U.DC nest injection logic. The existing, rather random stuff host-access logic will be hard to specify, and will be subsumed (and outdated) by nestmates. The isolated method idea can be specified "as if" there were a class wrapped around the method, but discarded. The specification burden for that, probably, is defining what MethodHandleInfo (if any) comes out of cracking the MH for the isolated method. "No info" is a good starting point. Remi's idea of an ad hoc "get my user data" API point (in Lookup for safety) makes sense to me; I don't see how to improve it. ? John From karen.kinnear at oracle.com Wed Jul 12 13:20:47 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 12 Jul 2017 09:20:47 -0400 Subject: class, type, instance, object, value In-Reply-To: <1F516BE7-30D2-47AF-9B83-3F8AA0A00FEE@oracle.com> References: <1F516BE7-30D2-47AF-9B83-3F8AA0A00FEE@oracle.com> Message-ID: <2FD8448E-CA9E-412C-9185-DF847F8FA666@oracle.com> John, Thank you for writing this up. Couple of questions/comments. - The class of a boxed value is the value class. (Thus each value class derives at least two types.) This one confuses me. I am not sure what you are referring to. 1) source: declaration - declared as a value class 2) classfile - marked via ACC_VALUE, from could derive a value class and a boxed class 3) constant_pool entry - at which we want a way to distinguish the two types 4) vm internal metadata - again distinguish two types 5) java level use - at which I am assuming we will have a way to distinguish a value class and a boxed value I believe Dan?s use of the term value class is for the unboxed value. I think we want to explicitly call out boxed value. - A "java.lang.Class" is usually a reference to class metadata, but not necessarily unique. There's wiggle room here for class-for-the-box vs. class-for-the-value, and int.class. We don't allow java.lang.Class to constrain other uses of the term "class". - When clarity is at risk, we can say "class mirror" rather than just "Class". I?m not sure what you mean here by ?not necessarily unique?. Perhaps that is because for me a java.lang.Class is always a mirror, i.e. a reflection of the vm?s internal representation for the unique class. Even if we use a name&mode to find a class-for-the-box vs. class-for-the-value, the java.lang.Class itself would be unique, wouldn?t it? thanks, Karen > On Jun 25, 2017, at 10:17 PM, John Rose wrote: > > So, I'm writing more and more documentation that discusses > objects and primitives while bringing values into the mix. > > What seems right to me is that we allow the terms "class", "type", > and "instance" to symmetrically cover both legacy object types > and new value types. We should continue to use the word "value" > but be careful about distinguishing its overloadings, especially > its role as an absolute noun vs. its role as an adjective. > > We should tolerate asymmetries that arise from the reference vs. > value distinction, and from box types which arise from value classes. > > Summary: > > Classes = Object Classes <+> Value Classes > Instances = Object Instances <+> Value Instances > Object Instances = instances of Object Classes <+> boxes of Value Instances > Reference Values = Object Instances <+> null > Values (noun) = Reference Values <+> Value Instances <+> Primitives > > (?where <+> denotes disjoint union) > > Details: > > - A "class" is at root metadata describing a type or implementation. > (It has API surface and/or implementation: super types, methods, fields, etc.) > - An "instance" is derived from a class and/or conforms to that class's API. > - An instance of an "object class" (or "object type") is an "object instance" (or just "object"). > - An instance of an "value class" (or "object value") is a "value instance" (or just "value" if context allows). > - When clarity is at risk, we can call a value class or value instance a "non-object class" or "non-object value". > - Because object instances are referred to by reference, a variable bound to one is a "reference". > (References can be to object instances, to boxes of value instances, or to the unique reference null.) > - A reference can also take "null" ("the null reference") as a value. > - References, primitives, and value instances are all "values" since they are passed by value. > - An instance of a "value class" is a "value instance" or (when clarity is not at risk) just a "value". > - Because value instances are referred to "by value", a variable bound to one is just a "value". > (When clarity is at risk, such a variable can be called a "pure value" or "non-reference".) > > Ambiguity: > > - The term "value" used as a noun can refer to the contents of a variable: reference, primitive, or value instance. > - The term "value" used as an adjective distinguishes a class, type, or instance from the "object" version. > - The term "value" can abbreviate "value instance"; context must clear this usage from ambiguity. > - Thus, the term "value" must always be used in a context which resolves it ambiguity. > (We could coin a new term to avoid ambiguity, but the meaning of "value" perfect, so let's keep it.) > - Sometimes when we say "value type" we really mean "non-object type", and expect primitives to be included. > - As part of fit-and-finish of Value Types we will give the primitives a comfortable seat at the table. > (Perhaps we can cleverly ret-con primitive types as value types, and their wrappers as boxes thereof.) > > Boxing, buffering, identity: > > - A value can be "boxed" into an object. Such an object can be "unboxed" back into its value. > - Boxed values are true objects, with object type. > - The class of a boxed value is the value class. (Thus each value class derives at least two types.) > - A value (of any sort) does not have identity, only the object instance under a non-null reference does. > - A "boxed value" (or "value is an object has identity, since it is an object instance. > - If an implementation uses pointer indirection to access a value, we say it is stored in a "buffer". > (This avoids confusion, since boxes are objects but buffers are not necessarily objects.) > - Buffers are invisible to the user, except perhaps via performance effects, or trusted APIs like Unsafe. > - Buffers can be on the stack, the heap, or anywhere else in memory. > - Boxes can secretly serve as buffers. > > False friends: > > - A "java.lang.Class" is usually a reference to class metadata, but not necessarily unique. > There's wiggle room here for class-for-the-box vs. class-for-the-value, and int.class. > We don't allow java.lang.Class to constrain other uses of the term "class". > - When clarity is at risk, we can say "class mirror" rather than just "Class". > - Similar point for "CONSTANT_Class" in the constant pool schema. Relatively few folks > are conscious of this term anyway. > - "Object-oriented" programming usually refers to some combination of > classes with reference-based polymorphism. Value types are object > oriented, even though their reference-based polymorphism is limited to > interfaces. Also they are squarely based on classes. > > Glossary: > > value type: a type which may be used without an accompanying reference (i.e., no intrinsic reference identity or aliasing) > value class: a code entity which defines a value type > value instance: a possible value (at runtime) of a variable of value type, derived from a value class > value field: (ambig.) field whose type is a value type (in any kind of class) OR a field in a value class (of any type) > value parameter: (ambig.) a parameter whose type is a value type OR a parameter, with emphasis on by-value transmission > value: (ambig.) a reference, value instance, or primitive OR context-dependent ellipsis for value type/class/instance > > object type: a type without references (i.e., no reference identity, no aliasing) > object class: a code entity which defines an object type > object instance: a possible value (at runtime) of a non-null variable of reference type > object field/parameter: (ambig., see above) > object: (ambig.) a reference to an object instance OR context-dependent ellipsis for value type/class/instance > > box type: an object type derived from a value class > box instance: a possible value (at runtime) of a non-null variable of box type > box: (ambig., see above) > > instance/class/type: (ambig., see above) > From forax at univ-mlv.fr Wed Jul 12 14:49:54 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Wed, 12 Jul 2017 16:49:54 +0200 (CEST) Subject: class, type, instance, object, value In-Reply-To: References: <1F516BE7-30D2-47AF-9B83-3F8AA0A00FEE@oracle.com> Message-ID: <477711826.553924.1499870994575.JavaMail.zimbra@u-pem.fr> Usually the difference between a class and a type is more runtime vs compile time. A type exist at compile time, a class exist at runtime. A type at compile time which is propagated as a class at runtime is a reified type, etc... R?mi ----- Mail original ----- > De: "John Rose" > ?: "Bjorn B Vardal" > Cc: valhalla-spec-experts at openjdk.java.net > Envoy?: Lundi 26 Juin 2017 20:41:49 > Objet: Re: class, type, instance, object, value > On Jun 26, 2017, at 5:16 AM, Bjorn B Vardal wrote: >> >>> > value field: (ambig.) field whose type is a value type (in any kind of class) OR >>> > a field in a value class (of any type) >> >> If you want to resolve this ambiguity, I've been referring to the former as a >> "value typed field" and the latter as a "value field". >> > > Yes, that can work where the context is strong enough to keep the reader alert. > But a single letter 'd' is a slender hook to hang your meaning on, and its > *absence* is even > more delicate. Unless the context makes it very clear, I'd want to say "value > class field", > or "field in a value" (ellipsis for "value class") instead of "value field" as > you suggest. > > (Remember, classes define fields, and then they show up in a type's API surface. > So you can usually clarify "field of some type" to "field in some class" or > "field of > that type's class". And on the other hand "field with that type" or even "field > of that > type". The word "of" is treacherous here, and "in" and "with" are more > reliable.) > > In some cases you have to spit out even more words to be safe: "field within > value type", > "field that is a member of a value type", "field declared as a value type", > "field whose type > is a value type", etc., etc. Some of those circumlocutions benefit from > ellipsis (which is > "value" standing for "value type" with the "type" clear from context). > > Note that Java is already full of small ambiguities like this: "Interface > field", "inner class field", > "wrapper type field". Perhaps we could lean harder on the class-vs-type > distinction: "Field of > an interface type" is a "field typed as an interface (type)" whereas "Field of > an interface class" > is a "field declared in a class which defines an interface". > > (But we don't say "interface class" at this point, and it would be hard to get > folks to accept it, > even though it would clarify existing ambiguities about "class" meaning "class > or interface or > enum" in many places.) > > ? John From karen.kinnear at oracle.com Wed Jul 12 18:10:54 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 12 Jul 2017 14:10:54 -0400 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> Message-ID: <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> I think we have been discussing two different time frames. For the MVT EA we won?t have nest mates, so there I was pushing back on the dependency and we will stick with the package private access. Post-EA - I totally agree with going through a lookup mechanism, and I would like to design this around nest mates - and have the Lookup.defineClass(?) PRIVATE mode be an early use case of nest mates. Totally agree with trying to pull this one off. It would make sense for the VCC/DVT to be nest mates, the VCC would have to be the nest-top so it could be loaded with or without the DVT. ( Non-MVT I would expect the valhalla value class to be the nest-top.) For byte code generation uses - I assume you are generating additional methods that you would want to add to the nest. Are those temporary classes? And if I understand the proposal correctly, we are replacing constant pool patching with Lookup.getConstant() with a private Lookup, which uses an ldc of condy underneath, so essentially the BSM is filling in new types in the condy constant pool entries. hope this is clearer, thanks, Karen > On Jul 11, 2017, at 7:10 PM, Paul Sandoz wrote: > > Hi Karen, > > Thanks, i understand the need for being conservative here in case we get things wrong. The pragmatic relaxation is entirely reasonable, although i would still prefer to go through a lookup mechanism if we could pull it off :-) > > Paul. > >> On 11 Jul 2017, at 14:42, Karen Kinnear > wrote: >> >> Paul, >> >> We are working hard on getting the nest mates requirements clarified. >> I would like to use that to support the Lookup.defineClass and not do a Quick&Dirty >> in advance for MVT . I think we should stick with the reduced restrictions >> for withfield for early access. I think we should put our energy into getting >> nest mates and Lookup.defineClass ready. >> >> We have three parts to Lookup.defineClass. >> 1) PRIVATE mode handling - which we believe we can support with nest mates >> - we do not want to do any versions of this based on unsafe.DAC current behavior, >> - we are looking at cleaner behavior for nestmates >> 2) ?temporary? name - i.e. find doesn?t work >> 3) CP patching/user data >> >> My mental model is that we don?t have to add all of these at the same time, >> although we will want user feedback on when to remove unsafe.DefineAnonymousClass. >> In fact, we would love more examples of current use cases, to help guide our >> design. >> >> thanks, >> Karen >> >>> On Jul 5, 2017, at 2:43 PM, John Rose > wrote: >>> >>> On Jul 5, 2017, at 11:39 AM, Paul Sandoz > wrote: >>>> >>>> >>>> I was unsure if we require a new method L.defineAnonClass or could leverage the existing L.defineClass. IIUC for expediency the current hooks in the VM lean towards anon classes, since there is already code to defer to the host class, whereas the general defineClass case will likely require more work, although i can potentially see some short cuts if we focus on VCC/DVT. >>>> >>> >>> Good point. Yes, that part isn't designed yet. It may manifest as an extra argument or two to the L.dC. >>> >>> At least two degrees of freedom apply there: 1. suppressing the name (no system dictionary update), >>> 2. providing some sort of "user data" to bind to the class (can be a single ref., replaces CP patching). >>> >>> For MVT we can just generate a throwaway name, like DVT.getName()+":29348". >>> >>> ? John >> > From paul.sandoz at oracle.com Wed Jul 12 19:08:30 2017 From: paul.sandoz at oracle.com (Paul Sandoz) Date: Wed, 12 Jul 2017 12:08:30 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> Message-ID: <1EE0351E-5F74-4252-92AD-7C2CB9629E60@oracle.com> > On 12 Jul 2017, at 11:10, Karen Kinnear wrote: > > I think we have been discussing two different time frames. > For the MVT EA we won?t have nest mates, so there I was pushing back on the dependency > and we will stick with the package private access. > > Post-EA - I totally agree with going through a lookup mechanism, and I would like to design > this around nest mates - and have the Lookup.defineClass(?) PRIVATE > mode be an early use case of nest mates. Totally agree with trying to pull this one off. > > It would make sense for the VCC/DVT to be nest mates, the VCC would have to be the > nest-top so it could be loaded with or without the DVT. ( Non-MVT I would expect the valhalla > value class to be the nest-top.) > Ok. > For byte code generation uses - I assume you are generating additional methods that > you would want to add to the nest. Are those temporary classes? > By temporary do you mean sort of like our existing VM anonymous classes? i.e. stuff that cannot be found and is not in the system dictionary. IIUC they are the same in that regard. Code generation for lambda forms uses U.DAC (with LambdaForm as the host class), but could theoretically if supported could add new methods to a LambdaForm nest. (Which is sort of like what we are doing explicitly with pre-generation in the jlink stage for some lambda forms and also more explicitly for VarHandle linkage, see VarHandleGuards). > And if I understand the proposal correctly, we are replacing constant pool patching > with Lookup.getConstant() with a private Lookup, Yes, that looks like a promising direction to explore. > which uses an ldc of condy underneath, > so essentially the BSM is filling in new types in the condy constant pool entries. > Here is my understanding: there could be a condy BSM that calls Lookup.getConstant() and returns the result of invoking the returned method handle, or a class could do that explicitly in clinit and assigning the result in a static final field. If the constant is a Map there could be a condy with a key value constant, or likewise explicitly in clinit. Off the top of my head: byte[] classBytes = ... Map constant = ? Class c = l.defineClass(classBytes, Map.class, constant); ... Map _constant = (Map) MethodHandles.privateLookupIn(c, MethodHandles.lookup()).getConstant().invokeExact(); assert(_constant.equals(constant)); Implementation wise underneath the covers there could be a map say of Class -> MethodHandle e.g.: somewhere in the defineClass impl: MethodHandle cmh = MethodHandles.constant(constantType, constantValue); constantMap.put(definedClass, cmh); Then the Lookup.getConstant could be implemented as follows: return constantMap.get(lookupClass); A ClassValue kind of map might be more efficient than say a ConcurrentHM. Paul. Paul. From karen.kinnear at oracle.com Tue Jul 18 22:23:49 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Tue, 18 Jul 2017 18:23:49 -0400 Subject: Valhalla notes Jul05 2017 Message-ID: <20DD26BF-6B09-4A58-A60C-09CD8C1441B4@oracle.com> Valhalla EG July 05, 2017 attendees: John, Vlad, Dan S, Dan H, Fred, Karen, Remi AIs: All: review MVT JVMS http://cr.openjdk.java.net/~dlsmith/values.html All: review makeSecondaryClass: http://mail.openjdk.java.net/pipermail/valhalla-spec-experts/2017-June/000286.html (for post-EA) All: review ConstantDynamic JVMS http://cr.openjdk.java.net/~jrose/jvm/condy-jvms-2017-0620.html MVT use case: Vlad: try to emulate Panama Vector superlongs as DVT to see box elimination - not yet ported any of Panama - next step: port Vector Intrinsics MVT JVMS: Review comments requested. Karen's notes: 1. 4.10.1.8 - I owe review that this is a cleanup of protected handling, with not behavior changes 2. 4.9.1, 4.9.2 There are a couple of areas we need to clarify ClassFileFormatError vs. VerifyError 3. question about just listing a subset of VCC rules? Dan S: just the enforcable subset 4. 5.3. eager vs. lazy derivation - are we allowed to do either? Dan Smith already sent far better notes/thoughts on this one: http://mail.openjdk.java.net/pipermail/valhalla-spec-experts/2017-July/000324.html 5. One of the suggested changes was to move from using a classfile attribute to using a RuntimeVisibleAnnotation Maurizio reminded us later: hotspot implementation today already uses a RuntimeVisibleAnnotation: jvm.internal.value.DeriveValueType annotation so ask Dan Smith to modify the JVMS to match the annotation name? ==== ConstantDynamic JVMS: Review comments requested. Dan H: will send feedback during the next couple of weeks: Karen: we also owe feedback John: JVMS format experiment programatically - make more things like int.class not known to systemdictionary new class mirror - like a primitive mirror, not correspond to a class could make a shim over $Value real class with a different name note: java.lang.Class today needs a distinct class file perhaps use this for species "crass" (Karen request - need a new name - hard to hear the distinction between "class" and "crass") === Vector API experiments with MVT Vlad: Vector API - has boxing issues, JIT box elimination challenges initially tried heisenboxes now experimenting with MVT typed vectors ass VCC, use MethodHandles for operations - MH chains step 1: superlong primitives > 64 bit as VCC -> see what optimizations we can provide downside: API must as MH as well note: Ian Graves working on expression language for convenience to allow MH chains Toby should talk to Vlad Dan H: experiments with machine code snippets and intrinsics === Timing of MVT EA: after JVMLS - (sigh) - need to sync up on dates === Remi joined :-) MVT issues: 1) representation of __Value root type of all value types should it be boxed? Fred: No - can NOT box - there is no VCC associated with it Remi: how do we get from __Value to actual type? Today - there is no way to do this This is very temporary - longer term expect a new "mode" of Object, "QObject" Can't use for fields may need an unsafe hook to load a value from an instance My notes say that __Value allows reflection on it. (ed. note - is that accurate? Do you mean ValueType reflection or older reflection? We are planning to disallow older reflection for MVT for value ASM patch progress: 1) openjdk w/ASM re-align with module opcodes 2) do next patch -- almost ready to submit first patch (!) corrections welcome, Karen From karen.kinnear at oracle.com Wed Jul 19 14:46:49 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 19 Jul 2017 10:46:49 -0400 Subject: MVT JVMS comments Message-ID: <6B61378C-1828-498C-AE11-AAF24F5D4B1D@oracle.com> Dan, Super job on the JVMS draft - and many thanks for having this so early in a cycle. Couple of questions/comments: 0) Can you give the terminology summary here please? 1) 4.1. super_class (and 5.3 Creation and Loading): open issue We need to discuss the super_class of an ACC_VALUE class. It is not java/lang/Object. hotspot implementation today uses marker java/lang/__Value. Expect to evolve to java/lang/UObject perhaps so it can be shared across the value type and box? Perhaps the general answer is the value type root. You mentioned at one time that we need to determine what Class.getSuperclass returns for a derived value type - agreed. In general, for reflection, Class.forName returns ClassNotFoundException if we try to find a derived value type, other reflect requests today for EA throw UnsupportedOperationException. You need to use ValueType APIs, or work on the box for EA. 2) 4.7/4.7.25 new attribute/annotation Discussion proposed using a RuntimeVisibleAnnotation called ValueCapableClass. Hotspot implementation today already uses a RuntimeVisibleAnnotation. current name is jdk.vm.internal.DeriveValueType Can we keep that or need to change? Assume that the version support will be >= 54.0 3) 4.9.2 Structural Constraints If the method returns a direct value class type, only a vreturn instruction may be used, and the type of the returned value must be the same as the type given by the return descriptor of the method (4.10.1.2 ). Should this also mention java/lang/__Value? Or more generally the common super type of direct value class types? Where else is it legal to use java/lang/__Value? We can not use it for field declarations or for array component types. Do we need it for method parameters other than return values? 4) 4.10.1.1 By loadedSuperclasses - do you actually mean loadedSupertypes? 5) 4.10.1.2: fix ?initializing? -> ?initiating? 6) 4.10.1.2 The current verifier does explicitly check that an array can only be assigned to Cloneable and Serializable (I need to double-check with Harold exactly when), so so it looks like you are changing the rules for array support of interfaces. (Yes, in the more general case interfaces are treated as java.lang.Object - but this is actually called out). 7) 4.10.1.8 I need to check with Harold on the protected member checking. thanks, Karen From karen.kinnear at oracle.com Wed Jul 19 15:48:41 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Wed, 19 Jul 2017 11:48:41 -0400 Subject: ConstantDynamic JVMS comments Message-ID: <5DB8EBD6-BCFE-44A7-869C-ACFB6216767E@oracle.com> John, Condy JVMS looks really good. Could of small questions/comments: 1. 4.5 fields in 5.4.3.6 you have a much clearer description of the argument types could you either reference that or include the bullets here? (the syntax is not clear from the sentence structure) 2. instructions that can use condy The JVMS lists ldc/ldc_w I think you mentioned that a bootstrap method specifier could contain a condy CP reference Are there other places these can appear today? 3. We need to discuss redefineclasses and BootstrapMethod Attributes - Lois and I think we may already have an issue here with indy and condy could just make this more common - we may want to enhance the redefineclasses documentation restrictions on attributes The redefinition may change method bodies, the constant pool and attributes. The redefinition must not add, remove or rename fields or methods, change the signatures of methods, or change inheritance. These restrictions maybe be lifted in future versions. The class file bytes are not checked, verified and installed until after the transformations have been applied, if the resultant bytes are in error this method will throw an exception. thanks, Karen From forax at univ-mlv.fr Wed Jul 19 15:51:35 2017 From: forax at univ-mlv.fr (Remi Forax) Date: Wed, 19 Jul 2017 17:51:35 +0200 (CEST) Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> Message-ID: <645681499.1924126.1500479495458.JavaMail.zimbra@u-pem.fr> > De: "Daniel Heidinga" > ?: "daniel smith" > Cc: "valhalla-spec-experts" > Envoy?: Mercredi 19 Juillet 2017 16:31:18 > Objet: Re: Valhalla EG minutes 6/21/17 > There are a couple of different terms that have been used to describe early > access features - incubator (jep 11), experiment, or optional. At least for me, > these different terms result in different mental models for how this should > work for the VM. Hopefully, we're all thinking about the same behaviour > semantics and are just using different terms but I think it's worth clarifying. > 1) JEP 11 does a good job of describing incubator and makes it clear that it > refers to non-standard modules / java-level code. Not VM features. > 2) An optional feature is something you can chose to implement (or not) but must > exist as part of the current JVM spec. All of its JVM spec changes would need > to be in the spec and their enablement / enforcement would depend on whether > the VM chose to implement that optional feature. Removal of the optional > feature from the JVM spec would basically be impossible - it may fall into > disuse through VMs not implementing it, but it would be hard to remove. > 3) An experimental feature on the other hand, is something that would be allowed > to have an appendix or set of experimental JVM spec changes that are only > enabled by command line option + present in classes with new minor classfile > versions. These features would start life deprecated and expectation is that > classfiles with this particular minor version would no longer be recognized by > future VMs when the experimental features graduate to the real JVM features, > providing freedom to experiment without requiring the VM to carry the support > burden long term. > My understanding has been that with the MVT prototype work, we've been aiming > for the 3rd case. Does this match everyone's expectations? Anyone think we're > aiming for some other point on the spectrum? I agree, it's an experimental feature, like invokedynamic was at its time, at least for the MVT. > One of my fears is that we're going to end up with the VM required to support > multiple ways of recognizing ValueCapableClasses / ValueTypes, especially if > there are spec changes between the different ways (think the mess that is > invokespecial and the ACC_Super flag) based on attribute vs annotation or > classfile version, etc. R?mi > >> On Jul 5, 2017, at 8:12 AM, Karen Kinnear wrote: > >>> > Dan S: class loading in the proposed JVMS: if you see $Value > >>> > 1) first derive the VCC name and see if already resolved > >>> > 2) if not - load the VCC, check properties and derive > >>> > (ed. note - if see VCC - lazily derive derived value class on touch) > >>> It's not a requirement that the value class derivation is lazy, correct? > >> Let?s double-check with Dan Smith at today?s meeting. > >> The way I read 5.3 Creation and Loading in >>> [ http://cr.openjdk.java.net/~dlsmith/values.html | > >> http://cr.openjdk.java.net/~dlsmith/values.html ] >>> it appears to allow lazy derivation as well as eager derivation, which I think > >> is what we both want > >> since it allows implementations to optimize. > >> Our current derivation is also eager. >> Summary of today's discussion, supplemented with some reflection on what I see > > as the requirements: >> - The specification shouldn't care when the class is derived (though it must >> occur, naturally, no later than resolution of "Foo$Value"); the specification > > *might* care when error checking occurs, because that's observable. >> - Current specification draft says error checking occurs when Foo$Value is >> loaded (5.3), and that "Class or interface creation is triggered by another >> class or interface D, which references C through its run-time constant pool." >> So, as a test case: if my program has no references to Foo$Value (direct or > > reflective), no VCC-related errors would occur. >> - We could redesign this so that the VCC properties are checked during >> loading/verification of Foo. I am concerned that, where Foo is version 54.0 and >> has attribute ValueCapableClass, this sort of error checking will violate the > > Java SE 10 spec. > Doesn't the use of experimental features allow the new classfile versions to > define new behaviour? I would expect the ValueCapableClass attribute to b e > ignored in a v.54 classfile and only take affect in a v.54.1 classfile so that > the semantics can be changed in the future. >> Elaborating: we're presenting values as an optional feature of Java SE 10. For a >> JVM that does not implement the optional feature, JVMS 10 says that a >> ValueCapableClass attribute on a version 54.0 class file will be ignored. JVMS >> 4.7.1: "any attribute not defined as part of the class file specification must >> not affect the semantics of the class file. Java Virtual Machine >> implementations are required to silently ignore attributes they do not >> recognize." My interpretation of our mission, in adding an optional feature, is >> to provide new capabilities while having no impact on existing behavior. We can >> do new things where JVMS 10 specifies an error; we can't generate new errors > > where JVMS 10 specifies none. > New classfile version == new behaviour, right? >> - We could limit usage/interpretation of "ValueCapableClass" to 54.1 class >> files. Then eager error checks when loading Foo would be fine. But the ability > > to work with 54.0 ValueCapableClass class files is an important use case. > The model here is that using a JVM 10 javac, a classfile with the annotation is > v54 and on a VM with some -XX:EnableExperimentalFeatures flag, this derives a > v.54.1 class for the DVT? This basically gives new behavior to v.54 classfiles > which makes it very hard to change when Java 11 comes along and fully specifies > ValueTypes. Customers will still have these annotated v.54 classes and expect > them to keep working as values, meaning the JVMs will need to support both the > annotation and the new way. > Limiting the new behaviour to v.54.1 classfiles and then making them illegal in > Java 11 makes it obvious to the user that the experimental classfiles won't > work the same way and likely need to be refactored to the new "real" ValueTypes > way. > Would the annotation be in an incubator module so that it can be deprecated / > removed easily in a future release? >> - Actually, examining that use case more closely, we discussed how attributes >> are not the right tool at all. We want clients of MVT to be able to generate >> interesting programs using a vanilla Java SE 10 compiler. The best mechanism to >> communicate "I'm a value-capable class" using a vanilla Java compiler is > > annotations, not attributes. > Because we're dealing with experimental features, can we require a similar > -XX:EnableExperimentalFeatures flag (or -D option) for javac to convert the > annotation into a v.54.1 classfile with the attribute? This makes it easy to > write the code but keeps it sandboxed to the experimental classfile version. > > Tentatively, the spec should be revised so that: >> - The "ValueCapableClass" attribute no longer exists. Delete changes to 4.7 and > > delete new section 4.7.25. >> - A "value capable class" is a class whose RuntimeVisibleAnnotations includes a >> ValueCapableClass annotation (package TBD; whether the referenced class must be > > loaded TBD) > > - As usual, this annotation doesn't impact behavior of class Foo >> - When loading Foo$Value, as specified in 5.3, we'll check that Foo is a value > > capable class and that it has the right properties > > ?Dan > Annotations are typically more expensive to read in the VM than attributes. If > not for the vanilla-java concerns, a feature like this would have an attribute > in the JVMS. Shouldn't we try to start with the attribute to keep us close to > the path we'd pick for a future java release? > --Dan From john.r.rose at oracle.com Wed Jul 19 21:43:07 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 19 Jul 2017 14:43:07 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> Message-ID: On Jul 12, 2017, at 11:10 AM, Karen Kinnear wrote: > > > And if I understand the proposal correctly, we are replacing constant pool patching > with Lookup.getConstant() with a private Lookup, which uses an ldc of condy underneath, > so essentially the BSM is filling in new types in the condy constant pool entries. > That's not quite right. The Lookup.getConstant almost certainly won't look in the constant pool. (It could but there are about ten cleaner ways to do it.) The trick is carrying a single pointer supplied by the user from the Lookup.defineClass call, through (or past) the VM class loading mechanisms, and into a place where Lookup.getConstant can find it. My preference would be an extra injected field in the java.lang.Class mirror for the loaded class, as if it were a static final field, but without the extra stuff that gives it a name. The type would *always* be java.lang.Object. ? John From john.r.rose at oracle.com Wed Jul 19 21:56:11 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 19 Jul 2017 14:56:11 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: <1EE0351E-5F74-4252-92AD-7C2CB9629E60@oracle.com> References: <7CD0F59D-4376-4340-98A4-ED186630E114@oracle.com> <42DD22F1-7095-4C21-8308-D0FEB3E8E56E@oracle.com> <668B9D76-47BA-4DD7-8BA8-3305E172F639@oracle.com> <49BE4B8E-114E-4FD6-8FD4-13D7B0665628@oracle.com> <9A5B252B-FE91-4028-B607-64A71E60DE6E@oracle.com> <39C316D5-37BC-4396-A13C-7DBBEFBDD589@oracle.com> <9D26ACA3-D4C4-4688-854A-86B98742E174@oracle.com> <93159FDB-E608-4EDB-8DE3-2EA08FB2A975@oracle.com> <1EE0351E-5F74-4252-92AD-7C2CB9629E60@oracle.com> Message-ID: On Jul 12, 2017, at 12:08 PM, Paul Sandoz wrote: > > A ClassValue kind of map might be more efficient than say a ConcurrentHM. A cell in the java.lang.Class is better. It requires JVM collaboration. The trick can be done 99% correctly with ThreadLocal and ClassValue. The defineClass guy sets up a ThreadLocal to hold the value while the class is loaded. Then, in the same thread (we expect at a 99% level) the ClassValue for the newly defined class is tickled. The recursive call to ClassValue.computeValue catches the long pass from defineClass via the ThreadLocal, and? touchdown! That wouldn't require any JVM changes at all but it might not be reliable. Certainly not clean. ? John From john.r.rose at oracle.com Wed Jul 19 22:14:45 2017 From: john.r.rose at oracle.com (John Rose) Date: Wed, 19 Jul 2017 15:14:45 -0700 Subject: Valhalla EG minutes 6/21/17 In-Reply-To: References: <5DD65F4B-9996-42F8-A09A-EC454F128515@oracle.com> Message-ID: <579013EB-54B2-496D-95B5-79717FB06F8C@oracle.com> On Jul 19, 2017, at 7:31 AM, Daniel Heidinga wrote: > > There are a couple of different terms that have been used to describe early access features - incubator (jep 11), experiment, or optional. At least for me, these different terms result in different mental models for how this should work for the VM. Hopefully, we're all thinking about the same behaviour semantics and are just using different terms but I think it's worth clarifying. > > 1) JEP 11 does a good job of describing incubator and makes it clear that it refers to non-standard modules / java-level code. Not VM features. And what we want is "like JDK incubator code but for VM features", but defined rigorously. > 2) An optional feature is something you can chose to implement (or not) but must exist as part of the current JVM spec. All of its JVM spec changes would need to be in the spec and their enablement / enforcement would depend on whether the VM chose to implement that optional feature. Removal of the optional feature from the JVM spec would basically be impossible - it may fall into disuse through VMs not implementing it, but it would be hard to remove. Yes. As with incubator code we include a proviso that the experimental features will be dropped. > 3) An experimental feature on the other hand, is something that would be allowed to have an appendix or set of experimental JVM spec changes that are only enabled by command line option + present in classes with new minor classfile versions. These features would start life deprecated and expectation is that classfiles with this particular minor version would no longer be recognized by future VMs when the experimental features graduate to the real JVM features, providing freedom to experiment without requiring the VM to carry the support burden long term. That sounds right. We need features which customers can try out but which have a short shelf life. Short means on the order of a single release and/or a year or two. Shorter is better. > My understanding has been that with the MVT prototype work, we've been aiming for the 3rd case. Does this match everyone's expectations? Anyone think we're aiming for some other point on the spectrum? That's what I expect. > One of my fears is that we're going to end up with the VM required to support multiple ways of recognizing ValueCapableClasses / ValueTypes, especially if there are spec changes between the different ways (think the mess that is invokespecial and the ACC_Super flag) based on attribute vs annotation or classfile version, etc. Yes. > > ...> - We could redesign this so that the VCC properties are checked during loading/verification of Foo. I am concerned that, where Foo is version 54.0 and has attribute ValueCapableClass, this sort of error checking will violate the Java SE 10 spec. > > Doesn't the use of experimental features allow the new classfile versions to define new behaviour? I would expect the ValueCapableClass attribute to be ignored in a v.54 classfile and only take affect in a v.54.1 classfile so that the semantics can be changed in the future. The VCC is a special case, because it must be compiled from standard source with no changes to javac. Its class file doesn't directly use the new bytecodes (vload, etc.) or modifiers (ACC_VALUE). This feature must be triggered by an annotation, not an attribute, nor a classfile version bit. For the actual bytecodes (vload, etc.) a classfile version bit or attribute is the sort of thing we need to enable the experimental feature. > > > > Elaborating: we're presenting values as an optional feature of Java SE 10. For a JVM that does not implement the optional feature, JVMS 10 says that a ValueCapableClass attribute on a version 54.0 class file will be ignored. JVMS 4.7.1: "any attribute not defined as part of the class file specification must not affect the semantics of the class file. Java Virtual Machine implementations are required to silently ignore attributes they do not recognize." My interpretation of our mission, in adding an optional feature, is to provide new capabilities while having no impact on existing behavior. We can do new things where JVMS 10 specifies an error; we can't generate new errors where JVMS 10 specifies none. > > New classfile version == new behaviour, right? (Or new class file version + attribute. Or new class file version + class file minor-version bit. But yes.) > > > > > - We could limit usage/interpretation of "ValueCapableClass" to 54.1 class files. Then eager error checks when loading Foo would be fine. But the ability to work with 54.0 ValueCapableClass class files is an important use case. > > The model here is that using a JVM 10 javac, a classfile with the annotation is v54 and on a VM with some -XX:EnableExperimentalFeatures flag, this derives a v.54.1 class for the DVT? This basically gives new behavior to v.54 classfiles which makes it very hard to change when Java 11 comes along and fully specifies ValueTypes. The annotation (not attribute or version bit) for a VCC (remember, it's a special case) can be made contingent on 54. That's fulfills the contract for an experimental VM feature. The annotation will be treated as a no-op (like most other annotations) in 53 or 55. And, yes, the new class file format features for the DVT (and other experimental VTs) would be enabled only in 54.1 or (54 + SomeAttribute). > Customers will still have these annotated v.54 classes and expect them to keep working as values, meaning the JVMs will need to support both the annotation and the new way. They might expect this but it will fail in any version besides 54, per the contract of the experimental feature. > Limiting the new behaviour to v.54.1 classfiles and then making them illegal in Java 11 makes it obvious to the user that the experimental classfiles won't work the same way and likely need to be refactored to the new "real" ValueTypes way. > > Would the annotation be in an incubator module so that it can be deprecated / removed easily in a future release? Most definitely. So the incubator module and the JVM hook would go away at the same time. > > > > > - Actually, examining that use case more closely, we discussed how attributes are not the right tool at all. We want clients of MVT to be able to generate interesting programs using a vanilla Java SE 10 compiler. The best mechanism to communicate "I'm a value-capable class" using a vanilla Java compiler is annotations, not attributes. > > Because we're dealing with experimental features, can we require a similar -XX:EnableExperimentalFeatures flag (or -D option) for javac to convert the annotation into a v.54.1 classfile with the attribute? This makes it easy to write the code but keeps it sandboxed to the experimental classfile version. We will likely have such a compiler, and it will probably generate VT's natively. The VCC use case is designed for a "vanilla" tool chain. Adding extra "are you sure?" flags is not helpful IMO. > > > > Tentatively, the spec should be revised so that: > > - The "ValueCapableClass" attribute no longer exists. Delete changes to 4.7 and delete new section 4.7.25. > > - A "value capable class" is a class whose RuntimeVisibleAnnotations includes a ValueCapableClass annotation (package TBD; whether the referenced class must be loaded TBD) > > - As usual, this annotation doesn't impact behavior of class Foo > > - When loading Foo$Value, as specified in 5.3, we'll check that Foo is a value capable class and that it has the right properties Yep. You could mentally model this as not a JVM feature, but some sort of instrumentation-like feature which derives the DVT by looking at the "vanilla" VCC class. The VM features kick in which the DVT (or a stand-alone experimental VT) is loaded with version 54.1. (Or 54.1 plus an attribute. But I prefer just the version number bit.) > > > > ?Dan > > Annotations are typically more expensive to read in the VM than attributes. If not for the vanilla-java concerns, a feature like this would have an attribute in the JVMS. Shouldn't we try to start with the attribute to keep us close to the path we'd pick for a future java release? No, VCC has a different design center which mustn't be confused with the VT design center. ? John From karen.kinnear at oracle.com Thu Jul 27 17:38:00 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Thu, 27 Jul 2017 13:38:00 -0400 Subject: MVT change in new opcode numbers? Message-ID: <1A9B45E8-E958-4665-9F59-81833598C48D@oracle.com> Dan Smith, Bjorn, Dan H, Remi - Does it work for you if we change the JVMS to use the following value-type byte codes - i.e. make them contiguous? In the hotspot implementation, we ran out of internally-usable byte codes when we left holes here. _vload = 203, // 0xcb 248 _vstore = 204, // 0xcc 249 _vaload = 205, // 0xcd 250 _vastore = 206, // 0xce 251 _vreturn = 207, // 0xcf 252 _vdefault = 208, // 0xd0 253 _vwithfield = 209, // 0xd1 254 _vbox = 210, // 0xd2 255 _vunbox = 211, // 0xd3 (note: we removed vgetfield) thanks, Karen From karen.kinnear at oracle.com Thu Jul 27 19:10:31 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Thu, 27 Jul 2017 15:10:31 -0400 Subject: MVT change in new opcode numbers? In-Reply-To: References: <1A9B45E8-E958-4665-9F59-81833598C48D@oracle.com> Message-ID: <51BB75A4-D860-49D3-8977-EDCE7645C389@oracle.com> Sigh - it does matter to us where it starts - we do quickening internally using the higher ranges and our code knows about ranges for ?real? java byte codes vs internal byte codes. If it is possible we would appreciate the lower numbers since the higher numbers would slow down our range checking. thanks, Karen > On Jul 27, 2017, at 2:09 PM, Bjorn B Vardal wrote: > > If you want to make it contiguous, does it matter to you (HotSpot) where it starts? If not, the most practical for us would be 217-225. If that doesn't work, I believe we'll be able to work with 203-211. > > ----- Original message ----- > From: Karen Kinnear > Sent by: "valhalla-spec-experts" > To: valhalla-spec-experts at openjdk.java.net > Cc: > Subject: MVT change in new opcode numbers? > Date: Thu, Jul 27, 2017 1:38 PM > > Dan Smith, Bjorn, Dan H, Remi - > > Does it work for you if we change the JVMS to use the following value-type byte codes - i.e. > make them contiguous? > In the hotspot implementation, we ran out of internally-usable byte codes when we left holes here. > > _vload = 203, // 0xcb > 248 _vstore = 204, // 0xcc > 249 _vaload = 205, // 0xcd > 250 _vastore = 206, // 0xce > 251 _vreturn = 207, // 0xcf > 252 _vdefault = 208, // 0xd0 > 253 _vwithfield = 209, // 0xd1 > 254 _vbox = 210, // 0xd2 > 255 _vunbox = 211, // 0xd3 > (note: we removed vgetfield) > > thanks, > Karen > > From karen.kinnear at oracle.com Thu Jul 27 21:02:52 2017 From: karen.kinnear at oracle.com (Karen Kinnear) Date: Thu, 27 Jul 2017 17:02:52 -0400 Subject: MVT change in new opcode numbers? In-Reply-To: References: <51BB75A4-D860-49D3-8977-EDCE7645C389@oracle.com> <1A9B45E8-E958-4665-9F59-81833598C48D@oracle.com> Message-ID: <4A1F425F-1264-48D1-A473-ABDF6E81DAD9@oracle.com> Many thanks for being flexible here. Karen > On Jul 27, 2017, at 4:01 PM, Bjorn B Vardal wrote: > > Yes, we should be able to work with the lower range. > > ----- Original message ----- > From: Karen Kinnear > To: Bjorn B Vardal > Cc: valhalla-spec-experts at openjdk.java.net > Subject: Re: MVT change in new opcode numbers? > Date: Thu, Jul 27, 2017 3:10 PM > > Sigh - it does matter to us where it starts - we do quickening internally using the higher ranges and our code knows about > ranges for ?real? java byte codes vs internal byte codes. > > If it is possible we would appreciate the lower numbers since the higher numbers would slow down our range checking. > > thanks, > Karen > >> On Jul 27, 2017, at 2:09 PM, Bjorn B Vardal > wrote: >> >> If you want to make it contiguous, does it matter to you (HotSpot) where it starts? If not, the most practical for us would be 217-225. If that doesn't work, I believe we'll be able to work with 203-211. >> >> ----- Original message ----- >> From: Karen Kinnear > >> Sent by: "valhalla-spec-experts" > >> To: valhalla-spec-experts at openjdk.java.net >> Cc: >> Subject: MVT change in new opcode numbers? >> Date: Thu, Jul 27, 2017 1:38 PM >> >> Dan Smith, Bjorn, Dan H, Remi - >> >> Does it work for you if we change the JVMS to use the following value-type byte codes - i.e. >> make them contiguous? >> In the hotspot implementation, we ran out of internally-usable byte codes when we left holes here. >> >> _vload = 203, // 0xcb >> 248 _vstore = 204, // 0xcc >> 249 _vaload = 205, // 0xcd >> 250 _vastore = 206, // 0xce >> 251 _vreturn = 207, // 0xcf >> 252 _vdefault = 208, // 0xd0 >> 253 _vwithfield = 209, // 0xd1 >> 254 _vbox = 210, // 0xd2 >> 255 _vunbox = 211, // 0xd3 >> (note: we removed vgetfield) >> >> thanks, >> Karen >> > > > From frederic.parain at oracle.com Sun Jul 23 23:34:37 2017 From: frederic.parain at oracle.com (Frederic Parain) Date: Sun, 23 Jul 2017 23:34:37 -0000 Subject: notes from Valhalla meeting 5/24/17 In-Reply-To: <91543D9D-8FA2-4366-9E18-AE52FB0197FE@oracle.com> References: <5FFBDEBF-ECAB-41AC-A9D9-ADC712446522@oracle.com> <925C62C6-26FB-4795-BF84-F8F62B2933C2@oracle.com> <1347399309.1758320.1498059966359.JavaMail.zimbra@u-pem.fr> <91543D9D-8FA2-4366-9E18-AE52FB0197FE@oracle.com> Message-ID: <608D7323-20B8-4871-896D-F22C5954A26B@oracle.com> > On Jun 21, 2017, at 14:24, Paul Sandoz wrote: > >> >> On 21 Jun 2017, at 09:03, John Rose wrote: >> >> On Jun 21, 2017, at 8:46 AM, Remi Forax wrote: >>> >>> but i do not like with this proposal as is, i will explain why and how to fix it: >>> - condy is linked to a static final field but unlike invokedynamic which is a link from an invokedynamic instruction to a CONSTANT_InvokeDynamic_info, >>> there is no link from the static final field to the CONSTANT_ConstantDynamic_info. >>> Why not reuse the ConstantValue attribute [1] to reference the CONSTANT_ConstantDynamic_info instead (the constantvalue_index can be extended to allow a CONSTANT_ConstantDynamic). >>> >>> - condy if a 'dy' like indy, so it should do late late binding, i.e. being initialized (run the bootstrap method) only the first time someone access to the static field exactly like with indy the bsm is called the first time you try to access the instruction. >>> >>> >>> In term of semantics, my proposal does not introduce an item in the constant pool which is resolved only by the virtue of being in the constant pool unlike any other items. If condy is linked to the ConstantValue of a field, the condy item is resolved when necessary as usual. With my ASM hat, i see how to implement it easily without having to surface the constant pool itself (at least until the items are pointed by the j.l.i.BootstrapCallInfo). >> >> Indeed, repurposing ConstantValue in the way you describe is an add-on to this proposal. > > Can we get away with changing all static final fields to be lazily initialized without some explicit opt-in? It would be nice but it might induce subtle changes in behaviour and expectations (especially for where exceptions may occur). Whatever solution is chosen, it will induce changes in behavior and new places where exceptions can be thrown. Lazy initialized static fields allow us to support value types in static fields without having to modify the class loading/class initialization logic. Today if a class A has a static field of type class B, then class A can be initialized without having to load or initialized class B. If the rule is changed for value types, meaning that if class A has a static field of type value type V, then V has to be loaded and initialized before A can be initialized. And of course, loading and initialization of V can fail, leading to a new kind of initialization failure for A. The class loading/class initialization is way more complex than field access (at least in the VM), so we have to balance pros and cons of each solution. Fred > >> I almost threw it in, but didn't want to muddy the basic proposal. >> In the basic proposal, condy is *not* linked to static finals. >> It only repurposes the concept of field names and field types >> (as if from Fieldref but not using Fieldref) but does not actually link to fields. >> >> ? John From robert.j.saulnier at gmail.com Sun Jul 23 23:34:37 2017 From: robert.j.saulnier at gmail.com (Robert J. Saulnier) Date: Sun, 23 Jul 2017 23:34:37 -0000 Subject: Draft of spec for Minimal Value Types Message-ID: In a few places, the draft spec has the following: If the class file version number is not 54.1 ... Should it not be something like: If the class file version number is lower than 54.1 ... And this: Unless the class file version number is 54.1 ... replace with: Unless the class file version number is 54.1 or above ... Or will these be updated again in Java 11? Bob