@Override public boolean inferStamp() { return updateStamp(stamp.improveWith(createStamp(graph().getAssumptions(), array(), elementKind()))); }
protected ValueNode genLoadIndexed(ValueNode array, ValueNode index, GuardingNode boundsCheck, JavaKind kind) { return LoadIndexedNode.create(graph.getAssumptions(), array, index, boundsCheck, kind, metaAccess, constantReflection); }
public static ValueNode create(Assumptions assumptions, ValueNode array, ValueNode index, GuardingNode boundsCheck, JavaKind elementKind, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) { ValueNode constant = tryConstantFold(array, index, metaAccess, constantReflection); if (constant != null) { return constant; } return new LoadIndexedNode(assumptions, array, index, boundsCheck, elementKind); }
@Override public Node canonical(CanonicalizerTool tool) { ValueNode constant = tryConstantFold(array(), index(), tool.getMetaAccess(), tool.getConstantReflection()); if (constant != null) { return constant; } return this; }
protected void lowerLoadIndexedNode(LoadIndexedNode loadIndexed, LoweringTool tool) { StructuredGraph graph = loadIndexed.graph(); ValueNode array = loadIndexed.array(); array = createNullCheckedValue(array, loadIndexed, tool); JavaKind elementKind = loadIndexed.elementKind(); Stamp loadStamp = loadStamp(loadIndexed.stamp(NodeView.DEFAULT), elementKind); GuardingNode boundsCheck = getBoundsCheck(loadIndexed, array, tool); ValueNode index = loadIndexed.index(); if (UseIndexMasking.getValue(graph.getOptions())) { index = proxyIndex(loadIndexed, index, array, tool); } AddressNode address = createArrayIndexAddress(graph, array, elementKind, index, boundsCheck); ReadNode memoryRead = graph.add(new ReadNode(address, NamedLocationIdentity.getArrayLocation(elementKind), loadStamp, BarrierType.NONE)); memoryRead.setGuard(boundsCheck); ValueNode readValue = implicitLoadConvert(graph, elementKind, memoryRead); loadIndexed.replaceAtUsages(readValue); graph.replaceFixed(loadIndexed, memoryRead); }
if (loadIndexed.usages().count() > 1) { assert loadIndexed.usages().first() == this; ValueNode newValue = loadIndexed.index(); JavaConstant arrayConstant = loadIndexed.array().asJavaConstant(); if (arrayConstant == null || ((ConstantNode) loadIndexed.array()).getStableDimension() != 1 || !((ConstantNode) loadIndexed.array()).isDefaultStable()) { assert loadIndexed.hasNoUsages(); GraphUtil.removeFixedWithUnusedInputs(loadIndexed);
private boolean processLoadIndexed(LoadIndexedNode load, PEReadEliminationBlockState state, GraphEffectList effects) { if (load.index().isConstant()) { int index = ((JavaConstant) load.index().asConstant()).asInt(); JavaKind elementKind = load.elementKind(); LocationIdentity arrayLocation = NamedLocationIdentity.getArrayLocation(elementKind); return processLoad(load, load.array(), arrayLocation, index, elementKind, state, effects); } return false; }
@Override public void virtualize(VirtualizerTool tool) { ValueNode alias = tool.getAlias(array()); if (alias instanceof VirtualObjectNode) { VirtualArrayNode virtual = (VirtualArrayNode) alias; ValueNode indexValue = tool.getAlias(index()); int idx = indexValue.isConstant() ? indexValue.asJavaConstant().asInt() : -1; if (idx >= 0 && idx < virtual.entryCount()) { ValueNode entry = tool.getEntry(virtual, idx); if (stamp.isCompatible(entry.stamp(NodeView.DEFAULT))) { tool.replaceWith(entry); } else { assert stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Int && (entry.stamp(NodeView.DEFAULT).getStackKind() == JavaKind.Long || entry.getStackKind() == JavaKind.Double || entry.getStackKind() == JavaKind.Illegal) : "Can only allow different stack kind two slot marker writes on one stot fields."; } } } }
LoadIndexedNode loadIndexedNode = (LoadIndexedNode) node; PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadIndexedNode); ValueNode array = loadIndexedNode.array(); ValueNode index = loadIndexedNode.index(); for (NodePlugin nodePlugin : nodePlugins) { if (nodePlugin.handleLoadIndexed(graphBuilderContext, array, index, loadIndexedNode.getBoundsCheck(), loadIndexedNode.elementKind())) { replacedNode = graphBuilderContext.pushedNode; break;
@Override public void simplify(SimplifierTool tool) { if (tool.allUsagesAvailable() && hasNoUsages()) { NodeView view = NodeView.from(tool); ValueNode arrayLength = ArrayLengthNode.create(array, tool.getConstantReflection()); LogicNode boundsCheck = CompareNode.createCompareNode(CanonicalCondition.BT, index, arrayLength, tool.getConstantReflection(), view); if (boundsCheck.isTautology()) { return; } if (graph().getGuardsStage().allowsGuardInsertion()) { if (!arrayLength.isAlive()) { arrayLength = graph().addOrUniqueWithInputs(arrayLength); if (arrayLength instanceof FixedWithNextNode) { FixedWithNextNode fixedArrayLength = (FixedWithNextNode) arrayLength; graph().addBeforeFixed(this, fixedArrayLength); } } boundsCheck = graph().addOrUniqueWithInputs(boundsCheck); FixedGuardNode fixedGuard = new FixedGuardNode(boundsCheck, DeoptimizationReason.BoundsCheckException, DeoptimizationAction.InvalidateReprofile, false, getNodeSourcePosition()); graph().replaceFixedWithFixed(this, graph().add(fixedGuard)); } } }
TypeFlowBuilder<?> arrayBuilder = state.lookup(node.array()); if (node.getStackKind() == JavaKind.Object) { AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array()); AnalysisType componentType = arrayType != null ? arrayType.getComponentType() : null;
LoadIndexedNode load = new LoadIndexedNode(graph().getAssumptions(), srcAlias, ConstantNode.forInt(i + srcPosInt, graph()), null, destComponentType.getJavaKind()); load.setNodeSourcePosition(getNodeSourcePosition()); tool.addNode(load); tool.setVirtualEntry(destVirtual, destPosInt + i, load);
protected LoadIndexedNode genLoadIndexedNode(Assumptions assumptions, ValueNode originalAlias, ValueNode index, JavaKind elementKind) { return new LoadIndexedNode(assumptions, originalAlias, index, null, elementKind); }
/** * Creates a new LoadIndexedNode. * * @param array the instruction producing the array * @param index the instruction producing the index * @param elementKind the element type */ public LoadIndexedNode(Assumptions assumptions, ValueNode array, ValueNode index, GuardingNode boundsCheck, JavaKind elementKind) { this(TYPE, createStamp(assumptions, array, elementKind), array, index, boundsCheck, elementKind); }
private static Stamp createStamp(Assumptions assumptions, ValueNode array, JavaKind kind) { ResolvedJavaType type = StampTool.typeOrNull(array); if (kind == JavaKind.Object && type != null && type.isArray()) { return StampFactory.object(TypeReference.createTrusted(assumptions, type.getComponentType())); } else { JavaKind preciseKind = determinePreciseArrayElementType(array, kind); return StampFactory.forKind(preciseKind); } }
} else if (node instanceof LoadIndexedNode) { LoadIndexedNode loadIndexedNode = (LoadIndexedNode) node; return loadIndexedNode.canonical(canonicalizerTool); } else if (node instanceof ArrayLengthNode) { ArrayLengthNode arrayLengthNode = (ArrayLengthNode) node;
protected LoadIndexedNode createLoadIndexedNode(ValueNode array, ValueNode index, GuardingNode boundsCheck) { return new LoadIndexedNode(null, array, index, boundsCheck, wordKind); }
public ValueNode createLoadIndexed(ValueNode array, int index, JavaKind kind) { ValueNode loadIndexed = LoadIndexedNode.create(null, array, ConstantNode.forInt(index, getGraph()), null, kind, getMetaAccess(), getConstantReflection()); if (loadIndexed instanceof FixedNode) { return append((FixedNode) loadIndexed); } return unique((FloatingNode) loadIndexed); }
protected static void insertCounter(StructuredGraph graph, PhaseContext context, JavaConstant tableConstant, FixedWithNextNode targetNode, int slotIndex) { assert (tableConstant != null); TypeReference typeRef = TypeReference.createExactTrusted(context.getMetaAccess().lookupJavaType(tableConstant)); ConstantNode table = graph.unique(new ConstantNode(tableConstant, StampFactory.object(typeRef, true))); ConstantNode rawIndex = graph.unique(ConstantNode.forInt(slotIndex)); LoadIndexedNode load = graph.add(new LoadIndexedNode(null, table, rawIndex, null, JavaKind.Long)); ConstantNode one = graph.unique(ConstantNode.forLong(1L)); ValueNode add = graph.unique(new AddNode(load, one)); StoreIndexedNode store = graph.add(new StoreIndexedNode(table, rawIndex, null, null, JavaKind.Long, add)); graph.addAfterFixed(targetNode, load); graph.addAfterFixed(load, store); }
LoadIndexedNode load = new LoadIndexedNode(null, sourceAlias, ConstantNode.forInt(i + fromInt, graph), null, elementKind); tool.addNode(load); newEntryState[i] = load;