Search in sources :

Example 11 with HotSpotResolvedJavaMethod

use of jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerInvoke.

private void lowerInvoke(Invoke invoke, LoweringTool tool, StructuredGraph graph) {
    if (invoke.callTarget() instanceof MethodCallTargetNode) {
        MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
        NodeInputList<ValueNode> parameters = callTarget.arguments();
        ValueNode receiver = parameters.size() <= 0 ? null : parameters.get(0);
        if (!callTarget.isStatic() && receiver.stamp(NodeView.DEFAULT) instanceof ObjectStamp && !StampTool.isPointerNonNull(receiver)) {
            ValueNode nonNullReceiver = createNullCheckedValue(receiver, invoke.asNode(), tool);
            parameters.set(0, nonNullReceiver);
            receiver = nonNullReceiver;
        }
        JavaType[] signature = callTarget.targetMethod().getSignature().toParameterTypes(callTarget.isStatic() ? null : callTarget.targetMethod().getDeclaringClass());
        LoweredCallTargetNode loweredCallTarget = null;
        OptionValues options = graph.getOptions();
        if (InlineVTableStubs.getValue(options) && callTarget.invokeKind().isIndirect() && (AlwaysInlineVTableStubs.getValue(options) || invoke.isPolymorphic())) {
            HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod();
            ResolvedJavaType receiverType = invoke.getReceiverType();
            if (hsMethod.isInVirtualMethodTable(receiverType)) {
                JavaKind wordKind = runtime.getTarget().wordJavaKind;
                ValueNode hub = createReadHub(graph, receiver, tool);
                ReadNode metaspaceMethod = createReadVirtualMethod(graph, hub, hsMethod, receiverType);
                // We use LocationNode.ANY_LOCATION for the reads that access the
                // compiled code entry as HotSpot does not guarantee they are final
                // values.
                int methodCompiledEntryOffset = runtime.getVMConfig().methodCompiledEntryOffset;
                AddressNode address = createOffsetAddress(graph, metaspaceMethod, methodCompiledEntryOffset);
                ReadNode compiledEntry = graph.add(new ReadNode(address, any(), StampFactory.forKind(wordKind), BarrierType.NONE));
                loweredCallTarget = graph.add(new HotSpotIndirectCallTargetNode(metaspaceMethod, compiledEntry, parameters.toArray(new ValueNode[parameters.size()]), callTarget.returnStamp(), signature, callTarget.targetMethod(), HotSpotCallingConventionType.JavaCall, callTarget.invokeKind()));
                graph.addBeforeFixed(invoke.asNode(), metaspaceMethod);
                graph.addAfterFixed(metaspaceMethod, compiledEntry);
            }
        }
        if (loweredCallTarget == null) {
            loweredCallTarget = graph.add(new HotSpotDirectCallTargetNode(parameters.toArray(new ValueNode[parameters.size()]), callTarget.returnStamp(), signature, callTarget.targetMethod(), HotSpotCallingConventionType.JavaCall, callTarget.invokeKind()));
        }
        callTarget.replaceAndDelete(loweredCallTarget);
    }
}
Also used : HotSpotDirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotDirectCallTargetNode) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotIndirectCallTargetNode(org.graalvm.compiler.hotspot.nodes.HotSpotIndirectCallTargetNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 12 with HotSpotResolvedJavaMethod

use of jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod in project graal by oracle.

the class HotSpotInvokeDynamicPlugin method genAppendixNode.

@Override
public ValueNode genAppendixNode(GraphBuilderContext builder, int index, int opcode, JavaConstant appendixConstant, FrameState frameState) {
    JavaConstant appendix = appendixConstant;
    assert supportsDynamicInvoke(builder, index, opcode);
    HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) builder.getMethod();
    HotSpotResolvedObjectType methodHolder = method.getDeclaringClass();
    if (dynoStore != null) {
        appendix = dynoStore.recordAppendix(opcode, methodHolder, index, appendix);
    }
    ConstantNode appendixNode = ConstantNode.forConstant(appendix, builder.getMetaAccess(), builder.getGraph());
    Stamp appendixStamp = appendixNode.stamp(NodeView.DEFAULT);
    Stamp resolveStamp = treatAppendixAsConstant ? appendixStamp : appendixStamp.unrestricted();
    ResolveDynamicConstantNode resolveNode = new ResolveDynamicConstantNode(resolveStamp, appendixNode);
    ResolveDynamicConstantNode added = builder.append(resolveNode);
    assert added == resolveNode;
    added.setStateBefore(frameState);
    return resolveNode;
}
Also used : HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) Stamp(org.graalvm.compiler.core.common.type.Stamp) HotSpotResolvedObjectType(jdk.vm.ci.hotspot.HotSpotResolvedObjectType) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode)

Example 13 with HotSpotResolvedJavaMethod

use of jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod in project graal by oracle.

the class HotSpotInvokeDynamicPlugin method recordDynamicMethod.

@Override
public void recordDynamicMethod(GraphBuilderContext builder, int index, int opcode, ResolvedJavaMethod target) {
    assert supportsDynamicInvoke(builder, index, opcode);
    HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) builder.getMethod();
    HotSpotResolvedObjectType methodHolder = method.getDeclaringClass();
    HotSpotResolvedJavaMethod adapter = (HotSpotResolvedJavaMethod) target;
    if (dynoStore != null) {
        dynoStore.recordAdapter(opcode, methodHolder, index, adapter);
    }
}
Also used : HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) HotSpotResolvedObjectType(jdk.vm.ci.hotspot.HotSpotResolvedObjectType)

Example 14 with HotSpotResolvedJavaMethod

use of jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod in project graal by oracle.

the class HotSpotGraalMBean method optionsFor.

public OptionValues optionsFor(OptionValues initialValues, ResolvedJavaMethod forMethod) {
    ensureRegistered(true);
    if (forMethod instanceof HotSpotResolvedJavaMethod) {
        HotSpotResolvedObjectType type = ((HotSpotResolvedJavaMethod) forMethod).getDeclaringClass();
        if (type instanceof HotSpotResolvedJavaType) {
            Class<?> clazz = ((HotSpotResolvedJavaType) type).mirror();
            Reference<ClassLoader> addNewRef = new WeakReference<>(clazz.getClassLoader());
            if (!loaders.contains(addNewRef)) {
                EconomicSet<Reference<ClassLoader>> newLoaders = EconomicSet.create(RefEquivalence.INSTANCE, loaders);
                newLoaders.add(addNewRef);
                this.loaders = newLoaders;
            }
        }
    }
    return currentMap(initialValues, forMethod);
}
Also used : HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) HotSpotResolvedObjectType(jdk.vm.ci.hotspot.HotSpotResolvedObjectType) HotSpotResolvedJavaType(jdk.vm.ci.hotspot.HotSpotResolvedJavaType) WeakReference(java.lang.ref.WeakReference) Reference(java.lang.ref.Reference) WeakReference(java.lang.ref.WeakReference)

Example 15 with HotSpotResolvedJavaMethod

use of jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod in project graal by oracle.

the class HotSpotGraalMBean method dumpMethod.

public void dumpMethod(String className, String methodName, String filter, String host, int port) throws javax.management.MBeanException {
    String jvmName = MetaUtil.toInternalName(className);
    methodDumps.add(new Dump(host, port, jvmName, methodName, filter));
    ClassNotFoundException last = null;
    EconomicSet<Class<?>> found = EconomicSet.create();
    Iterator<Reference<ClassLoader>> it = loaders.iterator();
    while (it.hasNext()) {
        Reference<ClassLoader> ref = it.next();
        ClassLoader loader = ref.get();
        if (loader == null) {
            it.remove();
            continue;
        }
        try {
            Class<?> clazz = Class.forName(className, false, loader);
            if (found.add(clazz)) {
                ResolvedJavaType type = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess().lookupJavaType(clazz);
                if (compiler != null) {
                    for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
                        if (methodName.equals(method.getName()) && method instanceof HotSpotResolvedJavaMethod) {
                            HotSpotResolvedJavaMethod hotSpotMethod = (HotSpotResolvedJavaMethod) method;
                            compiler.compileMethod(new HotSpotCompilationRequest(hotSpotMethod, -1, 0L), false);
                        }
                    }
                }
            }
        } catch (ClassNotFoundException ex) {
            last = ex;
        }
    }
    if (found.isEmpty()) {
        throw new javax.management.MBeanException(last, "Cannot find class " + className + " to schedule recompilation");
    }
}
Also used : HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) WeakReference(java.lang.ref.WeakReference) Reference(java.lang.ref.Reference) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) HotSpotResolvedJavaType(jdk.vm.ci.hotspot.HotSpotResolvedJavaType) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

HotSpotResolvedJavaMethod (jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod)16 HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)6 HotSpotResolvedObjectType (jdk.vm.ci.hotspot.HotSpotResolvedObjectType)4 CompilationTask (org.graalvm.compiler.hotspot.CompilationTask)4 HotSpotDirectCallTargetNode (org.graalvm.compiler.hotspot.nodes.HotSpotDirectCallTargetNode)4 HotSpotJVMCIRuntimeProvider (jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 InvokeKind (org.graalvm.compiler.nodes.CallTargetNode.InvokeKind)3 OptionValues (org.graalvm.compiler.options.OptionValues)3 Reference (java.lang.ref.Reference)2 WeakReference (java.lang.ref.WeakReference)2 HotSpotResolvedJavaType (jdk.vm.ci.hotspot.HotSpotResolvedJavaType)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 HotSpotGraalCompiler (org.graalvm.compiler.hotspot.HotSpotGraalCompiler)2 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)2 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)2 File (java.io.File)1 Method (java.lang.reflect.Method)1 URLClassLoader (java.net.URLClassLoader)1 ByteBuffer (java.nio.ByteBuffer)1