use of org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameGetNode in project graal by oracle.
the class TruffleGraphBuilderPlugins method registerFrameAccessors.
/**
* We intrinsify the getXxx, setXxx, and isXxx methods for all type tags. The intrinsic nodes
* are lightweight fixed nodes without a {@link FrameState}. No {@link FrameState} is important
* for partial evaluation performance, because creating and later on discarding FrameStates for
* the setXxx methods have a high compile time cost.
*
* Intrinsification requires the following conditions: (1) the accessed frame is directly the
* {@link NewFrameNode}, (2) the accessed FrameSlot is a constant, and (3) the FrameDescriptor
* was never materialized before. All three conditions together guarantee that the escape
* analysis can virtualize the access. The condition (3) is necessary because a possible
* materialization of the frame can prevent escape analysis - so in that case a FrameState for
* setXxx methods is actually necessary since they stores can be state-changing memory
* operations.
*
* Note that we do not register an intrinsification for {@code FrameWithoutBoxing.getValue()}.
* It is a complicated method to intrinsify, and it is not used frequently enough to justify the
* complexity of an intrinsification.
*/
private static void registerFrameAccessors(Registration r, JavaKind accessKind, ConstantReflectionProvider constantReflection, KnownTruffleTypes types) {
TruffleCompilerRuntime runtime = TruffleCompilerRuntime.getRuntime();
int accessTag = runtime.getFrameSlotKindTagForJavaKind(accessKind);
String nameSuffix = accessKind.name();
ResolvedJavaSymbol frameSlotType = new ResolvedJavaSymbol(types.classFrameSlot);
r.register2("get" + nameSuffix, Receiver.class, frameSlotType, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frameNode, ValueNode frameSlotNode) {
int frameSlotIndex = maybeGetConstantFrameSlotIndex(frameNode, frameSlotNode, constantReflection, types);
if (frameSlotIndex >= 0) {
b.addPush(accessKind, new VirtualFrameGetNode(frameNode, frameSlotIndex, accessKind, accessTag));
return true;
}
return false;
}
});
r.register3("set" + nameSuffix, Receiver.class, frameSlotType, accessKind == JavaKind.Object ? Object.class : accessKind.toJavaClass(), new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frameNode, ValueNode frameSlotNode, ValueNode value) {
int frameSlotIndex = maybeGetConstantFrameSlotIndex(frameNode, frameSlotNode, constantReflection, types);
if (frameSlotIndex >= 0) {
b.add(new VirtualFrameSetNode(frameNode, frameSlotIndex, accessTag, value));
return true;
}
return false;
}
});
r.register2("is" + nameSuffix, Receiver.class, frameSlotType, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frameNode, ValueNode frameSlotNode) {
int frameSlotIndex = maybeGetConstantFrameSlotIndex(frameNode, frameSlotNode, constantReflection, types);
if (frameSlotIndex >= 0) {
b.addPush(JavaKind.Boolean, new VirtualFrameIsNode(frameNode, frameSlotIndex, accessTag));
return true;
}
return false;
}
});
}
Aggregations