Search in sources :

Example 6 with TruffleFromLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal in project graal by oracle.

the class TruffleFromLibGraalEntryPoints method checkHotSpotCalls.

/*----------------------*/
/**
 * Checks that all {@link TruffleFromLibGraal}s are implemented and that their signatures match
 * the {@linkplain Id#getSignature() ID signatures}.
 */
private static boolean checkHotSpotCalls() {
    Set<Id> unimplemented = EnumSet.allOf(Id.class);
    for (Method method : TruffleFromLibGraalEntryPoints.class.getDeclaredMethods()) {
        if (Modifier.isStatic(method.getModifiers())) {
            TruffleFromLibGraal a = method.getAnnotation(TruffleFromLibGraal.class);
            if (a != null) {
                Id id = a.value();
                unimplemented.remove(id);
                check(id, id.getMethodName().equals(method.getName()), "Expected name \"%s\", got \"%s\"", id.getMethodName(), method.getName());
                check(id, id.getReturnType().equals(method.getReturnType()), "Expected return type %s, got %s", id.getReturnType().getName(), method.getReturnType().getName());
                checkParameters(id, method.getParameterTypes());
            }
        }
    }
    check(null, unimplemented.isEmpty(), "Missing implementations:%n%s", unimplemented.stream().map(TruffleFromLibGraalEntryPoints::missingImpl).sorted().collect(joining(lineSeparator())));
    return true;
}
Also used : TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal) Id(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id) GetNodeId(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.GetNodeId) Method(java.lang.reflect.Method) IsSpecializationMethod(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.IsSpecializationMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 7 with TruffleFromLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal in project graal by oracle.

the class TruffleFromLibGraalEntryPoints method getConstantFieldInfo.

@TruffleFromLibGraal(GetConstantFieldInfo)
static int getConstantFieldInfo(Object truffleRuntime, long typeHandle, boolean isStatic, int fieldIndex) {
    ResolvedJavaType enclosing = LibGraal.unhand(ResolvedJavaType.class, typeHandle);
    ResolvedJavaField[] declaredFields = isStatic ? enclosing.getStaticFields() : enclosing.getInstanceFields(false);
    ResolvedJavaField field = declaredFields[fieldIndex];
    TruffleCompilerRuntime.ConstantFieldInfo constantFieldInfo = ((TruffleCompilerRuntime) truffleRuntime).getConstantFieldInfo(field);
    if (constantFieldInfo == null) {
        return Integer.MIN_VALUE;
    } else if (constantFieldInfo.isChildren()) {
        return -2;
    } else if (constantFieldInfo.isChild()) {
        return -1;
    } else {
        return constantFieldInfo.getDimensions();
    }
}
Also used : TruffleCompilerRuntime(org.graalvm.compiler.truffle.common.TruffleCompilerRuntime) HotSpotTruffleCompilerRuntime(org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 8 with TruffleFromLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal in project graal by oracle.

the class TruffleFromLibGraalEntryPoints method getInlineKind.

@TruffleFromLibGraal(GetInlineKind)
static int getInlineKind(Object truffleRuntime, long methodHandle, boolean duringPartialEvaluation) {
    ResolvedJavaMethod method = LibGraal.unhand(ResolvedJavaMethod.class, methodHandle);
    TruffleCompilerRuntime.InlineKind inlineKind = ((TruffleCompilerRuntime) truffleRuntime).getInlineKind(method, duringPartialEvaluation);
    return inlineKind.ordinal();
}
Also used : TruffleCompilerRuntime(org.graalvm.compiler.truffle.common.TruffleCompilerRuntime) HotSpotTruffleCompilerRuntime(org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 9 with TruffleFromLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal in project graal by oracle.

the class HSCompilableTruffleAST method cancelCompilation.

@TruffleFromLibGraal(CancelCompilation)
@Override
public boolean cancelCompilation(CharSequence reason) {
    JNIEnv env = env();
    JString jniReason = JNIUtil.createHSString(env, reason.toString());
    return callCancelCompilation(env, getHandle(), jniReason);
}
Also used : JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) JString(org.graalvm.jniutils.JNI.JString) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 10 with TruffleFromLibGraal

use of org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal in project graal by oracle.

the class HSCompilableTruffleAST method toString.

@TruffleFromLibGraal(CompilableToString)
@Override
public String toString() {
    String res = cachedString;
    if (res == null) {
        JNIEnv env = JNIMethodScope.env();
        JString value = callCompilableToString(env, getHandle());
        res = createString(env, value);
        cachedString = res;
    }
    return res;
}
Also used : HSCompilableTruffleASTGen.callCompilableToString(org.graalvm.compiler.truffle.compiler.hotspot.libgraal.HSCompilableTruffleASTGen.callCompilableToString) JNIUtil.createString(org.graalvm.jniutils.JNIUtil.createString) JString(org.graalvm.jniutils.JNI.JString) CompilableToString(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.CompilableToString) JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) JString(org.graalvm.jniutils.JNI.JString) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Aggregations

TruffleFromLibGraal (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)29 JNIEnv (org.graalvm.jniutils.JNI.JNIEnv)18 JObject (org.graalvm.jniutils.JNI.JObject)15 HotSpotTruffleCompilerRuntime (org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime)5 JString (org.graalvm.jniutils.JNI.JString)5 TruffleCompilerRuntime (org.graalvm.compiler.truffle.common.TruffleCompilerRuntime)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 JNIMethodScope (org.graalvm.jniutils.JNIMethodScope)3 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 CompilableToString (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.CompilableToString)2 HSCompilableTruffleASTGen.callCompilableToString (org.graalvm.compiler.truffle.compiler.hotspot.libgraal.HSCompilableTruffleASTGen.callCompilableToString)2 JNIUtil.createString (org.graalvm.jniutils.JNIUtil.createString)2 Method (java.lang.reflect.Method)1 InstalledCode (jdk.vm.ci.code.InstalledCode)1 HotSpotSpeculationLog (jdk.vm.ci.hotspot.HotSpotSpeculationLog)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 TruffleCallNode (org.graalvm.compiler.truffle.common.TruffleCallNode)1 Id (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id)1 AsJavaConstant (org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal.Id.AsJavaConstant)1