test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java
author iignatyev
Fri, 07 Jun 2019 21:35:26 -0700
changeset 55301 a9188ba494a3
parent 50642 fff48b02d4a6
permissions -rw-r--r--
8149040: Cleanup compiler/jsr292/NonInlinedCall tests after JDK-8148994 Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
55301
a9188ba494a3 8149040: Cleanup compiler/jsr292/NonInlinedCall tests after JDK-8148994
iignatyev
parents: 50642
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    23
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    24
package java.lang.invoke;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    25
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    26
import java.lang.invoke.MethodHandles.Lookup;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
import jdk.internal.vm.annotation.DontInline;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import jdk.internal.vm.annotation.ForceInline;
55301
a9188ba494a3 8149040: Cleanup compiler/jsr292/NonInlinedCall tests after JDK-8148994
iignatyev
parents: 50642
diff changeset
    29
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
/**
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 * Helper class to inject into java.lang.invoke that provides access to
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * package-private methods in this package.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
public class MethodHandleHelper {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    35
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    36
    private MethodHandleHelper() { }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    37
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
    public static final Lookup IMPL_LOOKUP = Lookup.IMPL_LOOKUP;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    39
    public static final Class<?> MHN_CALL_SITE_CONTEXT_CLASS
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
            = MethodHandleNatives.CallSiteContext.class;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    41
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    42
    public static void customize(MethodHandle mh) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    43
        mh.customize();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    44
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    45
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    46
    @ForceInline
43943
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    47
    public static Object internalMemberName(MethodHandle mh) throws Throwable {
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    48
        return mh.internalMemberName();
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    49
    }
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    50
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    51
    @ForceInline
50642
fff48b02d4a6 8198719: MethodHandleHelper.linkToStatic should drop MH arg
dchuyko
parents: 47216
diff changeset
    52
    public static void linkToStatic(float arg, Object name) throws Throwable {
fff48b02d4a6 8198719: MethodHandleHelper.linkToStatic should drop MH arg
dchuyko
parents: 47216
diff changeset
    53
        MethodHandle.linkToStatic(arg, name);
43943
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    54
    }
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    55
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    56
    @ForceInline
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    57
    public static void invokeBasicV(MethodHandle mh, float arg) throws Throwable {
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    58
        mh.invokeBasic(arg);
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    59
    }
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    60
e2fdae30bbc1 8166110: Inlining through MH invokers/linkers in unreachable code is unsafe
vlivanov
parents: 36508
diff changeset
    61
    @ForceInline
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    62
    public static Object invokeBasicL(MethodHandle mh) throws Throwable {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    63
        return mh.invokeBasic();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    64
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    65
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    66
    @ForceInline
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    67
    public static int invokeBasicI(MethodHandle mh) throws Throwable {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    68
        return (int) mh.invokeBasic();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    69
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    70
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    public static MethodHandle varargsArray(int nargs) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        return MethodHandleImpl.varargsArray(nargs);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    74
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    75
    public static MethodHandle varargsArray(Class<?> arrayType, int nargs) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        return MethodHandleImpl.varargsArray(arrayType, nargs);
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    77
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    78
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    79
    public static LambdaForm getLambdaForm(MethodHandle mh) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        return mh.form;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    81
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    82
}