-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to eliminate the generated code for the additional abstract `AbstractPrimitiveNode#execute(VirtualFrame)` method for each primitive.
- Loading branch information
Showing
13 changed files
with
109 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...wa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/DispatchPrimitiveNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024 Software Architecture Group, Hasso Plattner Institute | ||
* Copyright (c) 2024 Oracle and/or its affiliates | ||
* | ||
* Licensed under the MIT License. | ||
*/ | ||
package de.hpi.swa.trufflesqueak.nodes.primitives; | ||
|
||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import com.oracle.truffle.api.nodes.ExplodeLoop; | ||
|
||
import de.hpi.swa.trufflesqueak.nodes.AbstractNode; | ||
import de.hpi.swa.trufflesqueak.nodes.context.ArgumentNodes.AbstractArgumentNode; | ||
import de.hpi.swa.trufflesqueak.nodes.primitives.PrimitiveNodeFactory.ArgumentsLocation; | ||
|
||
public final class DispatchPrimitiveNode extends AbstractNode { | ||
@Child protected AbstractPrimitiveNode primitiveNode; | ||
@Children protected AbstractArgumentNode[] argumentNodes; | ||
|
||
private DispatchPrimitiveNode(final AbstractPrimitiveNode primitiveNode, final AbstractArgumentNode[] argumentNodes) { | ||
this.primitiveNode = primitiveNode; | ||
this.argumentNodes = argumentNodes; | ||
} | ||
|
||
public static DispatchPrimitiveNode create(final AbstractPrimitiveNode primitiveNode, final ArgumentsLocation location, final int numReceiverAndArguments) { | ||
return new DispatchPrimitiveNode(primitiveNode, createArgumentNodes(location, numReceiverAndArguments)); | ||
} | ||
|
||
private static AbstractArgumentNode[] createArgumentNodes(final ArgumentsLocation location, final int numReceiverAndArguments) { | ||
final AbstractArgumentNode[] argumentNodes = new AbstractArgumentNode[numReceiverAndArguments]; | ||
final boolean useStack = location == ArgumentsLocation.ON_STACK || location == ArgumentsLocation.ON_STACK_REVERSED; | ||
final int offset = location == ArgumentsLocation.ON_STACK_REVERSED ? numReceiverAndArguments : 0; | ||
for (int i = 0; i < numReceiverAndArguments; i++) { | ||
argumentNodes[i] = AbstractArgumentNode.create(i - offset, useStack); | ||
} | ||
return argumentNodes; | ||
} | ||
|
||
@ExplodeLoop | ||
public Object execute(final VirtualFrame frame) { | ||
final int numArguments = argumentNodes.length; | ||
final Object[] arguments = new Object[numArguments]; | ||
for (int i = 0; i < numArguments; i++) { | ||
arguments[i] = argumentNodes[i].execute(frame); | ||
} | ||
return primitiveNode.executeWithArguments(frame, arguments); | ||
} | ||
} |
Oops, something went wrong.
e711ba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance Report (e711ba7)
Benchmarks ran on
22.0.2-graal
.Steady (after 100 iterations)
Warmup (first 100 iterations)
e711ba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance Report (e711ba7)
Benchmarks ran on
22.0.2-graal
.Steady (after 100 iterations)
Warmup (first 100 iterations)