com.oracle.graal.python.lib.PyUnicodeCheckNodeGen Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.graal.python.lib;
import com.oracle.graal.python.builtins.objects.str.PString;
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
import com.oracle.graal.python.nodes.object.GetClassNode;
import com.oracle.graal.python.nodes.object.GetClassNodeGen;
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.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.RequiredField;
import com.oracle.truffle.api.dsl.InlineSupport.StateField;
import com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.strings.TruffleString;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.Objects;
/**
* Debug Info:
* Specialization {@link PyUnicodeCheckNode#doString}
* Activation probability: 0.48333
* With/without class size: 9/0 bytes
* Specialization {@link PyUnicodeCheckNode#doPString}
* Activation probability: 0.33333
* With/without class size: 8/0 bytes
* Specialization {@link PyUnicodeCheckNode#doGeneric}
* Activation probability: 0.18333
* With/without class size: 9/11 bytes
*
*/
@GeneratedBy(PyUnicodeCheckNode.class)
@SuppressWarnings({"javadoc", "unused"})
public final class PyUnicodeCheckNodeGen {
private static final StateField FALLBACK__PY_UNICODE_CHECK_NODE_FALLBACK_STATE_0_UPDATER = StateField.create(FallbackData.lookup_(), "fallback_state_0_");
private static final Uncached UNCACHED = new Uncached();
@NeverDefault
public static PyUnicodeCheckNode getUncached() {
return PyUnicodeCheckNodeGen.UNCACHED;
}
/**
* Required Fields:
* - {@link Inlined#state_0_}
*
- {@link Inlined#fallback_cache}
*
*/
@NeverDefault
public static PyUnicodeCheckNode inline(@RequiredField(bits = 3, value = StateField.class)@RequiredField(type = Node.class, value = ReferenceField.class) InlineTarget target) {
return new PyUnicodeCheckNodeGen.Inlined(target);
}
@GeneratedBy(PyUnicodeCheckNode.class)
@DenyReplace
private static final class Inlined extends PyUnicodeCheckNode {
/**
* State Info:
* 0: SpecializationActive {@link PyUnicodeCheckNode#doString}
* 1: SpecializationActive {@link PyUnicodeCheckNode#doPString}
* 2: SpecializationActive {@link PyUnicodeCheckNode#doGeneric}
*
*/
private final StateField state_0_;
private final ReferenceField fallback_cache;
/**
* Source Info:
* Specialization: {@link PyUnicodeCheckNode#doGeneric}
* Parameter: {@link GetClassNode} getClass
* Inline method: {@link GetClassNodeGen#inline}
*/
private final GetClassNode fallback_getClass_;
@SuppressWarnings("unchecked")
private Inlined(InlineTarget target) {
assert target.getTargetClass().isAssignableFrom(PyUnicodeCheckNode.class);
this.state_0_ = target.getState(0, 3);
this.fallback_cache = target.getReference(1, FallbackData.class);
this.fallback_getClass_ = GetClassNodeGen.inline(InlineTarget.create(GetClassNode.class, FALLBACK__PY_UNICODE_CHECK_NODE_FALLBACK_STATE_0_UPDATER.subUpdater(0, 17), ReferenceField.create(FallbackData.lookup_(), "fallback_getClass__field1_", Node.class)));
}
@SuppressWarnings("static-method")
private boolean fallbackGuard_(int state_0, Node arg0Value, Object arg1Value) {
if (!((state_0 & 0b1) != 0 /* is SpecializationActive[PyUnicodeCheckNode.doString(Node, TruffleString)] */) && arg1Value instanceof TruffleString) {
return false;
}
if (!((state_0 & 0b10) != 0 /* is SpecializationActive[PyUnicodeCheckNode.doPString(Node, PString)] */) && arg1Value instanceof PString) {
return false;
}
return true;
}
@Override
public boolean execute(Node arg0Value, Object arg1Value) {
int state_0 = this.state_0_.get(arg0Value);
if (state_0 != 0 /* is SpecializationActive[PyUnicodeCheckNode.doString(Node, TruffleString)] || SpecializationActive[PyUnicodeCheckNode.doPString(Node, PString)] || SpecializationActive[PyUnicodeCheckNode.doGeneric(Node, Object, GetClassNode, IsSubtypeNode)] */) {
if ((state_0 & 0b1) != 0 /* is SpecializationActive[PyUnicodeCheckNode.doString(Node, TruffleString)] */ && arg1Value instanceof TruffleString) {
TruffleString arg1Value_ = (TruffleString) arg1Value;
return PyUnicodeCheckNode.doString(arg0Value, arg1Value_);
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[PyUnicodeCheckNode.doPString(Node, PString)] */ && arg1Value instanceof PString) {
PString arg1Value_ = (PString) arg1Value;
return PyUnicodeCheckNode.doPString(arg0Value, arg1Value_);
}
if ((state_0 & 0b100) != 0 /* is SpecializationActive[PyUnicodeCheckNode.doGeneric(Node, Object, GetClassNode, IsSubtypeNode)] */) {
FallbackData s2_ = this.fallback_cache.get(arg0Value);
if (s2_ != null) {
if (fallbackGuard_(state_0, arg0Value, arg1Value)) {
return PyUnicodeCheckNode.doGeneric(s2_, arg1Value, this.fallback_getClass_, s2_.isSubtype_);
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value);
}
private boolean executeAndSpecialize(Node arg0Value, Object arg1Value) {
int state_0 = this.state_0_.get(arg0Value);
if (arg1Value instanceof TruffleString) {
TruffleString arg1Value_ = (TruffleString) arg1Value;
state_0 = state_0 | 0b1 /* add SpecializationActive[PyUnicodeCheckNode.doString(Node, TruffleString)] */;
this.state_0_.set(arg0Value, state_0);
return PyUnicodeCheckNode.doString(arg0Value, arg1Value_);
}
if (arg1Value instanceof PString) {
PString arg1Value_ = (PString) arg1Value;
state_0 = state_0 | 0b10 /* add SpecializationActive[PyUnicodeCheckNode.doPString(Node, PString)] */;
this.state_0_.set(arg0Value, state_0);
return PyUnicodeCheckNode.doPString(arg0Value, arg1Value_);
}
FallbackData s2_ = arg0Value.insert(new FallbackData());
IsSubtypeNode isSubtype__ = s2_.insert((IsSubtypeNode.create()));
Objects.requireNonNull(isSubtype__, "Specialization 'doGeneric(Node, Object, GetClassNode, IsSubtypeNode)' cache 'isSubtype' 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'.");
s2_.isSubtype_ = isSubtype__;
VarHandle.storeStoreFence();
this.fallback_cache.set(arg0Value, s2_);
state_0 = state_0 | 0b100 /* add SpecializationActive[PyUnicodeCheckNode.doGeneric(Node, Object, GetClassNode, IsSubtypeNode)] */;
this.state_0_.set(arg0Value, state_0);
return PyUnicodeCheckNode.doGeneric(s2_, arg1Value, this.fallback_getClass_, isSubtype__);
}
@Override
public boolean isAdoptable() {
return false;
}
}
@GeneratedBy(PyUnicodeCheckNode.class)
@DenyReplace
private static final class FallbackData extends Node implements SpecializationDataNode {
/**
* State Info:
* 0-16: InlinedCache
* Specialization: {@link PyUnicodeCheckNode#doGeneric}
* Parameter: {@link GetClassNode} getClass
* Inline method: {@link GetClassNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int fallback_state_0_;
/**
* Source Info:
* Specialization: {@link PyUnicodeCheckNode#doGeneric}
* Parameter: {@link GetClassNode} getClass
* Inline method: {@link GetClassNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node fallback_getClass__field1_;
/**
* Source Info:
* Specialization: {@link PyUnicodeCheckNode#doGeneric}
* Parameter: {@link IsSubtypeNode} isSubtype
*/
@Child IsSubtypeNode isSubtype_;
FallbackData() {
}
@Override
public NodeCost getCost() {
return NodeCost.NONE;
}
private static Lookup lookup_() {
return MethodHandles.lookup();
}
}
@GeneratedBy(PyUnicodeCheckNode.class)
@DenyReplace
private static final class Uncached extends PyUnicodeCheckNode {
@TruffleBoundary
@Override
public boolean execute(Node arg0Value, Object arg1Value) {
if (arg1Value instanceof TruffleString) {
TruffleString arg1Value_ = (TruffleString) arg1Value;
return PyUnicodeCheckNode.doString(arg0Value, arg1Value_);
}
if (arg1Value instanceof PString) {
PString arg1Value_ = (PString) arg1Value;
return PyUnicodeCheckNode.doPString(arg0Value, arg1Value_);
}
return PyUnicodeCheckNode.doGeneric(arg0Value, arg1Value, (GetClassNode.getUncached()), (IsSubtypeNode.getUncached()));
}
@Override
public NodeCost getCost() {
return NodeCost.MEGAMORPHIC;
}
@Override
public boolean isAdoptable() {
return false;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy