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