use of java.lang.invoke.ConstantCallSite in project presto by prestodb.
the class TestInvokeDynamicBytecodeExpression method bootstrap.
public static CallSite bootstrap(MethodHandles.Lookup callerLookup, String name, MethodType type, String prefix) throws Exception {
MethodHandle methodHandle = callerLookup.findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class));
methodHandle = methodHandle.bindTo(name + "-" + prefix + "-");
return new ConstantCallSite(methodHandle);
}
use of java.lang.invoke.ConstantCallSite in project gravel by gravel-st.
the class MethodLinker method constructorBootstrap.
public static CallSite constructorBootstrap(Lookup lookup, String selector, MethodType type, String referenceString) throws Throwable {
Reference reference = Reference.factory.value_(referenceString);
Constructor constructor = ImageBootstrapper.systemMapping.classMappingAtReference_(reference).identityClass().getConstructor();
MethodHandle constructorHandle = lookup.unreflectConstructor(constructor);
return new ConstantCallSite(constructorHandle.asType(type));
}
use of java.lang.invoke.ConstantCallSite in project gravel by gravel-st.
the class MethodLinker method globalReadBootstrap.
public static CallSite globalReadBootstrap(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);
return new ConstantCallSite(singletonHolder.createGetter());
}
use of java.lang.invoke.ConstantCallSite in project es6draft by anba.
the class Bootstrap method bootstrapDynamic.
/**
* The invokedynamic bootstrapping method.
*
* @param caller
* the caller lookup
* @param name
* the instruction name
* @param type
* the expected method type
* @return the invokedynamic call-site object
*/
public static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String name, MethodType type) {
// System.out.printf("type: %s\n", type);
try {
MutableCallSite callsite = new MutableCallSite(type);
MethodHandle setup;
switch(name) {
case CallNames.CALL:
setup = MethodHandles.insertArguments(callSetupMH, 0, callsite);
break;
case CallNames.CONSTRUCT:
setup = MethodHandles.insertArguments(constructSetupMH, 0, callsite);
break;
case CallNames.SUPER:
setup = MethodHandles.insertArguments(superSetupMH, 0, callsite);
break;
case CallNames.ADD:
setup = MethodHandles.insertArguments(addSetupMH, 0, callsite);
break;
case CallNames.SUB:
setup = MethodHandles.insertArguments(subSetupMH, 0, callsite);
break;
case CallNames.EXP:
setup = MethodHandles.insertArguments(expSetupMH, 0, callsite);
break;
case CallNames.MUL:
setup = MethodHandles.insertArguments(mulSetupMH, 0, callsite);
break;
case CallNames.DIV:
setup = MethodHandles.insertArguments(divSetupMH, 0, callsite);
break;
case CallNames.MOD:
setup = MethodHandles.insertArguments(modSetupMH, 0, callsite);
break;
case CallNames.SHL:
setup = MethodHandles.insertArguments(shlSetupMH, 0, callsite);
break;
case CallNames.SHR:
setup = MethodHandles.insertArguments(shrSetupMH, 0, callsite);
break;
case CallNames.USHR:
setup = MethodHandles.insertArguments(ushrSetupMH, 0, callsite);
break;
case CallNames.BITAND:
setup = MethodHandles.insertArguments(bitAndSetupMH, 0, callsite);
break;
case CallNames.BITOR:
setup = MethodHandles.insertArguments(bitOrSetupMH, 0, callsite);
break;
case CallNames.BITXOR:
setup = MethodHandles.insertArguments(bitXorSetupMH, 0, callsite);
break;
case CallNames.EQ:
setup = MethodHandles.insertArguments(eqCmpSetupMH, 0, callsite);
break;
case CallNames.SHEQ:
setup = MethodHandles.insertArguments(strictEqCmpSetupMH, 0, callsite);
break;
case CallNames.LT:
setup = MethodHandles.insertArguments(relCmpSetupMH, 0, callsite, RelationalOperator.LessThan);
break;
case CallNames.GT:
setup = MethodHandles.insertArguments(relCmpSetupMH, 0, callsite, RelationalOperator.GreaterThan);
break;
case CallNames.LE:
setup = MethodHandles.insertArguments(relCmpSetupMH, 0, callsite, RelationalOperator.LessThanEquals);
break;
case CallNames.GE:
setup = MethodHandles.insertArguments(relCmpSetupMH, 0, callsite, RelationalOperator.GreaterThanEquals);
break;
case CallNames.CONCAT:
concatSetup(callsite, type);
return callsite;
case CallNames.BITNOT:
setup = MethodHandles.insertArguments(bitNotSetupMH, 0, callsite);
break;
case CallNames.NEG:
setup = MethodHandles.insertArguments(negSetupMH, 0, callsite);
break;
case CallNames.INC:
setup = MethodHandles.insertArguments(incSetupMH, 0, callsite);
break;
case CallNames.DEC:
setup = MethodHandles.insertArguments(decSetupMH, 0, callsite);
break;
default:
throw new IllegalArgumentException(name);
}
callsite.setTarget(setupCallSiteTarget(type, setup));
return callsite;
} catch (StackOverflowError e) {
switch(name) {
case CallNames.CALL:
return stackOverFlow_Call;
case CallNames.CONSTRUCT:
return stackOverFlow_Construct;
case CallNames.SUPER:
return stackOverFlow_Super;
case CallNames.CONCAT:
return new ConstantCallSite(MethodHandles.dropArguments(stackOverFlow_Concat, 0, type.parameterArray()));
case CallNames.ADD:
return stackOverFlow_Add;
case CallNames.SUB:
case CallNames.EXP:
case CallNames.MUL:
case CallNames.DIV:
case CallNames.MOD:
case CallNames.SHL:
case CallNames.SHR:
case CallNames.USHR:
case CallNames.BITAND:
case CallNames.BITOR:
case CallNames.BITXOR:
return stackOverFlow_BinaryNumber;
case CallNames.EQ:
return stackOverFlow_Eq;
case CallNames.SHEQ:
return stackOverFlow_StrictEq;
case CallNames.LT:
case CallNames.GT:
case CallNames.LE:
case CallNames.GE:
return stackOverFlow_Cmp;
case CallNames.BITNOT:
case CallNames.NEG:
case CallNames.INC:
case CallNames.DEC:
return stackOverFlow_UnaryNumber;
default:
throw new IllegalArgumentException(name);
}
}
}
use of java.lang.invoke.ConstantCallSite in project es6draft by anba.
the class Operators method runtimeBootstrap.
public static CallSite runtimeBootstrap(MethodHandles.Lookup caller, String name, MethodType type) {
assert "rt:stack".equals(name) || "rt:locals".equals(name);
MethodHandle mh = MethodHandles.identity(Object[].class);
mh = mh.asCollector(Object[].class, type.parameterCount());
mh = mh.asType(type);
return new ConstantCallSite(mh);
}
Aggregations