Search in sources :

Example 16 with TruffleFromLibGraal

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

the class HSTruffleCompilerRuntime method getConstantFieldInfo.

@TruffleFromLibGraal(GetConstantFieldInfo)
@Override
public ConstantFieldInfo getConstantFieldInfo(ResolvedJavaField field) {
    ResolvedJavaType enclosingType = field.getDeclaringClass();
    boolean isStatic = field.isStatic();
    ResolvedJavaField[] declaredFields = isStatic ? enclosingType.getStaticFields() : enclosingType.getInstanceFields(false);
    int fieldIndex = -1;
    for (int i = 0; i < declaredFields.length; i++) {
        if (field.equals(declaredFields[i])) {
            fieldIndex = i;
            break;
        }
    }
    if (fieldIndex == -1) {
        throw new IllegalStateException(String.format("%s field: %s declared in: %s is not in declared fields: %s", isStatic ? "Static" : "Instance", field, enclosingType, Arrays.toString(declaredFields)));
    }
    long typeHandle = LibGraal.translate(enclosingType);
    int fieldInfoDimension = callGetConstantFieldInfo(env(), getHandle(), typeHandle, isStatic, fieldIndex);
    switch(fieldInfoDimension) {
        case Integer.MIN_VALUE:
            return null;
        case -2:
            return ConstantFieldInfo.CHILDREN;
        case -1:
            return ConstantFieldInfo.CHILD;
        default:
            return ConstantFieldInfo.forDimensions(fieldInfoDimension);
    }
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 17 with TruffleFromLibGraal

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

the class HSTruffleCompilerRuntime method onCodeInstallation.

@TruffleFromLibGraal(OnCodeInstallation)
@Override
public void onCodeInstallation(CompilableTruffleAST compilable, InstalledCode installedCode) {
    long installedCodeHandle = LibGraal.translate(installedCode);
    JNIEnv env = env();
    callOnCodeInstallation(env, getHandle(), ((HSCompilableTruffleAST) compilable).getHandle(), installedCodeHandle);
}
Also used : JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 18 with TruffleFromLibGraal

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

the class HSTruffleCompilerRuntime method log.

@TruffleFromLibGraal(Log)
@Override
public void log(String loggerId, CompilableTruffleAST compilable, String message) {
    JNIEnv env = env();
    JString jniLoggerId = JNIUtil.createHSString(env, loggerId);
    JString jniMessage = JNIUtil.createHSString(env, message);
    callLog(env, getHandle(), jniLoggerId, ((HSCompilableTruffleAST) compilable).getHandle(), jniMessage);
}
Also used : JNIEnv(org.graalvm.jniutils.JNI.JNIEnv) JString(org.graalvm.jniutils.JNI.JString) TruffleFromLibGraal(org.graalvm.compiler.truffle.common.hotspot.libgraal.TruffleFromLibGraal)

Example 19 with TruffleFromLibGraal

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

the class TruffleFromLibGraalEntryPoints method getLoopExplosionKind.

@TruffleFromLibGraal(GetLoopExplosionKind)
static int getLoopExplosionKind(Object truffleRuntime, long methodHandle) {
    ResolvedJavaMethod method = LibGraal.unhand(ResolvedJavaMethod.class, methodHandle);
    TruffleCompilerRuntime.LoopExplosionKind loopExplosionKind = ((TruffleCompilerRuntime) truffleRuntime).getLoopExplosionKind(method);
    return loopExplosionKind.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 20 with TruffleFromLibGraal

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

the class TruffleFromLibGraalEntryPoints method getFailedSpeculationsAddress.

@TruffleFromLibGraal(GetFailedSpeculationsAddress)
static long getFailedSpeculationsAddress(Object compilable) {
    OptimizedCallTarget callTarget = (OptimizedCallTarget) compilable;
    HotSpotSpeculationLog log = (HotSpotSpeculationLog) callTarget.getSpeculationLog();
    return LibGraal.getFailedSpeculationsAddress(log);
}
Also used : HotSpotSpeculationLog(jdk.vm.ci.hotspot.HotSpotSpeculationLog) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) 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