Search in sources :

Example 46 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class Target_com_oracle_truffle_api_interop_java_ObjectProxyHandler method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess config) {
    BeforeCompilationAccessImpl access = (BeforeCompilationAccessImpl) config;
    if (GraalFeature.Options.PrintRuntimeCompileMethods.getValue() && blacklistViolations.size() > 0) {
        System.out.println();
        System.out.println("=== Found " + blacklistViolations.size() + " compilation blacklist violations ===");
        System.out.println();
        for (GraalFeature.CallTreeNode node : blacklistViolations) {
            System.out.println("Blacklisted method");
            System.out.println(node.getImplementationMethod().format("  %H.%n(%p)"));
            System.out.println("called from");
            for (GraalFeature.CallTreeNode cur = node; cur != null; cur = cur.getParent()) {
                System.out.println("  " + cur.getSourceReference());
            }
        }
    }
    if (warnViolations.size() > 0) {
        /*
             * It is enough to print one warning message with one stack trace. Take the shortest
             * stack trace.
             */
        GraalFeature.CallTreeNode printNode = null;
        int printLength = Integer.MAX_VALUE;
        for (GraalFeature.CallTreeNode warnNode : warnViolations) {
            int warnLength = 0;
            for (GraalFeature.CallTreeNode cur = warnNode; cur != null; cur = cur.getParent()) {
                warnLength++;
            }
            if (warnLength < printLength) {
                printNode = warnNode;
                printLength = warnLength;
            }
        }
        System.out.println("WARNING: suspicious method reachable for runtime compilation: " + printNode.getImplementationMethod().format("%H.%n(%p)"));
        System.out.println("Check the complete tree of reachable methods using the option " + GraalFeature.Options.PrintRuntimeCompileMethods.getDescriptor().getFieldName());
        System.out.println("Suspicious method is called from");
        for (GraalFeature.CallTreeNode cur = printNode; cur != null; cur = cur.getParent()) {
            System.out.println("  " + cur.getSourceReference());
        }
    }
    if (neverPartOfCompilationViolations.size() > 0) {
        System.out.println("ERROR: CompilerAsserts.neverPartOfCompilation reachable for runtime compilation from " + neverPartOfCompilationViolations.size() + " places:");
        for (GraalFeature.CallTreeNode neverPartOfCompilationNode : neverPartOfCompilationViolations) {
            System.out.println("called from");
            for (GraalFeature.CallTreeNode cur = neverPartOfCompilationNode; cur != null; cur = cur.getParent()) {
                System.out.println("  " + cur.getSourceReference());
            }
        }
        throw VMError.shouldNotReachHere("CompilerAsserts.neverPartOfCompilation reachable for runtime compilation");
    }
    if (Options.TruffleCheckFrameImplementation.getValue() && useTruffleCompiler()) {
        /*
             * Check that only one Frame implementation is seen as instantiated by the static
             * analysis. That allows de-virtualization of all calls to Frame methods in the
             * interpreter.
             *
             * The DefaultTruffleRuntime uses multiple Frame implementations (DefaultVirtualFrame,
             * DefaultMaterializedFrame, ReadOnlyFrame) to detect wrong usages of the Frame API, so
             * we can only check when running with compilation enabled.
             */
        Optional<? extends ResolvedJavaType> optionalFrameType = access.getMetaAccess().optionalLookupJavaType(Frame.class);
        if (optionalFrameType.isPresent()) {
            HostedType frameType = (HostedType) optionalFrameType.get();
            Set<HostedType> implementations = new HashSet<>();
            collectImplementations(frameType, implementations);
            if (implementations.size() > 1) {
                throw UserError.abort("More than one implementation of " + Frame.class.getTypeName() + " found. For performance reasons, Truffle languages must not provide new implementations, and instead only use the single implementation provided by the Truffle runtime. " + "To disable this check, add " + SubstrateOptionsParser.commandArgument(Options.TruffleCheckFrameImplementation, "-") + " to the native-image command line. " + "Found classes: " + implementations.stream().map(m -> m.toJavaName(true)).collect(Collectors.joining(", ")));
            } else {
                assert implementations.size() == 0 || implementations.iterator().next() == frameType.getSingleImplementor();
            }
        }
    }
}
Also used : BeforeAnalysisAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) Arrays(java.util.Arrays) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) KnownTruffleTypes(org.graalvm.compiler.truffle.compiler.substitutions.KnownTruffleTypes) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) BooleanSupplier(java.util.function.BooleanSupplier) InlineInfo.createStandardInlineInfo(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo.createStandardInlineInfo) BigDecimal(java.math.BigDecimal) Vector(java.util.Vector) CompilerDirectives(com.oracle.truffle.api.CompilerDirectives) SubstrateTruffleCompiler(com.oracle.svm.truffle.api.SubstrateTruffleCompiler) Deoptimizer(com.oracle.svm.core.deopt.Deoptimizer) Map(java.util.Map) RootNode(com.oracle.truffle.api.nodes.RootNode) Executable(java.lang.reflect.Executable) BigInteger(java.math.BigInteger) TruffleCallBoundary(org.graalvm.compiler.truffle.runtime.TruffleCallBoundary) Alias(com.oracle.svm.core.annotate.Alias) JavaStackWalker(com.oracle.svm.core.stack.JavaStackWalker) FilesFeature(com.oracle.svm.core.jdk.FilesFeature) Set(java.util.Set) FilesSupport(com.oracle.svm.core.jdk.FilesSupport) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) GraalFeature(com.oracle.svm.graal.hosted.GraalFeature) InlineDuringParsingMaxDepth(org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsingMaxDepth) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) TreeSet(java.util.TreeSet) HostedOptionKey(com.oracle.svm.core.option.HostedOptionKey) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) TruffleInstrument(com.oracle.truffle.api.instrumentation.TruffleInstrument) SubstratePartialEvaluator(com.oracle.svm.truffle.api.SubstratePartialEvaluator) Field(java.lang.reflect.Field) Replacements(org.graalvm.compiler.nodes.spi.Replacements) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) TreeMap(java.util.TreeMap) RuntimeBytecodeParser(com.oracle.svm.graal.hosted.GraalFeature.RuntimeBytecodeParser) RecomputeFieldValue(com.oracle.svm.core.annotate.RecomputeFieldValue) SubstrateOptimizedCallTarget(com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget) Providers(org.graalvm.compiler.phases.util.Providers) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) ListIterator(java.util.ListIterator) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) SubstrateTruffleRuntime(com.oracle.svm.truffle.api.SubstrateTruffleRuntime) JavaKind(jdk.vm.ci.meta.JavaKind) Option(org.graalvm.compiler.options.Option) UserError(com.oracle.svm.core.util.UserError) Method(java.lang.reflect.Method) IdentityHashMap(java.util.IdentityHashMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) InstrumentPhase(org.graalvm.compiler.truffle.compiler.phases.InstrumentPhase) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Collectors(java.util.stream.Collectors) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) FileTypeDetector(java.nio.file.spi.FileTypeDetector) TargetClass(com.oracle.svm.core.annotate.TargetClass) VMError(com.oracle.svm.core.util.VMError) ValueNode(org.graalvm.compiler.nodes.ValueNode) CallTreeNode(com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode) List(java.util.List) Modifier(java.lang.reflect.Modifier) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) Optional(java.util.Optional) NeverInline(com.oracle.svm.core.annotate.NeverInline) SubstrateOptionsParser(com.oracle.svm.core.option.SubstrateOptionsParser) InliningUtilities(com.oracle.svm.hosted.code.InliningUtilities) Architecture(jdk.vm.ci.code.Architecture) HashMap(java.util.HashMap) Profile(com.oracle.truffle.api.profiles.Profile) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) HashSet(java.util.HashSet) Hashtable(java.util.Hashtable) WeakHashMap(java.util.WeakHashMap) HostedType(com.oracle.svm.hosted.meta.HostedType) CompilerAsserts(com.oracle.truffle.api.CompilerAsserts) ImageSingletons(org.graalvm.nativeimage.ImageSingletons) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Feature(org.graalvm.nativeimage.Feature) Heap(com.oracle.svm.core.heap.Heap) Delete(com.oracle.svm.core.annotate.Delete) BeforeCompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop) Frame(com.oracle.truffle.api.frame.Frame) AfterRegistrationAccessImpl(com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl) PartialEvaluator(org.graalvm.compiler.truffle.compiler.PartialEvaluator) Truffle(com.oracle.truffle.api.Truffle) Kind(com.oracle.svm.core.annotate.RecomputeFieldValue.Kind) Comparator(java.util.Comparator) Collections(java.util.Collections) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) HostedType(com.oracle.svm.hosted.meta.HostedType) CallTreeNode(com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode) GraalFeature(com.oracle.svm.graal.hosted.GraalFeature) BeforeCompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl) HashSet(java.util.HashSet)

