Skip to content

Commit

Permalink
Drop executeWithReceiverAndArguments()
Browse files Browse the repository at this point in the history
This reduces the amount of generated code by ~15k SLOC and the overall binary size by ~5MB.
  • Loading branch information
fniephaus committed May 31, 2022
1 parent 72b9f4a commit d516181
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,17 @@ protected static final Object[] doArrayOfDoubles(final ArrayObject obj,
}
}

@GenerateUncached
public abstract static class ArrayObjectToObjectArrayWithFirstNode extends AbstractNode {

public static ArrayObjectToObjectArrayWithFirstNode create() {
return ArrayObjectToObjectArrayWithFirstNodeGen.create();
}

public static ArrayObjectToObjectArrayWithFirstNode getUncached() {
return ArrayObjectToObjectArrayWithFirstNodeGen.getUncached();
}

public abstract Object[] execute(Object first, ArrayObject obj);

@Specialization(guards = "obj.isObjectType()")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public abstract class AbstractPrimitiveNode extends AbstractNode {

public abstract Object executeWithArguments(VirtualFrame frame, Object... receiverAndArguments);

public abstract Object executeWithReceiverAndArguments(VirtualFrame frame, Object receiver, Object... arguments);

public boolean acceptsMethod(@SuppressWarnings("unused") final CompiledCodeObject method) {
CompilerAsserts.neverPartOfCompilation();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public final Object executeWithArguments(final VirtualFrame frame, final Object.
return execute();
}

@Override
public final Object executeWithReceiverAndArguments(final VirtualFrame frame, final Object receiver, final Object... arguments) {
return execute();
}

@Override
public Object execute(final VirtualFrame frame) {
return execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import de.hpi.swa.trufflesqueak.nodes.accessing.AbstractPointersObjectNodes.AbstractPointersObjectWriteNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.ArrayObjectNodes.ArrayObjectReadNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.ArrayObjectNodes.ArrayObjectSizeNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.ArrayObjectNodes.ArrayObjectToObjectArrayCopyNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.ArrayObjectNodes.ArrayObjectToObjectArrayWithFirstNode;
import de.hpi.swa.trufflesqueak.nodes.accessing.SqueakObjectAt0Node;
import de.hpi.swa.trufflesqueak.nodes.accessing.SqueakObjectChangeClassOfToNode;
Expand Down Expand Up @@ -664,8 +663,8 @@ protected static final AbstractPrimitiveNode createPrimitiveNode(final long prim
}

protected static final Object primitiveWithArgs(final VirtualFrame frame, final Object receiver, final ArrayObject argumentArray,
final AbstractPrimitiveNode primitiveNode, final ArrayObjectToObjectArrayCopyNode toObjectArrayNode) {
return primitiveNode.executeWithReceiverAndArguments(frame, receiver, toObjectArrayNode.execute(argumentArray));
final AbstractPrimitiveNode primitiveNode, final ArrayObjectToObjectArrayWithFirstNode toObjectArrayNode) {
return primitiveNode.executeWithArguments(frame, toObjectArrayNode.execute(receiver, argumentArray));
}

protected final Object primitiveWithArgs(final VirtualFrame frame, final Object receiver, final long primitiveIndex, final ArrayObject argumentArray) {
Expand All @@ -676,8 +675,8 @@ protected final Object primitiveWithArgs(final VirtualFrame frame, final Object
if (primitiveNode == null) {
throw PrimitiveFailed.GENERIC_ERROR;
} else {
final Object[] arguments = ArrayObjectToObjectArrayCopyNode.getUncached().execute(argumentArray);
return primitiveNode.executeWithReceiverAndArguments(frame, receiver, arguments);
final Object[] receiverAndArguments = ArrayObjectToObjectArrayWithFirstNode.getUncached().execute(receiver, argumentArray);
return primitiveNode.executeWithArguments(frame, receiverAndArguments);
}
}
}
Expand All @@ -691,7 +690,7 @@ protected static final Object doPrimitiveWithArgsCached(final VirtualFrame frame
@SuppressWarnings("unused") @Cached final ArrayObjectSizeNode sizeNode,
@SuppressWarnings("unused") @Cached("sizeNode.execute(argumentArray)") final int cachedArraySize,
@Cached("createPrimitiveNode(cachedPrimitiveIndex, cachedArraySize)") final AbstractPrimitiveNode primitiveNode,
@Cached final ArrayObjectToObjectArrayCopyNode toObjectArrayNode) {
@Cached final ArrayObjectToObjectArrayWithFirstNode toObjectArrayNode) {
return primitiveWithArgs(frame, receiver, argumentArray, primitiveNode, toObjectArrayNode);
}

Expand All @@ -711,7 +710,7 @@ protected static final Object doPrimitiveWithArgsContextCached(final VirtualFram
@SuppressWarnings("unused") @Cached final ArrayObjectSizeNode sizeNode,
@SuppressWarnings("unused") @Cached("sizeNode.execute(argumentArray)") final int cachedArraySize,
@Cached("createPrimitiveNode(cachedPrimitiveIndex, cachedArraySize)") final AbstractPrimitiveNode primitiveNode,
@Cached final ArrayObjectToObjectArrayCopyNode toObjectArrayNode) {
@Cached final ArrayObjectToObjectArrayWithFirstNode toObjectArrayNode) {
return primitiveWithArgs(frame, receiver, argumentArray, primitiveNode, toObjectArrayNode);
}

Expand Down Expand Up @@ -1140,8 +1139,8 @@ protected static final Object doNamedPrimitiveWithArgsContextCached(final Virtua
@SuppressWarnings("unused") @Cached final ArrayObjectSizeNode sizeNode,
@SuppressWarnings("unused") @Cached("sizeNode.execute(argumentArray)") final int cachedArraySize,
@Cached("createPrimitiveNode(methodObject)") final AbstractPrimitiveNode primitiveNode,
@Cached final ArrayObjectToObjectArrayCopyNode toObjectArrayNode) {
return primitiveNode.executeWithReceiverAndArguments(frame, target, toObjectArrayNode.execute(argumentArray));
@Cached final ArrayObjectToObjectArrayWithFirstNode toObjectArrayNode) {
return primitiveNode.executeWithArguments(frame, toObjectArrayNode.execute(target, argumentArray));
}

@Specialization(replaces = "doNamedPrimitiveWithArgsContextCached")
Expand All @@ -1155,8 +1154,8 @@ protected final Object doNamedPrimitiveWithArgsContext(final VirtualFrame frame,
if (primitiveNode == null) {
throw PrimitiveFailed.GENERIC_ERROR;
} else {
final Object[] arguments = ArrayObjectToObjectArrayCopyNode.getUncached().execute(argumentArray);
return primitiveNode.executeWithReceiverAndArguments(frame, target, arguments);
final Object[] receiverAndArguments = ArrayObjectToObjectArrayWithFirstNode.getUncached().execute(target, argumentArray);
return primitiveNode.executeWithArguments(frame, receiverAndArguments);
}
}

Expand Down

1 comment on commit d516181

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance Report (d516181)

Benchmarks ran on graalvm-ce-java17-22.1.0.

Steady (after 50 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 175 191 176.28 176 176.27 35256 0.59
DeltaBlue 286 440 396.77 406 395.55 79353 1.32
Havlak 1558 1646 1587.55 1586 1587.48 317510 5.29
Json 723 735 727.76 728 727.76 145552 2.43
List 902 909 903.77 903 903.76 180753 3.01
Mandelbrot 144 149 145.16 145 145.15 29031 0.48
NBody 275 285 277.85 277 277.84 55569 0.93
Permute 231 259 232.62 232 232.6 46523 0.78
Queens 255 266 256.82 257 256.81 51363 0.86
Richards 1078 1086 1082.01 1082 1082 216401 3.61
Sieve 210 219 211.34 211 211.34 42268 0.7
Storage 270 276 272.47 273 272.46 54494 0.91
Towers 391 402 392.6 392 392.59 78519 1.31
6498 6863 6662.96 6668 6661.62 1332592 22.21

d516181-2-steady.svg

Warmup (first 50 iterations)

d516181-3-warmup.svg

Please sign in to comment.