On Jul 16, 2014, at 6:28 PM, Vladimir Ivanov <vladimir.x.iva...@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.r...@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.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to