RFR 8183146 [MVT] Create composed vwithfield constructor
maurizio.cimadamore at oracle.com
Fri Jun 30 10:20:01 UTC 2017
I think even this could be expressed with a combinator; you need to walk
field in reverse and repeatedly call mh = collectArguments(mh, 0,
withfield). At the end of the process you get some MH whose type is
QT1T2T3...Tn, where T1, T2, T3 ... Tn are the types of the fields. Now,
if 'fromDefault' is set, you do another collectArgumemts(mh, 0,
defaultConstantValue). If it is not set, you just leave the MH as is.
That said, I have little clue as to what it's best for the VM to
optimize - I suspect the combinator based one generates plenty of LFs
under the hood, so might be more problematic than a single monolithic
On 30/06/17 01:42, Paul Sandoz wrote:
> Please review the following:
> This adds a method, named unrefllectWithers for want of a better name, that given a number of fields can produce a method handle that applies vwithfield, in order with each Field. SO it should produce some tight byte code for the production of values, which then can be optimized by the JIT (e.g. if a default value is obtained and all fields are updated then the JIT could optimize away the zeroing associated with vdefault).
> This method is quite general, depending on the arguments passed in, it can reduce to an identity function, findWither, or defaultValueConstant, which suggests the latter two could defer to this method.
> Rather than accepting an array of Field it should perhaps be a LinkedHashMap<String, Class<?>>, or two distinct arrays of the same size, String and Class. In any case we need a way for the caller to specify the set of fields in a defined order.
More information about the valhalla-dev