protected OperandModeAnnotation getOperandModeAnnotation(Field field) { OperandModeAnnotation result = null; MapCursor<Class<? extends Annotation>, OperandModeAnnotation> cursor = valueAnnotations.getEntries(); while (cursor.advance()) { Annotation annotation = field.getAnnotation(cursor.getKey()); if (annotation != null) { assert result == null : "Field has two operand mode annotations: " + field; result = cursor.getValue(); } } return result; }
@Override public String toString() { UnmodifiableMapCursor<String, List<Binding>> entries = getBindings(false, false).getEntries(); List<String> all = new ArrayList<>(); while (entries.advance()) { String c = MetaUtil.internalNameToJava(entries.getKey(), true, false); for (Binding b : entries.getValue()) { all.add(c + '.' + b); } } Collections.sort(all); StringBuilder buf = new StringBuilder(); String nl = String.format("%n"); for (String s : all) { if (buf.length() != 0) { buf.append(nl); } buf.append(s); } if (parent != null) { if (buf.length() != 0) { buf.append(nl); } buf.append("// parent").append(nl).append(parent); } return buf.toString(); }
private static void collectBindingsTo(EconomicMap<String, List<Binding>> res, String type, ClassPlugins cp) { MapCursor<String, Binding> methods = cp.bindings.getEntries(); while (methods.advance()) { List<Binding> bindings = res.get(type); if (bindings == null) { bindings = new ArrayList<>(); res.put(type, bindings); } for (Binding b = methods.getValue(); b != null; b = b.next) { bindings.add(b); } } }
static void addArguments(List<String> result, String prefix, EconomicMap<OptionKey<?>, Object> values) { MapCursor<OptionKey<?>, Object> cursor = values.getEntries(); while (cursor.advance()) { result.add(prefix + cursor.getKey().getName() + "=" + cursor.getValue()); } } }
/** * Copies all of the mappings from {@code other} to this map. * * @since 1.0 */ default void putAll(EconomicMap<K, V> other) { MapCursor<K, V> e = other.getEntries(); while (e.advance()) { put(e.getKey(), e.getValue()); } }
/** * Copies all of the mappings from {@code other} to this map. * * @since 1.0 */ default void putAll(EconomicMap<K, V> other) { MapCursor<K, V> e = other.getEntries(); while (e.advance()) { put(e.getKey(), e.getValue()); } }
/** * Returns true if every value in subMap is also present in the superMap (according to "equals" * semantics). */ protected static <K, V> boolean isSubMapOf(EconomicMap<K, V> superMap, EconomicMap<K, V> subMap) { if (superMap == subMap) { return true; } UnmodifiableMapCursor<K, V> cursor = subMap.getEntries(); while (cursor.advance()) { K key = cursor.getKey(); V value = cursor.getValue(); assert value != null; V otherValue = superMap.get(key); if (otherValue != value && !value.equals(otherValue)) { return false; } } return true; }
public MemoryMapNode(EconomicMap<LocationIdentity, MemoryNode> mmap) { super(TYPE, StampFactory.forVoid()); int size = mmap.size(); locationIdentities = new ArrayList<>(size); nodes = new NodeInputList<>(this, size); int index = 0; MapCursor<LocationIdentity, MemoryNode> cursor = mmap.getEntries(); while (cursor.advance()) { locationIdentities.add(cursor.getKey()); nodes.initialize(index, (ValueNode) cursor.getValue()); index++; } assert checkOrder(mmap); }
/** * Parses a map representing assignments of values to options. * * @param optionSettings option settings (i.e., assignments of values to options) * @param values the object in which to store the parsed values * @param loader source of the available {@link OptionDescriptors} * @throws IllegalArgumentException if there's a problem parsing {@code option} */ public static void parseOptions(EconomicMap<String, String> optionSettings, EconomicMap<OptionKey<?>, Object> values, Iterable<OptionDescriptors> loader) { if (optionSettings != null && !optionSettings.isEmpty()) { MapCursor<String, String> cursor = optionSettings.getEntries(); while (cursor.advance()) { parseOption(cursor.getKey(), cursor.getValue(), values, loader); } } }
/** * Removes the plugins from {@code other} in this object that were added by * {@link #addTestPlugins}. */ public synchronized void removeTestPlugins(InvocationPlugins other) { assert resolvedRegistrations == null : "registration is closed"; if (testExtensions != null) { MapCursor<String, List<Binding>> c = other.getBindings(false).getEntries(); while (c.advance()) { String declaringClass = c.getKey(); List<Binding> bindings = testExtensions.get(declaringClass); if (bindings != null) { for (Binding b : c.getValue()) { int index = findBinding(bindings, b); if (index != -1) { bindings.remove(index); } } if (bindings.isEmpty()) { testExtensions.removeKey(declaringClass); } } } if (testExtensions.isEmpty()) { testExtensions = null; } } }
protected void registerCombinedStamps(MergeNode node) { EconomicMap<ValueNode, Stamp> endMap = endMaps.get(node); MapCursor<ValueNode, Stamp> entries = endMap.getEntries(); while (entries.advance()) { ValueNode value = entries.getKey(); if (value.isDeleted()) { // nodes from this map can be deleted when a loop dies continue; } if (registerNewValueStamp(value, entries.getValue())) { counterBetterMergedStamps.increment(debug); } } }
/** * Completely replace the current log with the copy of the specified log. * * The precondition is that the current inlining log is completely empty. This is usually called * when copying the entire graph. * * @see InliningLog#addDecision */ public void replaceLog(UnmodifiableEconomicMap<Node, Node> replacements, InliningLog replacementLog) { assert root.decisions.isEmpty(); assert root.children.isEmpty(); assert leaves.isEmpty(); EconomicMap<Callsite, Callsite> mapping = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE); copyTree(root, replacementLog.root, replacements, mapping); MapCursor<Invokable, Callsite> replacementEntries = replacementLog.leaves.getEntries(); while (replacementEntries.advance()) { Invokable replacementInvoke = replacementEntries.getKey(); Callsite replacementSite = replacementEntries.getValue(); if (replacementInvoke.isAlive()) { Invokable invoke = (Invokable) replacements.get((Node) replacementInvoke); Callsite site = mapping.get(replacementSite); leaves.put(invoke, site); } } }
OptionValuesImpl( final OptionValuesImpl owner, final UnmodifiableEconomicMap<OptionKey<?>, Object> overrides) { this.descriptors = owner.descriptors; this.values = EconomicMap.create(); UnmodifiableMapCursor<OptionKey<?>, Object> cursor = owner.values.getEntries(); while (cursor.advance()) { this.values.put(cursor.getKey(), maskNull(cursor.getValue())); } cursor = overrides.getEntries(); while (cursor.advance()) { this.values.put(cursor.getKey(), maskNull(cursor.getValue())); } }
@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; }
try (DebugContext.Scope s = debug.scope("MatchComplexExpressions")) { debug.log("Match rules for %s", theClass.getSimpleName()); MapCursor<Class<? extends Node>, List<MatchStatement>> cursor = result.getEntries(); while (cursor.advance()) { debug.log(" For node class: %s", cursor.getKey());
/** * Updates a given stub with respect to the registers it destroys. * <p> * Any entry in {@code calleeSaveInfo} that {@linkplain SaveRegistersOp#supportsRemove() * supports} pruning will have {@code destroyedRegisters} * {@linkplain SaveRegistersOp#remove(EconomicSet) removed} as these registers are declared as * temporaries in the stub's {@linkplain ForeignCallLinkage linkage} (and thus will be saved by * the stub's caller). * * @param stub the stub to update * @param destroyedRegisters the registers destroyed by the stub * @param calleeSaveInfo a map from debug infos to the operations that provide their * {@linkplain RegisterSaveLayout callee-save information} * @param frameMap used to {@linkplain FrameMap#offsetForStackSlot(StackSlot) convert} a virtual * slot to a frame slot index */ protected void updateStub(Stub stub, EconomicSet<Register> destroyedRegisters, EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo, FrameMap frameMap) { stub.initDestroyedCallerRegisters(destroyedRegisters); MapCursor<LIRFrameState, SaveRegistersOp> cursor = calleeSaveInfo.getEntries(); while (cursor.advance()) { SaveRegistersOp save = cursor.getValue(); if (save.supportsRemove()) { save.remove(destroyedRegisters); } if (cursor.getKey() != LIRFrameState.NO_STATE) { cursor.getKey().debugInfo().setCalleeSaveInfo(save.getMap(frameMap)); } } }
@Override protected void processLoopExit(LoopExitNode exitNode, ReadEliminationBlockState initialState, ReadEliminationBlockState exitState, GraphEffectList effects) { if (exitNode.graph().hasValueProxies()) { MapCursor<CacheEntry<?>, ValueNode> entry = exitState.getReadCache().getEntries(); while (entry.advance()) { if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) { ProxyNode proxy = new ValueProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode); effects.addFloatingNode(proxy, "readCacheProxy"); exitState.getReadCache().put(entry.getKey(), proxy); } } } }
/** * Append the inlining decision tree from the specified log. * * The subtrees of the specified log are appended below the root of this log. This is usually * called when a node in the graph is replaced with its snippet. * * @see InliningLog#addDecision */ public void addLog(UnmodifiableEconomicMap<Node, Node> replacements, InliningLog replacementLog) { EconomicMap<Callsite, Callsite> mapping = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE); for (Callsite calleeChild : replacementLog.root.children) { Callsite child = root.addChild(calleeChild.invoke); copyTree(child, calleeChild, replacements, mapping); } MapCursor<Invokable, Callsite> entries = replacementLog.leaves.getEntries(); while (entries.advance()) { Invokable replacementInvoke = entries.getKey(); Callsite replacementCallsite = entries.getValue(); if (replacementInvoke.asFixedNode().isDeleted()) { // Some invoke nodes could have been removed by optimizations. continue; } Invokable invoke = (Invokable) replacements.get(replacementInvoke.asFixedNode()); Callsite callsite = mapping.get(replacementCallsite); leaves.put(invoke, callsite); } }
private static void fixSurvivingAffectedMerges(EconomicSet<Node> markedNodes, EconomicMap<AbstractMergeNode, List<AbstractEndNode>> unmarkedMerges) { MapCursor<AbstractMergeNode, List<AbstractEndNode>> cursor = unmarkedMerges.getEntries(); while (cursor.advance()) { AbstractMergeNode merge = cursor.getKey(); for (AbstractEndNode end : cursor.getValue()) { merge.removeEnd(end); } if (merge.phiPredecessorCount() == 1) { if (merge instanceof LoopBeginNode) { LoopBeginNode loopBegin = (LoopBeginNode) merge; assert merge.forwardEndCount() == 1; for (LoopExitNode loopExit : loopBegin.loopExits().snapshot()) { if (markedNodes.contains(loopExit)) { /* * disconnect from loop begin so that reduceDegenerateLoopBegin doesn't * transform it into a new beginNode */ loopExit.replaceFirstInput(loopBegin, null); } } merge.graph().reduceDegenerateLoopBegin(loopBegin); } else { merge.graph().reduceTrivialMerge(merge); } } else { assert merge.phiPredecessorCount() > 1 : merge; } } }
@Override protected void processLoopExit(LoopExitNode exitNode, PEReadEliminationBlockState initialState, PEReadEliminationBlockState exitState, GraphEffectList effects) { super.processLoopExit(exitNode, initialState, exitState, effects); if (exitNode.graph().hasValueProxies()) { MapCursor<ReadCacheEntry, ValueNode> entry = exitState.getReadCache().getEntries(); while (entry.advance()) { if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) { ValueNode value = exitState.getReadCache(entry.getKey().object, entry.getKey().identity, entry.getKey().index, entry.getKey().kind, this); assert value != null : "Got null from read cache, entry's value:" + entry.getValue(); if (!(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint() != exitNode) { ProxyNode proxy = new ValueProxyNode(value, exitNode); effects.addFloatingNode(proxy, "readCacheProxy"); exitState.getReadCache().put(entry.getKey(), proxy); } } } } }