use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class VM method getEspressoRootFromFrame.
@TruffleBoundary
public static EspressoRootNode getEspressoRootFromFrame(FrameInstance frameInstance, EspressoContext context) {
EspressoRootNode root = getRawEspressoRootFromFrame(frameInstance);
if (root == null) {
return null;
}
Method method = root.getMethod();
if (method.getContext() != context) {
return null;
}
return root;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class BytecodeNode method getBaseQuickNode.
private BaseQuickNode getBaseQuickNode(int curBCI, int top, int statementIndex, BaseQuickNode quickNode) {
// block while class redefinition is ongoing
quickNode.getContext().getClassRedefinition().check();
BaseQuickNode result = quickNode;
synchronized (this) {
// re-check if node was already replaced by another thread
if (result != nodes[readCPI(curBCI)]) {
// another thread beat us
result = nodes[readCPI(curBCI)];
} else {
// other threads might still have beat us but if
// so, the resolution failed and so will we below
BytecodeStream original = new BytecodeStream(getMethodVersion().getCodeAttribute().getOriginalCode());
char cpi = original.readCPI(curBCI);
int nodeOpcode = original.currentBC(curBCI);
Method resolutionSeed = resolveMethodNoCache(nodeOpcode, cpi);
result = insert(dispatchQuickened(top, curBCI, cpi, nodeOpcode, statementIndex, resolutionSeed, getContext().InlineFieldAccessors));
nodes[readCPI(curBCI)] = result;
}
}
return result;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallNonvirtualCharMethodVarargs.
@JniImpl
public char CallNonvirtualCharMethodVarargs(@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().asChar(result, true);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method CallStaticVoidMethodVarargs.
@JniImpl
public void CallStaticVoidMethodVarargs(@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(null, popVarArgs(varargsPtr, method.getParsedSignature()));
assert result instanceof StaticObject && StaticObject.isNull((StaticObject) result) : "void methods must return StaticObject.NULL";
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class JniEnv method ToReflectedMethod.
// endregion Register/Unregister natives
// region Reflection
/**
* <h3>jobject ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID methodID, jboolean
* isStatic);</h3>
* <p>
* Converts a method ID derived from cls to a java.lang.reflect.Method or
* java.lang.reflect.Constructor object. isStatic must be set to JNI_TRUE if the method ID
* refers to a static field, and JNI_FALSE otherwise.
* <p>
* Throws OutOfMemoryError and returns 0 if fails.
*/
@JniImpl
@JavaType(java.lang.reflect.Executable.class)
public StaticObject ToReflectedMethod(@JavaType(Class.class) StaticObject unused, @Handle(Method.class) long methodId, @SuppressWarnings("unused") boolean isStatic) {
Method method = methodIds.getObject(methodId);
assert method.getDeclaringKlass().isAssignableFrom(unused.getMirrorKlass());
StaticObject methods = null;
if (method.isConstructor()) {
methods = getVM().JVM_GetClassDeclaredConstructors(method.getDeclaringKlass().mirror(), false);
} else {
methods = getVM().JVM_GetClassDeclaredMethods(method.getDeclaringKlass().mirror(), false);
}
for (StaticObject declMethod : methods.<StaticObject[]>unwrap()) {
assert InterpreterToVM.instanceOf(declMethod, getMeta().java_lang_reflect_Executable);
Method m = null;
if (method.isConstructor()) {
assert InterpreterToVM.instanceOf(declMethod, getMeta().java_lang_reflect_Constructor);
m = (Method) getMeta().HIDDEN_CONSTRUCTOR_KEY.getHiddenObject(declMethod);
} else {
assert InterpreterToVM.instanceOf(declMethod, getMeta().java_lang_reflect_Method);
m = (Method) getMeta().HIDDEN_METHOD_KEY.getHiddenObject(declMethod);
}
if (method == m) {
return declMethod;
}
}
throw EspressoError.shouldNotReachHere("Method/constructor not found ", method);
}
Aggregations