com.oracle.truffle.js.nodes.unary.JSOverloadedUnaryNodeGen Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.truffle.js.nodes.unary;
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.UnsupportedSpecializationException;
import com.oracle.truffle.api.dsl.DSLSupport.SpecializationDataNode;
import com.oracle.truffle.api.dsl.InlineSupport.ReferenceField;
import com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField;
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.strings.TruffleString;
import com.oracle.truffle.js.nodes.function.JSFunctionCallNode;
import com.oracle.truffle.js.runtime.builtins.JSOverloadedOperatorsObject;
import com.oracle.truffle.js.runtime.objects.OperatorSet;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Objects;
/**
* Debug Info:
* Specialization {@link JSOverloadedUnaryNode#doCached}
* Activation probability: 0.65000
* With/without class size: 24/12 bytes
* Specialization {@link JSOverloadedUnaryNode#doGeneric}
* Activation probability: 0.35000
* With/without class size: 11/4 bytes
*
*/
@GeneratedBy(JSOverloadedUnaryNode.class)
@SuppressWarnings("javadoc")
public final class JSOverloadedUnaryNodeGen extends JSOverloadedUnaryNode {
static final ReferenceField CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "cached_cache", CachedData.class);
/**
* State Info:
* 0: SpecializationActive {@link JSOverloadedUnaryNode#doCached}
* 1: SpecializationActive {@link JSOverloadedUnaryNode#doGeneric}
*
*/
@CompilationFinal private int state_0_;
@UnsafeAccessedField @Child private CachedData cached_cache;
/**
* Source Info:
* Specialization: {@link JSOverloadedUnaryNode#doGeneric}
* Parameter: {@link JSFunctionCallNode} callNode
*/
@Child private JSFunctionCallNode generic_callNode_;
private JSOverloadedUnaryNodeGen(TruffleString overloadedOperatorName) {
super(overloadedOperatorName);
}
@ExplodeLoop
@Override
public Object execute(Object arg0Value) {
int state_0 = this.state_0_;
if (state_0 != 0 /* is SpecializationActive[JSOverloadedUnaryNode.doCached(JSOverloadedOperatorsObject, int, Object, JSFunctionCallNode)] || SpecializationActive[JSOverloadedUnaryNode.doGeneric(JSOverloadedOperatorsObject, JSFunctionCallNode)] */ && arg0Value instanceof JSOverloadedOperatorsObject) {
JSOverloadedOperatorsObject arg0Value_ = (JSOverloadedOperatorsObject) arg0Value;
if ((state_0 & 0b1) != 0 /* is SpecializationActive[JSOverloadedUnaryNode.doCached(JSOverloadedOperatorsObject, int, Object, JSFunctionCallNode)] */) {
CachedData s0_ = this.cached_cache;
while (s0_ != null) {
if ((arg0Value_.matchesOperatorCounter(s0_.operatorCounter_))) {
return doCached(arg0Value_, s0_.operatorCounter_, s0_.operatorImplementation_, s0_.callNode_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[JSOverloadedUnaryNode.doGeneric(JSOverloadedOperatorsObject, JSFunctionCallNode)] */) {
{
JSFunctionCallNode callNode__ = this.generic_callNode_;
if (callNode__ != null) {
return doGeneric(arg0Value_, callNode__);
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value);
}
private Object executeAndSpecialize(Object arg0Value) {
int state_0 = this.state_0_;
int oldState_0 = state_0;
try {
if (arg0Value instanceof JSOverloadedOperatorsObject) {
JSOverloadedOperatorsObject arg0Value_ = (JSOverloadedOperatorsObject) arg0Value;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[JSOverloadedUnaryNode.doGeneric(JSOverloadedOperatorsObject, JSFunctionCallNode)] */) {
while (true) {
int count0_ = 0;
CachedData s0_ = CACHED_CACHE_UPDATER.getVolatile(this);
CachedData s0_original = s0_;
while (s0_ != null) {
if ((arg0Value_.matchesOperatorCounter(s0_.operatorCounter_))) {
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
{
int operatorCounter__ = (arg0Value_.getOperatorCounter());
if ((arg0Value_.matchesOperatorCounter(operatorCounter__)) && count0_ < (JSOverloadedUnaryNode.LIMIT)) {
s0_ = this.insert(new CachedData(s0_original));
s0_.operatorCounter_ = operatorCounter__;
s0_.operatorImplementation_ = (OperatorSet.getOperatorImplementation(arg0Value_, getOverloadedOperatorName()));
JSFunctionCallNode callNode__1 = s0_.insert((JSFunctionCallNode.createCall()));
Objects.requireNonNull(callNode__1, "A specialization cache returned a 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 the default value.");
s0_.callNode_ = callNode__1;
if (!CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[JSOverloadedUnaryNode.doCached(JSOverloadedOperatorsObject, int, Object, JSFunctionCallNode)] */;
this.state_0_ = state_0;
}
}
}
if (s0_ != null) {
return doCached(arg0Value_, s0_.operatorCounter_, s0_.operatorImplementation_, s0_.callNode_);
}
break;
}
}
JSFunctionCallNode callNode__ = this.insert((JSFunctionCallNode.createCall()));
Objects.requireNonNull(callNode__, "A specialization cache returned a 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 the default value.");
VarHandle.storeStoreFence();
this.generic_callNode_ = callNode__;
this.cached_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[JSOverloadedUnaryNode.doCached(JSOverloadedOperatorsObject, int, Object, JSFunctionCallNode)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[JSOverloadedUnaryNode.doGeneric(JSOverloadedOperatorsObject, JSFunctionCallNode)] */;
this.state_0_ = state_0;
return doGeneric(arg0Value_, callNode__);
}
throw new UnsupportedSpecializationException(this, null, arg0Value);
} finally {
if (oldState_0 != 0) {
checkForPolymorphicSpecialize(oldState_0);
}
}
}
private void checkForPolymorphicSpecialize(int oldState_0) {
if (((oldState_0 & 0b10) == 0 && (state_0_ & 0b10) != 0)) {
this.reportPolymorphicSpecialize();
}
}
@NeverDefault
public static JSOverloadedUnaryNode create(TruffleString overloadedOperatorName) {
return new JSOverloadedUnaryNodeGen(overloadedOperatorName);
}
@GeneratedBy(JSOverloadedUnaryNode.class)
@DenyReplace
private static final class CachedData extends Node implements SpecializationDataNode {
@Child CachedData next_;
/**
* Source Info:
* Specialization: {@link JSOverloadedUnaryNode#doCached}
* Parameter: int operatorCounter
*/
@CompilationFinal int operatorCounter_;
/**
* Source Info:
* Specialization: {@link JSOverloadedUnaryNode#doCached}
* Parameter: {@link Object} operatorImplementation
*/
@CompilationFinal Object operatorImplementation_;
/**
* Source Info:
* Specialization: {@link JSOverloadedUnaryNode#doCached}
* Parameter: {@link JSFunctionCallNode} callNode
*/
@Child JSFunctionCallNode callNode_;
CachedData(CachedData next_) {
this.next_ = next_;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy