Generated Files (listings for https://norswap.com/truffle-tutorial/)
// CheckStyle: start generated | |
package exni.nodes; | |
import com.oracle.truffle.api.CompilerDirectives; | |
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; | |
import com.oracle.truffle.api.dsl.GeneratedBy; | |
import com.oracle.truffle.api.frame.VirtualFrame; | |
import com.oracle.truffle.api.nodes.NodeCost; | |
import exni.nodes.AddNode; | |
import exni.nodes.ExniNode; | |
@GeneratedBy(AddNode.class) | |
public final class AddNodeGen extends AddNode { | |
@Child private ExniNode left_; | |
@Child private ExniNode right_; | |
@CompilationFinal private int state_; | |
private AddNodeGen(ExniNode left, ExniNode right) { | |
this.left_ = left; | |
this.right_ = right; | |
} | |
@Override | |
public Object execute(VirtualFrame frameValue) { | |
int state = state_; | |
Object leftValue_ = this.left_.execute(frameValue); | |
Object rightValue_ = this.right_.execute(frameValue); | |
if ((state & 0b1) != 0 /* is-active addLongs(long, long) */ && leftValue_ instanceof Long) { | |
long leftValue__ = (long) leftValue_; | |
if (rightValue_ instanceof Long) { | |
long rightValue__ = (long) rightValue_; | |
return addLongs(leftValue__, rightValue__); | |
} | |
} | |
if ((state & 0b10) != 0 /* is-active addStrings(String, String) */ && leftValue_ instanceof String) { | |
String leftValue__ = (String) leftValue_; | |
if (rightValue_ instanceof String) { | |
String rightValue__ = (String) rightValue_; | |
return addStrings(leftValue__, rightValue__); | |
} | |
} | |
CompilerDirectives.transferToInterpreterAndInvalidate(); | |
return executeAndSpecialize(leftValue_, rightValue_); | |
} | |
private Object executeAndSpecialize(Object leftValue, Object rightValue) { | |
int state = state_; | |
if (leftValue instanceof Long) { | |
long leftValue_ = (long) leftValue; | |
if (rightValue instanceof Long) { | |
long rightValue_ = (long) rightValue; | |
this.state_ = state = state | 0b1 /* add-active addLongs(long, long) */; | |
return addLongs(leftValue_, rightValue_); | |
} | |
} | |
if (leftValue instanceof String) { | |
String leftValue_ = (String) leftValue; | |
if (rightValue instanceof String) { | |
String rightValue_ = (String) rightValue; | |
this.state_ = state = state | 0b10 /* add-active addStrings(String, String) */; | |
return addStrings(leftValue_, rightValue_); | |
} | |
} | |
this.state_ = state = state | 0b100 /* add-active typeError(Object, Object) */; | |
typeError(leftValue, rightValue); | |
return null; | |
} | |
@Override | |
public NodeCost getCost() { | |
int state = state_; | |
if (state == 0b0) { | |
return NodeCost.UNINITIALIZED; | |
} else if ((state & (state - 1)) == 0 /* is-single-active */) { | |
return NodeCost.MONOMORPHIC; | |
} | |
return NodeCost.POLYMORPHIC; | |
} | |
private static boolean fallbackGuard_(int state, Object leftValue, Object rightValue) { | |
if (((state & 0b1)) == 0 /* is-not-active addLongs(long, long) */ && leftValue instanceof Long && rightValue instanceof Long) { | |
return false; | |
} | |
if (((state & 0b10)) == 0 /* is-not-active addStrings(String, String) */ && leftValue instanceof String && rightValue instanceof String) { | |
return false; | |
} | |
return true; | |
} | |
public static AddNode create(ExniNode left, ExniNode right) { | |
return new AddNodeGen(left, right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment