use of org.graalvm.compiler.hotspot.HotSpotBackendFactory in project graal by oracle.
the class HotSpotTruffleCompilerImpl method create.
public static HotSpotTruffleCompilerImpl create(final TruffleCompilerRuntime runtime) {
OptionValues options = runtime.getGraalOptions(OptionValues.class);
HotSpotGraalRuntimeProvider hotspotGraalRuntime = (HotSpotGraalRuntimeProvider) getCompiler(options).getGraalRuntime();
SnippetReflectionProvider snippetReflection = hotspotGraalRuntime.getRequiredCapability(SnippetReflectionProvider.class);
HotSpotBackend backend = hotspotGraalRuntime.getHostBackend();
GraphBuilderPhase phase = (GraphBuilderPhase) backend.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous();
Plugins plugins = phase.getGraphBuilderConfig().getPlugins();
final PartialEvaluatorConfiguration lastTierPe = createPartialEvaluatorConfiguration(hotspotGraalRuntime.getCompilerConfigurationName());
final TruffleTierConfiguration lastTierSetup = new TruffleTierConfiguration(lastTierPe, backend, options);
CompilerConfigurationFactory lowTierCompilerConfigurationFactory = new EconomyCompilerConfigurationFactory();
CompilerConfiguration compilerConfiguration = lowTierCompilerConfigurationFactory.createCompilerConfiguration();
HotSpotBackendFactory backendFactory = lowTierCompilerConfigurationFactory.createBackendMap().getBackendFactory(backend.getTarget().arch);
HotSpotBackend firstTierBackend = backendFactory.createBackend(hotspotGraalRuntime, compilerConfiguration, HotSpotJVMCIRuntime.runtime(), null);
Suites firstTierSuites = firstTierBackend.getSuites().getDefaultSuites(options);
LIRSuites firstTierLirSuites = firstTierBackend.getSuites().getDefaultLIRSuites(options);
Providers firstTierProviders = firstTierBackend.getProviders();
PartialEvaluatorConfiguration firstTierPe = new EconomyPartialEvaluatorConfiguration();
firstTierBackend.completeInitialization(HotSpotJVMCIRuntime.runtime(), options);
TruffleTierConfiguration firstTierSetup = new TruffleTierConfiguration(firstTierPe, firstTierBackend, firstTierProviders, firstTierSuites, firstTierLirSuites);
final TruffleCompilerConfiguration compilerConfig = new TruffleCompilerConfiguration(runtime, plugins, snippetReflection, firstTierSetup, lastTierSetup);
return new HotSpotTruffleCompilerImpl(hotspotGraalRuntime, compilerConfig);
}
use of org.graalvm.compiler.hotspot.HotSpotBackendFactory in project graal by oracle.
the class GraalObjectReplacer method apply.
@Override
public Object apply(Object source) {
if (source == null) {
return null;
}
Object dest = source;
if (source instanceof RelocatedPointer) {
return dest;
}
if (source instanceof SnippetResolvedJavaMethod || source instanceof SnippetResolvedJavaType) {
return source;
}
if (source instanceof MetaAccessProvider) {
dest = providerReplacements.getMetaAccessProvider();
} else if (source instanceof HotSpotJVMCIRuntime) {
throw new UnsupportedFeatureException("HotSpotJVMCIRuntime should not appear in the image: " + source);
} else if (source instanceof GraalHotSpotVMConfig) {
throw new UnsupportedFeatureException("GraalHotSpotVMConfig should not appear in the image: " + source);
} else if (source instanceof HotSpotBackendFactory) {
HotSpotBackendFactory factory = (HotSpotBackendFactory) source;
Architecture hostArch = HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getTarget().arch;
if (!factory.getArchitecture().equals(hostArch.getClass())) {
throw new UnsupportedFeatureException("Non-host archtecture HotSpotBackendFactory should not appear in the image: " + source);
}
} else if (source instanceof GraalRuntime) {
dest = sGraalRuntime;
} else if (source instanceof AnalysisConstantReflectionProvider) {
dest = providerReplacements.getConstantReflectionProvider();
} else if (source instanceof AnalysisConstantFieldProvider) {
dest = providerReplacements.getConstantFieldProvider();
} else if (source instanceof ForeignCallsProvider) {
dest = providerReplacements.getForeignCallsProvider();
} else if (source instanceof SnippetReflectionProvider) {
dest = providerReplacements.getSnippetReflectionProvider();
} else if (source instanceof MetricKey) {
/* Ensure lazily initialized name fields are computed. */
((MetricKey) source).getName();
} else if (source instanceof NodeClass) {
/* Ensure lazily initialized shortName field is computed. */
((NodeClass<?>) source).shortName();
} else if (source instanceof HotSpotResolvedJavaMethod) {
throw new UnsupportedFeatureException(source.toString());
} else if (source instanceof HotSpotResolvedJavaField) {
throw new UnsupportedFeatureException(source.toString());
} else if (source instanceof HotSpotResolvedJavaType) {
throw new UnsupportedFeatureException(source.toString());
} else if (source instanceof HotSpotSignature) {
throw new UnsupportedFeatureException(source.toString());
} else if (source instanceof HotSpotObjectConstant) {
throw new UnsupportedFeatureException(source.toString());
} else if (source instanceof ResolvedJavaMethod && !(source instanceof SubstrateMethod)) {
dest = createMethod((ResolvedJavaMethod) source);
} else if (source instanceof ResolvedJavaField && !(source instanceof SubstrateField)) {
dest = createField((ResolvedJavaField) source);
} else if (source instanceof ResolvedJavaType && !(source instanceof SubstrateType)) {
dest = createType((ResolvedJavaType) source);
} else if (source instanceof FieldLocationIdentity && !(source instanceof SubstrateFieldLocationIdentity)) {
dest = createFieldLocationIdentity((FieldLocationIdentity) source);
}
assert dest != null;
String className = dest.getClass().getName();
assert SubstrateUtil.isBuildingLibgraal() || !className.contains(".hotspot.") || className.contains(".svm.jtt.hotspot.") : "HotSpot object in image " + className;
assert !className.contains(".analysis.meta.") : "Analysis meta object in image " + className;
assert !className.contains(".hosted.meta.") : "Hosted meta object in image " + className;
assert !SubstrateUtil.isBuildingLibgraal() || !className.contains(".svm.hosted.snippets.") : "Hosted snippet object in image " + className;
return dest;
}
Aggregations