Path: blob/master/jcl/src/java.base/share/classes/java/lang/invoke/DynamicInvokerHandle.java
12520 views
/*[INCLUDE-IF Sidecar17 & !OPENJDK_METHODHANDLES]*/1/*******************************************************************************2* Copyright (c) 2011, 2020 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* 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-exception21*******************************************************************************/22package java.lang.invoke;2324/*[IF JAVA_SPEC_VERSION >= 15]*/25import java.util.List;26/*[ENDIF] JAVA_SPEC_VERSION >= 15 */2728@VMCONSTANTPOOL_CLASS29class DynamicInvokerHandle extends MethodHandle {30@VMCONSTANTPOOL_FIELD31final CallSite site;3233DynamicInvokerHandle(CallSite site) {34super(site.type(), MethodHandle.KIND_DYNAMICINVOKER, null); //$NON-NLS-1$35this.site = site;36}3738DynamicInvokerHandle(DynamicInvokerHandle originalHandle, MethodType newType) {39super(originalHandle, newType);40this.site = originalHandle.site;41}4243/*[IF JAVA_SPEC_VERSION >= 15]*/44@Override45boolean addRelatedMHs(List<MethodHandle> relatedMHs) {46return false;47}48/*[ENDIF] JAVA_SPEC_VERSION >= 15 */4950// {{{ JIT support5152private static final ThunkTable _thunkTable = new ThunkTable();53protected ThunkTable thunkTable(){ return _thunkTable; }5455@FrameIteratorSkip56private final int invokeExact_thunkArchetype_X(int argPlaceholder) throws Throwable {57if (ILGenMacros.isShareableThunk()) {58undoCustomizationLogic(site.getTarget());59}60if (!ILGenMacros.isCustomThunk()) {61doCustomizationLogic();62}63return ILGenMacros.invokeExact_X(site.getTarget(), argPlaceholder);64}6566// }}} JIT support6768@Override69MethodHandle cloneWithNewType(MethodType newType) {70return new DynamicInvokerHandle(this, newType);71}7273// Final because any pair of invokers are equivalent if the point at the same site74final void compareWith(MethodHandle right, Comparator c) {75if (right instanceof DynamicInvokerHandle) {76((DynamicInvokerHandle)right).compareWithDynamicInvoker(this, c);77} else {78c.fail();79}80}8182final void compareWithDynamicInvoker(DynamicInvokerHandle left, Comparator c) {83c.compareStructuralParameter(left.site, this.site);84}85}868788