use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualShortMethodVarargs.
@JniImpl
public short CallNonvirtualShortMethodVarargs(@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().asShort(result, true);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method UnregisterNatives.
/**
* <h3>jint UnregisterNatives(JNIEnv *env, jclass clazz);</h3>
* <p>
* Unregisters native methods of a class. The class goes back to the state before it was linked
* or registered with its native method functions.
* <p>
* This function should not be used in normal native code. Instead, it provides special programs
* a way to reload and relink native libraries.
*
* @param clazz a Java class object.
* <p>
* Returns 0 on success; returns a negative value on failure.
*/
@JniImpl
@TruffleBoundary
public int UnregisterNatives(@JavaType(Class.class) StaticObject clazz) {
Klass klass = clazz.getMirrorKlass();
for (Method m : klass.getDeclaredMethods()) {
if (m.isNative()) {
getSubstitutions().removeRuntimeSubstitution(m);
m.unregisterNative();
}
}
return JNI_OK;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class IntrinsifiedNativeMethodNode method executeBody.
@Override
Object executeBody(VirtualFrame frame) {
Object[] args = frame.getArguments();
Method method = getMethod();
if (method.isStatic()) {
int parameterCount = method.getParameterCount();
Object[] newArgs = new Object[parameterCount + 1];
newArgs[0] = method.getDeclaringKlass().mirror();
System.arraycopy(args, 0, newArgs, 1, parameterCount);
args = newArgs;
}
return nativeMethod.invokeDirect(env, args);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class EspressoInstrumentableNode method getScope.
@ExportMessage
@TruffleBoundary
@SuppressWarnings("static-method")
public final Object getScope(Frame frame, @SuppressWarnings("unused") boolean nodeEnter) {
// construct the current scope with valid local variables information
Method method = getMethod();
Local[] liveLocals = method.getLocalVariableTable().getLocalsAt(getBci(frame));
if (liveLocals.length == 0) {
// class was compiled without a local variable table
// include "this" in method arguments throughout the method
boolean hasReceiver = !method.isStatic();
int localCount = hasReceiver ? 1 : 0;
localCount += method.getParameterCount();
liveLocals = new Local[localCount];
Klass[] parameters = (Klass[]) method.getParameters();
Utf8ConstantTable utf8Constants = getContext().getLanguage().getUtf8ConstantTable();
int startslot = 0;
if (hasReceiver) {
// include 'this' and method arguments
liveLocals[0] = new Local(utf8Constants.getOrCreate(Symbol.Name.thiz), utf8Constants.getOrCreate(method.getDeclaringKlass().getType()), 0, 65536, 0);
startslot++;
}
// include method parameters
for (int i = startslot; i < localCount; i++) {
Klass param = hasReceiver ? parameters[i - 1] : parameters[i];
liveLocals[i] = new Local(utf8Constants.getOrCreate(ByteSequence.create("param_" + (i))), utf8Constants.getOrCreate(param.getType()), 0, 65536, i);
}
}
return EspressoScope.createVariables(liveLocals, frame, method.getName());
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualByteMethodVarargs.
@JniImpl
public byte CallNonvirtualByteMethodVarargs(@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().asByte(result, true);
}
Aggregations