use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualLongMethodVarargs.
@JniImpl
public long CallNonvirtualLongMethodVarargs(@JavaType(Object.class) StaticObject receiver, @JavaType(Class.class) StaticObject clazz, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
Method method = methodIds.getObject(methodId);
assert !method.isStatic();
assert (clazz.getMirrorKlass()) == method.getDeclaringKlass();
Object result = method.invokeDirect(receiver, popVarArgs(varargsPtr, method.getParsedSignature()));
return getMeta().asLong(result, true);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method NewObjectVarargs.
@JniImpl
@JavaType(Object.class)
public StaticObject NewObjectVarargs(@JavaType(Class.class) StaticObject clazz, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
Method method = methodIds.getObject(methodId);
assert method.isConstructor();
Klass klass = clazz.getMirrorKlass();
if (klass.isInterface() || klass.isAbstract()) {
Meta meta = getMeta();
throw meta.throwException(meta.java_lang_InstantiationException);
}
klass.initialize();
StaticObject instance;
if (CompilerDirectives.isPartialEvaluationConstant(klass)) {
instance = klass.allocateInstance();
} else {
instance = allocateBoundary(klass);
}
method.invokeDirect(instance, popVarArgs(varargsPtr, method.getParsedSignature()));
return instance;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualDoubleMethodVarargs.
@JniImpl
public double CallNonvirtualDoubleMethodVarargs(@JavaType(Object.class) StaticObject receiver, @JavaType(Class.class) StaticObject clazz, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
Method method = methodIds.getObject(methodId);
assert !method.isStatic();
assert (clazz.getMirrorKlass()) == method.getDeclaringKlass();
Object result = method.invokeDirect(receiver, popVarArgs(varargsPtr, method.getParsedSignature()));
return getMeta().asDouble(result, true);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method RegisterNative.
// endregion DirectBuffers
// region Register/Unregister natives
@JniImpl
@TruffleBoundary
public int RegisterNative(@JavaType(Class.class) StaticObject clazz, @Pointer TruffleObject methodNamePtr, @Pointer TruffleObject methodSignaturePtr, @Pointer TruffleObject closure) {
String methodName = NativeUtils.interopPointerToString(methodNamePtr);
String methodSignature = NativeUtils.interopPointerToString(methodSignaturePtr);
assert methodName != null && methodSignature != null;
Symbol<Name> name = getNames().lookup(methodName);
Symbol<Signature> signature = getSignatures().lookupValidSignature(methodSignature);
Meta meta = getMeta();
if (name == null || signature == null) {
setPendingException(Meta.initException(meta.java_lang_NoSuchMethodError));
return JNI_ERR;
}
Method targetMethod = clazz.getMirrorKlass().lookupDeclaredMethod(name, signature);
if (targetMethod != null && targetMethod.isNative()) {
targetMethod.unregisterNative();
getSubstitutions().removeRuntimeSubstitution(targetMethod);
} else {
setPendingException(Meta.initException(meta.java_lang_NoSuchMethodError));
return JNI_ERR;
}
Substitutions.EspressoRootNodeFactory factory = null;
// Lookup known VM methods to shortcut native boudaries.
factory = lookupKnownVmMethods(closure, targetMethod);
if (factory == null) {
NativeSignature ns = Method.buildJniNativeSignature(targetMethod.getParsedSignature());
final TruffleObject boundNative = getNativeAccess().bindSymbol(closure, ns);
factory = createJniRootNodeFactory(() -> new NativeMethodNode(boundNative, targetMethod.getMethodVersion()), targetMethod);
}
Symbol<Type> classType = clazz.getMirrorKlass().getType();
getSubstitutions().registerRuntimeSubstitution(classType, name, signature, factory, true);
return JNI_OK;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualObjectMethodVarargs.
// endregion Call*Method
// region CallNonvirtual*Method
@JniImpl
@JavaType(Object.class)
public StaticObject CallNonvirtualObjectMethodVarargs(@JavaType(Object.class) StaticObject receiver, @JavaType(Class.class) StaticObject clazz, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
Method method = methodIds.getObject(methodId);
assert !method.isStatic();
assert (clazz.getMirrorKlass()) == method.getDeclaringKlass();
Object result = method.invokeDirect(receiver, popVarArgs(varargsPtr, method.getParsedSignature()));
return getMeta().asObject(result);
}
Aggregations