use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class ByteArrayStoreQuickNode method execute.
@Override
public int execute(VirtualFrame frame) {
byte value = (byte) BytecodeNode.popInt(frame, top - 1);
int index = BytecodeNode.popInt(frame, top - 2);
StaticObject array = nullCheck(BytecodeNode.popObject(frame, top - 3));
byteArrayStore.execute(array, index, value);
return stackEffectOf_BASTORE;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class EspressoBindings method readMember.
@ExportMessage
Object readMember(String member, @CachedLibrary("this") InteropLibrary self, @Exclusive @Cached BranchProfile error) throws UnknownIdentifierException {
if (!isMemberReadable(member)) {
error.enter();
throw UnknownIdentifierException.create(member);
}
EspressoContext context = EspressoContext.get(self);
if (withNativeJavaVM && JAVA_VM.equals(member)) {
return context.getVM().getJavaVM();
}
Meta meta = context.getMeta();
try {
StaticObject clazz = (StaticObject) meta.java_lang_Class_forName_String_boolean_ClassLoader.invokeDirect(null, meta.toGuestString(member), false, loader);
return clazz.getMirrorKlass();
} catch (EspressoException e) {
error.enter();
if (InterpreterToVM.instanceOf(e.getGuestException(), meta.java_lang_ClassNotFoundException)) {
throw UnknownIdentifierException.create(member, e);
}
// exception during class loading
throw e;
}
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method CallStaticObjectMethodVarargs.
// endregion CallNonvirtual*Method
// region CallStatic*Method
@JniImpl
@JavaType(Object.class)
public StaticObject CallStaticObjectMethodVarargs(@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()));
return getMeta().asObject(result);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method GetPrimitiveArrayCritical.
@JniImpl
@Pointer
public TruffleObject GetPrimitiveArrayCritical(@JavaType(Object.class) StaticObject object, @Pointer TruffleObject isCopyPtr) {
if (!getUncached().isNull(isCopyPtr)) {
ByteBuffer isCopyBuf = NativeUtils.directByteBuffer(isCopyPtr, 1);
// Always copy since pinning is not supported.
isCopyBuf.put((byte) 1);
}
StaticObject array = object;
StaticObject clazz = GetObjectClass(array);
JavaKind componentKind = ((ArrayKlass) clazz.getMirrorKlass()).getComponentType().getJavaKind();
assert componentKind.isPrimitive();
int length = GetArrayLength(array);
ByteBuffer region = allocateDirect(length, componentKind);
@Pointer TruffleObject addressPtr = NativeUtils.byteBufferPointer(region);
// @formatter:off
switch(componentKind) {
case Boolean:
GetBooleanArrayRegion(array, 0, length, addressPtr);
break;
case Byte:
GetByteArrayRegion(array, 0, length, addressPtr);
break;
case Short:
GetShortArrayRegion(array, 0, length, addressPtr);
break;
case Char:
GetCharArrayRegion(array, 0, length, addressPtr);
break;
case Int:
GetIntArrayRegion(array, 0, length, addressPtr);
break;
case Float:
GetFloatArrayRegion(array, 0, length, addressPtr);
break;
case Long:
GetLongArrayRegion(array, 0, length, addressPtr);
break;
case Double:
GetDoubleArrayRegion(array, 0, length, addressPtr);
break;
// fall through
case Object:
// fall through
case Void:
// fall through
case Illegal:
default:
throw EspressoError.shouldNotReachHere();
}
return addressPtr;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method callVirtualMethodGeneric.
// endregion Set*Field
// region Call*Method
private Object callVirtualMethodGeneric(StaticObject receiver, @Handle(Method.class) long methodId, @Pointer TruffleObject varargsPtr) {
assert !receiver.getKlass().isInterface();
Method resolutionSeed = methodIds.getObject(methodId);
assert !resolutionSeed.isStatic();
assert resolutionSeed.getDeclaringKlass().isAssignableFrom(receiver.getKlass());
Object[] args = popVarArgs(varargsPtr, resolutionSeed.getParsedSignature());
Method target;
if (resolutionSeed.getDeclaringKlass().isInterface()) {
if (!resolutionSeed.isPrivate() && !resolutionSeed.isStatic()) {
target = ((ObjectKlass) receiver.getKlass()).itableLookup(resolutionSeed.getDeclaringKlass(), resolutionSeed.getITableIndex());
} else {
target = resolutionSeed;
}
} else {
if (resolutionSeed.isConstructor()) {
target = resolutionSeed;
} else if (resolutionSeed.isVirtualCall()) {
target = receiver.getKlass().vtableLookup(resolutionSeed.getVTableIndex());
} else {
target = resolutionSeed;
}
}
assert target != null;
assert target.getName() == resolutionSeed.getName() && resolutionSeed.getRawSignature() == target.getRawSignature();
return target.invokeDirect(receiver, args);
}
Aggregations