com.oracle.graal.python.nodes.util.CastToJavaLongNodeGen 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.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.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.27381
* With/without class size: 7/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(int)}
* Activation probability: 0.23095
* With/without class size: 6/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(long)}
* Activation probability: 0.18810
* With/without class size: 6/0 bytes
* Specialization {@link CastToJavaLongNode#doLong(boolean)}
* Activation probability: 0.14524
* With/without class size: 5/0 bytes
* Specialization {@link CastToJavaLongNode#doNativeObject}
* Activation probability: 0.10238
* With/without class size: 6/11 bytes
* Specialization {@link CastToJavaLongNode#doUnsupported}
* Activation probability: 0.05952
* With/without class size: 4/0 bytes
*
*/
@GeneratedBy(CastToJavaLongNode.class)
@SuppressWarnings({"javadoc", "unused"})
final class CastToJavaLongNodeGen {
private static final StateField NATIVE_OBJECT__CAST_TO_JAVA_LONG_NODE_NATIVE_OBJECT_STATE_0_UPDATER = StateField.create(NativeObjectData.lookup_(), "nativeObject_state_0_");
/**
* Required Fields:
* - {@link Inlined#state_0_}
*
- {@link Inlined#nativeObject_cache}
*
*/
@NeverDefault
public static CastToJavaLongNode inline(@RequiredField(bits = 6, value = StateField.class)@RequiredField(type = Node.class, value = ReferenceField.class) InlineTarget target) {
return new CastToJavaLongNodeGen.Inlined(target);
}
@GeneratedBy(CastToJavaLongNode.class)
@DenyReplace
private static final class Inlined extends CastToJavaLongNode {
/**
* 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 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(CastToJavaLongNode.class);
this.state_0_ = target.getState(0, 6);
this.nativeObject_cache = target.getReference(1, NativeObjectData.class);
this.nativeObject_getClassNode_ = GetClassNodeGen.inline(InlineTarget.create(GetClassNode.class, NATIVE_OBJECT__CAST_TO_JAVA_LONG_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;
}
return true;
}
@Override
public long execute(Node arg0Value, Object arg1Value) throws CannotCastException {
int state_0 = this.state_0_.get(arg0Value);
if (state_0 != 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[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 & 0b100000) != 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__);
}
state_0 = state_0 | 0b100000 /* add SpecializationActive[CastToJavaLongNode.doUnsupported(Object)] */;
this.state_0_.set(arg0Value, state_0);
return CastToJavaLongNode.doUnsupported(arg1Value);
}
@Override
public boolean isAdoptable() {
return false;
}
}
@GeneratedBy(CastToJavaLongNode.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();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy