com.oracle.graal.python.nodes.util.CastToJavaLongLossyNodeGen Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.graal.python.nodes.util;
import com.oracle.graal.python.builtins.objects.cext.PythonNativeObject;
import com.oracle.graal.python.builtins.objects.ints.PInt;
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.graal.python.util.OverflowException;
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 java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.Objects;
/**
* Debug Info:
* Specialization {@link CastToJavaLongNode#doLong(byte)}
* Activation probability: 0.21250
* With/without class size: 6/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(int)}
* Activation probability: 0.18750
* With/without class size: 6/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(long)}
* Activation probability: 0.16250
* With/without class size: 5/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(boolean)}
* Activation probability: 0.13750
* With/without class size: 5/0 bytes
* Specialization {@link CastToJavaLongNode#doNativeObject}
* Activation probability: 0.11250
* With/without class size: 7/11 bytes
* Specialization {@link CastToJavaLongLossyNode#toLong}
* Activation probability: 0.08750
* With/without class size: 5/0 bytes
* Specialization {@link CastToJavaLongLossyNode#toLongOverflow}
* Activation probability: 0.06250
* With/without class size: 4/0 bytes
* Specialization {@link CastToJavaLongNode#doUnsupported}
* Activation probability: 0.03750
* With/without class size: 4/0 bytes
*
*/
@GeneratedBy(CastToJavaLongLossyNode.class)
@SuppressWarnings({"javadoc", "unused"})
public final class CastToJavaLongLossyNodeGen {
private static final StateField NATIVE_OBJECT__CAST_TO_JAVA_LONG_LOSSY_NODE_NATIVE_OBJECT_STATE_0_UPDATER = StateField.create(NativeObjectData.lookup_(), "nativeObject_state_0_");
private static final Uncached UNCACHED = new Uncached();
@NeverDefault
public static CastToJavaLongLossyNode getUncached() {
return CastToJavaLongLossyNodeGen.UNCACHED;
}
/**
* Required Fields:
* - {@link Inlined#state_0_}
*
- {@link Inlined#nativeObject_cache}
*
*/
@NeverDefault
public static CastToJavaLongLossyNode inline(@RequiredField(bits = 9, value = StateField.class)@RequiredField(type = Node.class, value = ReferenceField.class) InlineTarget target) {
return new CastToJavaLongLossyNodeGen.Inlined(target);
}
@GeneratedBy(CastToJavaLongLossyNode.class)
@DenyReplace
private static final class Inlined extends CastToJavaLongLossyNode {
/**
* State Info:
* 0: SpecializationActive {@link CastToJavaLongNode#doLong(byte)}
* 1: SpecializationActive {@link CastToJavaLongNode#doLong(int)}
* 2: SpecializationActive {@link CastToJavaLongNode#doLong(long)}
* 3: SpecializationActive {@link CastToJavaLongNode#doLong(boolean)}
* 4: SpecializationActive {@link CastToJavaLongNode#doNativeObject}
* 5: SpecializationActive {@link CastToJavaLongLossyNode#toLong}
* 6: SpecializationExcluded {@link CastToJavaLongLossyNode#toLong}
* 7: SpecializationActive {@link CastToJavaLongLossyNode#toLongOverflow}
* 8: SpecializationActive {@link CastToJavaLongNode#doUnsupported}
*
*/
private final StateField state_0_;
private final ReferenceField nativeObject_cache;
/**
* Source Info:
* Specialization: {@link CastToJavaLongNode#doNativeObject}
* Parameter: {@link GetClassNode} getClassNode
* Inline method: {@link GetClassNodeGen#inline}
*/
private final GetClassNode nativeObject_getClassNode_;
@SuppressWarnings("unchecked")
private Inlined(InlineTarget target) {
assert target.getTargetClass().isAssignableFrom(CastToJavaLongLossyNode.class);
this.state_0_ = target.getState(0, 9);
this.nativeObject_cache = target.getReference(1, NativeObjectData.class);
this.nativeObject_getClassNode_ = GetClassNodeGen.inline(InlineTarget.create(GetClassNode.class, NATIVE_OBJECT__CAST_TO_JAVA_LONG_LOSSY_NODE_NATIVE_OBJECT_STATE_0_UPDATER.subUpdater(0, 17), ReferenceField.create(NativeObjectData.lookup_(), "nativeObject_getClassNode__field1_", Node.class)));
}
@SuppressWarnings("static-method")
private boolean fallbackGuard_(int state_0, Node arg0Value, Object arg1Value) {
if (!((state_0 & 0b1) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(byte)] */) && arg1Value instanceof Byte) {
return false;
}
if (!((state_0 & 0b10) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(int)] */) && arg1Value instanceof Integer) {
return false;
}
if (!((state_0 & 0b100) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(long)] */) && arg1Value instanceof Long) {
return false;
}
if (!((state_0 & 0b1000) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(boolean)] */) && arg1Value instanceof Boolean) {
return false;
}
if (!((state_0 & 0b10000) != 0 /* is SpecializationActive[CastToJavaLongNode.doNativeObject(Node, PythonNativeObject, GetClassNode, IsSubtypeNode)] */) && arg1Value instanceof PythonNativeObject) {
return false;
}
if (!((state_0 & 0b10000000) != 0 /* is SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] */) && arg1Value instanceof PInt) {
return false;
}
return true;
}
@Override
public long execute(Node arg0Value, Object arg1Value) throws CannotCastException {
int state_0 = this.state_0_.get(arg0Value);
if ((state_0 & 0b110111111) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(byte)] || SpecializationActive[CastToJavaLongNode.doLong(int)] || SpecializationActive[CastToJavaLongNode.doLong(long)] || SpecializationActive[CastToJavaLongNode.doLong(boolean)] || SpecializationActive[CastToJavaLongNode.doNativeObject(Node, PythonNativeObject, GetClassNode, IsSubtypeNode)] || SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] || SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] || SpecializationActive[CastToJavaLongNode.doUnsupported(Object)] */) {
if ((state_0 & 0b1) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(byte)] */ && arg1Value instanceof Byte) {
byte arg1Value_ = (byte) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(int)] */ && arg1Value instanceof Integer) {
int arg1Value_ = (int) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if ((state_0 & 0b100) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(long)] */ && arg1Value instanceof Long) {
long arg1Value_ = (long) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if ((state_0 & 0b1000) != 0 /* is SpecializationActive[CastToJavaLongNode.doLong(boolean)] */ && arg1Value instanceof Boolean) {
boolean arg1Value_ = (boolean) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if ((state_0 & 0b10000) != 0 /* is SpecializationActive[CastToJavaLongNode.doNativeObject(Node, PythonNativeObject, GetClassNode, IsSubtypeNode)] */ && arg1Value instanceof PythonNativeObject) {
PythonNativeObject arg1Value_ = (PythonNativeObject) arg1Value;
NativeObjectData s4_ = this.nativeObject_cache.get(arg0Value);
if (s4_ != null) {
return CastToJavaLongNode.doNativeObject(s4_, arg1Value_, this.nativeObject_getClassNode_, s4_.isSubtypeNode_);
}
}
if ((state_0 & 0b10100000) != 0 /* is SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] || SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] */ && arg1Value instanceof PInt) {
PInt arg1Value_ = (PInt) arg1Value;
if ((state_0 & 0b100000) != 0 /* is SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] */) {
try {
return CastToJavaLongLossyNode.toLong(arg1Value_);
} catch (OverflowException ex) {
CompilerDirectives.transferToInterpreterAndInvalidate();
state_0 = this.state_0_.get(arg0Value);
state_0 = state_0 & 0xffffffdf /* remove SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] */;
state_0 = state_0 | 0b1000000 /* add SpecializationExcluded */;
this.state_0_.set(arg0Value, state_0);
return executeAndSpecialize(arg0Value, arg1Value_);
}
}
if ((state_0 & 0b10000000) != 0 /* is SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] */) {
return CastToJavaLongLossyNode.toLongOverflow(arg1Value_);
}
}
if ((state_0 & 0b100000000) != 0 /* is SpecializationActive[CastToJavaLongNode.doUnsupported(Object)] */) {
if (fallbackGuard_(state_0, arg0Value, arg1Value)) {
return CastToJavaLongNode.doUnsupported(arg1Value);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value);
}
private long executeAndSpecialize(Node arg0Value, Object arg1Value) {
int state_0 = this.state_0_.get(arg0Value);
if (arg1Value instanceof Byte) {
byte arg1Value_ = (byte) arg1Value;
state_0 = state_0 | 0b1 /* add SpecializationActive[CastToJavaLongNode.doLong(byte)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Integer) {
int arg1Value_ = (int) arg1Value;
state_0 = state_0 | 0b10 /* add SpecializationActive[CastToJavaLongNode.doLong(int)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Long) {
long arg1Value_ = (long) arg1Value;
state_0 = state_0 | 0b100 /* add SpecializationActive[CastToJavaLongNode.doLong(long)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Boolean) {
boolean arg1Value_ = (boolean) arg1Value;
state_0 = state_0 | 0b1000 /* add SpecializationActive[CastToJavaLongNode.doLong(boolean)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof PythonNativeObject) {
PythonNativeObject arg1Value_ = (PythonNativeObject) arg1Value;
NativeObjectData s4_ = arg0Value.insert(new NativeObjectData());
IsSubtypeNode isSubtypeNode__ = s4_.insert((IsSubtypeNode.create()));
Objects.requireNonNull(isSubtypeNode__, "Specialization 'doNativeObject(Node, PythonNativeObject, GetClassNode, IsSubtypeNode)' cache 'isSubtypeNode' 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'.");
s4_.isSubtypeNode_ = isSubtypeNode__;
VarHandle.storeStoreFence();
this.nativeObject_cache.set(arg0Value, s4_);
state_0 = state_0 | 0b10000 /* add SpecializationActive[CastToJavaLongNode.doNativeObject(Node, PythonNativeObject, GetClassNode, IsSubtypeNode)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doNativeObject(s4_, arg1Value_, this.nativeObject_getClassNode_, isSubtypeNode__);
}
if (arg1Value instanceof PInt) {
PInt arg1Value_ = (PInt) arg1Value;
if (((state_0 & 0b10000000)) == 0 /* is-not SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] */ && ((state_0 & 0b1000000)) == 0 /* is-not SpecializationExcluded */) {
state_0 = state_0 | 0b100000 /* add SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] */;
this.state_0_.set(arg0Value, state_0);
try {
return CastToJavaLongLossyNode.toLong(arg1Value_);
} catch (OverflowException ex) {
CompilerDirectives.transferToInterpreterAndInvalidate();
state_0 = this.state_0_.get(arg0Value);
state_0 = state_0 & 0xffffffdf /* remove SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] */;
state_0 = state_0 | 0b1000000 /* add SpecializationExcluded */;
this.state_0_.set(arg0Value, state_0);
return executeAndSpecialize(arg0Value, arg1Value_);
}
}
state_0 = state_0 & 0xffffffdf /* remove SpecializationActive[CastToJavaLongLossyNode.toLong(PInt)] */;
state_0 = state_0 | 0b10000000 /* add SpecializationActive[CastToJavaLongLossyNode.toLongOverflow(PInt)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongLossyNode.toLongOverflow(arg1Value_);
}
state_0 = state_0 | 0b100000000 /* add SpecializationActive[CastToJavaLongNode.doUnsupported(Object)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doUnsupported(arg1Value);
}
@Override
public boolean isAdoptable() {
return false;
}
}
@GeneratedBy(CastToJavaLongLossyNode.class)
@DenyReplace
private static final class NativeObjectData extends Node implements SpecializationDataNode {
/**
* State Info:
* 0-16: InlinedCache
* Specialization: {@link CastToJavaLongNode#doNativeObject}
* Parameter: {@link GetClassNode} getClassNode
* Inline method: {@link GetClassNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int nativeObject_state_0_;
/**
* Source Info:
* Specialization: {@link CastToJavaLongNode#doNativeObject}
* Parameter: {@link GetClassNode} getClassNode
* Inline method: {@link GetClassNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node nativeObject_getClassNode__field1_;
/**
* Source Info:
* Specialization: {@link CastToJavaLongNode#doNativeObject}
* Parameter: {@link IsSubtypeNode} isSubtypeNode
*/
@Child IsSubtypeNode isSubtypeNode_;
NativeObjectData() {
}
@Override
public NodeCost getCost() {
return NodeCost.NONE;
}
private static Lookup lookup_() {
return MethodHandles.lookup();
}
}
@GeneratedBy(CastToJavaLongLossyNode.class)
@DenyReplace
private static final class Uncached extends CastToJavaLongLossyNode {
@TruffleBoundary
@Override
public long execute(Node arg0Value, Object arg1Value) throws CannotCastException {
if (arg1Value instanceof Byte) {
byte arg1Value_ = (byte) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Integer) {
int arg1Value_ = (int) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Long) {
long arg1Value_ = (long) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof Boolean) {
boolean arg1Value_ = (boolean) arg1Value;
return CastToJavaLongNode.doLong(arg1Value_);
}
if (arg1Value instanceof PythonNativeObject) {
PythonNativeObject arg1Value_ = (PythonNativeObject) arg1Value;
return CastToJavaLongNode.doNativeObject(arg0Value, arg1Value_, (GetClassNode.getUncached()), (IsSubtypeNode.getUncached()));
}
if (arg1Value instanceof PInt) {
PInt arg1Value_ = (PInt) arg1Value;
return CastToJavaLongLossyNode.toLongOverflow(arg1Value_);
}
return CastToJavaLongNode.doUnsupported(arg1Value);
}
@Override
public NodeCost getCost() {
return NodeCost.MEGAMORPHIC;
}
@Override
public boolean isAdoptable() {
return false;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy