
com.oracle.truffle.nfi.backend.libffi.LibFFISignatureGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-nfi-libffi Show documentation
Show all versions of truffle-nfi-libffi Show documentation
Implementation of the Truffle NFI using libffi.
The newest version!
// CheckStyle: start generated
package com.oracle.truffle.nfi.backend.libffi;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GenerateAOT;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.DSLSupport.SpecializationDataNode;
import com.oracle.truffle.api.dsl.InlineSupport.InlineTarget;
import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField;
import com.oracle.truffle.api.dsl.InlineSupport.StateField;
import com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField;
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.library.provider.EagerExportProvider;
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.api.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
import com.oracle.truffle.nfi.backend.libffi.LibFFIClosure.MonomorphicClosureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFIClosure.PolymorphicClosureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CachedSignatureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.Call;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CreateClosure;
import com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureLibrary;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.Objects;
import java.util.concurrent.locks.ReentrantLock;
@GeneratedBy(LibFFISignature.class)
@SuppressWarnings({"javadoc", "unused"})
public final class LibFFISignatureGen {
private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);
static {
LibraryExport.register(LibFFISignature.class, new NFIBackendSignatureLibraryExports());
}
private LibFFISignatureGen() {
}
private static void init() {
// This method is intended to ensure class initialization.
}
@GeneratedBy(LibFFISignature.class)
public static final class NFIBackendSignatureLibraryEagerProvider implements EagerExportProvider {
@Override
public void ensureRegistered() {
LibFFISignatureGen.init();
}
@Override
public String getLibraryClassName() {
return "com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureLibrary";
}
}
@GeneratedBy(LibFFISignature.class)
private static final class NFIBackendSignatureLibraryExports extends LibraryExport {
private NFIBackendSignatureLibraryExports() {
super(NFIBackendSignatureLibrary.class, LibFFISignature.class, false, true, 1);
}
@Override
protected NFIBackendSignatureLibrary createUncached(Object receiver) {
assert receiver instanceof LibFFISignature;
NFIBackendSignatureLibrary uncached = new Uncached();
return uncached;
}
@Override
protected NFIBackendSignatureLibrary createCached(Object receiver) {
assert receiver instanceof LibFFISignature || receiver instanceof LibraryExport>;
return new Cached();
}
@GeneratedBy(LibFFISignature.class)
private static final class Cached extends NFIBackendSignatureLibrary implements GenerateAOT.Provider {
private static final StateField STATE_0_Call_UPDATER = StateField.create(MethodHandles.lookup(), "state_0_");
private static final StateField CALL_GENERIC0__CALL_CALL_GENERIC0_STATE_0_UPDATER = StateField.create(CallCallGeneric0Data.lookup_(), "callGeneric0_state_0_");
private static final StateField CALL_GENERIC1__CALL_CALL_GENERIC1_STATE_0_UPDATER = StateField.create(CallCallGeneric1Data.lookup_(), "callGeneric1_state_0_");
static final ReferenceField CALL_CALL_GENERIC0_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "call_callGeneric0_cache", CallCallGeneric0Data.class);
/**
* Source Info:
* Specialization: {@link Call#callLibFFI}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*/
private static final FunctionExecuteNode INLINED_CALL_CALL_LIB_F_F_I_FUNCTION_EXECUTE_ = FunctionExecuteNodeGen.inline(InlineTarget.create(FunctionExecuteNode.class, STATE_0_Call_UPDATER.subUpdater(7, 3), ReferenceField.create(MethodHandles.lookup(), "call_callLibFFI_functionExecute__field1_", Node.class), ReferenceField.create(MethodHandles.lookup(), "call_callLibFFI_functionExecute__field2_", Node.class)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} isExecutable
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC0_IS_EXECUTABLE_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC0__CALL_CALL_GENERIC0_STATE_0_UPDATER.subUpdater(0, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} toNative
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC0_TO_NATIVE_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC0__CALL_CALL_GENERIC0_STATE_0_UPDATER.subUpdater(1, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} error
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC0_ERROR_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC0__CALL_CALL_GENERIC0_STATE_0_UPDATER.subUpdater(2, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*/
private static final FunctionExecuteNode INLINED_CALL_CALL_GENERIC0_FUNCTION_EXECUTE_ = FunctionExecuteNodeGen.inline(InlineTarget.create(FunctionExecuteNode.class, CALL_GENERIC0__CALL_CALL_GENERIC0_STATE_0_UPDATER.subUpdater(3, 3), ReferenceField.create(CallCallGeneric0Data.lookup_(), "call_callGeneric0_functionExecute__field1_", Node.class), ReferenceField.create(CallCallGeneric0Data.lookup_(), "call_callGeneric0_functionExecute__field2_", Node.class)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} isExecutable
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC1_IS_EXECUTABLE_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC1__CALL_CALL_GENERIC1_STATE_0_UPDATER.subUpdater(0, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} toNative
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC1_TO_NATIVE_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC1__CALL_CALL_GENERIC1_STATE_0_UPDATER.subUpdater(1, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} error
* Inline method: {@link InlinedBranchProfile#inline}
*/
private static final InlinedBranchProfile INLINED_CALL_CALL_GENERIC1_ERROR_ = InlinedBranchProfile.inline(InlineTarget.create(InlinedBranchProfile.class, CALL_GENERIC1__CALL_CALL_GENERIC1_STATE_0_UPDATER.subUpdater(2, 1)));
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*/
private static final FunctionExecuteNode INLINED_CALL_CALL_GENERIC1_FUNCTION_EXECUTE_ = FunctionExecuteNodeGen.inline(InlineTarget.create(FunctionExecuteNode.class, CALL_GENERIC1__CALL_CALL_GENERIC1_STATE_0_UPDATER.subUpdater(3, 3), ReferenceField.create(CallCallGeneric1Data.lookup_(), "call_callGeneric1_functionExecute__field1_", Node.class), ReferenceField.create(CallCallGeneric1Data.lookup_(), "call_callGeneric1_functionExecute__field2_", Node.class)));
static final ReferenceField CREATE_CLOSURE_CACHED_EXECUTABLE_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "createClosure_cachedExecutable_cache", CreateClosureCachedExecutableData.class);
static final ReferenceField CREATE_CLOSURE_CACHED_SIGNATURE_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "createClosure_cachedSignature_cache", CreateClosureCachedSignatureData.class);
/**
* State Info:
* 0: AOTPrepared
* 1: SpecializationActive {@link Call#callLibFFI}
* 2: SpecializationActive {@link Call#callGeneric}
* 3: SpecializationActive {@link Call#callGeneric}
* 4: SpecializationActive {@link CreateClosure#doCachedExecutable}
* 5: SpecializationActive {@link CreateClosure#doCachedSignature}
* 6: SpecializationActive {@link CreateClosure#createClosure}
* 7-9: InlinedCache
* Specialization: {@link Call#callLibFFI}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int state_0_;
/**
* Source Info:
* Specialization: {@link Call#callLibFFI}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callLibFFI_functionExecute__field1_;
/**
* Source Info:
* Specialization: {@link Call#callLibFFI}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field2
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callLibFFI_functionExecute__field2_;
@UnsafeAccessedField @Child private CallCallGeneric0Data call_callGeneric0_cache;
@Child private CallCallGeneric1Data call_callGeneric1_cache;
@UnsafeAccessedField @CompilationFinal private CreateClosureCachedExecutableData createClosure_cachedExecutable_cache;
@UnsafeAccessedField @CompilationFinal private CreateClosureCachedSignatureData createClosure_cachedSignature_cache;
protected Cached() {
}
@Override
public boolean accepts(Object receiver) {
assert !(receiver instanceof LibFFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof LibFFISignature;
}
/**
* Debug Info:
* Specialization {@link Call#callLibFFI}
* Activation probability: 0.24167
* With/without class size: 10/9 bytes
* Specialization {@link Call#callGeneric}
* Activation probability: 0.16667
* With/without class size: 10/13 bytes
* Specialization {@link Call#callGeneric}
* Activation probability: 0.09167
* With/without class size: 6/9 bytes
*
*/
@ExplodeLoop
@Override
public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
int state_0 = this.state_0_;
if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is AOTPrepared */) {
return callAndSpecialize(arg0Value, arg1Value, arg2Value);
}
if ((state_0 & 0b1110) != 0 /* is SpecializationActive[LibFFISignature.Call.callLibFFI(LibFFISignature, LibFFISymbol, Object[], Node, FunctionExecuteNode)] || SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] || SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */) {
if ((state_0 & 0b10) != 0 /* is SpecializationActive[LibFFISignature.Call.callLibFFI(LibFFISignature, LibFFISymbol, Object[], Node, FunctionExecuteNode)] */ && arg1Value instanceof LibFFISymbol) {
LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
{
Node node__ = (this);
return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, node__, INLINED_CALL_CALL_LIB_F_F_I_FUNCTION_EXECUTE_);
}
}
if ((state_0 & 0b1100) != 0 /* is SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] || SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */) {
if ((state_0 & 0b100) != 0 /* is SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */) {
CallCallGeneric0Data s1_ = this.call_callGeneric0_cache;
while (s1_ != null) {
if ((s1_.interop_.accepts(arg1Value))) {
Node node__1 = (s1_);
return Call.callGeneric(arg0Value, arg1Value, arg2Value, s1_.interop_, node__1, INLINED_CALL_CALL_GENERIC0_IS_EXECUTABLE_, INLINED_CALL_CALL_GENERIC0_TO_NATIVE_, INLINED_CALL_CALL_GENERIC0_ERROR_, INLINED_CALL_CALL_GENERIC0_FUNCTION_EXECUTE_);
}
s1_ = s1_.next_;
}
}
if ((state_0 & 0b1000) != 0 /* is SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */) {
CallCallGeneric1Data s2_ = this.call_callGeneric1_cache;
if (s2_ != null) {
return this.call_CallGeneric1Boundary(state_0, s2_, arg0Value, arg1Value, arg2Value);
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return callAndSpecialize(arg0Value, arg1Value, arg2Value);
}
@SuppressWarnings("static-method")
@TruffleBoundary
private Object call_CallGeneric1Boundary(int state_0, CallCallGeneric1Data s2_, LibFFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
{
InteropLibrary interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
Node node__1 = (s2_);
return Call.callGeneric(arg0Value, arg1Value, arg2Value, interop__, node__1, INLINED_CALL_CALL_GENERIC1_IS_EXECUTABLE_, INLINED_CALL_CALL_GENERIC1_TO_NATIVE_, INLINED_CALL_CALL_GENERIC1_ERROR_, INLINED_CALL_CALL_GENERIC1_FUNCTION_EXECUTE_);
}
} finally {
encapsulating_.set(prev_);
}
}
private Object callAndSpecialize(LibFFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException {
int state_0 = this.state_0_;
if ((state_0 & 0b1) != 0 /* is AOTPrepared */) {
this.resetAOT_();
state_0 = this.state_0_;
}
{
Node node__ = null;
if (arg1Value instanceof LibFFISymbol) {
LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
node__ = (this);
state_0 = state_0 | 0b10 /* add SpecializationActive[LibFFISignature.Call.callLibFFI(LibFFISignature, LibFFISymbol, Object[], Node, FunctionExecuteNode)] */;
this.state_0_ = state_0;
return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, node__, INLINED_CALL_CALL_LIB_F_F_I_FUNCTION_EXECUTE_);
}
}
{
Node node__1 = null;
if (((state_0 & 0b1000)) == 0 /* is-not SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */) {
while (true) {
int count1_ = 0;
CallCallGeneric0Data s1_ = CALL_CALL_GENERIC0_CACHE_UPDATER.getVolatile(this);
CallCallGeneric0Data s1_original = s1_;
while (s1_ != null) {
if ((s1_.interop_.accepts(arg1Value))) {
node__1 = (s1_);
break;
}
count1_++;
s1_ = s1_.next_;
}
if (s1_ == null) {
// assert (s1_.interop_.accepts(arg1Value));
if (count1_ < (3)) {
s1_ = this.insert(new CallCallGeneric0Data(s1_original));
InteropLibrary interop__ = s1_.insert((INTEROP_LIBRARY_.create(arg1Value)));
Objects.requireNonNull(interop__, "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.");
s1_.interop_ = interop__;
node__1 = (s1_);
if (!CALL_CALL_GENERIC0_CACHE_UPDATER.compareAndSet(this, s1_original, s1_)) {
continue;
}
state_0 = state_0 | 0b100 /* add SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */;
this.state_0_ = state_0;
}
}
if (s1_ != null) {
return Call.callGeneric(arg0Value, arg1Value, arg2Value, s1_.interop_, node__1, INLINED_CALL_CALL_GENERIC0_IS_EXECUTABLE_, INLINED_CALL_CALL_GENERIC0_TO_NATIVE_, INLINED_CALL_CALL_GENERIC0_ERROR_, INLINED_CALL_CALL_GENERIC0_FUNCTION_EXECUTE_);
}
break;
}
}
}
{
Node node__1 = null;
InteropLibrary interop__ = null;
{
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
CallCallGeneric1Data s2_ = this.insert(new CallCallGeneric1Data());
interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
node__1 = (s2_);
VarHandle.storeStoreFence();
this.call_callGeneric1_cache = s2_;
this.call_callGeneric0_cache = null;
state_0 = state_0 & 0xfffffffb /* remove SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */;
state_0 = state_0 | 0b1000 /* add SpecializationActive[LibFFISignature.Call.callGeneric(LibFFISignature, Object, Object[], InteropLibrary, Node, InlinedBranchProfile, InlinedBranchProfile, InlinedBranchProfile, FunctionExecuteNode)] */;
this.state_0_ = state_0;
return Call.callGeneric(arg0Value, arg1Value, arg2Value, interop__, node__1, INLINED_CALL_CALL_GENERIC1_IS_EXECUTABLE_, INLINED_CALL_CALL_GENERIC1_TO_NATIVE_, INLINED_CALL_CALL_GENERIC1_ERROR_, INLINED_CALL_CALL_GENERIC1_FUNCTION_EXECUTE_);
} finally {
encapsulating_.set(prev_);
}
}
}
}
@Override
public void prepareForAOT(TruffleLanguage> language, RootNode root) {
assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
if ((state_0_ & 0b1) != 0 /* is AOTPrepared */) {
return;
}
{
assert NodeUtil.assertRecursion(INLINED_CALL_CALL_LIB_F_F_I_FUNCTION_EXECUTE_, 1);
((GenerateAOT.Provider) INLINED_CALL_CALL_LIB_F_F_I_FUNCTION_EXECUTE_).prepareForAOT(language, root, this);
this.state_0_ = state_0_ | 0b10 /* add SpecializationActive[LibFFISignature.Call.callLibFFI(LibFFISignature, LibFFISymbol, Object[], Node, FunctionExecuteNode)] */;
}
{
this.state_0_ = state_0_ | 0b1000000 /* add SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */;
}
int state_0 = this.state_0_;
state_0 = state_0 | 0b1 /* add AOTPrepared */;
this.state_0_ = state_0;
}
private void resetAOT_() {
int state_0 = this.state_0_;
if (((state_0 & 0b1)) == 0 /* is-not AOTPrepared */) {
return;
}
this.state_0_ = 0;
}
/**
* Debug Info:
* Specialization {@link CreateClosure#doCachedExecutable}
* Activation probability: 0.24167
* With/without class size: 10/12 bytes
* Specialization {@link CreateClosure#doCachedSignature}
* Activation probability: 0.16667
* With/without class size: 8/8 bytes
* Specialization {@link CreateClosure#createClosure}
* Activation probability: 0.09167
* With/without class size: 5/0 bytes
*
*/
@ExplodeLoop
@Override
public Object createClosure(Object arg0Value_, Object arg1Value) {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted(this);
LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
int state_0 = this.state_0_;
if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is AOTPrepared */) {
return createClosureAndSpecialize(arg0Value, arg1Value);
}
if ((state_0 & 0b1110000) != 0 /* is SpecializationActive[LibFFISignature.CreateClosure.doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo)] || SpecializationActive[LibFFISignature.CreateClosure.doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo)] || SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */) {
if ((state_0 & 0b10000) != 0 /* is SpecializationActive[LibFFISignature.CreateClosure.doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo)] */) {
CreateClosureCachedExecutableData s0_ = this.createClosure_cachedExecutable_cache;
while (s0_ != null) {
if (!Assumption.isValidAssumption(s0_.assumption0_)) {
CompilerDirectives.transferToInterpreterAndInvalidate();
removeCachedExecutable_(s0_);
return createClosureAndSpecialize(arg0Value, arg1Value);
}
if ((arg0Value.signatureInfo == s0_.cachedSignatureInfo_) && (arg1Value == s0_.cachedExecutable_)) {
NFIBackendSignatureLibrary self__ = (this);
return CreateClosure.doCachedExecutable(arg0Value, arg1Value, s0_.cachedSignatureInfo_, s0_.cachedExecutable_, self__, s0_.cachedClosureInfo_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b100000) != 0 /* is SpecializationActive[LibFFISignature.CreateClosure.doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo)] */) {
CreateClosureCachedSignatureData s1_ = this.createClosure_cachedSignature_cache;
while (s1_ != null) {
if ((arg0Value.signatureInfo == s1_.cachedSignatureInfo_)) {
NFIBackendSignatureLibrary self__1 = (this);
return CreateClosure.doCachedSignature(arg0Value, arg1Value, s1_.cachedSignatureInfo_, self__1, s1_.cachedClosureInfo_);
}
s1_ = s1_.next_;
}
}
if ((state_0 & 0b1000000) != 0 /* is SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */) {
{
NFIBackendSignatureLibrary self__2 = (this);
return CreateClosure.createClosure(arg0Value, arg1Value, self__2);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return createClosureAndSpecialize(arg0Value, arg1Value);
}
private LibFFIClosure createClosureAndSpecialize(LibFFISignature arg0Value, Object arg1Value) {
int state_0 = this.state_0_;
if ((state_0 & 0b1) != 0 /* is AOTPrepared */) {
this.resetAOT_();
state_0 = this.state_0_;
}
{
NFIBackendSignatureLibrary self__ = null;
if (((state_0 & 0b1100000)) == 0 /* is-not SpecializationActive[LibFFISignature.CreateClosure.doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo)] && SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */) {
while (true) {
int count0_ = 0;
CreateClosureCachedExecutableData s0_ = CREATE_CLOSURE_CACHED_EXECUTABLE_CACHE_UPDATER.getVolatile(this);
CreateClosureCachedExecutableData s0_original = s0_;
while (s0_ != null) {
if ((arg0Value.signatureInfo == s0_.cachedSignatureInfo_) && (arg1Value == s0_.cachedExecutable_) && Assumption.isValidAssumption(s0_.assumption0_)) {
self__ = (this);
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (arg0Value.signatureInfo == s0_.cachedSignatureInfo_);
// assert (arg1Value == s0_.cachedExecutable_);
{
Assumption assumption0 = (LibFFILanguage.getSingleContextAssumption());
if (Assumption.isValidAssumption(assumption0)) {
if (count0_ < (3)) {
s0_ = new CreateClosureCachedExecutableData(s0_original);
s0_.cachedSignatureInfo_ = (arg0Value.signatureInfo);
s0_.cachedExecutable_ = (arg1Value);
self__ = (this);
s0_.cachedClosureInfo_ = (MonomorphicClosureInfo.create(s0_.cachedSignatureInfo_, s0_.cachedExecutable_));
s0_.assumption0_ = assumption0;
if (!CREATE_CLOSURE_CACHED_EXECUTABLE_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b10000 /* add SpecializationActive[LibFFISignature.CreateClosure.doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo)] */;
this.state_0_ = state_0;
}
}
}
}
if (s0_ != null) {
return CreateClosure.doCachedExecutable(arg0Value, arg1Value, s0_.cachedSignatureInfo_, s0_.cachedExecutable_, self__, s0_.cachedClosureInfo_);
}
break;
}
}
}
{
NFIBackendSignatureLibrary self__1 = null;
if (((state_0 & 0b1000000)) == 0 /* is-not SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */) {
while (true) {
int count1_ = 0;
CreateClosureCachedSignatureData s1_ = CREATE_CLOSURE_CACHED_SIGNATURE_CACHE_UPDATER.getVolatile(this);
CreateClosureCachedSignatureData s1_original = s1_;
while (s1_ != null) {
if ((arg0Value.signatureInfo == s1_.cachedSignatureInfo_)) {
self__1 = (this);
break;
}
count1_++;
s1_ = s1_.next_;
}
if (s1_ == null) {
// assert (arg0Value.signatureInfo == s1_.cachedSignatureInfo_);
if (count1_ < (3)) {
s1_ = new CreateClosureCachedSignatureData(s1_original);
s1_.cachedSignatureInfo_ = (arg0Value.signatureInfo);
self__1 = (this);
s1_.cachedClosureInfo_ = (PolymorphicClosureInfo.create(s1_.cachedSignatureInfo_));
if (!CREATE_CLOSURE_CACHED_SIGNATURE_CACHE_UPDATER.compareAndSet(this, s1_original, s1_)) {
continue;
}
this.createClosure_cachedExecutable_cache = null;
state_0 = state_0 & 0xffffffef /* remove SpecializationActive[LibFFISignature.CreateClosure.doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo)] */;
state_0 = state_0 | 0b100000 /* add SpecializationActive[LibFFISignature.CreateClosure.doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo)] */;
this.state_0_ = state_0;
}
}
if (s1_ != null) {
return CreateClosure.doCachedSignature(arg0Value, arg1Value, s1_.cachedSignatureInfo_, self__1, s1_.cachedClosureInfo_);
}
break;
}
}
}
{
NFIBackendSignatureLibrary self__2 = null;
self__2 = (this);
this.createClosure_cachedExecutable_cache = null;
this.createClosure_cachedSignature_cache = null;
state_0 = state_0 & 0xffffffcf /* remove SpecializationActive[LibFFISignature.CreateClosure.doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo)], SpecializationActive[LibFFISignature.CreateClosure.doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo)] */;
state_0 = state_0 | 0b1000000 /* add SpecializationActive[LibFFISignature.CreateClosure.createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary)] */;
this.state_0_ = state_0;
return CreateClosure.createClosure(arg0Value, arg1Value, self__2);
}
}
void removeCachedExecutable_(CreateClosureCachedExecutableData s0_) {
while (true) {
CreateClosureCachedExecutableData cur = this.createClosure_cachedExecutable_cache;
CreateClosureCachedExecutableData original = cur;
CreateClosureCachedExecutableData update = null;
while (cur != null) {
if (cur == s0_) {
if (cur == original) {
update = cur.next_;
} else {
update = original.remove(s0_);
}
break;
}
cur = cur.next_;
}
if (cur != null && !CREATE_CLOSURE_CACHED_EXECUTABLE_CACHE_UPDATER.compareAndSet(this, original, update)) {
continue;
}
break;
}
}
@GeneratedBy(LibFFISignature.class)
@DenyReplace
private static final class CallCallGeneric0Data extends Node implements SpecializationDataNode {
@Child CallCallGeneric0Data next_;
/**
* State Info:
* 0: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} isExecutable
* Inline method: {@link InlinedBranchProfile#inline}
* 1: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} toNative
* Inline method: {@link InlinedBranchProfile#inline}
* 2: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} error
* Inline method: {@link InlinedBranchProfile#inline}
* 3-5: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int callGeneric0_state_0_;
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InteropLibrary} interop
*/
@Child InteropLibrary interop_;
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callGeneric0_functionExecute__field1_;
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field2
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callGeneric0_functionExecute__field2_;
CallCallGeneric0Data(CallCallGeneric0Data next_) {
this.next_ = next_;
}
private static Lookup lookup_() {
return MethodHandles.lookup();
}
}
@GeneratedBy(LibFFISignature.class)
@DenyReplace
private static final class CallCallGeneric1Data extends Node implements SpecializationDataNode {
/**
* State Info:
* 0: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} isExecutable
* Inline method: {@link InlinedBranchProfile#inline}
* 1: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} toNative
* Inline method: {@link InlinedBranchProfile#inline}
* 2: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link InlinedBranchProfile} error
* Inline method: {@link InlinedBranchProfile#inline}
* 3-5: InlinedCache
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int callGeneric1_state_0_;
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callGeneric1_functionExecute__field1_;
/**
* Source Info:
* Specialization: {@link Call#callGeneric}
* Parameter: {@link FunctionExecuteNode} functionExecute
* Inline method: {@link FunctionExecuteNodeGen#inline}
* Inline field: {@link Node} field2
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node call_callGeneric1_functionExecute__field2_;
CallCallGeneric1Data() {
}
private static Lookup lookup_() {
return MethodHandles.lookup();
}
}
@GeneratedBy(LibFFISignature.class)
@DenyReplace
private static final class CreateClosureCachedExecutableData implements SpecializationDataNode {
@CompilationFinal final CreateClosureCachedExecutableData next_;
/**
* Source Info:
* Specialization: {@link CreateClosure#doCachedExecutable}
* Parameter: {@link CachedSignatureInfo} cachedSignatureInfo
*/
@CompilationFinal CachedSignatureInfo cachedSignatureInfo_;
/**
* Source Info:
* Specialization: {@link CreateClosure#doCachedExecutable}
* Parameter: {@link Object} cachedExecutable
*/
@CompilationFinal Object cachedExecutable_;
/**
* Source Info:
* Specialization: {@link CreateClosure#doCachedExecutable}
* Parameter: {@link MonomorphicClosureInfo} cachedClosureInfo
*/
@CompilationFinal MonomorphicClosureInfo cachedClosureInfo_;
@CompilationFinal Assumption assumption0_;
CreateClosureCachedExecutableData(CreateClosureCachedExecutableData next_) {
this.next_ = next_;
}
CreateClosureCachedExecutableData remove(CreateClosureCachedExecutableData search) {
CreateClosureCachedExecutableData newNext = this.next_;
if (newNext != null) {
if (search == newNext) {
newNext = newNext.next_;
} else {
newNext = newNext.remove(search);
}
}
CreateClosureCachedExecutableData copy = new CreateClosureCachedExecutableData(newNext);
copy.cachedSignatureInfo_ = this.cachedSignatureInfo_;
copy.cachedExecutable_ = this.cachedExecutable_;
copy.cachedClosureInfo_ = this.cachedClosureInfo_;
copy.assumption0_ = this.assumption0_;
return copy;
}
}
@GeneratedBy(LibFFISignature.class)
@DenyReplace
private static final class CreateClosureCachedSignatureData implements SpecializationDataNode {
@CompilationFinal final CreateClosureCachedSignatureData next_;
/**
* Source Info:
* Specialization: {@link CreateClosure#doCachedSignature}
* Parameter: {@link CachedSignatureInfo} cachedSignatureInfo
*/
@CompilationFinal CachedSignatureInfo cachedSignatureInfo_;
/**
* Source Info:
* Specialization: {@link CreateClosure#doCachedSignature}
* Parameter: {@link PolymorphicClosureInfo} cachedClosureInfo
*/
@CompilationFinal PolymorphicClosureInfo cachedClosureInfo_;
CreateClosureCachedSignatureData(CreateClosureCachedSignatureData next_) {
this.next_ = next_;
}
}
}
@GeneratedBy(LibFFISignature.class)
@DenyReplace
private static final class Uncached extends NFIBackendSignatureLibrary implements UnadoptableNode {
protected Uncached() {
}
@Override
@TruffleBoundary
public boolean accepts(Object receiver) {
assert !(receiver instanceof LibFFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof LibFFISignature;
}
@TruffleBoundary
@Override
public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
if (arg1Value instanceof LibFFISymbol) {
LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, (this), (FunctionExecuteNodeGen.getUncached()));
}
return Call.callGeneric(arg0Value, arg1Value, arg2Value, (INTEROP_LIBRARY_.getUncached(arg1Value)), (this), (InlinedBranchProfile.getUncached()), (InlinedBranchProfile.getUncached()), (InlinedBranchProfile.getUncached()), (FunctionExecuteNodeGen.getUncached()));
}
@TruffleBoundary
@Override
public Object createClosure(Object arg0Value_, Object arg1Value) {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
return CreateClosure.createClosure(arg0Value, arg1Value, (this));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy