org.truffleruby.cext.SymbolToIDNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ruby-language Show documentation
Show all versions of ruby-language Show documentation
Core module of Ruby on Truffle
The newest version!
// CheckStyle: start generated
package org.truffleruby.cext;
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.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import org.truffleruby.core.symbol.RubySymbol;
/**
* Debug Info:
* Specialization {@link SymbolToIDNode#getIDCached}
* Activation probability: 0.65000
* With/without class size: 19/8 bytes
* Specialization {@link SymbolToIDNode#getIDUncached}
* Activation probability: 0.35000
* With/without class size: 11/1 bytes
*
*/
@GeneratedBy(SymbolToIDNode.class)
@SuppressWarnings("javadoc")
public final class SymbolToIDNodeGen extends SymbolToIDNode {
private static final StateField STATE_0_SymbolToIDNode_UPDATER = StateField.create(MethodHandles.lookup(), "state_0_");
static final ReferenceField GET_I_D_CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "getIDCached_cache", GetIDCachedData.class);
/**
* Source Info:
* Specialization: {@link SymbolToIDNode#getIDUncached}
* Parameter: {@link InlinedConditionProfile} staticSymbolProfile
* Inline method: {@link InlinedConditionProfile#inline}
*/
private static final InlinedConditionProfile INLINED_GET_I_D_UNCACHED_STATIC_SYMBOL_PROFILE_ = InlinedConditionProfile.inline(InlineTarget.create(InlinedConditionProfile.class, STATE_0_SymbolToIDNode_UPDATER.subUpdater(2, 2)));
private static final Uncached UNCACHED = new Uncached();
/**
* State Info:
* 0: SpecializationActive {@link SymbolToIDNode#getIDCached}
* 1: SpecializationActive {@link SymbolToIDNode#getIDUncached}
* 2-3: InlinedCache
* Specialization: {@link SymbolToIDNode#getIDUncached}
* Parameter: {@link InlinedConditionProfile} staticSymbolProfile
* Inline method: {@link InlinedConditionProfile#inline}
*
*/
@CompilationFinal @UnsafeAccessedField private int state_0_;
/**
* Source Info:
* Specialization: {@link SymbolToIDNode#getIDCached}
* Parameter: {@link WrapNode} wrapNode
*/
@Child private WrapNode wrapNode;
@UnsafeAccessedField @CompilationFinal private GetIDCachedData getIDCached_cache;
private SymbolToIDNodeGen() {
}
@ExplodeLoop
@Override
public Object execute(Object arg0Value) {
int state_0 = this.state_0_;
if ((state_0 & 0b11) != 0 /* is SpecializationActive[SymbolToIDNode.getIDCached(RubySymbol, WrapNode, RubySymbol, Object)] || SpecializationActive[SymbolToIDNode.getIDUncached(RubySymbol, WrapNode, InlinedConditionProfile)] */ && arg0Value instanceof RubySymbol) {
RubySymbol arg0Value_ = (RubySymbol) arg0Value;
if ((state_0 & 0b1) != 0 /* is SpecializationActive[SymbolToIDNode.getIDCached(RubySymbol, WrapNode, RubySymbol, Object)] */) {
GetIDCachedData s0_ = this.getIDCached_cache;
while (s0_ != null) {
{
WrapNode wrapNode_ = this.wrapNode;
if (wrapNode_ != null) {
if ((arg0Value_ == s0_.cachedSymbol_)) {
return getIDCached(arg0Value_, wrapNode_, s0_.cachedSymbol_, s0_.cachedID_);
}
}
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[SymbolToIDNode.getIDUncached(RubySymbol, WrapNode, InlinedConditionProfile)] */) {
{
WrapNode wrapNode_1 = this.wrapNode;
if (wrapNode_1 != null) {
return getIDUncached(arg0Value_, wrapNode_1, INLINED_GET_I_D_UNCACHED_STATIC_SYMBOL_PROFILE_);
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value);
}
private Object executeAndSpecialize(Object arg0Value) {
int state_0 = this.state_0_;
int oldState_0 = (state_0 & 0b11);
int oldCacheCount = countCaches();
try {
if (arg0Value instanceof RubySymbol) {
RubySymbol arg0Value_ = (RubySymbol) arg0Value;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[SymbolToIDNode.getIDUncached(RubySymbol, WrapNode, InlinedConditionProfile)] */) {
while (true) {
int count0_ = 0;
GetIDCachedData s0_ = GET_I_D_CACHED_CACHE_UPDATER.getVolatile(this);
GetIDCachedData s0_original = s0_;
while (s0_ != null) {
{
WrapNode wrapNode_ = this.wrapNode;
if (wrapNode_ != null) {
if ((arg0Value_ == s0_.cachedSymbol_)) {
break;
}
}
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (arg0Value_ == s0_.cachedSymbol_);
if (count0_ < (2)) {
s0_ = new GetIDCachedData(s0_original);
WrapNode wrapNode_;
WrapNode wrapNode__shared = this.wrapNode;
if (wrapNode__shared != null) {
wrapNode_ = wrapNode__shared;
} else {
wrapNode_ = this.insert((WrapNode.create()));
if (wrapNode_ == null) {
throw new IllegalStateException("A specialization returned a default value for a cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.wrapNode == null) {
this.wrapNode = wrapNode_;
}
s0_.cachedSymbol_ = (arg0Value_);
s0_.cachedID_ = (getID(s0_.cachedSymbol_, wrapNode_));
if (!GET_I_D_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[SymbolToIDNode.getIDCached(RubySymbol, WrapNode, RubySymbol, Object)] */;
this.state_0_ = state_0;
}
}
if (s0_ != null) {
return getIDCached(arg0Value_, this.wrapNode, s0_.cachedSymbol_, s0_.cachedID_);
}
break;
}
}
WrapNode wrapNode_1;
WrapNode wrapNode_1_shared = this.wrapNode;
if (wrapNode_1_shared != null) {
wrapNode_1 = wrapNode_1_shared;
} else {
wrapNode_1 = this.insert((WrapNode.create()));
if (wrapNode_1 == null) {
throw new IllegalStateException("A specialization returned a default value for a cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.wrapNode == null) {
VarHandle.storeStoreFence();
this.wrapNode = wrapNode_1;
}
this.getIDCached_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[SymbolToIDNode.getIDCached(RubySymbol, WrapNode, RubySymbol, Object)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[SymbolToIDNode.getIDUncached(RubySymbol, WrapNode, InlinedConditionProfile)] */;
this.state_0_ = state_0;
return getIDUncached(arg0Value_, wrapNode_1, INLINED_GET_I_D_UNCACHED_STATIC_SYMBOL_PROFILE_);
}
throw new UnsupportedSpecializationException(this, null, arg0Value);
} finally {
if (oldState_0 != 0) {
checkForPolymorphicSpecialize(oldState_0, oldCacheCount);
}
}
}
private void checkForPolymorphicSpecialize(int oldState_0, int oldCacheCount) {
int state_0 = this.state_0_;
int newState_0 = (state_0 & 0b11);
if (((oldState_0 ^ newState_0) != 0) || oldCacheCount < countCaches()) {
this.reportPolymorphicSpecialize();
}
}
private int countCaches() {
int cacheCount = 0;
GetIDCachedData s0_ = this.getIDCached_cache;
while (s0_ != null) {
cacheCount++;
s0_ = s0_.next_;
}
return cacheCount;
}
@TruffleBoundary
private static UnsupportedSpecializationException newUnsupportedSpecializationException1(Node thisNode_, Object arg0Value) {
return new UnsupportedSpecializationException(thisNode_, null, arg0Value);
}
@NeverDefault
public static SymbolToIDNode create() {
return new SymbolToIDNodeGen();
}
@NeverDefault
public static SymbolToIDNode getUncached() {
return SymbolToIDNodeGen.UNCACHED;
}
@GeneratedBy(SymbolToIDNode.class)
@DenyReplace
private static final class GetIDCachedData implements SpecializationDataNode {
@CompilationFinal final GetIDCachedData next_;
/**
* Source Info:
* Specialization: {@link SymbolToIDNode#getIDCached}
* Parameter: {@link RubySymbol} cachedSymbol
*/
@CompilationFinal RubySymbol cachedSymbol_;
/**
* Source Info:
* Specialization: {@link SymbolToIDNode#getIDCached}
* Parameter: {@link Object} cachedID
*/
@CompilationFinal Object cachedID_;
GetIDCachedData(GetIDCachedData next_) {
this.next_ = next_;
}
}
@GeneratedBy(SymbolToIDNode.class)
@DenyReplace
private static final class Uncached extends SymbolToIDNode implements UnadoptableNode {
@TruffleBoundary
@Override
public Object execute(Object arg0Value) {
if (arg0Value instanceof RubySymbol) {
RubySymbol arg0Value_ = (RubySymbol) arg0Value;
return getIDUncached(arg0Value_, (WrapNodeGen.getUncached()), (InlinedConditionProfile.getUncached()));
}
throw newUnsupportedSpecializationException1(this, arg0Value);
}
}
}