Example 47 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class JNIFieldAccessorMethod method createSignature.

private JNISignature createSignature(MetaAccessProvider metaAccess) {
    Class<?> valueClass = fieldKind.toJavaClass();
    if (fieldKind.isObject()) {
        valueClass = JNIObjectHandle.class;
    }
    ResolvedJavaType objectHandle = metaAccess.lookupJavaType(JNIObjectHandle.class);
    List<JavaType> args = new ArrayList<>();
    args.add(metaAccess.lookupJavaType(JNIEnvironment.class));
    // this (instance field) or class (static field)
    args.add(objectHandle);
    args.add(metaAccess.lookupJavaType(JNIFieldId.class));
    if (isSetter) {
        args.add(metaAccess.lookupJavaType(valueClass));
    }
    ResolvedJavaType returnType;
    if (isSetter) {
        returnType = metaAccess.lookupJavaType(Void.TYPE);
    } else {
        returnType = metaAccess.lookupJavaType(valueClass);
    }
    return new JNISignature(args, returnType);
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) JNIEnvironment(com.oracle.svm.jni.nativeapi.JNIEnvironment) ArrayList(java.util.ArrayList) JNIFieldId(com.oracle.svm.jni.nativeapi.JNIFieldId) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 48 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class JVMCIInfopointErrorTest method testDuplicateVirtualObject.

