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

com.oracle.graal.python.runtime.NativeLibraryFactory Maven / Gradle / Ivy

There is a newer version: 24.1.1
Show newest version
// CheckStyle: start generated
package com.oracle.graal.python.runtime;

import com.oracle.graal.python.runtime.NativeLibrary.InvokeNativeFunction;
import com.oracle.graal.python.runtime.NativeLibrary.NativeFunction;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.DSLSupport;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.NeverDefault;
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.InteropLibrary;
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.api.profiles.InlinedExactClassProfile;
import com.oracle.truffle.api.utilities.TruffleWeakReference;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Objects;

@GeneratedBy(NativeLibrary.class)
@SuppressWarnings("javadoc")
public final class NativeLibraryFactory {

    private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);

    /**
     * Debug Info: 
     *   Specialization {@link InvokeNativeFunction#doSingleContext}
     *     Activation probability: 0.65000
     *     With/without class size: 27/16 bytes
     *   Specialization {@link InvokeNativeFunction#doMultiContext}
     *     Activation probability: 0.35000
     *     With/without class size: 13/9 bytes
     * 
*/ @GeneratedBy(InvokeNativeFunction.class) @SuppressWarnings("javadoc") public static final class InvokeNativeFunctionNodeGen extends InvokeNativeFunction { private static final StateField STATE_0_InvokeNativeFunction_UPDATER = StateField.create(MethodHandles.lookup(), "state_0_"); static final ReferenceField SINGLE_CONTEXT_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "singleContext_cache", SingleContextData.class); /** * Source Info:
         *   Specialization: {@link InvokeNativeFunction#doMultiContext}
         *   Parameter: {@link InlinedExactClassProfile} functionClassProfile
         *   Inline method: {@link InlinedExactClassProfile#inline}
*/ private static final InlinedExactClassProfile INLINED_MULTI_CONTEXT_FUNCTION_CLASS_PROFILE_ = InlinedExactClassProfile.inline(InlineTarget.create(InlinedExactClassProfile.class, STATE_0_InvokeNativeFunction_UPDATER.subUpdater(2, 2), ReferenceField.create(MethodHandles.lookup(), "multiContext_functionClassProfile__field1_", Class.class))); /** * State Info:
         *   0: SpecializationActive {@link InvokeNativeFunction#doSingleContext}
         *   1: SpecializationActive {@link InvokeNativeFunction#doMultiContext}
         *   2-3: InlinedCache
         *        Specialization: {@link InvokeNativeFunction#doMultiContext}
         *        Parameter: {@link InlinedExactClassProfile} functionClassProfile
         *        Inline method: {@link InlinedExactClassProfile#inline}
         * 
*/ @CompilationFinal @UnsafeAccessedField private int state_0_; @UnsafeAccessedField @Child private SingleContextData singleContext_cache; /** * Source Info:
         *   Specialization: {@link InvokeNativeFunction#doMultiContext}
         *   Parameter: {@link InlinedExactClassProfile} functionClassProfile
         *   Inline method: {@link InlinedExactClassProfile#inline}
         *   Inline field: {@link Class} field1
*/ @CompilationFinal @UnsafeAccessedField @SuppressWarnings("unused") private Class multiContext_functionClassProfile__field1_; /** * Source Info:
         *   Specialization: {@link InvokeNativeFunction#doMultiContext}
         *   Parameter: {@link InteropLibrary} funInterop
*/ @Child private InteropLibrary multiContext_funInterop_; private InvokeNativeFunctionNodeGen(InteropLibrary resultInterop) { super(resultInterop); } @ExplodeLoop @Override protected Object execute(NativeLibrary arg0Value, NativeFunction arg1Value, Object[] arg2Value) { int state_0 = this.state_0_; if ((state_0 & 0b11) != 0 /* is SpecializationActive[NativeLibrary.InvokeNativeFunction.doSingleContext(NativeLibrary, NativeFunction, Object[], NativeLibrary, NativeFunction, Object, InteropLibrary)] || SpecializationActive[NativeLibrary.InvokeNativeFunction.doMultiContext(NativeLibrary, NativeFunction, Object[], Node, InlinedExactClassProfile, InteropLibrary)] */) { if ((state_0 & 0b1) != 0 /* is SpecializationActive[NativeLibrary.InvokeNativeFunction.doSingleContext(NativeLibrary, NativeFunction, Object[], NativeLibrary, NativeFunction, Object, InteropLibrary)] */) { SingleContextData s0_ = this.singleContext_cache; while (s0_ != null) { { Object funObj__ = (s0_.weakFunObjGen__.get()); if ((funObj__ != null) && (s0_.funInterop_.accepts(funObj__))) { assert DSLSupport.assertIdempotence((isSingleContext())); if ((arg1Value == s0_.cachedFunction_)) { NativeLibrary cachedLib__ = (s0_.weakCachedLibGen__.get()); if ((cachedLib__ != null) && (arg0Value == cachedLib__)) { return InvokeNativeFunction.doSingleContext(arg0Value, arg1Value, arg2Value, cachedLib__, s0_.cachedFunction_, funObj__, s0_.funInterop_); } } } } s0_ = s0_.next_; } } if ((state_0 & 0b10) != 0 /* is SpecializationActive[NativeLibrary.InvokeNativeFunction.doMultiContext(NativeLibrary, NativeFunction, Object[], Node, InlinedExactClassProfile, InteropLibrary)] */) { { InteropLibrary funInterop__ = this.multiContext_funInterop_; if (funInterop__ != null) { Node inliningTarget__ = (this); return InvokeNativeFunction.doMultiContext(arg0Value, arg1Value, arg2Value, inliningTarget__, INLINED_MULTI_CONTEXT_FUNCTION_CLASS_PROFILE_, funInterop__); } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); return executeAndSpecialize(arg0Value, arg1Value, arg2Value); } private Object executeAndSpecialize(NativeLibrary arg0Value, NativeFunction arg1Value, Object[] arg2Value) { int state_0 = this.state_0_; { Object funObj__ = null; NativeLibrary cachedLib__ = null; if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[NativeLibrary.InvokeNativeFunction.doMultiContext(NativeLibrary, NativeFunction, Object[], Node, InlinedExactClassProfile, InteropLibrary)] */) { while (true) { int count0_ = 0; SingleContextData s0_ = SINGLE_CONTEXT_CACHE_UPDATER.getVolatile(this); SingleContextData s0_original = s0_; while (s0_ != null) { { funObj__ = (s0_.weakFunObjGen__.get()); if ((funObj__ != null) && (s0_.funInterop_.accepts(funObj__))) { assert DSLSupport.assertIdempotence((isSingleContext())); if ((arg1Value == s0_.cachedFunction_)) { cachedLib__ = (s0_.weakCachedLibGen__.get()); if ((cachedLib__ != null) && (arg0Value == cachedLib__)) { break; } } } } count0_++; s0_ = s0_.next_; } if (s0_ == null) { { TruffleWeakReference weakFunObjGen___ = (new TruffleWeakReference<>(getFunction(arg0Value, arg1Value))); funObj__ = (weakFunObjGen___.get()); if ((funObj__ != null)) { if ((isSingleContext())) { // assert (s0_.funInterop_.accepts(funObj__)); TruffleWeakReference weakCachedLibGen___ = (new TruffleWeakReference<>(arg0Value)); cachedLib__ = (weakCachedLibGen___.get()); // assert (arg1Value == s0_.cachedFunction_); if ((cachedLib__ != null) && (arg0Value == cachedLib__) && count0_ < (3)) { s0_ = this.insert(new SingleContextData(s0_original)); s0_.weakFunObjGen__ = weakFunObjGen___; s0_.weakCachedLibGen__ = weakCachedLibGen___; s0_.cachedFunction_ = (arg1Value); InteropLibrary funInterop__1 = s0_.insert((INTEROP_LIBRARY_.create(funObj__))); Objects.requireNonNull(funInterop__1, "Specialization 'doSingleContext(NativeLibrary, NativeFunction, Object[], NativeLibrary, NativeFunction, Object, InteropLibrary)' cache 'funInterop' returned a 'null' 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 'null'."); s0_.funInterop_ = funInterop__1; if (!SINGLE_CONTEXT_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) { continue; } state_0 = state_0 | 0b1 /* add SpecializationActive[NativeLibrary.InvokeNativeFunction.doSingleContext(NativeLibrary, NativeFunction, Object[], NativeLibrary, NativeFunction, Object, InteropLibrary)] */; this.state_0_ = state_0; } } } } } if (s0_ != null) { return InvokeNativeFunction.doSingleContext(arg0Value, arg1Value, arg2Value, cachedLib__, s0_.cachedFunction_, funObj__, s0_.funInterop_); } break; } } } { Node inliningTarget__ = null; inliningTarget__ = (this); InteropLibrary funInterop__ = this.insert((INTEROP_LIBRARY_.createDispatched(1))); Objects.requireNonNull(funInterop__, "Specialization 'doMultiContext(NativeLibrary, NativeFunction, Object[], Node, InlinedExactClassProfile, InteropLibrary)' cache 'funInterop' returned a 'null' 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 'null'."); VarHandle.storeStoreFence(); this.multiContext_funInterop_ = funInterop__; this.singleContext_cache = null; state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[NativeLibrary.InvokeNativeFunction.doSingleContext(NativeLibrary, NativeFunction, Object[], NativeLibrary, NativeFunction, Object, InteropLibrary)] */; state_0 = state_0 | 0b10 /* add SpecializationActive[NativeLibrary.InvokeNativeFunction.doMultiContext(NativeLibrary, NativeFunction, Object[], Node, InlinedExactClassProfile, InteropLibrary)] */; this.state_0_ = state_0; return InvokeNativeFunction.doMultiContext(arg0Value, arg1Value, arg2Value, inliningTarget__, INLINED_MULTI_CONTEXT_FUNCTION_CLASS_PROFILE_, funInterop__); } } @Override public NodeCost getCost() { int state_0 = this.state_0_; if ((state_0 & 0b11) == 0) { return NodeCost.UNINITIALIZED; } else { if (((state_0 & 0b11) & ((state_0 & 0b11) - 1)) == 0 /* is-single */) { SingleContextData s0_ = this.singleContext_cache; if ((s0_ == null || s0_.next_ == null)) { return NodeCost.MONOMORPHIC; } } } return NodeCost.POLYMORPHIC; } @NeverDefault public static InvokeNativeFunction create(InteropLibrary resultInterop) { return new InvokeNativeFunctionNodeGen(resultInterop); } @GeneratedBy(InvokeNativeFunction.class) @DenyReplace private static final class SingleContextData extends Node implements SpecializationDataNode { @Child SingleContextData next_; /** * Source Info:
             *   Specialization: {@link InvokeNativeFunction#doSingleContext}
             *   Parameter: {@link TruffleWeakReference} weakFunObjGen_
*/ @CompilationFinal TruffleWeakReference weakFunObjGen__; /** * Source Info:
             *   Specialization: {@link InvokeNativeFunction#doSingleContext}
             *   Parameter: {@link TruffleWeakReference} weakCachedLibGen_
*/ @CompilationFinal TruffleWeakReference weakCachedLibGen__; /** * Source Info:
             *   Specialization: {@link InvokeNativeFunction#doSingleContext}
             *   Parameter: {@link NativeFunction} cachedFunction
*/ @CompilationFinal NativeFunction cachedFunction_; /** * Source Info:
             *   Specialization: {@link InvokeNativeFunction#doSingleContext}
             *   Parameter: {@link InteropLibrary} funInterop
*/ @Child InteropLibrary funInterop_; SingleContextData(SingleContextData next_) { this.next_ = next_; } @Override public NodeCost getCost() { return NodeCost.NONE; } } } }