8303678: [JVMCI] Add possibility to convert object JavaConstant to jobject.

Reviewed-by: never
This commit is contained in:
Tomas Zezula 2023-03-13 08:40:12 +00:00 committed by Doug Simon
parent d20bde29f2
commit 1148a659a8

View File

@ -858,6 +858,26 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
}
}
/**
* Gets the {@code jobject} value wrapped by {@code peerObject}. The returned "naked" value is
* only valid as long as {@code peerObject} is valid. Note that the latter may be shorter than
* the lifetime of {@code peerObject}. As such, this method should only be used to pass an
* object parameter across a JNI call from the JVMCI shared library to HotSpot. This method must
* only be called from within the JVMCI shared library.
*
* @param peerObject a reference to an object in the peer runtime
* @return the {@code jobject} value wrapped by {@code peerObject}
* @throws IllegalArgumentException if the current runtime is not the JVMCI shared library or
* {@code peerObject} is not a peer object reference
*/
public long getJObjectValue(HotSpotObjectConstant peerObject) {
if (peerObject instanceof IndirectHotSpotObjectConstantImpl) {
IndirectHotSpotObjectConstantImpl remote = (IndirectHotSpotObjectConstantImpl) peerObject;
return remote.getHandle();
}
throw new IllegalArgumentException("Cannot get jobject value for " + peerObject + " (" + peerObject.getClass().getName() + ")");
}
@Override
public JVMCIBackend getHostJVMCIBackend() {
return hostBackend;