Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/jcl/src/java.base/share/classes/java/lang/invoke/DynamicInvokerHandle.java
12520 views
1
/*[INCLUDE-IF Sidecar17 & !OPENJDK_METHODHANDLES]*/
2
/*******************************************************************************
3
* Copyright (c) 2011, 2020 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
22
*******************************************************************************/
23
package java.lang.invoke;
24
25
/*[IF JAVA_SPEC_VERSION >= 15]*/
26
import java.util.List;
27
/*[ENDIF] JAVA_SPEC_VERSION >= 15 */
28
29
@VMCONSTANTPOOL_CLASS
30
class DynamicInvokerHandle extends MethodHandle {
31
@VMCONSTANTPOOL_FIELD
32
final CallSite site;
33
34
DynamicInvokerHandle(CallSite site) {
35
super(site.type(), MethodHandle.KIND_DYNAMICINVOKER, null); //$NON-NLS-1$
36
this.site = site;
37
}
38
39
DynamicInvokerHandle(DynamicInvokerHandle originalHandle, MethodType newType) {
40
super(originalHandle, newType);
41
this.site = originalHandle.site;
42
}
43
44
/*[IF JAVA_SPEC_VERSION >= 15]*/
45
@Override
46
boolean addRelatedMHs(List<MethodHandle> relatedMHs) {
47
return false;
48
}
49
/*[ENDIF] JAVA_SPEC_VERSION >= 15 */
50
51
// {{{ JIT support
52
53
private static final ThunkTable _thunkTable = new ThunkTable();
54
protected ThunkTable thunkTable(){ return _thunkTable; }
55
56
@FrameIteratorSkip
57
private final int invokeExact_thunkArchetype_X(int argPlaceholder) throws Throwable {
58
if (ILGenMacros.isShareableThunk()) {
59
undoCustomizationLogic(site.getTarget());
60
}
61
if (!ILGenMacros.isCustomThunk()) {
62
doCustomizationLogic();
63
}
64
return ILGenMacros.invokeExact_X(site.getTarget(), argPlaceholder);
65
}
66
67
// }}} JIT support
68
69
@Override
70
MethodHandle cloneWithNewType(MethodType newType) {
71
return new DynamicInvokerHandle(this, newType);
72
}
73
74
// Final because any pair of invokers are equivalent if the point at the same site
75
final void compareWith(MethodHandle right, Comparator c) {
76
if (right instanceof DynamicInvokerHandle) {
77
((DynamicInvokerHandle)right).compareWithDynamicInvoker(this, c);
78
} else {
79
c.fail();
80
}
81
}
82
83
final void compareWithDynamicInvoker(DynamicInvokerHandle left, Comparator c) {
84
c.compareStructuralParameter(left.site, this.site);
85
}
86
}
87
88