author | alanb |
Fri, 02 Nov 2012 15:50:11 +0000 | |
changeset 14342 | 8435a30053c1 |
parent 11534 | 9949ffb8eb3a |
child 14408 | db08012d1d6f |
permissions | -rw-r--r-- |
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 |
/** |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
26 |
* @test |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
27 |
* @summary smoke tests for CallSite |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
28 |
* |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
29 |
* @build indify.Indify |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
30 |
* @compile CallSiteTest.java |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
31 |
* @run main/othervm |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
32 |
* indify.Indify |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
33 |
* --expand-properties --classpath ${test.classes} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
34 |
* --java test.java.lang.invoke.CallSiteTest |
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 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
37 |
package test.java.lang.invoke; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
38 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
39 |
import java.io.*; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
40 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
41 |
import java.lang.invoke.*; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
42 |
import static java.lang.invoke.MethodHandles.*; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
43 |
import static java.lang.invoke.MethodType.*; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
44 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
45 |
public class CallSiteTest { |
11534
9949ffb8eb3a
7117167: Misc warnings in java.lang.invoke and sun.invoke.*
jrose
parents:
11007
diff
changeset
|
46 |
private final static Class<?> CLASS = CallSiteTest.class; |
11006
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
47 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
48 |
private static CallSite mcs; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
49 |
private static CallSite vcs; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
50 |
private static MethodHandle mh_foo; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
51 |
private static MethodHandle mh_bar; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
52 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
53 |
static { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
54 |
try { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
55 |
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
|
56 |
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
|
57 |
mcs = new MutableCallSite(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
58 |
vcs = new VolatileCallSite(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
59 |
} catch (Exception e) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
60 |
e.printStackTrace(); |
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 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
64 |
public static void main(String... av) throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
65 |
testMutableCallSite(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
66 |
testVolatileCallSite(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
67 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
68 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
69 |
private final static int N = Integer.MAX_VALUE / 100; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
70 |
private final static int RESULT1 = 762786192; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
71 |
private final static int RESULT2 = -21474836; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
72 |
|
11007 | 73 |
private static void assertEquals(int expected, int actual) { |
74 |
if (expected != actual) |
|
75 |
throw new AssertionError("expected: " + expected + ", actual: " + actual); |
|
76 |
} |
|
77 |
||
11006
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
78 |
private static void testMutableCallSite() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
79 |
// warm-up |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
80 |
for (int i = 0; i < 20000; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
81 |
mcs.setTarget(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
82 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
83 |
// run |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
84 |
for (int n = 0; n < 2; n++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
85 |
mcs.setTarget(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
86 |
for (int i = 0; i < 5; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
87 |
assertEquals(RESULT1, runMutableCallSite()); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
88 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
89 |
mcs.setTarget(mh_bar); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
90 |
for (int i = 0; i < 5; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
91 |
assertEquals(RESULT2, runMutableCallSite()); |
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 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
95 |
private static void testVolatileCallSite() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
96 |
// warm-up |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
97 |
for (int i = 0; i < 20000; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
98 |
vcs.setTarget(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
99 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
100 |
// run |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
101 |
for (int n = 0; n < 2; n++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
102 |
vcs.setTarget(mh_foo); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
103 |
for (int i = 0; i < 5; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
104 |
assertEquals(RESULT1, runVolatileCallSite()); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
105 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
106 |
vcs.setTarget(mh_bar); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
107 |
for (int i = 0; i < 5; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
108 |
assertEquals(RESULT2, runVolatileCallSite()); |
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 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
113 |
private static int runMutableCallSite() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
114 |
int sum = 0; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
115 |
for (int i = 0; i < N; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
116 |
sum += (int) INDY_mcs().invokeExact(i, i+1); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
117 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
118 |
return sum; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
119 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
120 |
private static int runVolatileCallSite() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
121 |
int sum = 0; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
122 |
for (int i = 0; i < N; i++) { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
123 |
sum += (int) INDY_vcs().invokeExact(i, i+1); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
124 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
125 |
return sum; |
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 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
131 |
private static MethodType MT_bsm() { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
132 |
shouldNotCallThis(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
133 |
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
|
134 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
135 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
136 |
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
|
137 |
return mcs; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
138 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
139 |
private static MethodHandle MH_bsm_mcs() throws ReflectiveOperationException { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
140 |
shouldNotCallThis(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
141 |
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
|
142 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
143 |
private static MethodHandle INDY_mcs() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
144 |
shouldNotCallThis(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
145 |
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
|
146 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
147 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
148 |
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
|
149 |
return vcs; |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
150 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
151 |
private static MethodHandle MH_bsm_vcs() throws ReflectiveOperationException { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
152 |
shouldNotCallThis(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
153 |
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
|
154 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
155 |
private static MethodHandle INDY_vcs() throws Throwable { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
156 |
shouldNotCallThis(); |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
157 |
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
|
158 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
159 |
|
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
160 |
private static void shouldNotCallThis() { |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
161 |
// 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
|
162 |
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
|
163 |
} |
734080358bec
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
diff
changeset
|
164 |
} |