com.oracle.graal.python.nodes.util.CastToJavaStringNodeGen 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.str.PString;
import com.oracle.graal.python.builtins.objects.str.StringNodes.StringMaterializeNode;
import com.oracle.graal.python.builtins.objects.str.StringNodesFactory.StringMaterializeNodeGen;
import com.oracle.graal.python.nodes.PGuards;
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.nodes.util.CastToTruffleStringNode.ReadNativeStringNode;
import com.oracle.graal.python.nodes.util.CastToTruffleStringNodeGen.ReadNativeStringNodeGen;
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.UnsupportedSpecializationException;
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.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.strings.TruffleString;
import com.oracle.truffle.api.strings.TruffleString.ToJavaStringNode;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.Objects;
/**
* Debug Info:
* Specialization {@link CastToJavaStringNode#doString}
* Activation probability: 0.32000
* With/without class size: 7/0 bytes
* Specialization {@link CastToJavaStringNode#doPStringMaterialized}
* Activation probability: 0.26000
* With/without class size: 7/0 bytes
* Specialization {@link CastToJavaStringNode#doPStringGeneric}
* Activation probability: 0.20000
* With/without class size: 9/9 bytes
* Specialization {@link CastToJavaStringNode#doNativeObject}
* Activation probability: 0.14000
* With/without class size: 8/15 bytes
* Specialization {@link CastToJavaStringNode#doUnsupported}
* Activation probability: 0.08000
* With/without class size: 4/0 bytes
*
*/
@GeneratedBy(CastToJavaStringNode.class)
@SuppressWarnings("javadoc")
public final class CastToJavaStringNodeGen extends CastToJavaStringNode {
private static final StateField STATE_0_CastToJavaStringNode_UPDATER = StateField.create(MethodHandles.lookup(), "state_0_");
private static final StateField NATIVE_OBJECT__CAST_TO_JAVA_STRING_NODE_NATIVE_OBJECT_STATE_0_UPDATER = StateField.create(NativeObjectData.lookup_(), "nativeObject_state_0_");
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doPStringGeneric}
* Parameter: {@link StringMaterializeNode} materializeNode
* Inline method: {@link StringMaterializeNodeGen#inline}
*/
private static final StringMaterializeNode INLINED_P_STRING_GENERIC_MATERIALIZE_NODE_ = StringMaterializeNodeGen.inline(InlineTarget.create(StringMaterializeNode.class, STATE_0_CastToJavaStringNode_UPDATER.subUpdater(5, 3), ReferenceField.create(MethodHandles.lookup(), "pStringGeneric_materializeNode__field1_", Node.class), ReferenceField.create(MethodHandles.lookup(), "pStringGeneric_materializeNode__field2_", Node.class)));
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doNativeObject}
* Parameter: {@link GetClassNode} getClassNode
* Inline method: {@link GetClassNodeGen#inline}
*/
private static final GetClassNode INLINED_NATIVE_OBJECT_GET_CLASS_NODE_ = GetClassNodeGen.inline(InlineTarget.create(GetClassNode.class, NATIVE_OBJECT__CAST_TO_JAVA_STRING_NODE_NATIVE_OBJECT_STATE_0_UPDATER.subUpdater(0, 17), ReferenceField.create(NativeObjectData.lookup_(), "nativeObject_getClassNode__field1_", Node.class)));
private static final Uncached UNCACHED = new Uncached();
/**
* State Info:
* 0: SpecializationActive {@link CastToJavaStringNode#doString}
* 1: SpecializationActive {@link CastToJavaStringNode#doPStringMaterialized}
* 2: SpecializationActive {@link CastToJavaStringNode#doPStringGeneric}
* 3: SpecializationActive {@link CastToJavaStringNode#doNativeObject}
* 4: SpecializationActive {@link CastToJavaStringNode#doUnsupported}
* 5-7: InlinedCache
* Specialization: {@link CastToJavaStringNode#doPStringGeneric}
* Parameter: {@link StringMaterializeNode} materializeNode
* Inline method: {@link StringMaterializeNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int state_0_;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doString}
* Parameter: {@link ToJavaStringNode} toJavaStringNode
*/
@Child private ToJavaStringNode toJavaStringNode;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doPStringGeneric}
* Parameter: {@link ToJavaStringNode} toJavaString
*/
@Child private ToJavaStringNode toJavaString;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doPStringGeneric}
* Parameter: {@link StringMaterializeNode} materializeNode
* Inline method: {@link StringMaterializeNodeGen#inline}
* Inline field: {@link Node} field1
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node pStringGeneric_materializeNode__field1_;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doPStringGeneric}
* Parameter: {@link StringMaterializeNode} materializeNode
* Inline method: {@link StringMaterializeNodeGen#inline}
* Inline field: {@link Node} field2
*/
@Child @UnsafeAccessedField @SuppressWarnings("unused") private Node pStringGeneric_materializeNode__field2_;
@Child private NativeObjectData nativeObject_cache;
private CastToJavaStringNodeGen() {
}
@Override
public String execute(Object arg0Value) throws CannotCastException {
int state_0 = this.state_0_;
if ((state_0 & 0b11111) != 0 /* is SpecializationActive[CastToJavaStringNode.doString(TruffleString, ToJavaStringNode)] || SpecializationActive[CastToJavaStringNode.doPStringMaterialized(PString, ToJavaStringNode)] || SpecializationActive[CastToJavaStringNode.doPStringGeneric(PString, Node, StringMaterializeNode, ToJavaStringNode)] || SpecializationActive[CastToJavaStringNode.doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)] || SpecializationActive[CastToJavaStringNode.doUnsupported(Object)] */) {
if ((state_0 & 0b1) != 0 /* is SpecializationActive[CastToJavaStringNode.doString(TruffleString, ToJavaStringNode)] */ && arg0Value instanceof TruffleString) {
TruffleString arg0Value_ = (TruffleString) arg0Value;
{
ToJavaStringNode toJavaStringNode_ = this.toJavaStringNode;
if (toJavaStringNode_ != null) {
return CastToJavaStringNode.doString(arg0Value_, toJavaStringNode_);
}
}
}
if ((state_0 & 0b110) != 0 /* is SpecializationActive[CastToJavaStringNode.doPStringMaterialized(PString, ToJavaStringNode)] || SpecializationActive[CastToJavaStringNode.doPStringGeneric(PString, Node, StringMaterializeNode, ToJavaStringNode)] */ && arg0Value instanceof PString) {
PString arg0Value_ = (PString) arg0Value;
if ((state_0 & 0b10) != 0 /* is SpecializationActive[CastToJavaStringNode.doPStringMaterialized(PString, ToJavaStringNode)] */) {
{
ToJavaStringNode toJavaStringNode_1 = this.toJavaStringNode;
if (toJavaStringNode_1 != null) {
if ((arg0Value_.isMaterialized())) {
return CastToJavaStringNode.doPStringMaterialized(arg0Value_, toJavaStringNode_1);
}
}
}
}
if ((state_0 & 0b100) != 0 /* is SpecializationActive[CastToJavaStringNode.doPStringGeneric(PString, Node, StringMaterializeNode, ToJavaStringNode)] */) {
{
ToJavaStringNode toJavaString_ = this.toJavaString;
if (toJavaString_ != null) {
if ((!(arg0Value_.isMaterialized()))) {
Node inliningTarget__ = (this);
return CastToJavaStringNode.doPStringGeneric(arg0Value_, inliningTarget__, INLINED_P_STRING_GENERIC_MATERIALIZE_NODE_, toJavaString_);
}
}
}
}
}
if ((state_0 & 0b1000) != 0 /* is SpecializationActive[CastToJavaStringNode.doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)] */ && arg0Value instanceof PythonNativeObject) {
PythonNativeObject arg0Value_ = (PythonNativeObject) arg0Value;
NativeObjectData s3_ = this.nativeObject_cache;
if (s3_ != null) {
{
ToJavaStringNode toJavaString_1 = this.toJavaString;
if (toJavaString_1 != null) {
Node inliningTarget__1 = (s3_);
return CastToJavaStringNode.doNativeObject(arg0Value_, inliningTarget__1, INLINED_NATIVE_OBJECT_GET_CLASS_NODE_, s3_.isSubtypeNode_, toJavaString_1, s3_.read_);
}
}
}
}
if ((state_0 & 0b10000) != 0 /* is SpecializationActive[CastToJavaStringNode.doUnsupported(Object)] */) {
if ((!(PGuards.isString(arg0Value))) && (!(PGuards.isNativeObject(arg0Value)))) {
return CastToJavaStringNode.doUnsupported(arg0Value);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value);
}
private String executeAndSpecialize(Object arg0Value) {
int state_0 = this.state_0_;
if (arg0Value instanceof TruffleString) {
TruffleString arg0Value_ = (TruffleString) arg0Value;
ToJavaStringNode toJavaStringNode_;
ToJavaStringNode toJavaStringNode__shared = this.toJavaStringNode;
if (toJavaStringNode__shared != null) {
toJavaStringNode_ = toJavaStringNode__shared;
} else {
toJavaStringNode_ = this.insert((ToJavaStringNode.create()));
if (toJavaStringNode_ == null) {
throw new IllegalStateException("Specialization 'doString(TruffleString, ToJavaStringNode)' contains a shared cache with name 'toJavaStringNode' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.toJavaStringNode == null) {
VarHandle.storeStoreFence();
this.toJavaStringNode = toJavaStringNode_;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[CastToJavaStringNode.doString(TruffleString, ToJavaStringNode)] */;
this.state_0_ = state_0;
return CastToJavaStringNode.doString(arg0Value_, toJavaStringNode_);
}
if (arg0Value instanceof PString) {
PString arg0Value_ = (PString) arg0Value;
if ((arg0Value_.isMaterialized())) {
ToJavaStringNode toJavaStringNode_1;
ToJavaStringNode toJavaStringNode_1_shared = this.toJavaStringNode;
if (toJavaStringNode_1_shared != null) {
toJavaStringNode_1 = toJavaStringNode_1_shared;
} else {
toJavaStringNode_1 = this.insert((ToJavaStringNode.create()));
if (toJavaStringNode_1 == null) {
throw new IllegalStateException("Specialization 'doPStringMaterialized(PString, ToJavaStringNode)' contains a shared cache with name 'toJavaStringNode' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.toJavaStringNode == null) {
VarHandle.storeStoreFence();
this.toJavaStringNode = toJavaStringNode_1;
}
state_0 = state_0 | 0b10 /* add SpecializationActive[CastToJavaStringNode.doPStringMaterialized(PString, ToJavaStringNode)] */;
this.state_0_ = state_0;
return CastToJavaStringNode.doPStringMaterialized(arg0Value_, toJavaStringNode_1);
}
{
Node inliningTarget__ = null;
if ((!(arg0Value_.isMaterialized()))) {
inliningTarget__ = (this);
ToJavaStringNode toJavaString_;
ToJavaStringNode toJavaString__shared = this.toJavaString;
if (toJavaString__shared != null) {
toJavaString_ = toJavaString__shared;
} else {
toJavaString_ = this.insert((ToJavaStringNode.create()));
if (toJavaString_ == null) {
throw new IllegalStateException("Specialization 'doPStringGeneric(PString, Node, StringMaterializeNode, ToJavaStringNode)' contains a shared cache with name 'toJavaString' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.toJavaString == null) {
VarHandle.storeStoreFence();
this.toJavaString = toJavaString_;
}
state_0 = state_0 | 0b100 /* add SpecializationActive[CastToJavaStringNode.doPStringGeneric(PString, Node, StringMaterializeNode, ToJavaStringNode)] */;
this.state_0_ = state_0;
return CastToJavaStringNode.doPStringGeneric(arg0Value_, inliningTarget__, INLINED_P_STRING_GENERIC_MATERIALIZE_NODE_, toJavaString_);
}
}
}
{
Node inliningTarget__1 = null;
if (arg0Value instanceof PythonNativeObject) {
PythonNativeObject arg0Value_ = (PythonNativeObject) arg0Value;
NativeObjectData s3_ = this.insert(new NativeObjectData());
inliningTarget__1 = (s3_);
IsSubtypeNode isSubtypeNode__ = s3_.insert((IsSubtypeNode.create()));
Objects.requireNonNull(isSubtypeNode__, "Specialization 'doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)' 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'.");
s3_.isSubtypeNode_ = isSubtypeNode__;
ToJavaStringNode toJavaString_1;
ToJavaStringNode toJavaString_1_shared = this.toJavaString;
if (toJavaString_1_shared != null) {
toJavaString_1 = toJavaString_1_shared;
} else {
toJavaString_1 = s3_.insert((ToJavaStringNode.create()));
if (toJavaString_1 == null) {
throw new IllegalStateException("Specialization 'doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)' contains a shared cache with name 'toJavaString' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.toJavaString == null) {
this.toJavaString = toJavaString_1;
}
ReadNativeStringNode read__ = s3_.insert((ReadNativeStringNodeGen.create()));
Objects.requireNonNull(read__, "Specialization 'doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)' cache 'read' 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'.");
s3_.read_ = read__;
VarHandle.storeStoreFence();
this.nativeObject_cache = s3_;
state_0 = state_0 | 0b1000 /* add SpecializationActive[CastToJavaStringNode.doNativeObject(PythonNativeObject, Node, GetClassNode, IsSubtypeNode, ToJavaStringNode, ReadNativeStringNode)] */;
this.state_0_ = state_0;
return CastToJavaStringNode.doNativeObject(arg0Value_, inliningTarget__1, INLINED_NATIVE_OBJECT_GET_CLASS_NODE_, isSubtypeNode__, toJavaString_1, read__);
}
}
if ((!(PGuards.isString(arg0Value))) && (!(PGuards.isNativeObject(arg0Value)))) {
state_0 = state_0 | 0b10000 /* add SpecializationActive[CastToJavaStringNode.doUnsupported(Object)] */;
this.state_0_ = state_0;
return CastToJavaStringNode.doUnsupported(arg0Value);
}
throw new UnsupportedSpecializationException(this, new Node[] {null}, arg0Value);
}
@Override
public NodeCost getCost() {
int state_0 = this.state_0_;
if ((state_0 & 0b11111) == 0) {
return NodeCost.UNINITIALIZED;
} else {
if (((state_0 & 0b11111) & ((state_0 & 0b11111) - 1)) == 0 /* is-single */) {
return NodeCost.MONOMORPHIC;
}
}
return NodeCost.POLYMORPHIC;
}
@NeverDefault
public static CastToJavaStringNode create() {
return new CastToJavaStringNodeGen();
}
@NeverDefault
public static CastToJavaStringNode getUncached() {
return CastToJavaStringNodeGen.UNCACHED;
}
@GeneratedBy(CastToJavaStringNode.class)
@DenyReplace
private static final class NativeObjectData extends Node implements SpecializationDataNode {
/**
* State Info:
* 0-16: InlinedCache
* Specialization: {@link CastToJavaStringNode#doNativeObject}
* Parameter: {@link GetClassNode} getClassNode
* Inline method: {@link GetClassNodeGen#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int nativeObject_state_0_;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#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 CastToJavaStringNode#doNativeObject}
* Parameter: {@link IsSubtypeNode} isSubtypeNode
*/
@Child IsSubtypeNode isSubtypeNode_;
/**
* Source Info:
* Specialization: {@link CastToJavaStringNode#doNativeObject}
* Parameter: {@link ReadNativeStringNode} read
*/
@Child ReadNativeStringNode read_;
NativeObjectData() {
}
@Override
public NodeCost getCost() {
return NodeCost.NONE;
}
private static Lookup lookup_() {
return MethodHandles.lookup();
}
}
@GeneratedBy(CastToJavaStringNode.class)
@DenyReplace
private static final class Uncached extends CastToJavaStringNode {
@TruffleBoundary
@Override
public String execute(Object arg0Value) throws CannotCastException {
if (arg0Value instanceof TruffleString) {
TruffleString arg0Value_ = (TruffleString) arg0Value;
return CastToJavaStringNode.doString(arg0Value_, (ToJavaStringNode.getUncached()));
}
if (arg0Value instanceof PString) {
PString arg0Value_ = (PString) arg0Value;
if ((arg0Value_.isMaterialized())) {
return CastToJavaStringNode.doPStringMaterialized(arg0Value_, (ToJavaStringNode.getUncached()));
}
if ((!(arg0Value_.isMaterialized()))) {
return CastToJavaStringNode.doPStringGeneric(arg0Value_, (this), (StringMaterializeNodeGen.getUncached()), (ToJavaStringNode.getUncached()));
}
}
if (arg0Value instanceof PythonNativeObject) {
PythonNativeObject arg0Value_ = (PythonNativeObject) arg0Value;
return CastToJavaStringNode.doNativeObject(arg0Value_, (this), (GetClassNode.getUncached()), (IsSubtypeNode.getUncached()), (ToJavaStringNode.getUncached()), (ReadNativeStringNodeGen.getUncached()));
}
if ((!(PGuards.isString(arg0Value))) && (!(PGuards.isNativeObject(arg0Value)))) {
return CastToJavaStringNode.doUnsupported(arg0Value);
}
throw new UnsupportedSpecializationException(this, new Node[] {null}, arg0Value);
}
@Override
public NodeCost getCost() {
return NodeCost.MEGAMORPHIC;
}
@Override
public boolean isAdoptable() {
return false;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy