com.oracle.truffle.nfi.backend.panama.PanamaSignatureBuilderGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-nfi-panama Show documentation
Show all versions of truffle-nfi-panama Show documentation
Implementation of the Truffle NFI using CLinker from project panama.
The newest version!
// CheckStyle: start generated
package com.oracle.truffle.nfi.backend.panama;
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.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.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.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.ArgsState;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.CachedSignatureInfo;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.PanamaSignatureBuilder;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.PanamaSignatureBuilder.AddArgument;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.PanamaSignatureBuilder.Build;
import com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureBuilderLibrary;
import java.lang.invoke.MethodHandles;
@GeneratedBy(PanamaSignatureBuilder.class)
@SuppressWarnings("javadoc")
final class PanamaSignatureBuilderGen {
private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
static {
LibraryExport.register(PanamaSignatureBuilder.class, new NFIBackendSignatureBuilderLibraryExports());
}
private PanamaSignatureBuilderGen() {
}
@GeneratedBy(PanamaSignatureBuilder.class)
private static final class NFIBackendSignatureBuilderLibraryExports extends LibraryExport {
private NFIBackendSignatureBuilderLibraryExports() {
super(NFIBackendSignatureBuilderLibrary.class, PanamaSignatureBuilder.class, false, false, 0);
}
@Override
protected NFIBackendSignatureBuilderLibrary createUncached(Object receiver) {
assert receiver instanceof PanamaSignatureBuilder;
NFIBackendSignatureBuilderLibrary uncached = new Uncached();
return uncached;
}
@Override
protected NFIBackendSignatureBuilderLibrary createCached(Object receiver) {
assert receiver instanceof PanamaSignatureBuilder;
return new Cached();
}
@GeneratedBy(PanamaSignatureBuilder.class)
private static final class Cached extends NFIBackendSignatureBuilderLibrary {
static final ReferenceField ADD_ARGUMENT_CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "addArgument_cached_cache", AddArgumentCachedData.class);
static final ReferenceField BUILD_CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "build_cached_cache", BuildCachedData.class);
/**
* State Info:
* 0: SpecializationActive {@link AddArgument#doCached}
* 1: SpecializationActive {@link AddArgument#doGeneric}
* 2: SpecializationActive {@link Build#doCached}
* 3: SpecializationActive {@link Build#doGeneric}
*
*/
@CompilationFinal private int state_0_;
@UnsafeAccessedField @CompilationFinal private AddArgumentCachedData addArgument_cached_cache;
@UnsafeAccessedField @CompilationFinal private BuildCachedData build_cached_cache;
protected Cached() {
}
@Override
public boolean accepts(Object receiver) {
assert !(receiver instanceof PanamaSignatureBuilder) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof PanamaSignatureBuilder;
}
/**
* Debug Info:
* Specialization {@link AddArgument#doCached}
* Activation probability: 0.32500
* With/without class size: 11/12 bytes
* Specialization {@link AddArgument#doGeneric}
* Activation probability: 0.17500
* With/without class size: 6/0 bytes
*
*/
@Override
public void addArgument(Object arg0Value_, Object arg1Value) {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
PanamaSignatureBuilder arg0Value = ((PanamaSignatureBuilder) arg0Value_);
int state_0 = this.state_0_;
if ((state_0 & 0b11) != 0 /* is SpecializationActive[PanamaSignatureBuilder.AddArgument.doCached(PanamaSignatureBuilder, PanamaType, PanamaType, ArgsState, ArgsState)] || SpecializationActive[PanamaSignatureBuilder.AddArgument.doGeneric(PanamaSignatureBuilder, PanamaType)] */ && arg1Value instanceof PanamaType) {
PanamaType arg1Value_ = (PanamaType) arg1Value;
if ((state_0 & 0b1) != 0 /* is SpecializationActive[PanamaSignatureBuilder.AddArgument.doCached(PanamaSignatureBuilder, PanamaType, PanamaType, ArgsState, ArgsState)] */) {
AddArgumentCachedData s0_ = this.addArgument_cached_cache;
if (s0_ != null) {
if ((arg0Value.argsState == s0_.oldState_) && (arg1Value_ == s0_.cachedType_)) {
AddArgument.doCached(arg0Value, arg1Value_, s0_.cachedType_, s0_.oldState_, s0_.newState_);
return;
}
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[PanamaSignatureBuilder.AddArgument.doGeneric(PanamaSignatureBuilder, PanamaType)] */) {
AddArgument.doGeneric(arg0Value, arg1Value_);
return;
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
addArgumentAndSpecialize(arg0Value, arg1Value);
return;
}
private void addArgumentAndSpecialize(PanamaSignatureBuilder arg0Value, Object arg1Value) {
int state_0 = this.state_0_;
if (arg1Value instanceof PanamaType) {
PanamaType arg1Value_ = (PanamaType) arg1Value;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[PanamaSignatureBuilder.AddArgument.doGeneric(PanamaSignatureBuilder, PanamaType)] */) {
while (true) {
int count0_ = 0;
AddArgumentCachedData s0_ = ADD_ARGUMENT_CACHED_CACHE_UPDATER.getVolatile(this);
AddArgumentCachedData s0_original = s0_;
while (s0_ != null) {
if ((arg0Value.argsState == s0_.oldState_) && (arg1Value_ == s0_.cachedType_)) {
break;
}
count0_++;
s0_ = null;
break;
}
if (s0_ == null && count0_ < 1) {
// assert (arg0Value.argsState == s0_.oldState_);
// assert (arg1Value_ == s0_.cachedType_);
s0_ = new AddArgumentCachedData();
s0_.cachedType_ = (arg1Value_);
s0_.oldState_ = (arg0Value.argsState);
s0_.newState_ = (s0_.oldState_.addArg(s0_.cachedType_));
if (!ADD_ARGUMENT_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[PanamaSignatureBuilder.AddArgument.doCached(PanamaSignatureBuilder, PanamaType, PanamaType, ArgsState, ArgsState)] */;
this.state_0_ = state_0;
}
if (s0_ != null) {
AddArgument.doCached(arg0Value, arg1Value_, s0_.cachedType_, s0_.oldState_, s0_.newState_);
return;
}
break;
}
}
this.addArgument_cached_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[PanamaSignatureBuilder.AddArgument.doCached(PanamaSignatureBuilder, PanamaType, PanamaType, ArgsState, ArgsState)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[PanamaSignatureBuilder.AddArgument.doGeneric(PanamaSignatureBuilder, PanamaType)] */;
this.state_0_ = state_0;
AddArgument.doGeneric(arg0Value, arg1Value_);
return;
}
throw new UnsupportedSpecializationException(this, null, arg0Value, arg1Value);
}
/**
* Debug Info:
* Specialization {@link Build#doCached}
* Activation probability: 0.32500
* With/without class size: 13/12 bytes
* Specialization {@link Build#doGeneric}
* Activation probability: 0.17500
* With/without class size: 6/0 bytes
*
*/
@ExplodeLoop
@Override
public Object build(Object arg0Value_) {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
PanamaSignatureBuilder arg0Value = ((PanamaSignatureBuilder) arg0Value_);
int state_0 = this.state_0_;
if ((state_0 & 0b1100) != 0 /* is SpecializationActive[PanamaSignatureBuilder.Build.doCached(PanamaSignatureBuilder, PanamaType, ArgsState, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] || SpecializationActive[PanamaSignatureBuilder.Build.doGeneric(PanamaSignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) {
if ((state_0 & 0b100) != 0 /* is SpecializationActive[PanamaSignatureBuilder.Build.doCached(PanamaSignatureBuilder, PanamaType, ArgsState, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */) {
BuildCachedData s0_ = this.build_cached_cache;
while (s0_ != null) {
if ((arg0Value.argsState == s0_.cachedState_) && (arg0Value.retType == s0_.cachedRetType_)) {
NFIBackendSignatureBuilderLibrary self__ = (this);
return Build.doCached(arg0Value, s0_.cachedRetType_, s0_.cachedState_, self__, s0_.cachedSignatureInfo_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b1000) != 0 /* is SpecializationActive[PanamaSignatureBuilder.Build.doGeneric(PanamaSignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) {
{
NFIBackendSignatureBuilderLibrary self__1 = (this);
return Build.doGeneric(arg0Value, self__1);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return buildAndSpecialize(arg0Value);
}
private Object buildAndSpecialize(PanamaSignatureBuilder arg0Value) {
int state_0 = this.state_0_;
{
NFIBackendSignatureBuilderLibrary self__ = null;
if (((state_0 & 0b1000)) == 0 /* is-not SpecializationActive[PanamaSignatureBuilder.Build.doGeneric(PanamaSignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) {
while (true) {
int count0_ = 0;
BuildCachedData s0_ = BUILD_CACHED_CACHE_UPDATER.getVolatile(this);
BuildCachedData s0_original = s0_;
while (s0_ != null) {
if ((arg0Value.argsState == s0_.cachedState_) && (arg0Value.retType == s0_.cachedRetType_)) {
self__ = (this);
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (arg0Value.argsState == s0_.cachedState_);
// assert (arg0Value.retType == s0_.cachedRetType_);
if (count0_ < (3)) {
s0_ = new BuildCachedData(s0_original);
s0_.cachedRetType_ = (arg0Value.retType);
s0_.cachedState_ = (arg0Value.argsState);
self__ = (this);
s0_.cachedSignatureInfo_ = (PanamaSignature.prepareSignatureInfo(s0_.cachedRetType_, s0_.cachedState_));
if (!BUILD_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b100 /* add SpecializationActive[PanamaSignatureBuilder.Build.doCached(PanamaSignatureBuilder, PanamaType, ArgsState, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */;
this.state_0_ = state_0;
}
}
if (s0_ != null) {
return Build.doCached(arg0Value, s0_.cachedRetType_, s0_.cachedState_, self__, s0_.cachedSignatureInfo_);
}
break;
}
}
}
{
NFIBackendSignatureBuilderLibrary self__1 = null;
self__1 = (this);
this.build_cached_cache = null;
state_0 = state_0 & 0xfffffffb /* remove SpecializationActive[PanamaSignatureBuilder.Build.doCached(PanamaSignatureBuilder, PanamaType, ArgsState, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */;
state_0 = state_0 | 0b1000 /* add SpecializationActive[PanamaSignatureBuilder.Build.doGeneric(PanamaSignatureBuilder, NFIBackendSignatureBuilderLibrary)] */;
this.state_0_ = state_0;
return Build.doGeneric(arg0Value, self__1);
}
}
@Override
public void setReturnType(Object receiver, Object type) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
(((PanamaSignatureBuilder) receiver)).setReturnType(type);
return;
}
@Override
public void makeVarargs(Object receiver) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
(((PanamaSignatureBuilder) receiver)).makeVarargs();
return;
}
@GeneratedBy(PanamaSignatureBuilder.class)
@DenyReplace
private static final class AddArgumentCachedData implements SpecializationDataNode {
/**
* Source Info:
* Specialization: {@link AddArgument#doCached}
* Parameter: {@link PanamaType} cachedType
*/
@CompilationFinal PanamaType cachedType_;
/**
* Source Info:
* Specialization: {@link AddArgument#doCached}
* Parameter: {@link ArgsState} oldState
*/
@CompilationFinal ArgsState oldState_;
/**
* Source Info:
* Specialization: {@link AddArgument#doCached}
* Parameter: {@link ArgsState} newState
*/
@CompilationFinal ArgsState newState_;
AddArgumentCachedData() {
}
}
@GeneratedBy(PanamaSignatureBuilder.class)
@DenyReplace
private static final class BuildCachedData implements SpecializationDataNode {
@CompilationFinal final BuildCachedData next_;
/**
* Source Info:
* Specialization: {@link Build#doCached}
* Parameter: {@link PanamaType} cachedRetType
*/
@CompilationFinal PanamaType cachedRetType_;
/**
* Source Info:
* Specialization: {@link Build#doCached}
* Parameter: {@link ArgsState} cachedState
*/
@CompilationFinal ArgsState cachedState_;
/**
* Source Info:
* Specialization: {@link Build#doCached}
* Parameter: {@link CachedSignatureInfo} cachedSignatureInfo
*/
@CompilationFinal CachedSignatureInfo cachedSignatureInfo_;
BuildCachedData(BuildCachedData next_) {
this.next_ = next_;
}
}
}
@GeneratedBy(PanamaSignatureBuilder.class)
@DenyReplace
private static final class Uncached extends NFIBackendSignatureBuilderLibrary implements UnadoptableNode {
protected Uncached() {
}
@Override
@TruffleBoundary
public boolean accepts(Object receiver) {
assert !(receiver instanceof PanamaSignatureBuilder) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof PanamaSignatureBuilder;
}
@TruffleBoundary
@Override
public void addArgument(Object arg0Value_, Object arg1Value) {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
PanamaSignatureBuilder arg0Value = ((PanamaSignatureBuilder) arg0Value_);
if (arg1Value instanceof PanamaType) {
PanamaType arg1Value_ = (PanamaType) arg1Value;
AddArgument.doGeneric(arg0Value, arg1Value_);
return;
}
throw newUnsupportedSpecializationException2(this, arg0Value, arg1Value);
}
@TruffleBoundary
@Override
public Object build(Object arg0Value_) {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
PanamaSignatureBuilder arg0Value = ((PanamaSignatureBuilder) arg0Value_);
return Build.doGeneric(arg0Value, (this));
}
@TruffleBoundary
@Override
public void setReturnType(Object receiver, Object type) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
((PanamaSignatureBuilder) receiver) .setReturnType(type);
return;
}
@TruffleBoundary
@Override
public void makeVarargs(Object receiver) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
((PanamaSignatureBuilder) receiver) .makeVarargs();
return;
}
@TruffleBoundary
private static UnsupportedSpecializationException newUnsupportedSpecializationException2(Node thisNode_, Object arg0Value, Object arg1Value) {
return new UnsupportedSpecializationException(thisNode_, null, arg0Value, arg1Value);
}
}
}
}