jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
author vlivanov
Wed, 29 Oct 2014 09:31:37 -0700
changeset 27295 8ed31033bf48
parent 26479 a60a19ec5ce5
child 29020 9f6d43586ccb
permissions -rw-r--r--
8059877: GWT branch frequencies pollution due to LF sharing Reviewed-by: psandoz, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20527
diff changeset
     2
 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     4
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    10
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    15
 * accompanied this code).
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    16
 *
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4537
diff changeset
    23
 * questions.
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    24
 */
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    25
8822
8145ab9f5f86 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8821
diff changeset
    26
package java.lang.invoke;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    27
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    28
import java.lang.reflect.Array;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
    29
import java.util.Arrays;
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    30
14089
0a41b980d62a 8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents: 13610
diff changeset
    31
import static java.lang.invoke.MethodHandleStatics.*;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
    32
import static java.lang.invoke.MethodHandleNatives.Constants.*;
8822
8145ab9f5f86 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8821
diff changeset
    33
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
    34
import static java.lang.invoke.LambdaForm.*;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    35
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    36
/**
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    37
 * Construction and caching of often-used invokers.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    38
 * @author jrose
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    39
 */
8821
2836ee97ee27 6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents: 8347
diff changeset
    40
class Invokers {
25979
42e5d9f8087e 8054857: Fix typos in java.lang.** packages
prappo
parents: 23010
diff changeset
    41
    // exact type (sans leading target MH) for the outgoing call
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    42
    private final MethodType targetType;
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    43
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    44
    // Cached adapter information:
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    45
    private final @Stable MethodHandle[] invokers = new MethodHandle[INV_LIMIT];
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    46
    // Indexes into invokers:
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    47
    static final int
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    48
            INV_EXACT          =  0,  // MethodHandles.exactInvoker
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    49
            INV_GENERIC        =  1,  // MethodHandles.invoker (generic invocation)
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    50
            INV_BASIC          =  2,  // MethodHandles.basicInvoker
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    51
            INV_LIMIT          =  3;
7555
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
    52
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    53
    /** Compute and cache information common to all collecting adapters
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    54
     *  that implement members of the erasure-family of the given erased type.
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    55
     */
8345
9e2483e6cfab 7013417: JSR 292 needs to support variadic method handle calls
jrose
parents: 7668
diff changeset
    56
    /*non-public*/ Invokers(MethodType targetType) {
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    57
        this.targetType = targetType;
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    58
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    59
8821
2836ee97ee27 6839872: remove implementation inheritance from JSR 292 APIs
jrose
parents: 8347
diff changeset
    60
    /*non-public*/ MethodHandle exactInvoker() {
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    61
        MethodHandle invoker = cachedInvoker(INV_EXACT);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    62
        if (invoker != null)  return invoker;
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
    63
        invoker = makeExactOrGeneralInvoker(true);
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    64
        return setCachedInvoker(INV_EXACT, invoker);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    65
    }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    66
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    67
    /*non-public*/ MethodHandle genericInvoker() {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    68
        MethodHandle invoker = cachedInvoker(INV_GENERIC);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    69
        if (invoker != null)  return invoker;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    70
        invoker = makeExactOrGeneralInvoker(false);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    71
        return setCachedInvoker(INV_GENERIC, invoker);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    72
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    73
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    74
    /*non-public*/ MethodHandle basicInvoker() {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    75
        MethodHandle invoker = cachedInvoker(INV_BASIC);
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
    76
        if (invoker != null)  return invoker;
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    77
        MethodType basicType = targetType.basicType();
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    78
        if (basicType != targetType) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    79
            // double cache; not used significantly
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    80
            return setCachedInvoker(INV_BASIC, basicType.invokers().basicInvoker());
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    81
        }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    82
        invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_BASIC_INV);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    83
        if (invoker == null) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    84
            MemberName method = invokeBasicMethod(basicType);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    85
            invoker = DirectMethodHandle.make(method);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    86
            assert(checkInvoker(invoker));
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    87
            invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_BASIC_INV, invoker);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    88
        }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    89
        return setCachedInvoker(INV_BASIC, invoker);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    90
    }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    91
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    92
    private MethodHandle cachedInvoker(int idx) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    93
        return invokers[idx];
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    94
    }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    95
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    96
    private synchronized MethodHandle setCachedInvoker(int idx, final MethodHandle invoker) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    97
        // Simulate a CAS, to avoid racy duplication of results.
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    98
        MethodHandle prev = invokers[idx];
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
    99
        if (prev != null)  return prev;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   100
        return invokers[idx] = invoker;
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   101
    }
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   102
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   103
    private MethodHandle makeExactOrGeneralInvoker(boolean isExact) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   104
        MethodType mtype = targetType;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   105
        MethodType invokerType = mtype.invokerType();
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   106
        int which = (isExact ? MethodTypeForm.LF_EX_INVOKER : MethodTypeForm.LF_GEN_INVOKER);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   107
        LambdaForm lform = invokeHandleForm(mtype, false, which);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   108
        MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, mtype);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   109
        String whichName = (isExact ? "invokeExact" : "invoke");
26471
1de6be0c6945 8050174: Support overriding of isInvokeSpecial flag in WrappedMember
vlivanov
parents: 26468
diff changeset
   110
        invoker = invoker.withInternalMemberName(MemberName.makeMethodHandleInvoke(whichName, mtype), false);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   111
        assert(checkInvoker(invoker));
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   112
        maybeCompileToBytecode(invoker);
9752
88ab34b6da6d 7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents: 9646
diff changeset
   113
        return invoker;
88ab34b6da6d 7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents: 9646
diff changeset
   114
    }
88ab34b6da6d 7032323: code changes for JSR 292 EG adjustments to API, through Public Review
jrose
parents: 9646
diff changeset
   115
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   116
    /** If the target type seems to be common enough, eagerly compile the invoker to bytecodes. */
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   117
    private void maybeCompileToBytecode(MethodHandle invoker) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   118
        final int EAGER_COMPILE_ARITY_LIMIT = 10;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   119
        if (targetType == targetType.erase() &&
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   120
            targetType.parameterCount() < EAGER_COMPILE_ARITY_LIMIT) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   121
            invoker.form.compileToBytecode();
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   122
        }
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   123
    }
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   124
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   125
    // This next one is called from LambdaForm.NamedFunction.<init>.
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   126
    /*non-public*/ static MemberName invokeBasicMethod(MethodType basicType) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   127
        assert(basicType == basicType.basicType());
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   128
        try {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   129
            //Lookup.findVirtual(MethodHandle.class, name, type);
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   130
            return IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, MethodHandle.class, "invokeBasic", basicType);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   131
        } catch (ReflectiveOperationException ex) {
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   132
            throw newInternalError("JVM cannot find invoker for "+basicType, ex);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   133
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   134
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   135
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   136
    private boolean checkInvoker(MethodHandle invoker) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   137
        assert(targetType.invokerType().equals(invoker.type()))
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   138
                : java.util.Arrays.asList(targetType, targetType.invokerType(), invoker);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   139
        assert(invoker.internalMemberName() == null ||
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   140
               invoker.internalMemberName().getMethodType().equals(targetType));
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   141
        assert(!invoker.isVarargsCollector());
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   142
        return true;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   143
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   144
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   145
    /**
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   146
     * Find or create an invoker which passes unchanged a given number of arguments
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   147
     * and spreads the rest from a trailing array argument.
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   148
     * The invoker target type is the post-spread type {@code (TYPEOF(uarg*), TYPEOF(sarg*))=>RT}.
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   149
     * All the {@code sarg}s must have a common type {@code C}.  (If there are none, {@code Object} is assumed.}
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   150
     * @param leadingArgCount the number of unchanged (non-spread) arguments
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   151
     * @return {@code invoker.invokeExact(mh, uarg*, C[]{sarg*}) := (RT)mh.invoke(uarg*, sarg*)}
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   152
     */
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   153
    /*non-public*/ MethodHandle spreadInvoker(int leadingArgCount) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   154
        int spreadArgCount = targetType.parameterCount() - leadingArgCount;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   155
        MethodType postSpreadType = targetType;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   156
        Class<?> argArrayType = impliedRestargType(postSpreadType, leadingArgCount);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   157
        if (postSpreadType.parameterSlotCount() <= MethodType.MAX_MH_INVOKER_ARITY) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   158
            return genericInvoker().asSpreader(argArrayType, spreadArgCount);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   159
        }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   160
        // Cannot build a generic invoker here of type ginvoker.invoke(mh, a*[254]).
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   161
        // Instead, factor sinvoker.invoke(mh, a) into ainvoker.invoke(filter(mh), a)
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   162
        // where filter(mh) == mh.asSpreader(Object[], spreadArgCount)
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   163
        MethodType preSpreadType = postSpreadType
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   164
            .replaceParameterTypes(leadingArgCount, postSpreadType.parameterCount(), argArrayType);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   165
        MethodHandle arrayInvoker = MethodHandles.invoker(preSpreadType);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   166
        MethodHandle makeSpreader = MethodHandles.insertArguments(Lazy.MH_asSpreader, 1, argArrayType, spreadArgCount);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   167
        return MethodHandles.filterArgument(arrayInvoker, 0, makeSpreader);
7554
8a0ad9757002 6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents: 7052
diff changeset
   168
    }
8a0ad9757002 6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents: 7052
diff changeset
   169
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   170
    private static Class<?> impliedRestargType(MethodType restargType, int fromPos) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   171
        if (restargType.isGeneric())  return Object[].class;  // can be nothing else
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   172
        int maxPos = restargType.parameterCount();
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   173
        if (fromPos >= maxPos)  return Object[].class;  // reasonable default
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   174
        Class<?> argType = restargType.parameterType(fromPos);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   175
        for (int i = fromPos+1; i < maxPos; i++) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   176
            if (argType != restargType.parameterType(i))
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   177
                throw newIllegalArgumentException("need homogeneous rest arguments", restargType);
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   178
        }
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   179
        if (argType == Object.class)  return Object[].class;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   180
        return Array.newInstance(argType, 0).getClass();
7555
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   181
    }
a279ebc3b25c 6981777: implement JSR 292 EG adjustments from summer 2010
jrose
parents: 7554
diff changeset
   182
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   183
    public String toString() {
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   184
        return "Invokers"+targetType;
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   185
    }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   186
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   187
    static MemberName methodHandleInvokeLinkerMethod(String name,
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   188
                                                     MethodType mtype,
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   189
                                                     Object[] appendixResult) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   190
        int which;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   191
        switch (name) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   192
        case "invokeExact":  which = MethodTypeForm.LF_EX_LINKER; break;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   193
        case "invoke":       which = MethodTypeForm.LF_GEN_LINKER; break;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   194
        default:             throw new InternalError("not invoker: "+name);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   195
        }
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   196
        LambdaForm lform;
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   197
        if (mtype.parameterSlotCount() <= MethodType.MAX_MH_ARITY - MH_LINKER_ARG_APPENDED) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   198
            lform = invokeHandleForm(mtype, false, which);
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   199
            appendixResult[0] = mtype;
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   200
        } else {
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   201
            lform = invokeHandleForm(mtype, true, which);
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   202
        }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   203
        return lform.vmentry;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   204
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   205
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   206
    // argument count to account for trailing "appendix value" (typically the mtype)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   207
    private static final int MH_LINKER_ARG_APPENDED = 1;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   208
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   209
    /** Returns an adapter for invokeExact or generic invoke, as a MH or constant pool linker.
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   210
     * If !customized, caller is responsible for supplying, during adapter execution,
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   211
     * a copy of the exact mtype.  This is because the adapter might be generalized to
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   212
     * a basic type.
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   213
     * @param mtype the caller's method type (either basic or full-custom)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   214
     * @param customized whether to use a trailing appendix argument (to carry the mtype)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   215
     * @param which bit-encoded 0x01 whether it is a CP adapter ("linker") or MHs.invoker value ("invoker");
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   216
     *                          0x02 whether it is for invokeExact or generic invoke
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   217
     */
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   218
    private static LambdaForm invokeHandleForm(MethodType mtype, boolean customized, int which) {
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   219
        boolean isCached;
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   220
        if (!customized) {
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   221
            mtype = mtype.basicType();  // normalize Z to I, String to Object, etc.
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   222
            isCached = true;
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   223
        } else {
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   224
            isCached = false;  // maybe cache if mtype == mtype.basicType()
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   225
        }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   226
        boolean isLinker, isGeneric;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   227
        String debugName;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   228
        switch (which) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   229
        case MethodTypeForm.LF_EX_LINKER:   isLinker = true;  isGeneric = false; debugName = "invokeExact_MT"; break;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   230
        case MethodTypeForm.LF_EX_INVOKER:  isLinker = false; isGeneric = false; debugName = "exactInvoker"; break;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   231
        case MethodTypeForm.LF_GEN_LINKER:  isLinker = true;  isGeneric = true;  debugName = "invoke_MT"; break;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   232
        case MethodTypeForm.LF_GEN_INVOKER: isLinker = false; isGeneric = true;  debugName = "invoker"; break;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   233
        default: throw new InternalError();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   234
        }
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   235
        LambdaForm lform;
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   236
        if (isCached) {
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   237
            lform = mtype.form().cachedLambdaForm(which);
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   238
            if (lform != null)  return lform;
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   239
        }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   240
        // exactInvokerForm (Object,Object)Object
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   241
        //   link with java.lang.invoke.MethodHandle.invokeBasic(MethodHandle,Object,Object)Object/invokeSpecial
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   242
        final int THIS_MH      = 0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   243
        final int CALL_MH      = THIS_MH + (isLinker ? 0 : 1);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   244
        final int ARG_BASE     = CALL_MH + 1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   245
        final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   246
        final int INARG_LIMIT  = OUTARG_LIMIT + (isLinker && !customized ? 1 : 0);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   247
        int nameCursor = OUTARG_LIMIT;
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   248
        final int MTYPE_ARG    = customized ? -1 : nameCursor++;  // might be last in-argument
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   249
        final int CHECK_TYPE   = nameCursor++;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   250
        final int LINKER_CALL  = nameCursor++;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   251
        MethodType invokerFormType = mtype.invokerType();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   252
        if (isLinker) {
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   253
            if (!customized)
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   254
                invokerFormType = invokerFormType.appendParameterTypes(MemberName.class);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   255
        } else {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   256
            invokerFormType = invokerFormType.invokerType();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   257
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   258
        Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType);
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   259
        assert(names.length == nameCursor)
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   260
                : Arrays.asList(mtype, customized, which, nameCursor, names.length);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   261
        if (MTYPE_ARG >= INARG_LIMIT) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   262
            assert(names[MTYPE_ARG] == null);
