All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.truffle.nfi.backend.libffi.SignatureBuilderGen Maven / Gradle / Ivy

// CheckStyle: start generated
package com.oracle.truffle.nfi.backend.libffi;

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.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.NodeCost;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.ArgsState;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CachedSignatureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.SignatureBuilder;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.SignatureBuilder.AddArgument;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.SignatureBuilder.Build;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.SignatureBuilder.SetReturnType;
import com.oracle.truffle.nfi.backend.libffi.LibFFIType.CachedTypeInfo;
import com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureBuilderLibrary;
import java.lang.invoke.MethodHandles;

@GeneratedBy(SignatureBuilder.class)
@SuppressWarnings("javadoc")
final class SignatureBuilderGen {

    private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);

    static  {
        LibraryExport.register(SignatureBuilder.class, new NFIBackendSignatureBuilderLibraryExports());
    }

    private SignatureBuilderGen() {
    }

    @GeneratedBy(SignatureBuilder.class)
    private static final class NFIBackendSignatureBuilderLibraryExports extends LibraryExport {

        private NFIBackendSignatureBuilderLibraryExports() {
            super(NFIBackendSignatureBuilderLibrary.class, SignatureBuilder.class, false, false, 0);
        }

        @Override
        protected NFIBackendSignatureBuilderLibrary createUncached(Object receiver) {
            assert receiver instanceof SignatureBuilder;
            NFIBackendSignatureBuilderLibrary uncached = new Uncached();
            return uncached;
        }

        @Override
        protected NFIBackendSignatureBuilderLibrary createCached(Object receiver) {
            assert receiver instanceof SignatureBuilder;
            return new Cached();
        }

        @GeneratedBy(SignatureBuilder.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 SetReturnType#doSet}
             *   1: SpecializationActive {@link AddArgument#doCached}
             *   2: SpecializationActive {@link AddArgument#doGeneric}
             *   3: SpecializationActive {@link Build#doCached}
             *   4: 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 SignatureBuilder) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected."; return receiver instanceof SignatureBuilder; } /** * Debug Info:
             *   Specialization {@link SetReturnType#doSet}
             *     Activation probability: 0.33333
             *     With/without class size: 8/0 bytes
             * 
*/ @Override public void setReturnType(Object arg0Value_, Object arg1Value) { assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); int state_0 = this.state_0_; if ((state_0 & 0b1) != 0 /* is SpecializationActive[SignatureBuilder.SetReturnType.doSet(SignatureBuilder, LibFFIType)] */ && arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; SetReturnType.doSet(arg0Value, arg1Value_); return; } CompilerDirectives.transferToInterpreterAndInvalidate(); setReturnTypeAndSpecialize(arg0Value, arg1Value); return; } private void setReturnTypeAndSpecialize(SignatureBuilder arg0Value, Object arg1Value) { int state_0 = this.state_0_; if (arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; state_0 = state_0 | 0b1 /* add SpecializationActive[SignatureBuilder.SetReturnType.doSet(SignatureBuilder, LibFFIType)] */; this.state_0_ = state_0; SetReturnType.doSet(arg0Value, arg1Value_); return; } throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value); } @Override public NodeCost getCost() { int state_0 = this.state_0_; if ((state_0 & 0b1) == 0) { return NodeCost.UNINITIALIZED; } else { return NodeCost.MONOMORPHIC; } } /** * Debug Info:
             *   Specialization {@link AddArgument#doCached}
             *     Activation probability: 0.21667
             *     With/without class size: 10/12 bytes
             *   Specialization {@link AddArgument#doGeneric}
             *     Activation probability: 0.11667
             *     With/without class size: 5/0 bytes
             * 
*/ @ExplodeLoop @Override public void addArgument(Object arg0Value_, Object arg1Value) { assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); int state_0 = this.state_0_; if ((state_0 & 0b110) != 0 /* is SpecializationActive[SignatureBuilder.AddArgument.doCached(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary, LibFFIType, ArgsState, CachedTypeInfo, ArgsState)] || SpecializationActive[SignatureBuilder.AddArgument.doGeneric(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary)] */ && arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; if ((state_0 & 0b10) != 0 /* is SpecializationActive[SignatureBuilder.AddArgument.doCached(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary, LibFFIType, ArgsState, CachedTypeInfo, ArgsState)] */) { AddArgumentCachedData s0_ = this.addArgument_cached_cache; while (s0_ != null) { if ((arg0Value.state == s0_.oldState_)) { NFIBackendSignatureBuilderLibrary self__ = (this); LibFFIType promotedType__ = (arg0Value.maybePromote(self__, arg1Value_)); if ((AddArgument.isSame(promotedType__.typeInfo, s0_.cachedTypeInfo_))) { AddArgument.doCached(arg0Value, arg1Value_, self__, promotedType__, s0_.oldState_, s0_.cachedTypeInfo_, s0_.newState_); return; } } s0_ = s0_.next_; } } if ((state_0 & 0b100) != 0 /* is SpecializationActive[SignatureBuilder.AddArgument.doGeneric(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary)] */) { { NFIBackendSignatureBuilderLibrary self__1 = (this); AddArgument.doGeneric(arg0Value, arg1Value_, self__1); return; } } } CompilerDirectives.transferToInterpreterAndInvalidate(); addArgumentAndSpecialize(arg0Value, arg1Value); return; } private void addArgumentAndSpecialize(SignatureBuilder arg0Value, Object arg1Value) { int state_0 = this.state_0_; if (arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; { LibFFIType promotedType__ = null; NFIBackendSignatureBuilderLibrary self__ = null; if (((state_0 & 0b100)) == 0 /* is-not SpecializationActive[SignatureBuilder.AddArgument.doGeneric(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary)] */) { while (true) { int count0_ = 0; AddArgumentCachedData s0_ = ADD_ARGUMENT_CACHED_CACHE_UPDATER.getVolatile(this); AddArgumentCachedData s0_original = s0_; while (s0_ != null) { if ((arg0Value.state == s0_.oldState_)) { self__ = (this); promotedType__ = (arg0Value.maybePromote(self__, arg1Value_)); if ((AddArgument.isSame(promotedType__.typeInfo, s0_.cachedTypeInfo_))) { break; } } count0_++; s0_ = s0_.next_; } if (s0_ == null) { { self__ = (this); promotedType__ = (arg0Value.maybePromote(self__, arg1Value_)); CachedTypeInfo cachedTypeInfo__ = (promotedType__.typeInfo); // assert (arg0Value.state == s0_.oldState_); if ((AddArgument.isSame(promotedType__.typeInfo, cachedTypeInfo__)) && count0_ < (3)) { s0_ = new AddArgumentCachedData(s0_original); s0_.oldState_ = (arg0Value.state); s0_.cachedTypeInfo_ = cachedTypeInfo__; s0_.newState_ = (s0_.oldState_.addArg(cachedTypeInfo__)); if (!ADD_ARGUMENT_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) { continue; } state_0 = state_0 | 0b10 /* add SpecializationActive[SignatureBuilder.AddArgument.doCached(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary, LibFFIType, ArgsState, CachedTypeInfo, ArgsState)] */; this.state_0_ = state_0; } } } if (s0_ != null) { AddArgument.doCached(arg0Value, arg1Value_, self__, promotedType__, s0_.oldState_, s0_.cachedTypeInfo_, s0_.newState_); return; } break; } } } { NFIBackendSignatureBuilderLibrary self__1 = null; self__1 = (this); this.addArgument_cached_cache = null; state_0 = state_0 & 0xfffffffd /* remove SpecializationActive[SignatureBuilder.AddArgument.doCached(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary, LibFFIType, ArgsState, CachedTypeInfo, ArgsState)] */; state_0 = state_0 | 0b100 /* add SpecializationActive[SignatureBuilder.AddArgument.doGeneric(SignatureBuilder, LibFFIType, NFIBackendSignatureBuilderLibrary)] */; this.state_0_ = state_0; AddArgument.doGeneric(arg0Value, arg1Value_, self__1); return; } } throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value); } /** * Debug Info:
             *   Specialization {@link Build#doCached}
             *     Activation probability: 0.21667
             *     With/without class size: 10/12 bytes
             *   Specialization {@link Build#doGeneric}
             *     Activation probability: 0.11667
             *     With/without class size: 5/0 bytes
             * 
*/ @ExplodeLoop @Override public Object build(Object arg0Value_) { assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); int state_0 = this.state_0_; if ((state_0 & 0b11000) != 0 /* is SpecializationActive[SignatureBuilder.Build.doCached(SignatureBuilder, ArgsState, CachedTypeInfo, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] || SpecializationActive[SignatureBuilder.Build.doGeneric(SignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) { if ((state_0 & 0b1000) != 0 /* is SpecializationActive[SignatureBuilder.Build.doCached(SignatureBuilder, ArgsState, CachedTypeInfo, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */) { BuildCachedData s0_ = this.build_cached_cache; while (s0_ != null) { if ((arg0Value.state == s0_.cachedState_) && (arg0Value.retTypeInfo == s0_.cachedRetType_)) { NFIBackendSignatureBuilderLibrary self__ = (this); return Build.doCached(arg0Value, s0_.cachedState_, s0_.cachedRetType_, self__, s0_.cachedSigInfo_); } s0_ = s0_.next_; } } if ((state_0 & 0b10000) != 0 /* is SpecializationActive[SignatureBuilder.Build.doGeneric(SignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) { { NFIBackendSignatureBuilderLibrary self__1 = (this); return Build.doGeneric(arg0Value, self__1); } } } CompilerDirectives.transferToInterpreterAndInvalidate(); return buildAndSpecialize(arg0Value); } private Object buildAndSpecialize(SignatureBuilder arg0Value) { int state_0 = this.state_0_; { NFIBackendSignatureBuilderLibrary self__ = null; if (((state_0 & 0b10000)) == 0 /* is-not SpecializationActive[SignatureBuilder.Build.doGeneric(SignatureBuilder, NFIBackendSignatureBuilderLibrary)] */) { while (true) { int count0_ = 0; BuildCachedData s0_ = BUILD_CACHED_CACHE_UPDATER.getVolatile(this); BuildCachedData s0_original = s0_; while (s0_ != null) { if ((arg0Value.state == s0_.cachedState_) && (arg0Value.retTypeInfo == s0_.cachedRetType_)) { self__ = (this); break; } count0_++; s0_ = s0_.next_; } if (s0_ == null) { { CachedTypeInfo cachedRetType__ = (arg0Value.retType.typeInfo); // assert (arg0Value.state == s0_.cachedState_); if ((arg0Value.retTypeInfo == cachedRetType__) && count0_ < (3)) { s0_ = new BuildCachedData(s0_original); s0_.cachedState_ = (arg0Value.state); s0_.cachedRetType_ = cachedRetType__; self__ = (this); s0_.cachedSigInfo_ = (LibFFISignature.prepareSignatureInfo(cachedRetType__, s0_.cachedState_)); if (!BUILD_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) { continue; } state_0 = state_0 | 0b1000 /* add SpecializationActive[SignatureBuilder.Build.doCached(SignatureBuilder, ArgsState, CachedTypeInfo, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */; this.state_0_ = state_0; } } } if (s0_ != null) { return Build.doCached(arg0Value, s0_.cachedState_, s0_.cachedRetType_, self__, s0_.cachedSigInfo_); } break; } } } { NFIBackendSignatureBuilderLibrary self__1 = null; self__1 = (this); this.build_cached_cache = null; state_0 = state_0 & 0xfffffff7 /* remove SpecializationActive[SignatureBuilder.Build.doCached(SignatureBuilder, ArgsState, CachedTypeInfo, NFIBackendSignatureBuilderLibrary, CachedSignatureInfo)] */; state_0 = state_0 | 0b10000 /* add SpecializationActive[SignatureBuilder.Build.doGeneric(SignatureBuilder, NFIBackendSignatureBuilderLibrary)] */; this.state_0_ = state_0; return Build.doGeneric(arg0Value, self__1); } } @Override public void makeVarargs(Object receiver) { assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver."; assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed."; (((SignatureBuilder) receiver)).makeVarargs(); return; } @GeneratedBy(SignatureBuilder.class) @DenyReplace private static final class AddArgumentCachedData { @CompilationFinal final AddArgumentCachedData next_; /** * Source Info:
                 *   Specialization: {@link AddArgument#doCached}
                 *   Parameter: {@link ArgsState} oldState
*/ @CompilationFinal ArgsState oldState_; /** * Source Info:
                 *   Specialization: {@link AddArgument#doCached}
                 *   Parameter: {@link CachedTypeInfo} cachedTypeInfo
*/ @CompilationFinal CachedTypeInfo cachedTypeInfo_; /** * Source Info:
                 *   Specialization: {@link AddArgument#doCached}
                 *   Parameter: {@link ArgsState} newState
*/ @CompilationFinal ArgsState newState_; AddArgumentCachedData(AddArgumentCachedData next_) { this.next_ = next_; } } @GeneratedBy(SignatureBuilder.class) @DenyReplace private static final class BuildCachedData { @CompilationFinal final BuildCachedData next_; /** * Source Info:
                 *   Specialization: {@link Build#doCached}
                 *   Parameter: {@link ArgsState} cachedState
*/ @CompilationFinal ArgsState cachedState_; /** * Source Info:
                 *   Specialization: {@link Build#doCached}
                 *   Parameter: {@link CachedTypeInfo} cachedRetType
*/ @CompilationFinal CachedTypeInfo cachedRetType_; /** * Source Info:
                 *   Specialization: {@link Build#doCached}
                 *   Parameter: {@link CachedSignatureInfo} cachedSigInfo
*/ @CompilationFinal CachedSignatureInfo cachedSigInfo_; BuildCachedData(BuildCachedData next_) { this.next_ = next_; } } } @GeneratedBy(SignatureBuilder.class) @DenyReplace private static final class Uncached extends NFIBackendSignatureBuilderLibrary { protected Uncached() { } @Override @TruffleBoundary public boolean accepts(Object receiver) { assert !(receiver instanceof SignatureBuilder) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected."; return receiver instanceof SignatureBuilder; } @Override public boolean isAdoptable() { return false; } @Override public NodeCost getCost() { return NodeCost.MEGAMORPHIC; } @TruffleBoundary @Override public void setReturnType(Object arg0Value_, Object arg1Value) { // declared: true assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); if (arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; SetReturnType.doSet(arg0Value, arg1Value_); return; } throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value); } @TruffleBoundary @Override public void addArgument(Object arg0Value_, Object arg1Value) { // declared: true assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); if (arg1Value instanceof LibFFIType) { LibFFIType arg1Value_ = (LibFFIType) arg1Value; AddArgument.doGeneric(arg0Value, arg1Value_, (this)); return; } throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value); } @TruffleBoundary @Override public Object build(Object arg0Value_) { // declared: true assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver."; SignatureBuilder arg0Value = ((SignatureBuilder) arg0Value_); return Build.doGeneric(arg0Value, (this)); } @TruffleBoundary @Override public void makeVarargs(Object receiver) { // declared: true assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver."; ((SignatureBuilder) receiver) .makeVarargs(); return; } } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy