use of org.graalvm.compiler.nodes.java.StoreIndexedNode in project graal by oracle.
the class MethodTypeFlowBuilder method registerUsedElements.
public static void registerUsedElements(BigBang bb, StructuredGraph graph, MethodTypeFlow methodFlow) {
for (Node n : graph.getNodes()) {
if (n instanceof InstanceOfNode) {
InstanceOfNode node = (InstanceOfNode) n;
AnalysisType type = (AnalysisType) node.type().getType();
type.registerAsInTypeCheck();
} else if (n instanceof NewInstanceNode) {
NewInstanceNode node = (NewInstanceNode) n;
AnalysisType type = (AnalysisType) node.instanceClass();
type.registerAsAllocated(node);
} else if (n instanceof NewArrayNode) {
NewArrayNode node = (NewArrayNode) n;
AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass();
type.registerAsAllocated(node);
} else if (n instanceof NewMultiArrayNode) {
NewMultiArrayNode node = (NewMultiArrayNode) n;
AnalysisType type = ((AnalysisType) node.type());
for (int i = 0; i < node.dimensionCount(); i++) {
type.registerAsAllocated(node);
type = type.getComponentType();
}
} else if (n instanceof BoxNode) {
BoxNode node = (BoxNode) n;
AnalysisType type = (AnalysisType) StampTool.typeOrNull(node);
type.registerAsAllocated(node);
} else if (n instanceof LoadFieldNode) {
LoadFieldNode node = (LoadFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsRead(methodFlow);
} else if (n instanceof StoreFieldNode) {
StoreFieldNode node = (StoreFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsWritten(methodFlow);
} else if (n instanceof StoreIndexedNode) {
StoreIndexedNode node = (StoreIndexedNode) n;
AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array());
if (arrayType != null) {
assert arrayType.isArray();
arrayType.getComponentType().registerAsInTypeCheck();
}
} else if (n instanceof BytecodeExceptionNode) {
BytecodeExceptionNode node = (BytecodeExceptionNode) n;
AnalysisType type = bb.getMetaAccess().lookupJavaType(node.getExceptionClass());
type.registerAsInHeap();
} else if (n instanceof ConstantNode) {
ConstantNode cn = (ConstantNode) n;
if (cn.hasUsages() && cn.asJavaConstant().getJavaKind() == JavaKind.Object && cn.asJavaConstant().isNonNull()) {
assert StampTool.isExactType(cn);
AnalysisType type = (AnalysisType) StampTool.typeOrNull(cn);
type.registerAsInHeap();
}
} else if (n instanceof ForeignCallNode) {
ForeignCallNode node = (ForeignCallNode) n;
registerForeignCall(bb, node.getDescriptor());
} else if (n instanceof UnaryMathIntrinsicNode) {
UnaryMathIntrinsicNode node = (UnaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
} else if (n instanceof BinaryMathIntrinsicNode) {
BinaryMathIntrinsicNode node = (BinaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
}
}
}
use of org.graalvm.compiler.nodes.java.StoreIndexedNode in project graal by oracle.
the class PEGraphDecoder method canonicalizeFixedNode.
@SuppressWarnings("try")
@Override
protected Node canonicalizeFixedNode(MethodScope s, Node node) {
PEMethodScope methodScope = (PEMethodScope) s;
Node replacedNode = node;
if (nodePlugins != null && nodePlugins.length > 0) {
if (node instanceof LoadFieldNode) {
LoadFieldNode loadFieldNode = (LoadFieldNode) node;
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, loadFieldNode);
ResolvedJavaField field = loadFieldNode.field();
if (loadFieldNode.isStatic()) {
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleLoadStaticField(graphBuilderContext, field)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else {
ValueNode object = loadFieldNode.object();
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleLoadField(graphBuilderContext, object, field)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
}
} else if (node instanceof StoreFieldNode) {
StoreFieldNode storeFieldNode = (StoreFieldNode) node;
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, storeFieldNode);
ResolvedJavaField field = storeFieldNode.field();
if (storeFieldNode.isStatic()) {
ValueNode value = storeFieldNode.value();
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleStoreStaticField(graphBuilderContext, field, value)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else {
ValueNode object = storeFieldNode.object();
ValueNode value = storeFieldNode.value();
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleStoreField(graphBuilderContext, object, field, value)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
}
} else if (node instanceof LoadIndexedNode) {
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.elementKind())) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else if (node instanceof StoreIndexedNode) {
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.elementKind(), value)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else if (node instanceof NewInstanceNode) {
NewInstanceNode newInstanceNode = (NewInstanceNode) node;
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newInstanceNode);
ResolvedJavaType type = newInstanceNode.instanceClass();
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleNewInstance(graphBuilderContext, type)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else if (node instanceof NewArrayNode) {
NewArrayNode newArrayNode = (NewArrayNode) node;
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newArrayNode);
ResolvedJavaType elementType = newArrayNode.elementType();
ValueNode length = newArrayNode.length();
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleNewArray(graphBuilderContext, elementType, length)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
} else if (node instanceof NewMultiArrayNode) {
NewMultiArrayNode newArrayNode = (NewMultiArrayNode) node;
PEAppendGraphBuilderContext graphBuilderContext = new PEAppendGraphBuilderContext(methodScope, newArrayNode);
ResolvedJavaType elementType = newArrayNode.type();
ValueNode[] dimensions = newArrayNode.dimensions().toArray(new ValueNode[0]);
for (NodePlugin nodePlugin : nodePlugins) {
if (nodePlugin.handleNewMultiArray(graphBuilderContext, elementType, dimensions)) {
replacedNode = graphBuilderContext.pushedNode;
break;
}
}
}
}
return super.canonicalizeFixedNode(methodScope, replacedNode);
}
use of org.graalvm.compiler.nodes.java.StoreIndexedNode in project graal by oracle.
the class VerifyDebugUsage method verifyParameters.
private void verifyParameters(MethodCallTargetNode callTarget, StructuredGraph callerGraph, NodeInputList<? extends ValueNode> args, ResolvedJavaType stringType, int startArgIdx) {
if (callTarget.targetMethod().isVarArgs() && args.get(args.count() - 1) instanceof NewArrayNode) {
// unpack the arguments to the var args
List<ValueNode> unpacked = new ArrayList<>(args.snapshot());
NewArrayNode varArgParameter = (NewArrayNode) unpacked.remove(unpacked.size() - 1);
int firstVarArg = unpacked.size();
for (Node usage : varArgParameter.usages()) {
if (usage instanceof StoreIndexedNode) {
StoreIndexedNode si = (StoreIndexedNode) usage;
unpacked.add(si.value());
}
}
verifyParameters(callerGraph, callTarget, unpacked, stringType, startArgIdx, firstVarArg);
} else {
verifyParameters(callerGraph, callTarget, args, stringType, startArgIdx, -1);
}
}
use of org.graalvm.compiler.nodes.java.StoreIndexedNode in project graal by oracle.
the class PEReadEliminationClosure method processNode.
@Override
protected boolean processNode(Node node, PEReadEliminationBlockState state, GraphEffectList effects, FixedWithNextNode lastFixedNode) {
if (super.processNode(node, state, effects, lastFixedNode)) {
return true;
}
if (node instanceof LoadFieldNode) {
return processLoadField((LoadFieldNode) node, state, effects);
} else if (node instanceof StoreFieldNode) {
return processStoreField((StoreFieldNode) node, state, effects);
} else if (node instanceof LoadIndexedNode) {
return processLoadIndexed((LoadIndexedNode) node, state, effects);
} else if (node instanceof StoreIndexedNode) {
return processStoreIndexed((StoreIndexedNode) node, state, effects);
} else if (node instanceof ArrayLengthNode) {
return processArrayLength((ArrayLengthNode) node, state, effects);
} else if (node instanceof UnboxNode) {
return processUnbox((UnboxNode) node, state, effects);
} else if (node instanceof RawLoadNode) {
return processUnsafeLoad((RawLoadNode) node, state, effects);
} else if (node instanceof RawStoreNode) {
return processUnsafeStore((RawStoreNode) node, state, effects);
} else if (node instanceof MemoryCheckpoint.Single) {
COUNTER_MEMORYCHECKPOINT.increment(node.getDebug());
LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
processIdentity(state, identity);
} else if (node instanceof MemoryCheckpoint.Multi) {
COUNTER_MEMORYCHECKPOINT.increment(node.getDebug());
for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
processIdentity(state, identity);
}
}
return false;
}
use of org.graalvm.compiler.nodes.java.StoreIndexedNode in project graal by oracle.
the class InstrumentPhase method insertCounter.
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, 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, JavaKind.Long, add));
graph.addAfterFixed(targetNode, load);
graph.addAfterFixed(load, store);
}
Aggregations