Search in sources :

Example 1 with PointerBase

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;
}
Also used : Word(org.graalvm.compiler.word.Word) PointerBase(org.graalvm.word.PointerBase) Uninterruptible(com.oracle.svm.core.annotate.Uninterruptible)

Example 2 with PointerBase

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();
}
Also used : PointerBase(org.graalvm.word.PointerBase) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 3 with PointerBase

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();
}
Also used : PointerBase(org.graalvm.word.PointerBase)

Example 4 with PointerBase

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);
        }
    }
}
Also used : PointerBase(org.graalvm.word.PointerBase)

Example 5 with PointerBase

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;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) UnsignedWord(org.graalvm.word.UnsignedWord) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) PointerBase(org.graalvm.word.PointerBase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

PointerBase (org.graalvm.word.PointerBase)8 Substitute (com.oracle.svm.core.annotate.Substitute)2 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)1 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)1 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)1 StringBuilderLog (com.oracle.svm.core.log.StringBuilderLog)1 ClosureData (com.oracle.svm.truffle.nfi.LibFFI.ClosureData)1 NativeClosureHandle (com.oracle.svm.truffle.nfi.LibFFI.NativeClosureHandle)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 Word (org.graalvm.compiler.word.Word)1 WordPointer (org.graalvm.nativeimage.c.type.WordPointer)1 UnsignedWord (org.graalvm.word.UnsignedWord)1