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); } } }
/** * Ensures a given metric key is registered. * * @return the globally unique id for {@code value} */ static synchronized int register(AbstractKey key) { String name = key.getName(); if (!keyMap.containsKey(name)) { keyMap.put(name, keys.size()); keys.add(key); } return keyMap.get(name); }
private void keepForLater(FixedNode x, T s) { assert !nodeStates.containsKey(x); assert (x instanceof LoopBeginNode) || (x instanceof LoopEndNode) || (x instanceof EndNode); assert s != null; nodeStates.put(x, s); }
/** * 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); } } }
return; assert leaves.containsKey(invoke); assert (!positive && replacements == null && calleeLog == null) || (positive && replacements != null && calleeLog != null) || (positive && replacements == null && calleeLog == null); Callsite callsite = leaves.get(invoke); callsite.target = callsite.invoke.getTargetMethod(); Decision decision = new Decision(positive, String.format(reason, args), phase, invoke.getTargetMethod()); callsite.decisions.add(decision); if (positive) { leaves.removeKey(invoke); if (calleeLog == null) { return; EconomicMap<Callsite, Callsite> mapping = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE); for (Callsite calleeChild : calleeLog.root.children) { Callsite child = callsite.addChild(calleeChild.invoke); copyTree(child, calleeChild, replacements, mapping); MapCursor<Invokable, Callsite> entries = calleeLog.leaves.getEntries(); while (entries.advance()) { Invokable invokeFromCallee = entries.getKey(); Invokable inlinedInvokeFromCallee = (Invokable) replacements.get(invokeFromCallee.asFixedNode()); Callsite descendant = mapping.get(callsiteFromCallee); leaves.put(inlinedInvokeFromCallee, descendant);
super.processInitialLoopState(loop, initialState); if (!initialState.getReadCache().isEmpty()) { EconomicMap<ValueNode, Pair<ValueNode, Object>> firstValueSet = null; for (PhiNode phi : ((LoopBeginNode) loop.getHeader().getBeginNode()).phis()) { ValueNode unproxified = GraphUtil.unproxify(firstValue); if (firstValueSet == null) { firstValueSet = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE); Pair<ValueNode, Object> pair = Pair.create(unproxified, firstValueSet.get(unproxified)); firstValueSet.put(unproxified, pair); ReadCacheEntry[] entries = new ReadCacheEntry[initialState.getReadCache().size()]; int z = 0; for (ReadCacheEntry entry : initialState.getReadCache().getKeys()) { entries[z++] = entry; ValueNode object = entry.object; if (object != null) { Pair<ValueNode, Object> pair = firstValueSet.get(object); while (pair != null) { initialState.addReadCache(pair.getLeft(), entry.identity, entry.index, entry.kind, entry.overflowAccess, initialState.getReadCache().get(entry), this); pair = (Pair<ValueNode, Object>) pair.getRight();
if (value instanceof VirtualObjectNode) { VirtualObjectNode obj = (VirtualObjectNode) value; EscapeObjectState state = objectStates.get(obj); if (state == null && obj.entryCount() > 0) { } else { assert obj.entryCount() == 0 || state instanceof VirtualObjectState; VirtualObject vobject = virtualObjects.get(obj); if (vobject == null) { vobject = VirtualObject.get(obj.type(), virtualObjects.size()); virtualObjects.put(obj, vobject); pendingVirtualObjects.add(obj);
EconomicMap<String, List<Binding>> res = EconomicMap.create(Equivalence.DEFAULT); if (parent != null && includeParents) { res.putAll(parent.getBindings(true, flushDeferrables)); InvocationPlugin plugin = cursor.getValue(); String type = method.getDeclaringClass().getName(); List<Binding> bindings = res.get(type); if (bindings == null) { bindings = new ArrayList<>(); res.put(type, bindings); flushDeferrables(); MapCursor<String, ClassPlugins> classes = registrations.getEntries(); while (classes.advance()) { String type = classes.getKey(); MapCursor<String, List<Binding>> c = testExtensions.getEntries(); while (c.advance()) { String name = c.getKey(); List<Binding> bindings = res.get(name); if (bindings == null) { bindings = new ArrayList<>(); res.put(name, bindings);
public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) { assert virtualObjects.size() == 0; assert objectStates.size() == 0; assert pendingVirtualObjects.size() == 0; if (current.virtualObjectMappingCount() > 0) { for (EscapeObjectState state : current.virtualObjectMappings()) { if (!objectStates.containsKey(state.object())) { if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) { objectStates.put(state.object(), state); if (virtualObjects.size() != 0) { VirtualObject vobjValue = virtualObjects.get(vobjNode); assert vobjValue.getValues() == null; VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobjNode); assert currentField != null; int pos = 0; virtualObjectsArray = new VirtualObject[virtualObjects.size()]; int index = 0; for (VirtualObject value : virtualObjects.getValues()) { virtualObjectsArray[index++] = value; virtualObjects.clear(); objectStates.clear();
assert initialState != null; assert mergedStates != null; if (initialState.readCache.size() > 0) { LoopKillCache loopKilledLocations = loopLocationKillCache.get(loop); loopLocationKillCache.put(loop, loopKilledLocations); } else { AbstractBeginNode beginNode = loop.getHeader().getBeginNode(); for (ReadCacheEntry entry : initialState.readCache.getKeys()) { forwardEndLiveLocations.add(entry.identity); for (ReadCacheEntry entry : mergedStates.readCache.getKeys()) { forwardEndLiveLocations.remove(entry.identity);
/** * Updates this object with the given key/value pair. * * @see #UNSET_KEY */ public void update(OptionKey<?> key, Object value) { UnmodifiableEconomicMap<OptionKey<?>, Object> expect; EconomicMap<OptionKey<?>, Object> newMap; do { expect = v.get(); newMap = EconomicMap.create(Equivalence.IDENTITY, expect); if (value == UNSET_KEY) { newMap.removeKey(key); } else { key.update(newMap, value); // Need to do the null encoding here as `key.update()` doesn't do it newMap.put(key, encodeNull(value)); } } while (!v.compareAndSet(expect, newMap)); }
EconomicMap<Class<? extends Node>, List<MatchStatement>> result = registry.get(theClass); registry.put(theClass, rules); assert registry.get(theClass) == rules; result = rules; 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()); if (result.size() == 0) { return null;
@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; }
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())); } }
/** * Creates a new map that guarantees insertion order on the key set with the default * {@link Equivalence#DEFAULT} comparison strategy for keys. * * @since 1.0 */ static <K, V> EconomicMap<K, V> create() { return EconomicMap.create(Equivalence.DEFAULT); }
/** * Parses a given option setting string and adds the parsed key and value {@code dst}. * * @param optionSetting a string matching the pattern {@code <name>=<value>} */ public static void parseOptionSettingTo(String optionSetting, EconomicMap<String, String> dst) { int eqIndex = optionSetting.indexOf('='); if (eqIndex == -1) { throw new InternalError("Option setting has does not match the pattern <name>=<value>: " + optionSetting); } dst.put(optionSetting.substring(0, eqIndex), optionSetting.substring(eqIndex + 1)); }
@Override public boolean isReexecutable(ForeignCallDescriptor descriptor) { assert foreignCalls.containsKey(descriptor) : "unknown foreign call: " + descriptor; return foreignCalls.get(descriptor).isReexecutable(); }