@SuppressWarnings("try") public boolean doTypeflow() throws InterruptedException { boolean didSomeWork; try (StopTimer ignored = typeFlowTimer.start()) { executor.start(); executor.complete(); didSomeWork = (executor.getPostedOperations() > 0); executor.shutdown(); } /* Initialize for the next iteration. */ executor.init(timing); return didSomeWork; }
public void postTask(final DebugContextRunnable task) { executor.execute(task); }
public boolean executorIsStarted() { return executor.isStarted(); }
executor = new CompletionExecutor(this, executorService); executor.init(timing);
public void shutdown() { assert isSequential() || !executorService.hasQueuedSubmissions() : "There should be no queued submissions on shutdown."; assert completedOperations.sum() == postedOperations.sum() : "Posted operations must match completed operations"; setState(State.UNUSED); }
public void init() { init(null); }
public CompileQueue(DebugContext debug, FeatureHandler featureHandler, HostedUniverse universe, SharedRuntimeConfigurationBuilder runtimeConfigBuilder, Boolean deoptimizeAll, SnippetReflectionProvider snippetReflection, ForkJoinPool executorService) { this.universe = universe; this.compilations = new ConcurrentHashMap<>(); this.runtimeConfig = runtimeConfigBuilder.getRuntimeConfig(); this.optimisticOpts = OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.UseLoopLimitChecks); this.deoptimizeAll = deoptimizeAll; this.dataCache = new ConcurrentHashMap<>(); this.executor = new CompletionExecutor(universe.getBigBang(), executorService); regularSuites = NativeImageGenerator.createSuites(featureHandler, runtimeConfig, snippetReflection, true); deoptTargetSuites = NativeImageGenerator.createSuites(featureHandler, runtimeConfig, snippetReflection, true); removeDeoptTargetOptimizations(deoptTargetSuites); regularLIRSuites = NativeImageGenerator.createLIRSuites(featureHandler, runtimeConfig.getProviders(), true); deoptTargetLIRSuites = NativeImageGenerator.createLIRSuites(featureHandler, runtimeConfig.getProviders(), true); removeDeoptTargetOptimizations(deoptTargetLIRSuites); // let aotjs override the replacements registration callForReplacements(debug, featureHandler, runtimeConfig, snippetReflection); }
public void start() { assert state.get() == State.BEFORE_START; assert Thread.currentThread() == mainThread; setState(State.STARTED); postedBeforeStart.forEach(this::execute); postedBeforeStart.clear(); }
assert executor.getPostedOperations() == 0; numTypes = universe.getTypes().size(); try (StopTimer t = checkObjectsTimer.start()) { } while (executor.getPostedOperations() != 0 || numTypes != universe.getTypes().size());
if (isSequential()) { try (DebugContext debug = command.getDebug(bb.getOptions(), bb.getDebugHandlerFactories()); Scope s = debug.scope("Operation")) {
public void init(Timing newTiming) { assert isSequential() || !executorService.hasQueuedSubmissions(); assert Thread.currentThread() == mainThread; timing = newTiming; setState(State.BEFORE_START); postedOperations.reset(); completedOperations.reset(); postedBeforeStart.clear(); vmConfig = bb.getHostVM().getConfiguration(); }
public void postFlow(final TypeFlow<?> operation) { if (operation.inQueue) { return; } operation.inQueue = true; executor.execute(new TypeFlowRunnable() { @Override public void run(DebugContext ignored) { PointsToStats.registerTypeFlowQueuedUpdate(BigBang.this, operation); operation.inQueue = false; operation.update(BigBang.this); } @Override public String toString() { return "Operation: " + operation.toString(); } @Override public TypeFlow<?> getTypeFlow() { return operation; } @Override public DebugContext getDebug(OptionValues opts, List<DebugHandlersFactory> factories) { return DebugContext.DISABLED; } }); }
public long complete() throws InterruptedException { if (isSequential()) { long completed = completedOperations.sum(); long posted = postedOperations.sum(); setState(State.UNUSED); throw new ParallelExecutionException(exceptions);
protected void compileAll() throws InterruptedException { executor.init(); universe.getMethods().stream() .filter(method -> method.isEntryPoint() || CompilationInfoSupport.singleton().isForcedCompilation(method)) .forEach(method -> ensureCompiled(method, new EntryPointReason())); universe.getMethods().stream() .map(method -> method.compilationInfo.getDeoptTargetMethod()) .filter(deoptTargetMethod -> deoptTargetMethod != null) .forEach(deoptTargetMethod -> ensureCompiled(deoptTargetMethod, new EntryPointReason())); executor.start(); executor.complete(); executor.shutdown(); }
protected void ensureParsed(HostedMethod method, CompileReason reason) { if (!method.compilationInfo.inParseQueue.getAndSet(true)) { executor.execute(new ParseTask(method, reason)); } }
@SuppressWarnings("try") private void inlineTrivialMethods(DebugContext debug) throws InterruptedException { for (HostedMethod method : universe.getMethods()) { try (DebugContext.Scope s = debug.scope("InlineTrivial", method.compilationInfo.getGraph(), method, this)) { if (method.compilationInfo.getGraph() != null) { checkTrivial(method); } } catch (Throwable e) { throw debug.handle(e); } } int round = 0; do { inliningProgress = false; round++; try (Indent ignored = debug.logAndIndent("==== Trivial Inlining round %d\n", round)) { executor.init(); universe.getMethods().stream().filter(method -> method.compilationInfo.getGraph() != null).forEach(method -> executor.execute(new TrivialInlineTask(method))); universe.getMethods().stream().map(method -> method.compilationInfo.getDeoptTargetMethod()).filter(Objects::nonNull).forEach( deoptTargetMethod -> executor.execute(new TrivialInlineTask(deoptTargetMethod))); executor.start(); executor.complete(); executor.shutdown(); } } while (inliningProgress); }
protected void ensureCompiled(HostedMethod method, CompileReason reason) { CompileTask task = new CompileTask(method, reason); CompileTask oldTask = compilations.putIfAbsent(method, task); if (oldTask != null) { // Method is already scheduled for compilation. if (oldTask.allReasons != null) { oldTask.allReasons.add(reason); } return; } if (method.compilationInfo.specializedArguments != null) { // Do the specialization: replace the argument locals with the constant arguments. StructuredGraph graph = method.compilationInfo.graph; int idx = 0; for (ConstantNode argument : method.compilationInfo.specializedArguments) { ParameterNode local = graph.getParameter(idx++); if (local != null) { local.replaceAndDelete(ConstantNode.forConstant(argument.asJavaConstant(), runtimeConfig.getProviders().getMetaAccess(), graph)); } } } executor.execute(task); method.setCompiled(); }