提交 dc0e5ea7 编写于 作者: J jrose

6983728: JSR 292 remove argument count limitations

Summary: Remove workarounds and limitations from before 6939861.
Reviewed-by: never
上级 8cd530d6
...@@ -247,10 +247,6 @@ class AdapterMethodHandle extends BoundMethodHandle { ...@@ -247,10 +247,6 @@ class AdapterMethodHandle extends BoundMethodHandle {
MethodType needConversion = MethodType.methodType(needReturn, haveReturn); MethodType needConversion = MethodType.methodType(needReturn, haveReturn);
adjustReturn = MethodHandles.identity(needReturn).asType(needConversion); adjustReturn = MethodHandles.identity(needReturn).asType(needConversion);
} }
if (!canCollectArguments(adjustReturn.type(), target.type(), 0, false)) {
assert(MethodHandleNatives.workaroundWithoutRicochetFrames()); // this code is deprecated
throw new InternalError("NYI");
}
return makeCollectArguments(adjustReturn, target, 0, false); return makeCollectArguments(adjustReturn, target, 0, false);
} }
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.lang.invoke;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
/**
* Unary function composition, useful for many small plumbing jobs.
* The invoke method takes a single reference argument, and returns a reference
* Internally, it first calls the {@code filter} method on the argument,
* Making up the difference between the raw method type and the
* final method type is the responsibility of a JVM-level adapter.
* @author jrose
*/
class FilterOneArgument extends BoundMethodHandle {
protected final MethodHandle filter; // Object -> Object
protected final MethodHandle target; // Object -> Object
@Override
String debugString() {
return target.toString();
}
protected Object invoke(Object argument) throws Throwable {
Object filteredArgument = filter.invokeExact(argument);
return target.invokeExact(filteredArgument);
}
private static final MethodHandle INVOKE;
static {
try {
INVOKE =
IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke",
MethodType.genericMethodType(1));
} catch (ReflectiveOperationException ex) {
throw uncaughtException(ex);
}
}
protected FilterOneArgument(MethodHandle filter, MethodHandle target) {
super(INVOKE);
this.filter = filter;
this.target = target;
}
static {
assert(MethodHandleNatives.workaroundWithoutRicochetFrames()); // this class is deprecated
}
public static MethodHandle make(MethodHandle filter, MethodHandle target) {
if (filter == null) return target;
if (target == null) return filter;
return new FilterOneArgument(filter, target);
}
// MethodHandle make(MethodHandle filter1, MethodHandle filter2, MethodHandle target) {
// MethodHandle filter = make(filter1, filter2);
// return make(filter, target);
// }
}
...@@ -391,13 +391,4 @@ class MethodHandleNatives { ...@@ -391,13 +391,4 @@ class MethodHandleNatives {
throw err; throw err;
} }
} }
/**
* This assertion marks code which was written before ricochet frames were implemented.
* Such code will go away when the ports catch up.
*/
static boolean workaroundWithoutRicochetFrames() {
assert(!HAVE_RICOCHET_FRAMES) : "this code should not be executed if `-XX:+UseRicochetFrames is enabled";
return true;
}
} }
...@@ -1995,16 +1995,8 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2 ...@@ -1995,16 +1995,8 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
// lambda( arg...) { target(arg...) } ) // lambda( arg...) { target(arg...) } )
MethodType newType = targetType.changeReturnType(filterType.returnType()); MethodType newType = targetType.changeReturnType(filterType.returnType());
MethodHandle result = null; MethodHandle result = null;
if (AdapterMethodHandle.canCollectArguments(filterType, targetType, 0, false)) { assert(AdapterMethodHandle.canCollectArguments(filterType, targetType, 0, false));
result = AdapterMethodHandle.makeCollectArguments(filter, target, 0, false); return AdapterMethodHandle.makeCollectArguments(filter, target, 0, false);
if (result != null) return result;
}
// FIXME: Too many nodes here.
assert(MethodHandleNatives.workaroundWithoutRicochetFrames()); // this class is deprecated
MethodHandle returner = dropArguments(filter, filterValues, targetType.parameterList());
result = foldArguments(returner, target);
assert(result.type().equals(newType));
return result;
} }
/** /**
......
...@@ -56,10 +56,6 @@ class MethodTypeForm { ...@@ -56,10 +56,6 @@ class MethodTypeForm {
/*lazy*/ MethodType primsAtEnd; // reorder primitives to the end /*lazy*/ MethodType primsAtEnd; // reorder primitives to the end
// Cached adapter information: // Cached adapter information:
/*lazy*/ ToGeneric toGeneric; // convert cs. with prims to w/o
/*lazy*/ FromGeneric fromGeneric; // convert cs. w/o prims to with
/*lazy*/ SpreadGeneric[] spreadGeneric; // expand one argument to many
/*lazy*/ FilterGeneric filterGeneric; // convert argument(s) on the fly
/*lazy*/ MethodHandle genericInvoker; // hook for inexact invoke /*lazy*/ MethodHandle genericInvoker; // hook for inexact invoke
public MethodType erasedType() { public MethodType erasedType() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册