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);
}
}
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);
}
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);
}
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();
}
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);
}
Aggregations