org.truffleruby.cext.WrapperFunctionGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ruby-language Show documentation
Show all versions of ruby-language Show documentation
Core module of Ruby on Truffle
The newest version!
// CheckStyle: start generated
package org.truffleruby.cext;
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.interop.ArityException;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
import com.oracle.truffle.api.library.LibraryExport;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import java.lang.invoke.VarHandle;
import java.util.Objects;
import org.truffleruby.cext.ValueWrapperManager.WrapperFunction;
@GeneratedBy(WrapperFunction.class)
@SuppressWarnings("javadoc")
final class WrapperFunctionGen {
private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
static {
LibraryExport.register(WrapperFunction.class, new InteropLibraryExports());
}
private WrapperFunctionGen() {
}
@GeneratedBy(WrapperFunction.class)
private static final class InteropLibraryExports extends LibraryExport {
private InteropLibraryExports() {
super(InteropLibrary.class, WrapperFunction.class, false, false, 0);
}
@Override
protected InteropLibrary createUncached(Object receiver) {
assert receiver instanceof WrapperFunction;
InteropLibrary uncached = new Uncached();
return uncached;
}
@Override
protected InteropLibrary createCached(Object receiver) {
assert receiver instanceof WrapperFunction;
return new Cached();
}
@GeneratedBy(WrapperFunction.class)
private static final class Cached extends InteropLibrary {
/**
* State Info:
* 0: SpecializationActive {@link WrapperFunction#execute(WrapperFunction, Object[], WrapNode)}
*
*/
@CompilationFinal private int state_0_;
/**
* Source Info:
* Specialization: {@link WrapperFunction#execute(WrapperFunction, Object[], WrapNode)}
* Parameter: {@link WrapNode} wrapNode
*/
@Child private WrapNode wrapNode_;
protected Cached() {
}
@Override
public boolean accepts(Object receiver) {
assert !(receiver instanceof WrapperFunction) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof WrapperFunction;
}
@Override
public boolean isExecutable(Object receiver) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
return (((WrapperFunction) receiver)).isExecutable();
}
/**
* Debug Info:
* Specialization {@link WrapperFunction#execute(WrapperFunction, Object[], WrapNode)}
* Activation probability: 1.00000
* With/without class size: 24/4 bytes
*
*/
@Override
public Object execute(Object arg0Value_, Object... arg1Value) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
WrapperFunction arg0Value = ((WrapperFunction) arg0Value_);
int state_0 = this.state_0_;
if (state_0 != 0 /* is SpecializationActive[WrapperFunction.execute(WrapperFunction, Object[], WrapNode)] */) {
{
WrapNode wrapNode__ = this.wrapNode_;
if (wrapNode__ != null) {
return arg0Value.execute(arg1Value, wrapNode__);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value);
}
private ValueWrapper executeAndSpecialize(WrapperFunction arg0Value, Object[] arg1Value) {
int state_0 = this.state_0_;
WrapNode wrapNode__ = this.insert((WrapNode.create()));
Objects.requireNonNull(wrapNode__, "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.");
VarHandle.storeStoreFence();
this.wrapNode_ = wrapNode__;
state_0 = state_0 | 0b1 /* add SpecializationActive[WrapperFunction.execute(WrapperFunction, Object[], WrapNode)] */;
this.state_0_ = state_0;
return arg0Value.execute(arg1Value, wrapNode__);
}
}
@GeneratedBy(WrapperFunction.class)
@DenyReplace
private static final class Uncached extends InteropLibrary implements UnadoptableNode {
protected Uncached() {
}
@Override
@TruffleBoundary
public boolean accepts(Object receiver) {
assert !(receiver instanceof WrapperFunction) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof WrapperFunction;
}
@TruffleBoundary
@Override
public boolean isExecutable(Object receiver) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((WrapperFunction) receiver) .isExecutable();
}
@TruffleBoundary
@Override
public Object execute(Object arg0Value_, Object... arg1Value) {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
WrapperFunction arg0Value = ((WrapperFunction) arg0Value_);
return arg0Value.execute(arg1Value, (WrapNodeGen.getUncached()));
}
}
}
}