com.oracle.truffle.sl.builtins.SLIsExecutableBuiltinFactory 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.CompilerDirectives.TruffleBoundary;
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.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.interop.InteropLibrary;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import java.lang.invoke.MethodHandles;
import java.util.List;
import java.util.Objects;
@GeneratedBy(SLIsExecutableBuiltin.class)
@SuppressWarnings({"javadoc", "unused"})
public final class SLIsExecutableBuiltinFactory implements NodeFactory {
private static final SLIsExecutableBuiltinFactory INSTANCE = new SLIsExecutableBuiltinFactory();
private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);
private SLIsExecutableBuiltinFactory() {
}
@Override
public Class getNodeClass() {
return SLIsExecutableBuiltin.class;
}
@Override
public List> getExecutionSignature() {
return List.of(SLExpressionNode.class);
}
@Override
public List>> getNodeSignatures() {
return List.of(List.of(SLExpressionNode[].class));
}
@Override
public SLIsExecutableBuiltin 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 SLIsExecutableBuiltin create(SLExpressionNode[] arguments) {
return new SLIsExecutableBuiltinNodeGen(arguments);
}
/**
* Debug Info:
* Specialization {@link SLIsExecutableBuiltin#isExecutable}
* Activation probability: 0.65000
* With/without class size: 19/4 bytes
* Specialization {@link SLIsExecutableBuiltin#isExecutable}
* Activation probability: 0.35000
* With/without class size: 8/0 bytes
*
*/
@GeneratedBy(SLIsExecutableBuiltin.class)
@SuppressWarnings("javadoc")
public static final class SLIsExecutableBuiltinNodeGen extends SLIsExecutableBuiltin {
static final ReferenceField IS_EXECUTABLE0_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "isExecutable0_cache", IsExecutable0Data.class);
@Child private SLExpressionNode arguments0_;
/**
* State Info:
* 0: SpecializationActive {@link SLIsExecutableBuiltin#isExecutable}
* 1: SpecializationActive {@link SLIsExecutableBuiltin#isExecutable}
*
*/
@CompilationFinal private int state_0_;
@UnsafeAccessedField @Child private IsExecutable0Data isExecutable0_cache;
private SLIsExecutableBuiltinNodeGen(SLExpressionNode[] arguments) {
this.arguments0_ = arguments != null && 0 < arguments.length ? arguments[0] : null;
}
@ExplodeLoop
@Override
protected Object execute(VirtualFrame frameValue) {
int state_0 = this.state_0_;
Object arguments0Value_ = this.arguments0_.executeGeneric(frameValue);
if (state_0 != 0 /* is SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] || SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */) {
if ((state_0 & 0b1) != 0 /* is SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */) {
IsExecutable0Data s0_ = this.isExecutable0_cache;
while (s0_ != null) {
if ((s0_.executables_.accepts(arguments0Value_))) {
return isExecutable(arguments0Value_, s0_.executables_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */) {
return this.isExecutable1Boundary(state_0, arguments0Value_);
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arguments0Value_);
}
@SuppressWarnings("static-method")
@TruffleBoundary
private Object isExecutable1Boundary(int state_0, Object arguments0Value_) {
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
{
InteropLibrary executables__ = (INTEROP_LIBRARY_.getUncached(arguments0Value_));
return isExecutable(arguments0Value_, executables__);
}
} finally {
encapsulating_.set(prev_);
}
}
private boolean executeAndSpecialize(Object arguments0Value) {
int state_0 = this.state_0_;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */) {
while (true) {
int count0_ = 0;
IsExecutable0Data s0_ = IS_EXECUTABLE0_CACHE_UPDATER.getVolatile(this);
IsExecutable0Data s0_original = s0_;
while (s0_ != null) {
if ((s0_.executables_.accepts(arguments0Value))) {
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (s0_.executables_.accepts(arguments0Value));
if (count0_ < (3)) {
s0_ = this.insert(new IsExecutable0Data(s0_original));
InteropLibrary executables__ = s0_.insert((INTEROP_LIBRARY_.create(arguments0Value)));
Objects.requireNonNull(executables__, "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_.executables_ = executables__;
if (!IS_EXECUTABLE0_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */;
this.state_0_ = state_0;
}
}
if (s0_ != null) {
return isExecutable(arguments0Value, s0_.executables_);
}
break;
}
}
{
InteropLibrary executables__ = null;
{
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
executables__ = (INTEROP_LIBRARY_.getUncached(arguments0Value));
this.isExecutable0_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[SLIsExecutableBuiltin.isExecutable(Object, InteropLibrary)] */;
this.state_0_ = state_0;
return isExecutable(arguments0Value, executables__);
} finally {
encapsulating_.set(prev_);
}
}
}
}
@GeneratedBy(SLIsExecutableBuiltin.class)
@DenyReplace
private static final class IsExecutable0Data extends Node implements SpecializationDataNode {
@Child IsExecutable0Data next_;
/**
* Source Info:
* Specialization: {@link SLIsExecutableBuiltin#isExecutable}
* Parameter: {@link InteropLibrary} executables
*/
@Child InteropLibrary executables_;
IsExecutable0Data(IsExecutable0Data next_) {
this.next_ = next_;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy