RFR: 8244413: Avoid rebinds in MethodHandle.viewAsType
Claes Redestad
claes.redestad at oracle.com
Tue May 5 22:12:33 UTC 2020
Hi,
in the current implementation MethodHandle.viewAsType eagerly rebinds
when creating a view of a method type as an alternative type:
MethodHandle viewAsType(MethodType newType, boolean strict) {
...
MethodHandle mh = rebind();
return this.copyWith(newType, mh.form);
}
This prevents exposing uncrackable DMHs, ie, ones where calling
Lookup.revealDirect(mh) would not produce a correct MethodHandleInfo.
If we restructure this so that crackability is a property on the DMH, we
can avoid the rebinds:
http://cr.openjdk.java.net/~redestad/8244413/open.00/
This improves overhead slightly when calling MH.asType with a "viewable"
type (one where all parameters in the new type can be assigned without
transforms to parameters in the old; and return in the old can be
assigned without transforms in the new).
At the very least this means a small startup gain for a selection of
apps.
(The patch looks footprint neutral since 15, since the added boolean can
slot into a padding gap created by fields in the MethodHandle base
class.)
Testing: tier1-3
/Claes
More information about the core-libs-dev
mailing list