From 6b17dc92e4cdc42c092eb4a2cd237778661c1751 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 3 Mar 2021 09:58:22 +0100 Subject: [PATCH] Turn HandlePrimitiveFailedNoopNode into singleton --- .../nodes/HandlePrimitiveFailedNode.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/HandlePrimitiveFailedNode.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/HandlePrimitiveFailedNode.java index 6dbfd7a37..3585a59aa 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/HandlePrimitiveFailedNode.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/HandlePrimitiveFailedNode.java @@ -10,6 +10,7 @@ import com.oracle.truffle.api.dsl.CachedContext; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeInfo; @@ -21,13 +22,12 @@ import de.hpi.swa.trufflesqueak.nodes.accessing.ArrayObjectNodes.ArrayObjectSizeNode; import de.hpi.swa.trufflesqueak.nodes.context.frame.FrameStackPushNode; -@NodeInfo(cost = NodeCost.NONE) public abstract class HandlePrimitiveFailedNode extends AbstractNode { public static HandlePrimitiveFailedNode create(final CompiledCodeObject code) { if (code.hasStoreIntoTemp1AfterCallPrimitive()) { return HandlePrimitiveFailedImplNodeGen.create(); } else { - return new HandlePrimitiveFailedNoopNode(); + return HandlePrimitiveFailedNoopNode.SINGLETON; } } @@ -57,10 +57,28 @@ protected static final void doHandleRawValue(final VirtualFrame frame, final int } } + @NodeInfo(cost = NodeCost.NONE) private static final class HandlePrimitiveFailedNoopNode extends HandlePrimitiveFailedNode { + private static final HandlePrimitiveFailedNoopNode SINGLETON = new HandlePrimitiveFailedNoopNode(); + @Override public void executeHandle(final VirtualFrame frame, final int reasonCode) { // nothing to do } + + @Override + public boolean isAdoptable() { + return false; + } + + @Override + public Node copy() { + return SINGLETON; + } + + @Override + public Node deepCopy() { + return SINGLETON; + } } }