private boolean processStoreIndexed(StoreIndexedNode store, PEReadEliminationBlockState state, GraphEffectList effects) { int index = store.index().isConstant() ? ((JavaConstant) store.index().asConstant()).asInt() : -1; JavaKind elementKind = store.elementKind(); LocationIdentity arrayLocation = NamedLocationIdentity.getArrayLocation(elementKind); if (index != -1) { return processStore(store, store.array(), arrayLocation, index, elementKind, false, store.value(), state, effects); } else { state.killReadCache(arrayLocation, -1); } return false; }
protected StoreIndexedNode createStoreIndexedNode(ValueNode array, ValueNode index, GuardingNode boundsCheck, ValueNode value) { return new StoreIndexedNode(array, index, boundsCheck, null, wordKind, value); }
protected void lowerStoreIndexedNode(StoreIndexedNode storeIndexed, LoweringTool tool) { StructuredGraph graph = storeIndexed.graph(); ValueNode value = storeIndexed.value(); ValueNode array = storeIndexed.array(); JavaKind elementKind = storeIndexed.elementKind(); if (storeIndexed.getStoreCheck() == null && elementKind == JavaKind.Object && !StampTool.isPointerAlwaysNull(value)) { ResolvedJavaType elementType = arrayType.getType().getComponentType(); if (!elementType.isJavaLangObject()) { TypeReference typeReference = TypeReference.createTrusted(storeIndexed.graph().getAssumptions(), elementType); LogicNode typeTest = graph.addOrUniqueWithInputs(InstanceOfNode.create(typeReference, value)); condition = LogicNode.or(graph.unique(IsNullNode.create(value)), typeTest, GraalDirectives.UNLIKELY_PROBABILITY); AddressNode address = createArrayIndexAddress(graph, array, elementKind, storeIndexed.index(), boundsCheck); WriteNode memoryWrite = graph.add(new WriteNode(address, NamedLocationIdentity.getArrayLocation(elementKind), implicitStoreConvert(graph, elementKind, value), arrayStoreBarrierType(storeIndexed.elementKind()))); memoryWrite.setGuard(boundsCheck); if (condition != null) { tool.createGuard(storeIndexed, condition, DeoptimizationReason.ArrayStoreException, DeoptimizationAction.InvalidateReprofile); memoryWrite.setStateAfter(storeIndexed.stateAfter()); graph.replaceFixedWithFixed(storeIndexed, memoryWrite);
StoreIndexedNode storeIndexedNode = (StoreIndexedNode) node; PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, storeIndexedNode); ValueNode array = storeIndexedNode.array(); ValueNode index = storeIndexedNode.index(); ValueNode value = storeIndexedNode.value(); for (NodePlugin nodePlugin : nodePlugins) { if (nodePlugin.handleStoreIndexed(graphBuilderContext, array, index, storeIndexedNode.getBoundsCheck(), storeIndexedNode.getStoreCheck(), storeIndexedNode.elementKind(), value)) { replacedNode = graphBuilderContext.pushedNode; break;
@Override public void virtualize(VirtualizerTool tool) { ValueNode alias = tool.getAlias(array()); if (alias instanceof VirtualObjectNode) { ValueNode indexValue = tool.getAlias(index()); int idx = indexValue.isConstant() ? indexValue.asJavaConstant().asInt() : -1; VirtualArrayNode virtual = (VirtualArrayNode) alias; if (idx >= 0 && idx < virtual.entryCount()) { ResolvedJavaType componentType = virtual.type().getComponentType(); if (componentType.isPrimitive() || StampTool.isPointerAlwaysNull(value) || componentType.isJavaLangObject() || (StampTool.typeReferenceOrNull(value) != null && componentType.isAssignableFrom(StampTool.typeOrNull(value)))) { tool.setVirtualEntry(virtual, idx, value()); tool.delete(); } } } }
while (successor instanceof StoreIndexedNode) { StoreIndexedNode store = (StoreIndexedNode) successor; assert store.array().equals(newArray); ValueNode valueNode = store.value(); if (valueNode.isConstant() && !valueNode.isNullConstant()) { Class<?> clazz = snippetReflection.asObject(Class.class, valueNode.asJavaConstant()); break; assert store.successors().count() <= 1 : "Detected node with multiple successors: " + store; successor = store.successors().first();
if (node.value().getStackKind() == JavaKind.Object) { AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array()); AnalysisType componentType = arrayType != null ? arrayType.getComponentType() : null; TypeFlowBuilder<?> arrayBuilder = state.lookup(node.array()); TypeFlowBuilder<?> valueBuilder = state.lookup(node.value()); TypeFlowBuilder<?> storeIndexedBuilder = TypeFlowBuilder.create(bb, node, StoreIndexedTypeFlow.class, () -> { StoreIndexedTypeFlow storeIndexedFlow = new StoreIndexedTypeFlow(node, componentType, arrayBuilder.get(), valueBuilder.get());
AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array()); if (arrayType != null) { assert arrayType.isArray();
protected void genStoreIndexed(ValueNode array, ValueNode index, GuardingNode boundsCheck, GuardingNode storeCheck, JavaKind kind, ValueNode value) { add(new StoreIndexedNode(array, index, boundsCheck, storeCheck, kind, value)); }
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); }