use of java.lang.invoke.ConstantCallSite in project es6draft by anba.
the class NativeCalls method bootstrapDynamic.
/**
* Returns the native call {@code CallSite} object.
*
* @param caller
* the caller lookup object
* @param name
* the native call name
* @param type
* the native call type
* @return the native call {@code CallSite} object
*/
public static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String name, MethodType type) {
MethodHandle target;
try {
if (!name.startsWith("native:")) {
throw new IllegalArgumentException();
}
String methodName = name.substring("native:".length());
MethodHandle mh = nativeMethods.computeIfAbsent(methodName, NativeCalls::getNativeMethodHandle);
if (mh == null) {
return createRuntimeCallSite(methodName, type);
}
target = adaptMethodHandle(methodName, type, mh);
} catch (IllegalArgumentException e) {
target = invalidCallHandle(name, type);
}
return new ConstantCallSite(target);
}
use of java.lang.invoke.ConstantCallSite in project presto by prestodb.
the class Bootstrap method bootstrap.
public static CallSite bootstrap(MethodHandles.Lookup callerLookup, String name, MethodType type, long bindingId) {
ClassLoader classLoader = callerLookup.lookupClass().getClassLoader();
checkArgument(classLoader instanceof DynamicClassLoader, "Expected %s's classloader to be of type %s", callerLookup.lookupClass().getName(), DynamicClassLoader.class.getName());
DynamicClassLoader dynamicClassLoader = (DynamicClassLoader) classLoader;
MethodHandle target = dynamicClassLoader.getCallSiteBindings().get(bindingId);
checkArgument(target != null, "Binding %s for function %s%s not found", bindingId, name, type.parameterList());
return new ConstantCallSite(target);
}
use of java.lang.invoke.ConstantCallSite in project gravel by gravel-st.
the class MethodLinker method globalWriteBootstrap.
public static CallSite globalWriteBootstrap(Lookup lookup, String selector, MethodType type, String namespaceString) throws Throwable {
AbsoluteReference namespace = (AbsoluteReference) Reference.factory.value_(namespaceString);
AbsoluteReference fullReference = namespace.$slash$(Symbol.value(selector));
final AlmostFinalValue singletonHolder = ImageBootstrapper.systemMapping.resolveSingletonHolder_(fullReference);
final MethodHandle target = lookup.findVirtual(AlmostFinalValue.class, "setValue", MethodType.methodType(Object.class, Object.class)).bindTo(singletonHolder);
return new ConstantCallSite(target);
}
Aggregations