26479
a60a19ec5ce5 8057657: Annotate LambdaForm parameters with types
vlivanov
parents: 26471
diff changeset
   263
            BoundMethodHandle.SpeciesData speciesData = BoundMethodHandle.speciesData_L();
a60a19ec5ce5 8057657: Annotate LambdaForm parameters with types
vlivanov
parents: 26471
diff changeset
   264
            names[THIS_MH] = names[THIS_MH].withConstraint(speciesData);
a60a19ec5ce5 8057657: Annotate LambdaForm parameters with types
vlivanov
parents: 26471
diff changeset
   265
            NamedFunction getter = speciesData.getterFunction(0);
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   266
            names[MTYPE_ARG] = new Name(getter, names[THIS_MH]);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   267
            // else if isLinker, then MTYPE is passed in from the caller (e.g., the JVM)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   268
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   269
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   270
        // Make the final call.  If isGeneric, then prepend the result of type checking.
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   271
        MethodType outCallType = mtype.basicType();
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   272
        Object[] outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   273
        Object mtypeArg = (customized ? mtype : names[MTYPE_ARG]);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   274
        if (!isGeneric) {
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   275
            names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], mtypeArg);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   276
            // mh.invokeExact(a*):R => checkExactType(mh, TYPEOF(a*:R)); mh.invokeBasic(a*)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   277
        } else {
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   278
            names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   279
            // mh.invokeGeneric(a*):R => checkGenericType(mh, TYPEOF(a*:R)).invokeBasic(a*)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   280
            outArgs[0] = names[CHECK_TYPE];
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   281
        }
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   282
        names[LINKER_CALL] = new Name(outCallType, outArgs);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   283
        lform = new LambdaForm(debugName, INARG_LIMIT, names);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   284
        if (isLinker)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   285
            lform.compileToBytecode();  // JVM needs a real methodOop
13610
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   286
        if (isCached)
28122b96858e 7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents: 13423
diff changeset
   287
            lform = mtype.form().setCachedLambdaForm(which, lform);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   288
        return lform;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   289
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   290
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   291
    /*non-public*/ static
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   292
    WrongMethodTypeException newWrongMethodTypeException(MethodType actual, MethodType expected) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   293
        // FIXME: merge with JVM logic for throwing WMTE
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   294
        return new WrongMethodTypeException("expected "+expected+" but found "+actual);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   295
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   296
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   297
    /** Static definition of MethodHandle.invokeExact checking code. */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   298
    /*non-public*/ static
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   299
    @ForceInline
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   300
    void checkExactType(Object mhObj, Object expectedObj) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   301
        MethodHandle mh = (MethodHandle) mhObj;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   302
        MethodType expected = (MethodType) expectedObj;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   303
        MethodType actual = mh.type();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   304
        if (actual != expected)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   305
            throw newWrongMethodTypeException(expected, actual);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   306
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   307
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   308
    /** Static definition of MethodHandle.invokeGeneric checking code.
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   309
     * Directly returns the type-adjusted MH to invoke, as follows:
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   310
     * {@code (R)MH.invoke(a*) => MH.asType(TYPEOF(a*:R)).invokeBasic(a*)}
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   311
     */
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   312
    /*non-public*/ static
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   313
    @ForceInline
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   314
    Object checkGenericType(Object mhObj, Object expectedObj) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   315
        MethodHandle mh = (MethodHandle) mhObj;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   316
        MethodType expected = (MethodType) expectedObj;
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   317
        return mh.asType(expected);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   318
        /* Maybe add more paths here.  Possible optimizations:
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   319
         * for (R)MH.invoke(a*),
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   320
         * let MT0 = TYPEOF(a*:R), MT1 = MH.type
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   321
         *
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   322
         * if MT0==MT1 or MT1 can be safely called by MT0
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   323
         *  => MH.invokeBasic(a*)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   324
         * if MT1 can be safely called by MT0[R := Object]
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   325
         *  => MH.invokeBasic(a*) & checkcast(R)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   326
         * if MT1 can be safely called by MT0[* := Object]
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   327
         *  => checkcast(A)* & MH.invokeBasic(a*) & checkcast(R)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   328
         * if a big adapter BA can be pulled out of (MT0,MT1)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   329
         *  => BA.invokeBasic(MT0,MH,a*)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   330
         * if a local adapter LA can cached on static CS0 = new GICS(MT0)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   331
         *  => CS0.LA.invokeBasic(MH,a*)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   332
         * else
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   333
         *  => MH.asType(MT0).invokeBasic(A*)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   334
         */
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   335
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   336
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   337
    static MemberName linkToCallSiteMethod(MethodType mtype) {
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   338
        LambdaForm lform = callSiteForm(mtype, false);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   339
        return lform.vmentry;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   340
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   341
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   342
    static MemberName linkToTargetMethod(MethodType mtype) {
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   343
        LambdaForm lform = callSiteForm(mtype, true);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   344
        return lform.vmentry;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   345
    }
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   346
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   347
    // skipCallSite is true if we are optimizing a ConstantCallSite
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   348
    private static LambdaForm callSiteForm(MethodType mtype, boolean skipCallSite) {
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   349
        mtype = mtype.basicType();  // normalize Z to I, String to Object, etc.
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   350
        final int which = (skipCallSite ? MethodTypeForm.LF_MH_LINKER : MethodTypeForm.LF_CS_LINKER);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   351
        LambdaForm lform = mtype.form().cachedLambdaForm(which);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   352
        if (lform != null)  return lform;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   353
        // exactInvokerForm (Object,Object)Object
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   354
        //   link with java.lang.invoke.MethodHandle.invokeBasic(MethodHandle,Object,Object)Object/invokeSpecial
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   355
        final int ARG_BASE     = 0;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   356
        final int OUTARG_LIMIT = ARG_BASE + mtype.parameterCount();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   357
        final int INARG_LIMIT  = OUTARG_LIMIT + 1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   358
        int nameCursor = OUTARG_LIMIT;
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   359
        final int APPENDIX_ARG = nameCursor++;  // the last in-argument
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   360
        final int CSITE_ARG    = skipCallSite ? -1 : APPENDIX_ARG;
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   361
        final int CALL_MH      = skipCallSite ? APPENDIX_ARG : nameCursor++;  // result of getTarget
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   362
        final int LINKER_CALL  = nameCursor++;
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   363
        MethodType invokerFormType = mtype.appendParameterTypes(skipCallSite ? MethodHandle.class : CallSite.class);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   364
        Name[] names = arguments(nameCursor - INARG_LIMIT, invokerFormType);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   365
        assert(names.length == nameCursor);
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   366
        assert(names[APPENDIX_ARG] != null);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   367
        if (!skipCallSite)
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   368
            names[CALL_MH] = new Name(NF_getCallSiteTarget, names[CSITE_ARG]);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   369
        // (site.)invokedynamic(a*):R => mh = site.getTarget(); mh.invokeBasic(a*)
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   370
        final int PREPEND_MH = 0, PREPEND_COUNT = 1;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   371
        Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, OUTARG_LIMIT + PREPEND_COUNT, Object[].class);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   372
        // prepend MH argument:
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   373
        System.arraycopy(outArgs, 0, outArgs, PREPEND_COUNT, outArgs.length - PREPEND_COUNT);
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   374
        outArgs[PREPEND_MH] = names[CALL_MH];
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   375
        names[LINKER_CALL] = new Name(mtype, outArgs);
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   376
        lform = new LambdaForm((skipCallSite ? "linkToTargetMethod" : "linkToCallSite"), INARG_LIMIT, names);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   377
        lform.compileToBytecode();  // JVM needs a real methodOop
20527
d241258cfbcb 8024761: JSR 292 improve performance of generic invocation
jrose
parents: 19804
diff changeset
   378
        lform = mtype.form().setCachedLambdaForm(which, lform);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   379
        return lform;
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   380
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   381
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   382
    /** Static definition of MethodHandle.invokeGeneric checking code. */
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   383
    /*non-public*/ static
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   384
    @ForceInline
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   385
    Object getCallSiteTarget(Object site) {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   386
        return ((CallSite)site).getTarget();
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   387
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   388
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   389
    // Local constant functions:
26467
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   390
    private static final NamedFunction
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   391
        NF_checkExactType,
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   392
        NF_checkGenericType,
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   393
        NF_getCallSiteTarget;
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   394
    static {
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   395
        try {
26467
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   396
            NamedFunction nfs[] = {
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   397
                NF_checkExactType = new NamedFunction(Invokers.class
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   398
                        .getDeclaredMethod("checkExactType", Object.class, Object.class)),
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   399
                NF_checkGenericType = new NamedFunction(Invokers.class
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   400
                        .getDeclaredMethod("checkGenericType", Object.class, Object.class)),
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   401
                NF_getCallSiteTarget = new NamedFunction(Invokers.class
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   402
                        .getDeclaredMethod("getCallSiteTarget", Object.class))
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   403
            };
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   404
            for (NamedFunction nf : nfs) {
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   405
                // Each nf must be statically invocable or we get tied up in our bootstraps.
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   406
                assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf.member)) : nf;
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   407
                nf.resolve();
d69abed3a07d 8050052: Small cleanups in java.lang.invoke code
vlivanov
parents: 25991
diff changeset
   408
            }
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   409
        } catch (ReflectiveOperationException ex) {
14089
0a41b980d62a 8000989: smaller code changes to make future JSR 292 backports easier
twisti
parents: 13610
diff changeset
   410
            throw newInternalError(ex);
13423
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   411
        }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   412
    }
17843fff200d 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10419
diff changeset
   413
26468
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   414
    private static class Lazy {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   415
        private static final MethodHandle MH_asSpreader;
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   416
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   417
        static {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   418
            try {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   419
                MH_asSpreader = IMPL_LOOKUP.findVirtual(MethodHandle.class, "asSpreader",
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   420
                        MethodType.methodType(MethodHandle.class, Class.class, int.class));
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   421
            } catch (ReflectiveOperationException ex) {
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   422
                throw newInternalError(ex);
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   423
            }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   424
        }
2d57604f9299 8050053: Improve caching of different invokers
vlivanov
parents: 26467
diff changeset
   425
    }
2707
5a17df307cbc 6829144: JSR 292 JVM features need a provisional Java API
jrose
parents:
diff changeset
   426
}