com.oracle.graal.python.runtime.NativeLibraryFactory Maven / Gradle / Ivy
// 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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy