Search in sources :

Example 1 with LayoutFactory

use of com.oracle.truffle.api.object.LayoutFactory in project graal by oracle.

the class GraalTruffleRuntime method selectObjectLayoutFactory.

protected static LayoutFactory selectObjectLayoutFactory(Iterable<LayoutFactory> availableLayoutFactories) {
    String layoutFactoryImplName = System.getProperty("truffle.object.LayoutFactory");
    LayoutFactory bestLayoutFactory = null;
    for (LayoutFactory currentLayoutFactory : availableLayoutFactories) {
        if (layoutFactoryImplName != null) {
            if (currentLayoutFactory.getClass().getName().equals(layoutFactoryImplName)) {
                return currentLayoutFactory;
            }
        } else {
            if (bestLayoutFactory == null) {
                bestLayoutFactory = currentLayoutFactory;
            } else if (currentLayoutFactory.getPriority() >= bestLayoutFactory.getPriority()) {
                assert currentLayoutFactory.getPriority() != bestLayoutFactory.getPriority();
                bestLayoutFactory = currentLayoutFactory;
            }
        }
    }
    return bestLayoutFactory;
}
Also used : LayoutFactory(com.oracle.truffle.api.object.LayoutFactory)

Example 2 with LayoutFactory

use of com.oracle.truffle.api.object.LayoutFactory in project graal by oracle.

the class TruffleRuntimeTest method testGetLayoutFactory.

@Test
public void testGetLayoutFactory() {
    TruffleRuntime runtime = Truffle.getRuntime();
    LayoutFactory layoutFactory = runtime.getCapability(LayoutFactory.class);
    assertNotNull("LayoutFactory not found", layoutFactory);
    boolean java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
    ClassLoader layoutFactoryCL = layoutFactory.getClass().getClassLoader();
    if (java8OrEarlier) {
        // Bootstrap class loader or JVMCI class loader
        assertTrue(layoutFactoryCL == null || layoutFactoryCL == runtime.getClass().getClassLoader());
    } else {
    // Rely on modules to only load trusted service providers
    }
}
Also used : LayoutFactory(com.oracle.truffle.api.object.LayoutFactory) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) Test(org.junit.Test)

Aggregations

LayoutFactory (com.oracle.truffle.api.object.LayoutFactory)2 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)1 DefaultTruffleRuntime (com.oracle.truffle.api.impl.DefaultTruffleRuntime)1 Test (org.junit.Test)1