use of org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin in project graal by oracle.
the class BytecodeParser method genCheckCast.
private void genCheckCast() {
int cpi = getStream().readCPI();
JavaType type = lookupType(cpi, CHECKCAST);
ValueNode object = frameState.pop(JavaKind.Object);
if (!(type instanceof ResolvedJavaType)) {
handleUnresolvedCheckCast(type, object);
return;
}
TypeReference checkedType = TypeReference.createTrusted(graph.getAssumptions(), (ResolvedJavaType) type);
JavaTypeProfile profile = getProfileForTypeCheck(checkedType);
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleCheckCast(this, object, checkedType.getType(), profile)) {
return;
}
}
ValueNode castNode = null;
if (profile != null) {
if (profile.getNullSeen().isFalse()) {
object = nullCheckedValue(object);
ResolvedJavaType singleType = profile.asSingleType();
if (singleType != null && checkedType.getType().isAssignableFrom(singleType)) {
LogicNode typeCheck = append(createInstanceOf(TypeReference.createExactTrusted(singleType), object, profile));
if (typeCheck.isTautology()) {
castNode = object;
} else {
FixedGuardNode fixedGuard = append(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile, false));
castNode = append(PiNode.create(object, StampFactory.objectNonNull(TypeReference.createExactTrusted(singleType)), fixedGuard));
}
}
}
}
boolean nonNull = ((ObjectStamp) object.stamp(NodeView.DEFAULT)).nonNull();
if (castNode == null) {
LogicNode condition = genUnique(createInstanceOfAllowNull(checkedType, object, null));
if (condition.isTautology()) {
castNode = object;
} else {
FixedGuardNode fixedGuard = append(new FixedGuardNode(condition, DeoptimizationReason.ClassCastException, DeoptimizationAction.InvalidateReprofile, false));
castNode = append(PiNode.create(object, StampFactory.object(checkedType, nonNull), fixedGuard));
}
}
frameState.push(JavaKind.Object, castNode);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin in project graal by oracle.
the class BytecodeParser method genNewPrimitiveArray.
private void genNewPrimitiveArray(int typeCode) {
ResolvedJavaType elementType = metaAccess.lookupJavaType(arrayTypeCodeToClass(typeCode));
ValueNode length = frameState.pop(JavaKind.Int);
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleNewArray(this, elementType, length)) {
return;
}
}
frameState.push(JavaKind.Object, append(createNewArray(elementType, length, true)));
}
use of org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin in project graal by oracle.
the class BytecodeParser method genPutStatic.
protected void genPutStatic(JavaField field) {
ValueNode value = frameState.pop(field.getJavaKind());
ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, value);
if (resolvedField == null) {
return;
}
if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
graph.recordField(resolvedField);
}
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedField.getDeclaringClass())) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedField.getDeclaringClass(), stateBefore);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleStoreStaticField(this, resolvedField, value)) {
return;
}
}
genStoreField(null, resolvedField, value);
}
Aggregations