use of java.lang.invoke.ConstantCallSite in project es6draft by anba.
the class ScriptRuntime 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);
}
use of java.lang.invoke.ConstantCallSite in project openj9 by eclipse.
the class BootstrapMethods method bootstrap_guard_with_test_let_input_decide.
// Bootstrap method for guardWithTest MH test where decision is made based on an incoming argument
public static CallSite bootstrap_guard_with_test_let_input_decide(Lookup lookup, String name, MethodType type) throws Throwable {
MethodHandle mh_isDivisibleByThree = lookup.findStatic(Helper.class, "isDivisibleByThree", methodType(boolean.class, int.class));
MethodHandle mh_isDivisibleByFive = lookup.findStatic(Helper.class, "isDivisibleByFive", methodType(boolean.class, int.class));
MethodHandle mh_returnFizz = lookup.findStatic(Helper.class, "returnFizz", methodType(String.class, int.class));
MethodHandle mh_returnBuzz = lookup.findStatic(Helper.class, "returnBuzz", methodType(String.class, int.class));
MethodHandle mh_returnNothing = lookup.findStatic(Helper.class, "returnNothing", methodType(String.class, int.class));
// if input % 3 , return "fizz", else if input % 5 , return "buzz" , else return "nothing"
MethodHandle otherGWT = MethodHandles.guardWithTest(mh_isDivisibleByFive, mh_returnBuzz, mh_returnNothing);
MethodHandle result = MethodHandles.guardWithTest(mh_isDivisibleByThree, mh_returnFizz, otherGWT);
return new ConstantCallSite(result);
}
use of java.lang.invoke.ConstantCallSite in project openj9 by eclipse.
the class BootstrapMethods method bootstrap_guard_with_test_constant_true.
// Bootstrap method for guardWithTest MH test using a constant true condition
public static CallSite bootstrap_guard_with_test_constant_true(Lookup lookup, String name, MethodType type) throws Throwable {
MethodHandle constant_true = MethodHandles.constant(boolean.class, true);
MethodHandle trueTarget = lookup.findStatic(Helper.class, "negativeInt", methodType(int.class, int.class));
MethodHandle falseTarget = MethodHandles.identity(int.class);
// if (true_gwt()) { negativeInt(5) } else { identity(5) }
MethodHandle true_gwt = MethodHandles.guardWithTest(constant_true, trueTarget, falseTarget);
return new ConstantCallSite(true_gwt);
}
use of java.lang.invoke.ConstantCallSite in project openj9 by eclipse.
the class BootstrapMethods method bootstrap_bind_mh_to_receiver.
// Bootstrap method for bindTo MH test
public static CallSite bootstrap_bind_mh_to_receiver(Lookup lookup, String name, MethodType type) throws Throwable {
MethodHandle mh = lookup.findGetter(Helper.class, "publicInt", int.class);
mh = mh.bindTo(new Helper());
return new ConstantCallSite(mh);
}
use of java.lang.invoke.ConstantCallSite in project openj9 by eclipse.
the class BootstrapMethods method bootstrapAddInts.
public static CallSite bootstrapAddInts(Lookup caller, String name, MethodType type) throws Throwable {
MethodHandles.Lookup lookup = MethodHandles.lookup();
Class<?> thisClass = lookup.lookupClass();
MethodHandle addIntegers = lookup.findStatic(thisClass, "addIntegers", type);
return new ConstantCallSite(addIntegers);
}
Aggregations