private static EconomicSet<String> parseUnscopedMetricSpec(String spec, boolean unconditional, boolean accumulatedKey) { EconomicSet<String> res; if (spec == null) { if (!unconditional) { res = null; } else { res = EconomicSet.create(); } } else { res = EconomicSet.create(); if (!spec.isEmpty()) { if (!accumulatedKey) { res.addAll(Arrays.asList(spec.split(","))); } else { for (String n : spec.split(",")) { res.add(n + AccumulatedKey.ACCUMULATED_KEY_SUFFIX); res.add(n + AccumulatedKey.FLAT_KEY_SUFFIX); } } } } return res; }
/** * Checks that loops are ordered such that outer loops appear first. */ private static boolean checkLoopOrder(Iterable<Loop<Block>> loops) { EconomicSet<Loop<Block>> seen = EconomicSet.create(Equivalence.IDENTITY); for (Loop<Block> loop : loops) { if (loop.getParent() != null && !seen.contains(loop.getParent())) { return false; } seen.add(loop); } return true; }
@CompilerDirectives.TruffleBoundary static String[] findUniquePublicMemberNames(Class<?> clazz, boolean onlyStatic, boolean includeInternal) throws SecurityException { HostClassDesc classDesc = HostClassDesc.forClass(clazz); EconomicSet<String> names = EconomicSet.create(); names.addAll(classDesc.getFieldNames(onlyStatic)); names.addAll(classDesc.getMethodNames(onlyStatic, includeInternal)); if (onlyStatic) { names.add("class"); if (!TruffleOptions.AOT) { // GR-13208: SVM does not support Class.getClasses() yet if (Modifier.isPublic(clazz.getModifiers())) { // no support for non-static member types now for (Class<?> t : clazz.getClasses()) { if (!isStaticTypeOrInterface(t)) { continue; } names.add(t.getSimpleName()); } } } } return names.toArray(new String[names.size()]); }
EconomicSet<LocationIdentity> kills = EconomicSet.create(Equivalence.DEFAULT); kills.addAll(memoryMap.getLocations()); assert kills.contains(locationIdentity) : replacee + " kills " + locationIdentity + ", but snippet doesn't contain a kill to this location"; kills.remove(locationIdentity); kills.remove(any()); assert !kills.contains(any()) : "snippet graph contains a kill to ANY_LOCATION, but replacee (" + replacee + ") doesn't kill ANY_LOCATION. kills: " + kills; kills.remove(p); assert kills.isEmpty() : "snippet graph kills non-private locations " + kills + " that replacee (" + replacee + ") doesn't kill"; return true;
/** * Creates a new set guaranteeing insertion order when iterating over its elements with the * default {@link Equivalence#DEFAULT} comparison strategy. * * @since 1.0 */ static <E> EconomicSet<E> create() { return EconomicSet.create(Equivalence.DEFAULT); }
public void add(ResolvedJavaType type) { types.add(type); }
@Override protected EconomicMap<LoopExitNode, MemoryMapImpl> processLoop(LoopBeginNode loop, MemoryMapImpl initialState) { EconomicSet<LocationIdentity> modifiedLocations = modifiedInLoops.get(loop); EconomicMap<LocationIdentity, MemoryPhiNode> phis = EconomicMap.create(Equivalence.DEFAULT); if (modifiedLocations.contains(LocationIdentity.any())) { // create phis for all locations if ANY is modified in the loop modifiedLocations = EconomicSet.create(Equivalence.DEFAULT, modifiedLocations); modifiedLocations.addAll(initialState.lastMemorySnapshot.getKeys()); } for (LocationIdentity location : modifiedLocations) { createMemoryPhi(loop, initialState, phis, location); } initialState.lastMemorySnapshot.putAll(phis); LoopInfo<MemoryMapImpl> loopInfo = ReentrantNodeIterator.processLoop(this, loop, initialState); UnmodifiableMapCursor<LoopEndNode, MemoryMapImpl> endStateCursor = loopInfo.endStates.getEntries(); while (endStateCursor.advance()) { int endIndex = loop.phiPredecessorIndex(endStateCursor.getKey()); UnmodifiableMapCursor<LocationIdentity, MemoryPhiNode> phiCursor = phis.getEntries(); while (phiCursor.advance()) { LocationIdentity key = phiCursor.getKey(); PhiNode phi = phiCursor.getValue(); phi.initializeValueAt(endIndex, ValueNodeUtil.asNode(endStateCursor.getValue().getLastLocationAccess(key))); } } return loopInfo.exitStates; }
/** * Tries to resolve {@code className} to {@link Class} instances with the loaders in this set. * * @param className name of a class to resolve * @param resolutionFailures all resolution failures are returned in this set * @return the set of classes successfully resolved */ public EconomicSet<Class<?>> resolve(String className, EconomicSet<ClassNotFoundException> resolutionFailures) { EconomicSet<Class<?>> found = EconomicSet.create(); Iterator<Reference<ClassLoader>> it = loaders.get().iterator(); while (it.hasNext()) { Reference<ClassLoader> ref = it.next(); ClassLoader loader = ref.get(); if (loader == null) { it.remove(); continue; } try { Class<?> clazz = Class.forName(className, false, loader); found.add(clazz); } catch (ClassNotFoundException ex) { resolutionFailures.add(ex); } } return found; }
EconomicSet<Value> usedRegs = EconomicSet.create(Equivalence.DEFAULT); if (!areMultipleReadsAllowed()) { for (i = 0; i < mappingFrom.size(); i++) { Interval interval = mappingFrom.get(i); if (interval != null && !isIllegal(interval.location())) { boolean unique = usedRegs.add(interval.location()); assert unique : "cannot read from same register twice"; usedRegs.clear(); for (i = 0; i < mappingTo.size(); i++) { Interval interval = mappingTo.get(i); boolean unique = usedRegs.add(interval.location()); assert unique : "cannot write to same register twice";
private void collectReferencedVirtualObjects(BlockT state, EconomicSet<VirtualObjectNode> virtual) { Iterator<VirtualObjectNode> iterator = virtual.iterator(); while (iterator.hasNext()) { VirtualObjectNode object = iterator.next(); int id = object.getObjectId(); if (id != -1) { ObjectState objState = state.getObjectStateOptional(id); if (objState != null && objState.isVirtual()) { for (ValueNode entry : objState.getEntries()) { if (entry instanceof VirtualObjectNode) { VirtualObjectNode entryVirtual = (VirtualObjectNode) entry; if (!virtual.contains(entryVirtual)) { virtual.add(entryVirtual); } } } } } } }
private static void markUsages(EconomicSet<Node> markedNodes) { NodeStack workStack = new NodeStack(markedNodes.size() + 4); for (Node marked : markedNodes) { workStack.push(marked); } while (!workStack.isEmpty()) { Node marked = workStack.pop(); for (Node usage : marked.usages()) { if (!markedNodes.contains(usage)) { workStack.push(usage); markedNodes.add(usage); } } } }
static int prune(EconomicSet<Register> toRemove, Register[] registers) { int pruned = 0; for (int i = 0; i < registers.length; i++) { if (registers[i] != null) { if (toRemove.contains(registers[i])) { registers[i] = null; pruned++; } } } return pruned; }
EconomicSet<Node> collectedUnusedNodes = unusedNodes = EconomicSet.create(Equivalence.IDENTITY); nodeEventScope = node.graph().trackNodeEvents(new Graph.NodeEventListener() { @Override if (Graph.Options.VerifyGraalGraphEdges.getValue(options)) { EconomicSet<Node> newUnsafeNodes = collectUnsafeNodes(node.graph()); newUnsafeNodes.removeAll(unsafeNodes); assert newUnsafeNodes.isEmpty() : "New unsafe nodes: " + newUnsafeNodes; Iterator<Node> iterator = unusedNodes.iterator(); while (iterator.hasNext()) { Node curNode = iterator.next(); assert unusedNodes.isEmpty() : "New unused nodes: " + unusedNodes;
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); } } } }