Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core) EspressoVM compatibility #1003

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,25 @@ public static void setCapabilities(long capabilities) {

// Ensures FUNCTION_MISSING_ABORT will be called even if no context is current,
public static void setFunctionMissingAddresses(int functionCount) {
// OpenJDK: NULL
// GraalVM Native Image: pointer to UnimplementedWithJNIEnvArgument function (see #875)
long RESERVED0_NULL = memGetAddress(JNI_NATIVE_INTERFACE);

long ptr = JNI_NATIVE_INTERFACE + CAPABILITIES_OFFSET;

long currentTable = memGetAddress(ptr);
if (functionCount == 0) {
if (currentTable != RESERVED0_NULL) {
if (currentTable != FUNCTION_MISSING_ABORT) {
FUNCTION_MISSING_ABORT_TABLE = NULL;
getAllocator().free(currentTable);
memPutAddress(ptr, NULL);
}
} else {
if (currentTable != RESERVED0_NULL) {
// OpenJDK: NULL
// EspressoVM: NULL
lewurm marked this conversation as resolved.
Show resolved Hide resolved
// GraalVM Native Image: pointer to UnimplementedWithJNIEnvArgument function (see #875)
long RESERVED0_NULL = memGetAddress(JNI_NATIVE_INTERFACE);

boolean slotAvailable = currentTable == NULL; // on HotSpot or Espresso
slotAvailable |= currentTable == RESERVED0_NULL; // on Native Image

if (!slotAvailable) {
throw new IllegalStateException("setFunctionMissingAddresses has been called already");
}
if (currentTable != NULL) {
Expand Down Expand Up @@ -233,4 +237,4 @@ public static boolean areCapabilitiesDifferent(PointerBuffer ref, PointerBuffer
return false;
}

}
}