test/jdk/java/lang/invoke/CallSiteTest.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 40684 jdk/test/java/lang/invoke/CallSiteTest.java@2e37c119dc2a
child 59275 a6e25566cb56
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 11534
diff changeset
     2
 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     4
 *
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     8
 *
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    13
 * accompanied this code).
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    14
 *
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    18
 *
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    21
 * questions.
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    22
 */
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    23
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    24
/**
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    25
 * @test
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    26
 * @summary smoke tests for CallSite
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    27
 *
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    28
 * @build indify.Indify
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    29
 * @compile CallSiteTest.java
14408
db08012d1d6f 7197210: java/lang/invoke/CallSiteTest.java failing on armsflt.
jiangli
parents: 14342
diff changeset
    30
 * @run main/othervm/timeout=3600 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    31
 *      indify.Indify
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    32
 *      --expand-properties --classpath ${test.classes}
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    33
 *      --java test.java.lang.invoke.CallSiteTest
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    34
 */
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    35
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    36
package test.java.lang.invoke;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    37
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    38
import java.io.*;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    39
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    40
import java.lang.invoke.*;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    41
import static java.lang.invoke.MethodHandles.*;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    42
import static java.lang.invoke.MethodType.*;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    43
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    44
public class CallSiteTest {
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14408
diff changeset
    45
    private static final Class<?> CLASS = CallSiteTest.class;
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    46
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    47
    private static CallSite mcs;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    48
    private static CallSite vcs;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    49
    private static MethodHandle mh_foo;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    50
    private static MethodHandle mh_bar;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    51
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    52
    static {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    53
        try {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    54
            mh_foo = lookup().findStatic(CLASS, "foo", methodType(int.class, int.class, int.class));
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    55
            mh_bar = lookup().findStatic(CLASS, "bar", methodType(int.class, int.class, int.class));
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    56
            mcs = new MutableCallSite(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    57
            vcs = new VolatileCallSite(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    58
        } catch (Exception e) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    59
            e.printStackTrace();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    60
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    61
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    62
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    63
    public static void main(String... av) throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    64
        testMutableCallSite();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    65
        testVolatileCallSite();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    66
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    67
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14408
diff changeset
    68
    private static final int N = Integer.MAX_VALUE / 100;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14408
diff changeset
    69
    private static final int RESULT1 = 762786192;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 14408
diff changeset
    70
    private static final int RESULT2 = -21474836;
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    71
11007
09d3dddac781 7109063: JSR 292: fix for 7085860 is incomplete
twisti
parents: 11006
diff changeset
    72
    private static void assertEquals(int expected, int actual) {
09d3dddac781 7109063: JSR 292: fix for 7085860 is incomplete
twisti
parents: 11006
diff changeset
    73
        if (expected != actual)
09d3dddac781 7109063: JSR 292: fix for 7085860 is incomplete
twisti
parents: 11006
diff changeset
    74
            throw new AssertionError("expected: " + expected + ", actual: " + actual);
09d3dddac781 7109063: JSR 292: fix for 7085860 is incomplete
twisti
parents: 11006
diff changeset
    75
    }
09d3dddac781 7109063: JSR 292: fix for 7085860 is incomplete
twisti
parents: 11006
diff changeset
    76
11006
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    77
    private static void testMutableCallSite() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    78
        // warm-up
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    79
        for (int i = 0; i < 20000; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    80
            mcs.setTarget(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    81
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    82
        // run
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    83
        for (int n = 0; n < 2; n++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    84
            mcs.setTarget(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    85
            for (int i = 0; i < 5; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    86
                assertEquals(RESULT1, runMutableCallSite());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    87
            }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    88
            mcs.setTarget(mh_bar);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    89
            for (int i = 0; i < 5; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    90
                assertEquals(RESULT2, runMutableCallSite());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    91
            }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    92
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    93
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    94
    private static void testVolatileCallSite() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    95
        // warm-up
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    96
        for (int i = 0; i < 20000; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    97
            vcs.setTarget(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    98
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
    99
        // run
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   100
        for (int n = 0; n < 2; n++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   101
            vcs.setTarget(mh_foo);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   102
            for (int i = 0; i < 5; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   103
                assertEquals(RESULT1, runVolatileCallSite());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   104
            }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   105
            vcs.setTarget(mh_bar);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   106
            for (int i = 0; i < 5; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   107
                assertEquals(RESULT2, runVolatileCallSite());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   108
            }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   109
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   110
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   111
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   112
    private static int runMutableCallSite() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   113
        int sum = 0;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   114
        for (int i = 0; i < N; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   115
            sum += (int) INDY_mcs().invokeExact(i, i+1);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   116
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   117
        return sum;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   118
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   119
    private static int runVolatileCallSite() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   120
        int sum = 0;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   121
        for (int i = 0; i < N; i++) {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   122
            sum += (int) INDY_vcs().invokeExact(i, i+1);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   123
        }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   124
        return sum;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   125
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   126
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   127
    static int foo(int a, int b) { return a + b; }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   128
    static int bar(int a, int b) { return a - b; }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   129
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   130
    private static MethodType MT_bsm() {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   131
        shouldNotCallThis();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   132
        return methodType(CallSite.class, Lookup.class, String.class, MethodType.class);
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   133
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   134
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   135
    private static CallSite bsm_mcs(Lookup caller, String name, MethodType type) throws ReflectiveOperationException {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   136
        return mcs;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   137
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   138
    private static MethodHandle MH_bsm_mcs() throws ReflectiveOperationException {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   139
        shouldNotCallThis();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   140
        return lookup().findStatic(lookup().lookupClass(), "bsm_mcs", MT_bsm());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   141
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   142
    private static MethodHandle INDY_mcs() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   143
        shouldNotCallThis();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   144
        return ((CallSite) MH_bsm_mcs().invoke(lookup(), "foo", methodType(int.class, int.class, int.class))).dynamicInvoker();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   145
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   146
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   147
    private static CallSite bsm_vcs(Lookup caller, String name, MethodType type) throws ReflectiveOperationException {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   148
        return vcs;
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   149
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   150
    private static MethodHandle MH_bsm_vcs() throws ReflectiveOperationException {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   151
        shouldNotCallThis();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   152
        return lookup().findStatic(lookup().lookupClass(), "bsm_vcs", MT_bsm());
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   153
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   154
    private static MethodHandle INDY_vcs() throws Throwable {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   155
        shouldNotCallThis();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   156
        return ((CallSite) MH_bsm_vcs().invoke(lookup(), "foo", methodType(int.class, int.class, int.class))).dynamicInvoker();
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   157
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   158
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   159
    private static void shouldNotCallThis() {
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   160
        // if this gets called, the transformation has not taken place
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   161
        throw new AssertionError("this code should be statically transformed away by Indify");
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   162
    }
734080358bec 7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff changeset
   163
}