use of com.oracle.truffle.espresso.runtime.StaticObject 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);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method NewString.
@JniImpl
@TruffleBoundary
@JavaType(String.class)
public StaticObject NewString(@Pointer TruffleObject unicodePtr, int len) {
// TODO(garcia) : works only for UTF16 encoded strings.
final char[] array = new char[len];
StaticObject value = StaticObject.wrap(array, getMeta());
SetCharArrayRegion(value, 0, len, unicodePtr);
return getMeta().toGuestString(new String(array));
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method ReleasePrimitiveArrayElements.
// endregion Get*ArrayElements
// region Release*ArrayElements
private void ReleasePrimitiveArrayElements(StaticObject object, @Pointer TruffleObject bufPtr, int mode) {
if (mode == 0 || mode == JNI_COMMIT) {
// Update array contents.
StaticObject array = object;
StaticObject clazz = GetObjectClass(array);
JavaKind componentKind = ((ArrayKlass) clazz.getMirrorKlass()).getComponentType().getJavaKind();
assert componentKind.isPrimitive();
int length = GetArrayLength(array);
// @formatter:off
switch(componentKind) {
case Boolean:
SetBooleanArrayRegion(array, 0, length, bufPtr);
break;
case Byte:
SetByteArrayRegion(array, 0, length, bufPtr);
break;
case Short:
SetShortArrayRegion(array, 0, length, bufPtr);
break;
case Char:
SetCharArrayRegion(array, 0, length, bufPtr);
break;
case Int:
SetIntArrayRegion(array, 0, length, bufPtr);
break;
case Float:
SetFloatArrayRegion(array, 0, length, bufPtr);
break;
case Long:
SetLongArrayRegion(array, 0, length, bufPtr);
break;
case Double:
SetDoubleArrayRegion(array, 0, length, bufPtr);
break;
default:
throw EspressoError.shouldNotReachHere();
}
// @formatter:on
}
if (mode == 0 || mode == JNI_ABORT) {
// Dispose copy.
releasePtr(bufPtr);
}
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class JniEnv method CallStaticCharMethodVarargs.
@JniImpl
public char CallStaticCharMethodVarargs(@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().asChar(result, true);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class RedefineAddedField method getObject.
@Override
protected StaticObject getObject(StaticObject obj, boolean forceVolatile) {
if (hasCompatibleField()) {
return getCompatibleField().getObject(obj, forceVolatile);
} else {
FieldStorageObject storageObject = getStorageObject(obj);
StaticObject result;
if (forceVolatile) {
result = (StaticObject) linkedField.getObjectVolatile(storageObject);
} else {
result = (StaticObject) linkedField.getObject(storageObject);
}
if (result == StaticObject.NULL) {
return result;
}
if (getDeclaringKlass().getContext().anyHierarchyChanged()) {
return checkGetValueValidity(result);
}
return result;
}
}
Aggregations