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