use of org.graalvm.word.PointerBase in project graal by oracle.
the class PosixIsolates method tearDownCurrent.
@Uninterruptible(reason = "Tear-down in progress.")
public static int tearDownCurrent() {
if (SubstrateOptions.SpawnIsolates.getValue()) {
PointerBase heapBase = getHeapBase(CEntryPointContext.getCurrentIsolate());
Word size = IMAGE_HEAP_END.get().subtract(IMAGE_HEAP_BEGIN.get());
if (Mman.NoTransitions.munmap(heapBase, size) != 0) {
return Errors.UNSPECIFIED;
}
}
return Errors.NO_ERROR;
}
use of org.graalvm.word.PointerBase in project graal by oracle.
the class Target_com_oracle_truffle_nfi_impl_NFIContext method lookup.
@Substitute
@TruffleBoundary
static long lookup(@SuppressWarnings("unused") long nativeContext, long library, String name) {
// clear previous error
Dlfcn.dlerror();
PointerBase ret;
if (library == 0) {
ret = PosixUtils.dlsym(Dlfcn.RTLD_DEFAULT(), name);
} else {
ret = PosixUtils.dlsym(WordFactory.pointer(library), name);
}
if (ret.equal(WordFactory.zero())) {
CompilerDirectives.transferToInterpreter();
String error = PosixUtils.dlerror();
if (error != null) {
throw new UnsatisfiedLinkError(error);
}
}
return ret.rawValue();
}
use of org.graalvm.word.PointerBase in project graal by oracle.
the class JNILibraryInitializer method isBuiltinLibrary.
@Override
public boolean isBuiltinLibrary(String libName) {
String onLoadName = getOnLoadName(libName, true);
PointerBase onLoad = PlatformNativeLibrarySupport.singleton().findBuiltinSymbol(onLoadName);
return onLoad.isNonNull();
}
use of org.graalvm.word.PointerBase in project graal by oracle.
the class JNILibraryInitializer method initialize.
@Override
public void initialize(NativeLibrary lib) {
String name = getOnLoadName(lib.getCanonicalIdentifier(), lib.isBuiltin());
PointerBase symbol = lib.findSymbol(name);
if (symbol.isNonNull()) {
JNIOnLoadFunctionPointer onLoad = (JNIOnLoadFunctionPointer) symbol;
int expected = onLoad.invoke(JNIFunctionTables.singleton().getGlobalJavaVM(), Word.nullPointer());
if (expected != JNI_VERSION_1_8() && expected != JNI_VERSION_1_6() && expected != JNI_VERSION_1_4() && expected != JNI_VERSION_1_2() && expected != JNI_VERSION_1_1()) {
String message = "Unsupported JNI version 0x" + Integer.toHexString(expected) + ", required by " + lib.getCanonicalIdentifier();
throw new UnsatisfiedLinkError(message);
}
}
}
use of org.graalvm.word.PointerBase in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerSizeOfPlugins.
private static void registerSizeOfPlugins(SnippetReflectionProvider snippetReflection, InvocationPlugins plugins) {
Registration r = new Registration(plugins, SizeOf.class);
r.register1("get", Class.class, new InvocationPlugin() {
@SuppressWarnings("unchecked")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
Class<? extends PointerBase> clazz = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
int result = SizeOf.get(clazz);
b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Int, ConstantNode.forInt(result)));
return true;
}
});
r.register1("unsigned", Class.class, new InvocationPlugin() {
@SuppressWarnings("unchecked")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
Class<? extends PointerBase> clazz = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
UnsignedWord result = SizeOf.unsigned(clazz);
b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Object, ConstantNode.forConstant(snippetReflection.forObject(result), b.getMetaAccess())));
return true;
}
});
}
Aggregations