Search in sources :

Example 1 with CompilationFinal

use of com.oracle.truffle.api.CompilerDirectives.CompilationFinal in project graal by oracle.

the class GraalTruffleRuntime method getConstantFieldInfo.

@Override
public ConstantFieldInfo getConstantFieldInfo(ResolvedJavaField field) {
    for (Annotation a : field.getAnnotations()) {
        if (a.annotationType() == Child.class) {
            return TruffleCompilerRuntime.ConstantFieldInfo.CHILD;
        }
        if (a.annotationType() == Children.class) {
            return TruffleCompilerRuntime.ConstantFieldInfo.CHILDREN;
        }
        if (a.annotationType() == CompilationFinal.class) {
            CompilationFinal cf = (CompilationFinal) a;
            int dimensions = actualStableDimensions(field, cf.dimensions());
            return TruffleCompilerRuntime.ConstantFieldInfo.forDimensions(dimensions);
        }
    }
    return null;
}
Also used : CompilationFinal(com.oracle.truffle.api.CompilerDirectives.CompilationFinal) Annotation(java.lang.annotation.Annotation)

Example 2 with CompilationFinal

use of com.oracle.truffle.api.CompilerDirectives.CompilationFinal in project graal by oracle.

the class AssumptionsTest method testAssumptionArraysAreCompilationFinalCached.

@Test
public void testAssumptionArraysAreCompilationFinalCached() throws NoSuchFieldException, SecurityException, IllegalArgumentException {
    AssumptionArraysAreCompilationFinalCached node = TestHelper.createNode(AssumptionArraysAreCompilationFinalCachedFactory.getInstance(), false);
    Field doCachedField = node.getClass().getDeclaredField("do1_cache");
    doCachedField.setAccessible(true);
    Field field = doCachedField.getType().getDeclaredField("assumption0_");
    field.setAccessible(true);
    assertEquals(Assumption[].class, field.getType());
    CompilationFinal compilationFinal = field.getAnnotation(CompilationFinal.class);
    assertEquals(1, compilationFinal.dimensions());
}
Also used : NodeField(com.oracle.truffle.api.dsl.NodeField) Field(java.lang.reflect.Field) CompilationFinal(com.oracle.truffle.api.CompilerDirectives.CompilationFinal) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 3 with CompilationFinal

use of com.oracle.truffle.api.CompilerDirectives.CompilationFinal in project graal by oracle.

the class AssumptionsTest method testAssumptionArraysAreCompilationFinal.

@Test
public void testAssumptionArraysAreCompilationFinal() throws NoSuchFieldException, SecurityException {
    AssumptionArraysAreCompilationFinal node = TestHelper.createNode(AssumptionArraysAreCompilationFinalFactory.getInstance(), false);
    Field field = node.getClass().getDeclaredField("do1_assumption0_");
    field.setAccessible(true);
    assertEquals(Assumption[].class, field.getType());
    CompilationFinal compilationFinal = field.getAnnotation(CompilationFinal.class);
    assertEquals(1, compilationFinal.dimensions());
}
Also used : NodeField(com.oracle.truffle.api.dsl.NodeField) Field(java.lang.reflect.Field) CompilationFinal(com.oracle.truffle.api.CompilerDirectives.CompilationFinal) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Aggregations

CompilationFinal (com.oracle.truffle.api.CompilerDirectives.CompilationFinal)3 Assumption (com.oracle.truffle.api.Assumption)2 NodeField (com.oracle.truffle.api.dsl.NodeField)2 Field (java.lang.reflect.Field)2 Test (org.junit.Test)2 Annotation (java.lang.annotation.Annotation)1