[9] RFR (M): 8050877: Improve code for pairwise argument conversions and value boxing/unboxing
Paul Sandoz
paul.sandoz at oracle.com
Thu Jul 17 15:43:57 UTC 2014
On Jul 16, 2014, at 6:28 PM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
> http://cr.openjdk.java.net/~vlivanov/8050877/webrev.00/
> https://bugs.openjdk.java.net/browse/JDK-8050877
>
> Improved MethodHandleImpl.makePairwiseConvert & ValueConversions.unbox and small cleanups in related code.
>
> Also, improved method handle caching in ValueConversions.
>
> MethodHandleImpl.makePairwiseConvert:
> - * @param level which strength of conversion is allowed
> + * @param strict if true, only asType conversions are allowed; if false, explicitCastArguments conversions allowed
> + * @param monobox if true, unboxing conversions are assumed to be exactly typed (Integer to int only, not long or double)
>
> ValueConversions.unbox:
> - private static MethodHandle unbox(Wrapper wrap, boolean cast) {
> + private static MethodHandle unbox(Wrapper wrap, int kind) {
> + // kind 0 -> strongly typed with NPE
> + // kind 1 -> strongly typed but zero for null,
> + // kind 2 -> asType rules: accept multiple box types but only widening conversions with NPE
> + // kind 3 -> explicitCastArguments rules: allow narrowing conversions, zero for null
> + WrapperCache cache = UNBOX_CONVERSIONS[kind];
>
> Testing: jdk/java/lang/invoke, jdk/java/util/streams, nashorn, octane w/ "-ea -esa" and COMPILE_THRESHOLD={0,30}.
>
> Reviewed-by: vlivanov, ?
> Contributed-by: john.r.rose at oracle.com
>
MethodHandleImpl
Merge the the 'if' into an 'else if':
365 } else {
366 if (dst.isPrimitive()) {
ValueConversions
I can see why an EnumMap is used for convenience mapping the Wrapper to MH. IIUC it means the MH ref values are not @Stable? I guess it would be easy to unpack into an explicit array and index from the wrapper ordinal, plus then no additional runtime type checks on the key will be performed for get/put. Dunno how important that is.
Can UNBOX_CONVERSIONS be marked as @Stable? does that make any difference? Same for BOX_CONVERSIONS etc.
Paul.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20140717/3c75d48b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20140717/3c75d48b/signature.asc>
More information about the mlvm-dev
mailing list