use of jdk.vm.ci.common.InitTimer in project graal by oracle.
the class AMD64HotSpotBackendFactory method createBackend.
@Override
@SuppressWarnings("try")
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRuntime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
assert host == null;
OptionValues options = graalRuntime.getOptions();
JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
HotSpotProviders providers;
HotSpotRegistersProvider registers;
HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
TargetDescription target = codeCache.getTarget();
HotSpotHostForeignCallsProvider foreignCalls;
Value[] nativeABICallerSaveRegisters;
HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
ConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
HotSpotLoweringProvider lowerer;
HotSpotSnippetReflectionProvider snippetReflection;
HotSpotReplacementsImpl replacements;
HotSpotSuitesProvider suites;
HotSpotWordTypes wordTypes;
Plugins plugins;
BytecodeProvider bytecodeProvider;
try (InitTimer t = timer("create providers")) {
try (InitTimer rt = timer("create HotSpotRegisters provider")) {
registers = createRegisters();
}
try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) {
nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
}
try (InitTimer rt = timer("create WordTypes")) {
wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
}
try (InitTimer rt = timer("create ForeignCalls provider")) {
foreignCalls = createForeignCalls(jvmciRuntime, graalRuntime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
}
try (InitTimer rt = timer("create Lowerer provider")) {
lowerer = createLowerer(graalRuntime, metaAccess, foreignCalls, registers, constantReflection, target);
}
HotSpotStampProvider stampProvider = new HotSpotStampProvider();
Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
try (InitTimer rt = timer("create SnippetReflection provider")) {
snippetReflection = createSnippetReflection(graalRuntime, constantReflection, wordTypes);
}
try (InitTimer rt = timer("create Bytecode provider")) {
bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
}
try (InitTimer rt = timer("create Replacements provider")) {
replacements = createReplacements(options, p, snippetReflection, bytecodeProvider);
}
try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
plugins = createGraphBuilderPlugins(compilerConfiguration, config, options, target, constantReflection, foreignCalls, lowerer, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
replacements.setGraphBuilderPlugins(plugins);
}
try (InitTimer rt = timer("create Suites provider")) {
suites = createSuites(config, graalRuntime, compilerConfiguration, plugins, registers, replacements, options);
}
providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
}
try (InitTimer rt = timer("instantiate backend")) {
return createBackend(config, graalRuntime, providers);
}
}
use of jdk.vm.ci.common.InitTimer in project graal by oracle.
the class AArch64HotSpotBackendFactory method createBackend.
@Override
@SuppressWarnings("try")
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRuntime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
assert host == null;
JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
HotSpotProviders providers;
HotSpotRegistersProvider registers;
HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
TargetDescription target = codeCache.getTarget();
HotSpotHostForeignCallsProvider foreignCalls;
Value[] nativeABICallerSaveRegisters;
HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
HotSpotConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
HotSpotLoweringProvider lowerer;
HotSpotSnippetReflectionProvider snippetReflection;
HotSpotReplacementsImpl replacements;
HotSpotSuitesProvider suites;
HotSpotWordTypes wordTypes;
Plugins plugins;
BytecodeProvider bytecodeProvider;
try (InitTimer t = timer("create providers")) {
try (InitTimer rt = timer("create HotSpotRegisters provider")) {
registers = createRegisters();
}
try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) {
nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
}
try (InitTimer rt = timer("create WordTypes")) {
wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
}
try (InitTimer rt = timer("create ForeignCalls provider")) {
foreignCalls = createForeignCalls(jvmciRuntime, graalRuntime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
}
try (InitTimer rt = timer("create Lowerer provider")) {
lowerer = createLowerer(graalRuntime, metaAccess, foreignCalls, registers, constantReflection, target);
}
HotSpotStampProvider stampProvider = new HotSpotStampProvider();
Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
try (InitTimer rt = timer("create SnippetReflection provider")) {
snippetReflection = createSnippetReflection(graalRuntime, constantReflection, wordTypes);
}
try (InitTimer rt = timer("create Bytecode provider")) {
bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
}
try (InitTimer rt = timer("create Replacements provider")) {
replacements = createReplacements(graalRuntime.getOptions(), p, snippetReflection, bytecodeProvider);
}
try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
plugins = createGraphBuilderPlugins(compilerConfiguration, config, constantReflection, foreignCalls, lowerer, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
replacements.setGraphBuilderPlugins(plugins);
}
try (InitTimer rt = timer("create Suites provider")) {
suites = createSuites(config, graalRuntime, compilerConfiguration, plugins);
}
providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
}
try (InitTimer rt = timer("instantiate backend")) {
return createBackend(config, graalRuntime, providers);
}
}
use of jdk.vm.ci.common.InitTimer in project graal by oracle.
the class CompilerConfigurationFactory method selectFactory.
/**
* Selects and instantiates a {@link CompilerConfigurationFactory}. The selection algorithm is
* as follows: if {@code name} is non-null, then select the factory with the same name else if
* {@code Options.CompilerConfiguration.getValue()} is non-null then select the factory whose
* name matches the value else select the factory with the highest
* {@link #autoSelectionPriority} value.
*
* @param name the name of the compiler configuration to select (optional)
*/
@SuppressWarnings("try")
public static CompilerConfigurationFactory selectFactory(String name, OptionValues options) {
CompilerConfigurationFactory factory = null;
try (InitTimer t = timer("CompilerConfigurationFactory.selectFactory")) {
String value = name == null ? Options.CompilerConfiguration.getValue(options) : name;
if ("help".equals(value)) {
System.out.println("The available Graal compiler configurations are:");
for (CompilerConfigurationFactory candidate : getAllCandidates()) {
System.out.println(" " + candidate.name);
}
System.exit(0);
} else if (value != null) {
for (CompilerConfigurationFactory candidate : GraalServices.load(CompilerConfigurationFactory.class)) {
if (candidate.name.equals(value)) {
factory = candidate;
break;
}
}
if (factory == null) {
throw new GraalError("Graal compiler configuration '%s' not found. Available configurations are: %s", value, getAllCandidates().stream().map(c -> c.name).collect(Collectors.joining(", ")));
}
} else {
List<CompilerConfigurationFactory> candidates = getAllCandidates();
if (candidates.isEmpty()) {
throw new GraalError("No %s providers found", CompilerConfigurationFactory.class.getName());
}
factory = candidates.get(0);
}
}
ShowConfigurationLevel level = Options.ShowConfiguration.getValue(options);
if (level != ShowConfigurationLevel.none) {
switch(level) {
case info:
{
printConfigInfo(factory);
break;
}
case verbose:
{
printConfigInfo(factory);
CompilerConfiguration config = factory.createCompilerConfiguration();
TTY.println("High tier: " + phaseNames(config.createHighTier(options)));
TTY.println("Mid tier: " + phaseNames(config.createMidTier(options)));
TTY.println("Low tier: " + phaseNames(config.createLowTier(options)));
TTY.println("Pre regalloc stage: " + phaseNames(config.createPreAllocationOptimizationStage(options)));
TTY.println("Regalloc stage: " + phaseNames(config.createAllocationStage(options)));
TTY.println("Post regalloc stage: " + phaseNames(config.createPostAllocationOptimizationStage(options)));
config.createAllocationStage(options);
break;
}
}
}
return factory;
}
use of jdk.vm.ci.common.InitTimer in project graal by oracle.
the class HotSpotHostBackend method completeInitialization.
@Override
@SuppressWarnings("try")
public void completeInitialization(HotSpotJVMCIRuntime jvmciRuntime, OptionValues options) {
final HotSpotProviders providers = getProviders();
HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls();
final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
try (InitTimer st = timer("foreignCalls.initialize")) {
foreignCalls.initialize(providers, options);
}
try (InitTimer st = timer("lowerer.initialize")) {
Iterable<DebugHandlersFactory> factories = Collections.singletonList(new GraalDebugHandlersFactory(providers.getSnippetReflection()));
lowerer.initialize(options, factories, providers, config);
}
}
use of jdk.vm.ci.common.InitTimer in project graal by oracle.
the class HotSpotGraalOptionValues method initializeOptions.
/**
* Global options. The values for these options are initialized by parsing the file denoted by
* the {@code VM.getSavedProperty(String) saved} system property named
* {@value #GRAAL_OPTIONS_FILE_PROPERTY_NAME} if the file exists followed by parsing the options
* encoded in saved system properties whose names start with
* {@value #GRAAL_OPTION_PROPERTY_PREFIX}. Key/value pairs are parsed from the aforementioned
* file with {@link Properties#load(java.io.Reader)}.
*/
@SuppressWarnings("try")
private static OptionValues initializeOptions() {
EconomicMap<OptionKey<?>, Object> values = OptionValues.newOptionMap();
try (InitTimer t = timer("InitializeOptions")) {
Iterable<OptionDescriptors> loader = OptionsParser.getOptionsLoader();
Map<String, String> savedProps = jdk.vm.ci.services.Services.getSavedProperties();
String optionsFile = savedProps.get(GRAAL_OPTIONS_FILE_PROPERTY_NAME);
if (optionsFile != null) {
File graalOptions = new File(optionsFile);
if (graalOptions.exists()) {
try (FileReader fr = new FileReader(graalOptions)) {
Properties props = new Properties();
props.load(fr);
EconomicMap<String, String> optionSettings = EconomicMap.create();
for (Map.Entry<Object, Object> e : props.entrySet()) {
optionSettings.put((String) e.getKey(), (String) e.getValue());
}
try {
OptionsParser.parseOptions(optionSettings, values, loader);
} catch (Throwable e) {
throw new InternalError("Error parsing an option from " + graalOptions, e);
}
} catch (IOException e) {
throw new InternalError("Error reading " + graalOptions, e);
}
}
}
EconomicMap<String, String> optionSettings = EconomicMap.create();
for (Map.Entry<String, String> e : savedProps.entrySet()) {
String name = e.getKey();
if (name.startsWith(GRAAL_OPTION_PROPERTY_PREFIX)) {
if (name.equals("graal.PrintFlags") || name.equals("graal.ShowFlags")) {
System.err.println("The " + name + " option has been removed and will be ignored. Use -XX:+JVMCIPrintProperties instead.");
} else if (name.equals(GRAAL_OPTIONS_FILE_PROPERTY_NAME) || name.equals(GRAAL_VERSION_PROPERTY_NAME)) {
// Ignore well known properties that do not denote an option
} else {
String value = e.getValue();
optionSettings.put(name.substring(GRAAL_OPTION_PROPERTY_PREFIX.length()), value);
}
}
}
OptionsParser.parseOptions(optionSettings, values, loader);
return new OptionValues(values);
}
}
Aggregations