com.oracle.truffle.sl.builtins.SLEvalBuiltinFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-sl Show documentation
Show all versions of truffle-sl Show documentation
Truffle SL is an example language implemented using the Truffle API.
The newest version!
// CheckStyle: start generated
package com.oracle.truffle.sl.builtins;
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.dsl.NeverDefault;
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.dsl.DSLSupport.SpecializationDataNode;
import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField;
import com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.strings.TruffleString;
import com.oracle.truffle.api.strings.TruffleString.EqualNode;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.Objects;
@GeneratedBy(SLEvalBuiltin.class)
@SuppressWarnings("javadoc")
public final class SLEvalBuiltinFactory implements NodeFactory {
private static final SLEvalBuiltinFactory INSTANCE = new SLEvalBuiltinFactory();
private SLEvalBuiltinFactory() {
}
@Override
public Class getNodeClass() {
return SLEvalBuiltin.class;
}
@Override
public List> getExecutionSignature() {
return List.of(SLExpressionNode.class, SLExpressionNode.class);
}
@Override
public List>> getNodeSignatures() {
return List.of(List.of(SLExpressionNode[].class));
}
@Override
public SLEvalBuiltin createNode(Object... arguments) {
if (arguments.length == 1 && (arguments[0] == null || arguments[0] instanceof SLExpressionNode[])) {
return create((SLExpressionNode[]) arguments[0]);
} else {
throw new IllegalArgumentException("Invalid create signature.");
}
}
public static NodeFactory getInstance() {
return INSTANCE;
}
@NeverDefault
public static SLEvalBuiltin create(SLExpressionNode[] arguments) {
return new SLEvalBuiltinNodeGen(arguments);
}
/**
* Debug Info:
* Specialization {@link SLEvalBuiltin#evalCached}
* Activation probability: 0.65000
* With/without class size: 30/20 bytes
* Specialization {@link SLEvalBuiltin#evalGeneric}
* Activation probability: 0.35000
* With/without class size: 8/0 bytes
*
*/
@GeneratedBy(SLEvalBuiltin.class)
@SuppressWarnings("javadoc")
public static final class SLEvalBuiltinNodeGen extends SLEvalBuiltin {
static final ReferenceField EVAL_CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "evalCached_cache", EvalCachedData.class);
@Child private SLExpressionNode arguments0_;
@Child private SLExpressionNode arguments1_;
/**
* State Info:
* 0: SpecializationActive {@link SLEvalBuiltin#evalCached}
* 1: SpecializationActive {@link SLEvalBuiltin#evalGeneric}
*
*/
@CompilationFinal private int state_0_;
@UnsafeAccessedField @Child private EvalCachedData evalCached_cache;
private SLEvalBuiltinNodeGen(SLExpressionNode[] arguments) {
this.arguments0_ = arguments != null && 0 < arguments.length ? arguments[0] : null;
this.arguments1_ = arguments != null && 1 < arguments.length ? arguments[1] : null;
}
@ExplodeLoop
@Override
protected Object execute(VirtualFrame frameValue) {
int state_0 = this.state_0_;
Object arguments0Value_ = this.arguments0_.executeGeneric(frameValue);
Object arguments1Value_ = this.arguments1_.executeGeneric(frameValue);
if (state_0 != 0 /* is SpecializationActive[SLEvalBuiltin.evalCached(TruffleString, TruffleString, TruffleString, TruffleString, DirectCallNode, EqualNode, EqualNode)] || SpecializationActive[SLEvalBuiltin.evalGeneric(TruffleString, TruffleString)] */ && arguments0Value_ instanceof TruffleString) {
TruffleString arguments0Value__ = (TruffleString) arguments0Value_;
if (arguments1Value_ instanceof TruffleString) {
TruffleString arguments1Value__ = (TruffleString) arguments1Value_;
if ((state_0 & 0b1) != 0 /* is SpecializationActive[SLEvalBuiltin.evalCached(TruffleString, TruffleString, TruffleString, TruffleString, DirectCallNode, EqualNode, EqualNode)] */) {
EvalCachedData s0_ = this.evalCached_cache;
while (s0_ != null) {
if ((SLEvalBuiltin.stringsEqual(s0_.equalNodeId_, s0_.cachedId_, arguments0Value__)) && (SLEvalBuiltin.stringsEqual(s0_.equalNodeCode_, s0_.cachedCode_, arguments1Value__))) {
return evalCached(arguments0Value__, arguments1Value__, s0_.cachedId_, s0_.cachedCode_, s0_.callNode_, s0_.equalNodeId_, s0_.equalNodeCode_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[SLEvalBuiltin.evalGeneric(TruffleString, TruffleString)] */) {
return evalGeneric(arguments0Value__, arguments1Value__);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arguments0Value_, arguments1Value_);
}
@SuppressWarnings("unused")
private Object executeAndSpecialize(Object arguments0Value, Object arguments1Value) {
int state_0 = this.state_0_;
if (arguments0Value instanceof TruffleString) {
TruffleString arguments0Value_ = (TruffleString) arguments0Value;
if (arguments1Value instanceof TruffleString) {
TruffleString arguments1Value_ = (TruffleString) arguments1Value;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[SLEvalBuiltin.evalGeneric(TruffleString, TruffleString)] */) {
while (true) {
int count0_ = 0;
EvalCachedData s0_ = EVAL_CACHED_CACHE_UPDATER.getVolatile(this);
EvalCachedData s0_original = s0_;
while (s0_ != null) {
if ((SLEvalBuiltin.stringsEqual(s0_.equalNodeId_, s0_.cachedId_, arguments0Value_)) && (SLEvalBuiltin.stringsEqual(s0_.equalNodeCode_, s0_.cachedCode_, arguments1Value_))) {
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
{
TruffleString cachedId__ = (arguments0Value_);
EqualNode equalNodeId__ = this.insert((EqualNode.create()));
if ((SLEvalBuiltin.stringsEqual(equalNodeId__, cachedId__, arguments0Value_))) {
TruffleString cachedCode__ = (arguments1Value_);
EqualNode equalNodeCode__ = this.insert((EqualNode.create()));
if ((SLEvalBuiltin.stringsEqual(equalNodeCode__, cachedCode__, arguments1Value_)) && count0_ < (SLEvalBuiltin.LIMIT)) {
s0_ = this.insert(new EvalCachedData(s0_original));
s0_.cachedId_ = cachedId__;
s0_.cachedCode_ = cachedCode__;
s0_.callNode_ = s0_.insert((DirectCallNode.create(parse(arguments0Value_, arguments1Value_))));
Objects.requireNonNull(s0_.insert(equalNodeId__), "A specialization cache returned a default value. The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns the default value.");
s0_.equalNodeId_ = equalNodeId__;
Objects.requireNonNull(s0_.insert(equalNodeCode__), "A specialization cache returned a default value. The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns the default value.");
s0_.equalNodeCode_ = equalNodeCode__;
if (!EVAL_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[SLEvalBuiltin.evalCached(TruffleString, TruffleString, TruffleString, TruffleString, DirectCallNode, EqualNode, EqualNode)] */;
this.state_0_ = state_0;
}
}
}
}
if (s0_ != null) {
return evalCached(arguments0Value_, arguments1Value_, s0_.cachedId_, s0_.cachedCode_, s0_.callNode_, s0_.equalNodeId_, s0_.equalNodeCode_);
}
break;
}
}
this.evalCached_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[SLEvalBuiltin.evalCached(TruffleString, TruffleString, TruffleString, TruffleString, DirectCallNode, EqualNode, EqualNode)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[SLEvalBuiltin.evalGeneric(TruffleString, TruffleString)] */;
this.state_0_ = state_0;
return evalGeneric(arguments0Value_, arguments1Value_);
}
}
throw new UnsupportedSpecializationException(this, new Node[] {this.arguments0_, this.arguments1_}, arguments0Value, arguments1Value);
}
@GeneratedBy(SLEvalBuiltin.class)
@DenyReplace
private static final class EvalCachedData extends Node implements SpecializationDataNode {
@Child EvalCachedData next_;
/**
* Source Info:
* Specialization: {@link SLEvalBuiltin#evalCached}
* Parameter: {@link TruffleString} cachedId
*/
@CompilationFinal TruffleString cachedId_;
/**
* Source Info:
* Specialization: {@link SLEvalBuiltin#evalCached}
* Parameter: {@link TruffleString} cachedCode
*/
@CompilationFinal TruffleString cachedCode_;
/**
* Source Info:
* Specialization: {@link SLEvalBuiltin#evalCached}
* Parameter: {@link DirectCallNode} callNode
*/
@Child DirectCallNode callNode_;
/**
* Source Info:
* Specialization: {@link SLEvalBuiltin#evalCached}
* Parameter: {@link EqualNode} equalNodeId
*/
@Child EqualNode equalNodeId_;
/**
* Source Info:
* Specialization: {@link SLEvalBuiltin#evalCached}
* Parameter: {@link EqualNode} equalNodeCode
*/
@Child EqualNode equalNodeCode_;
EvalCachedData(EvalCachedData next_) {
this.next_ = next_;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy