use of org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameClearNode in project graal by oracle.
the class TruffleGraphBuilderPlugins method registerFrameMethods.
private static void registerFrameMethods(Registration r, ConstantReflectionProvider constantReflection, KnownTruffleTypes types) {
r.register(new RequiredInvocationPlugin("getArguments", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frame) {
if (frame.get(false) instanceof NewFrameNode) {
b.push(JavaKind.Object, ((NewFrameNode) frame.get()).getArguments());
return true;
}
return false;
}
});
r.register(new RequiredInvocationPlugin("getFrameDescriptor", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frame) {
if (frame.get(false) instanceof NewFrameNode) {
b.push(JavaKind.Object, ((NewFrameNode) frame.get()).getDescriptor());
return true;
}
return false;
}
});
r.register(new RequiredInvocationPlugin("materialize", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode frame = receiver.get();
if (frame instanceof NewFrameNode && ((NewFrameNode) frame).getIntrinsifyAccessors()) {
Speculation speculation = b.getGraph().getSpeculationLog().speculate(((NewFrameNode) frame).getIntrinsifyAccessorsSpeculation());
b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.RuntimeConstraint, speculation));
return true;
}
b.addPush(JavaKind.Object, new AllowMaterializeNode(frame));
return true;
}
});
r.register(new RequiredInvocationPlugin("clear", Receiver.class, new ResolvedJavaSymbol(types.classFrameSlot)) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot) {
int frameSlotIndex = maybeGetConstantFrameSlotIndex(receiver, frameSlot, constantReflection, types);
if (frameSlotIndex >= 0) {
TruffleCompilerRuntime runtime = getRuntime();
b.add(new VirtualFrameClearNode(receiver, frameSlotIndex, runtime.getFrameSlotKindTagForJavaKind(JavaKind.Illegal), VirtualFrameAccessType.Legacy));
return true;
}
return false;
}
});
r.register(new RequiredInvocationPlugin("clear", Receiver.class, int.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot) {
int frameSlotIndex = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot);
if (frameSlotIndex >= 0) {
TruffleCompilerRuntime runtime = getRuntime();
b.add(new VirtualFrameClearNode(receiver, frameSlotIndex, runtime.getFrameSlotKindTagForJavaKind(JavaKind.Illegal), VirtualFrameAccessType.Indexed));
return true;
}
return false;
}
});
r.register(new RequiredInvocationPlugin("swap", Receiver.class, int.class, int.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot1, ValueNode frameSlot2) {
int frameSlot1Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot1);
int frameSlot2Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot2);
if (frameSlot1Index >= 0 && frameSlot2Index >= 0) {
b.add(new VirtualFrameSwapNode(receiver, frameSlot1Index, frameSlot2Index, VirtualFrameAccessType.Indexed));
return true;
}
return false;
}
});
r.register(new RequiredInvocationPlugin("copy", Receiver.class, int.class, int.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot1, ValueNode frameSlot2) {
int frameSlot1Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot1);
int frameSlot2Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot2);
if (frameSlot1Index >= 0 && frameSlot2Index >= 0) {
b.add(new VirtualFrameCopyNode(receiver, frameSlot1Index, frameSlot2Index, VirtualFrameAccessType.Indexed));
return true;
}
return false;
}
});
}
Aggregations