void reportAllContextThreads(ThreadsListener listener) { List<PolyglotContextImpl> allContexts; synchronized (this) { if (contexts.isEmpty()) { return; } allContexts = collectAliveContexts(); } for (PolyglotContextImpl context : allContexts) { Thread[] threads; synchronized (context) { threads = context.getSeenThreads().keySet().toArray(new Thread[0]); } for (Thread thread : threads) { listener.onThreadInitialized(context.truffleContext, thread); } } }
private static boolean paramsAndInvokeAreInSameGraph(Invoke invoke, EconomicSet<ParameterNode> fixedParams) { if (fixedParams.isEmpty()) { return true; } for (ParameterNode p : fixedParams) { if (p.graph() != invoke.asNode().graph()) { return false; } } return true; }
private void dumpMethod(String className, String methodName, String filter, String host, int port) throws Exception { EconomicSet<ClassNotFoundException> failures = EconomicSet.create(); EconomicSet<Class<?>> found = loaders.resolve(className, failures); if (found.isEmpty()) { ClassNotFoundException cause = failures.isEmpty() ? new ClassNotFoundException(className) : failures.iterator().next(); throw new Exception("Cannot find class " + className + " to schedule recompilation", cause); } for (Class<?> clazz : found) { ResolvedJavaType type = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess().lookupJavaType(clazz); for (ResolvedJavaMethod method : type.getDeclaredMethods()) { if (methodName.equals(method.getName()) && method instanceof HotSpotResolvedJavaMethod) { HotSpotResolvedJavaMethod hotSpotMethod = (HotSpotResolvedJavaMethod) method; dumpMethod(hotSpotMethod, filter, host, port); } } } }
private boolean isTimerEnabledSlow(AbstractKey key) { if (currentScope != null && currentScope.isTimeEnabled()) { return true; } if (immutable.listMetrics) { key.ensureInitialized(); } assert checkNoConcurrentAccess(); EconomicSet<String> unscoped = immutable.unscopedTimers; return unscoped != null && (unscoped.isEmpty() || unscoped.contains(key.getName())); }
private boolean isCounterEnabledSlow(AbstractKey key) { if (currentScope != null && currentScope.isCountEnabled()) { return true; } if (immutable.listMetrics) { key.ensureInitialized(); } assert checkNoConcurrentAccess(); EconomicSet<String> unscoped = immutable.unscopedCounters; return unscoped != null && (unscoped.isEmpty() || unscoped.contains(key.getName())); }
private boolean isMemUseTrackerEnabledSlow(AbstractKey key) { if (currentScope != null && currentScope.isMemUseTrackingEnabled()) { return true; } if (immutable.listMetrics) { key.ensureInitialized(); } assert checkNoConcurrentAccess(); EconomicSet<String> unscoped = immutable.unscopedMemUseTrackers; return unscoped != null && (unscoped.isEmpty() || unscoped.contains(key.getName())); }
@Override @SuppressWarnings("try") protected void run(StructuredGraph graph, C context) { EconomicSetNodeEventListener listener = new EconomicSetNodeEventListener(); try (NodeEventScope nes = graph.trackNodeEvents(listener)) { super.run(graph, context); } if (!listener.getNodes().isEmpty()) { canonicalizer.applyIncremental(graph, context, listener.getNodes(), null, false); } } }
@Override public void finalizeAddress(Backend backend) { if (address == 0) { assert checkStubCondition(); InstalledCode code = stub.getCode(backend); EconomicSet<Register> destroyedRegisters = stub.getDestroyedCallerRegisters(); if (!destroyedRegisters.isEmpty()) { AllocatableValue[] temporaryLocations = new AllocatableValue[destroyedRegisters.size()]; int i = 0; for (Register reg : destroyedRegisters) { temporaryLocations[i++] = reg.asValue(); } temporaries = temporaryLocations; } address = code.getStart(); } }
void reportAllLanguageContexts(ContextsListener listener) { List<PolyglotContextImpl> allContexts; synchronized (this) { if (contexts.isEmpty()) { return; } allContexts = collectAliveContexts(); } for (PolyglotContextImpl context : allContexts) { listener.onContextCreated(context.truffleContext); for (PolyglotLanguageContext lc : context.contexts) { LanguageInfo language = lc.language.info; if (lc.eventsEnabled && lc.env != null) { listener.onLanguageContextCreated(context.truffleContext, language); if (lc.isInitialized()) { listener.onLanguageContextInitialized(context.truffleContext, language); if (lc.finalized) { listener.onLanguageContextFinalized(context.truffleContext, language); } } } } } }
if (contains) { set.remove(session); if (set.isEmpty()) { duplicateInThreads.removeKey(thread);
Predicate<String> classFilter, Map<String, String> options, Map<String, String[]> arguments, String[] onlyLanguages, FileSystem fileSystem, Object logHandlerOrStream) { checkState(); if (boundEngine && preInitializedContext == null && !contexts.isEmpty()) { throw new IllegalArgumentException("Automatically created engines cannot be used to create more than one context. " + "Use Engine.newBuilder().build() to construct a new engine and pass it using Context.newBuilder().engine(engine).build().");
/** * After an earliest schedule, this will re-sort guards to honor their * {@linkplain StaticDeoptimizingNode#computePriority() priority}. * * Note that this only changes the order of nodes within {@linkplain MicroBlock * micro-blocks}, nodes will not be moved from one micro-block to another. */ private static void resortGuards(StructuredGraph graph, NodeMap<MicroBlock> entries, NodeStack stack) { assert stack.isEmpty(); EconomicSet<MicroBlock> blocksWithGuards = EconomicSet.create(IDENTITY); for (GuardNode guard : graph.getNodes(GuardNode.TYPE)) { MicroBlock block = entries.get(guard); assert block != null : guard + "should already be scheduled to a micro-block"; blocksWithGuards.add(block); } assert !blocksWithGuards.isEmpty(); NodeMap<GuardPriority> priorities = graph.createNodeMap(); NodeBitMap blockNodes = graph.createNodeBitMap(); for (MicroBlock block : blocksWithGuards) { MicroBlock newBlock = resortGuards(block, stack, blockNodes, priorities); assert stack.isEmpty(); assert blockNodes.isEmpty(); if (newBlock != null) { assert block.getNodeCount() == newBlock.getNodeCount(); block.head = newBlock.head; block.tail = newBlock.tail; } } }
@Override @SuppressWarnings("try") protected void run(StructuredGraph graph, PhaseContext context) { EconomicSetNodeEventListener listener = new EconomicSetNodeEventListener().exclude(NODE_ADDED); int count = 0; while (true) { try (NodeEventScope nes = graph.trackNodeEvents(listener)) { new ConditionalEliminationPhase(fullSchedule).apply(graph, context); } if (listener.getNodes().isEmpty()) { break; } for (Node node : graph.getNodes()) { if (node instanceof Simplifiable) { listener.getNodes().add(node); } } canonicalizer.applyIncremental(graph, context, listener.getNodes()); listener.getNodes().clear(); if (++count > MAX_ITERATIONS) { throw new RetryableBailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds %d", MAX_ITERATIONS); } } }
assert kills.isEmpty() : "snippet graph kills non-private locations " + kills + " that replacee (" + replacee + ") doesn't kill"; return true;
if (!filteredNodes.isEmpty()) {