@Test(expected = JVMCIError.class)
public void testDuplicateVirtualObject() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o1 = VirtualObject.get(obj, 0);
        o1.setValues(new JavaValue[0], new JavaKind[0]);
        VirtualObject o2 = VirtualObject.get(obj, 0);
        o2.setValues(new JavaValue[0], new JavaKind[0]);
        safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o1, o2 }, state.exceptionEdge));
    });
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) VirtualObject(jdk.vm.ci.code.VirtualObject) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 49 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class JVMCIInfopointErrorTest method testUndefinedVirtualObject.

@Test(expected = JVMCIError.class)
public void testUndefinedVirtualObject() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o0 = VirtualObject.get(obj, 0);
        o0.setValues(new JavaValue[0], new JavaKind[0]);
        VirtualObject o1 = VirtualObject.get(obj, 1);
        o1.setValues(new JavaValue[0], new JavaKind[0]);
        LIRFrameState newState = modifyTopFrame(state, new VirtualObject[] { o0 }, new JavaValue[] { o1 }, new JavaKind[] { JavaKind.Object }, 1, 0, 0);
        safepoint.accept(newState);
    });
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) VirtualObject(jdk.vm.ci.code.VirtualObject) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Example 50 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class JVMCIInfopointErrorTest method testInvalidVirtualObjectId.

@Test(expected = JVMCIError.class)
public void testInvalidVirtualObjectId() {
    ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
    test((tool, state, safepoint) -> {
        VirtualObject o = VirtualObject.get(obj, 5);
        o.setValues(new JavaValue[0], new JavaKind[0]);
        safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o }, state.exceptionEdge));
    });
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) VirtualObject(jdk.vm.ci.code.VirtualObject) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) Test(org.junit.Test)

Aggregations

ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)161 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)63 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 JavaKind (jdk.vm.ci.meta.JavaKind)25 JavaType (jdk.vm.ci.meta.JavaType)25 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)19 Stamp (org.graalvm.compiler.core.common.type.Stamp)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)17 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)16 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)13 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)13 Signature (jdk.vm.ci.meta.Signature)11 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)11 LogicNode (org.graalvm.compiler.nodes.LogicNode)11 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)11 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)11 ArrayList (java.util.ArrayList)10 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)10 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)9