Skip to content

Commit

Permalink
Code Cleanup and todos.
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-spas committed Mar 15, 2022
1 parent 7ac7747 commit a985b76
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
public abstract class PartialEvaluator {

// Configs
public final TruffleCompilerConfiguration config;
protected final TruffleCompilerConfiguration config;
// TODO GR-37097 Move to TruffleCompilerImpl
volatile GraphBuilderConfiguration configForParsing;
// Methods
final ResolvedJavaMethod callDirectMethod;
Expand All @@ -112,13 +113,15 @@ public abstract class PartialEvaluator {
* Holds instrumentation options initialized in {@link #initialize(OptionValues)} method before
* the first compilation. These options are not engine aware.
*/
// TODO GR-37097 Move to TruffleCompilerImpl
public volatile InstrumentPhase.InstrumentationConfiguration instrumentationCfg;
/**
* The instrumentation object is used by the Truffle instrumentation to count executions. The
* value is lazily initialized the first time it is requested because it depends on the Truffle
* options, and tests that need the instrumentation table need to override these options after
* the TruffleRuntime object is created.
*/
// TODO GR-37097 Move to TruffleCompilerImpl
protected volatile InstrumentPhase.Instrumentation instrumentation;
protected final TruffleConstantFieldProvider compilationLocalConstantProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaType;
import jdk.vm.ci.meta.SpeculationLog;

/**
* Coordinates partial evaluation of a Truffle AST and subsequent compilation via Graal.
Expand All @@ -130,7 +129,8 @@ public abstract class TruffleCompilerImpl implements TruffleCompilerBase {
private volatile ExpansionStatistics expansionStatistics;
private volatile boolean expansionStatisticsInitialized;
private volatile boolean initialized;
TruffleTier truffleTier;
// Effectivelly final, but initialized in #initialize
private TruffleTier truffleTier;

public static final OptimisticOptimizations Optimizations = ALL.remove(
UseExceptionProbability,
Expand Down Expand Up @@ -327,7 +327,7 @@ public void initialize(Map<String, Object> optionsMap, CompilableTruffleAST comp
// Hook for SVM
protected TruffleTier newTruffleTier(org.graalvm.options.OptionValues options) {
return new TruffleTier(options, partialEvaluator,
new InstrumentationSuite(partialEvaluator.instrumentationCfg, partialEvaluator.config.snippetReflection(), partialEvaluator.getInstrumentation()),
new InstrumentationSuite(partialEvaluator.instrumentationCfg, config.snippetReflection(), partialEvaluator.getInstrumentation()),
new PostPartialEvaluationSuite(options.get(IterativePartialEscape)));
}

Expand Down Expand Up @@ -545,6 +545,10 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont
try (DebugCloseable a = PartialEvaluationTime.start(debug);
DebugCloseable c = PartialEvaluationMemUse.start(debug);
PerformanceInformationHandler handler = PerformanceInformationHandler.install(wrapper.options)) {
/*
* TODO GR-37097 Merge TruffleTierConfiguration and TruffleCompilationWrapper so that
* there is one place where compilation data lives
*/
TruffleTierContext context = new TruffleTierContext(partialEvaluator, wrapper, debug, handler);
try (Scope s = context.debug.scope("CreateGraph", context.graph);
Indent indent = context.debug.logAndIndent("evaluate %s", context.graph);) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public TruffleTierContext(PartialEvaluator partialEvaluator, OptionValues option
}

public TruffleTierContext(PartialEvaluator partialEvaluator, TruffleCompilerImpl.TruffleCompilationWrapper wrapper, DebugContext debug, PerformanceInformationHandler handler) {
this(partialEvaluator, wrapper.options, debug, wrapper.compilable, partialEvaluator.rootForCallTarget(wrapper.compilable), wrapper.compilationId, getSpeculationLog(wrapper), wrapper.task, handler);
this(partialEvaluator, wrapper.options, debug, wrapper.compilable, partialEvaluator.rootForCallTarget(wrapper.compilable), wrapper.compilationId, getSpeculationLog(wrapper), wrapper.task,
handler);
}

public boolean isFirstTier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.MetaUtil;

// TODO: make sure the subclasses of this are thread-safe
public abstract class InstrumentPhase extends BasePhase<TruffleTierContext> {

private static boolean checkMethodExists(String declaringClassName, String methodName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ protected static TruffleCompilerConfiguration createSubstrateTruffleCompilerConf
PartialEvaluatorConfiguration peConfig = TruffleCompilerImpl.createPartialEvaluatorConfiguration(compilerConfigurationName);
final TruffleTierConfiguration lastTier = new TruffleTierConfiguration(peConfig, GraalSupport.getRuntimeConfig().getBackendForNormalMethod(),
GraalSupport.getRuntimeConfig().getProviders(), GraalSupport.getSuites(), GraalSupport.getLIRSuites());
final TruffleCompilerConfiguration truffleCompilerConfig = new TruffleCompilerConfiguration(runtime, graphBuilderPlugins, snippetReflectionProvider, firstTier, lastTier);
return truffleCompilerConfig;

// return new SubstrateTruffleCompilerImpl(truffleCompilerConfig);
return new TruffleCompilerConfiguration(runtime, graphBuilderPlugins, snippetReflectionProvider, firstTier, lastTier);
}

public static boolean isIsolatedCompilation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void initialize(Map<String, Object> optionsMap, CompilableTruffleAST comp
@Override
protected TruffleTier newTruffleTier(org.graalvm.options.OptionValues options) {
return new TruffleTier(options, partialEvaluator,
new InstrumentationSuite(partialEvaluator.instrumentationCfg, partialEvaluator.config.snippetReflection(), partialEvaluator.getInstrumentation()),
new InstrumentationSuite(partialEvaluator.instrumentationCfg, config.snippetReflection(), partialEvaluator.getInstrumentation()),
new SubstratePostPartialEvaluationSuite(options.get(IterativePartialEscape)));
}

Expand Down

0 comments on commit a985b76

Please sign in to comment.