All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.truffle.js.nodes.CompileRegexNodeGen Maven / Gradle / Ivy

The newest version!
// CheckStyle: start generated
package com.oracle.truffle.js.nodes;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.DSLSupport;
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.api.strings.TruffleString.EqualNode;
import com.oracle.truffle.api.strings.TruffleString.ToJavaStringNode;
import com.oracle.truffle.api.utilities.AssumedValue;
import com.oracle.truffle.js.runtime.JSConfig;
import com.oracle.truffle.js.runtime.JSContext;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Objects;

/**
 * Debug Info: 
 *   Specialization {@link CompileRegexNode#getCached}
 *     Activation probability: 0.48333
 *     With/without class size: 23/20 bytes
 *   Specialization {@link CompileRegexNode#doCompileNoTrimCache}
 *     Activation probability: 0.33333
 *     With/without class size: 8/0 bytes
 *   Specialization {@link CompileRegexNode#doCompile}
 *     Activation probability: 0.18333
 *     With/without class size: 6/0 bytes
 * 
*/ @GeneratedBy(CompileRegexNode.class) @SuppressWarnings("javadoc") public final class CompileRegexNodeGen extends CompileRegexNode { static final ReferenceField GET_CACHED_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "getCached_cache", GetCachedData.class); /** * State Info:
     *   0: SpecializationActive {@link CompileRegexNode#getCached}
     *   1: SpecializationActive {@link CompileRegexNode#doCompile}
     *   2: SpecializationActive {@link CompileRegexNode#doCompileNoTrimCache}
     * 
*/ @CompilationFinal private int state_0_; /** * Source Info:
     *   Specialization: {@link CompileRegexNode#getCached}
     *   Parameter: {@link ToJavaStringNode} toJavaString
*/ @Child private ToJavaStringNode toJavaString; @UnsafeAccessedField @Child private GetCachedData getCached_cache; private CompileRegexNodeGen(JSContext context) { super(context); } @ExplodeLoop @Override protected Object executeCompile(Object arg0Value, Object arg1Value) { int state_0 = this.state_0_; if (state_0 != 0 /* is SpecializationActive[CompileRegexNode.getCached(TruffleString, TruffleString, TruffleString, TruffleString, AssumedValue, EqualNode, EqualNode, ToJavaStringNode)] || SpecializationActive[CompileRegexNode.doCompileNoTrimCache(TruffleString, TruffleString, ToJavaStringNode)] || SpecializationActive[CompileRegexNode.doCompile(TruffleString, TruffleString, ToJavaStringNode)] */ && arg0Value instanceof TruffleString) { TruffleString arg0Value_ = (TruffleString) arg0Value; if (arg1Value instanceof TruffleString) { TruffleString arg1Value_ = (TruffleString) arg1Value; if ((state_0 & 0b1) != 0 /* is SpecializationActive[CompileRegexNode.getCached(TruffleString, TruffleString, TruffleString, TruffleString, AssumedValue, EqualNode, EqualNode, ToJavaStringNode)] */) { GetCachedData s0_ = this.getCached_cache; while (s0_ != null) { { ToJavaStringNode toJavaString_ = this.toJavaString; if (toJavaString_ != null) { if ((CompileRegexNode.stringEquals(s0_.equalsNode_, arg0Value_, s0_.cachedPattern_)) && (CompileRegexNode.stringEquals(s0_.equalsNode2_, arg1Value_, s0_.cachedFlags_))) { return getCached(arg0Value_, arg1Value_, s0_.cachedPattern_, s0_.cachedFlags_, s0_.cachedCompiledRegex_, s0_.equalsNode_, s0_.equalsNode2_, toJavaString_); } } } s0_ = s0_.next_; } } if ((state_0 & 0b100) != 0 /* is SpecializationActive[CompileRegexNode.doCompileNoTrimCache(TruffleString, TruffleString, ToJavaStringNode)] */) { { ToJavaStringNode toJavaString_1 = this.toJavaString; if (toJavaString_1 != null) { assert DSLSupport.assertIdempotence((!(JSConfig.TrimCompiledRegexCache))); return doCompileNoTrimCache(arg0Value_, arg1Value_, toJavaString_1); } } } if ((state_0 & 0b10) != 0 /* is SpecializationActive[CompileRegexNode.doCompile(TruffleString, TruffleString, ToJavaStringNode)] */) { { ToJavaStringNode toJavaString_2 = this.toJavaString; if (toJavaString_2 != null) { return doCompile(arg0Value_, arg1Value_, toJavaString_2); } } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); return executeAndSpecialize(arg0Value, arg1Value); } @SuppressWarnings("unused") private Object executeAndSpecialize(Object arg0Value, Object arg1Value) { int state_0 = this.state_0_; int oldState_0 = state_0; try { if (arg0Value instanceof TruffleString) { TruffleString arg0Value_ = (TruffleString) arg0Value; if (arg1Value instanceof TruffleString) { TruffleString arg1Value_ = (TruffleString) arg1Value; if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[CompileRegexNode.doCompile(TruffleString, TruffleString, ToJavaStringNode)] */) { while (true) { int count0_ = 0; GetCachedData s0_ = GET_CACHED_CACHE_UPDATER.getVolatile(this); GetCachedData s0_original = s0_; while (s0_ != null) { { ToJavaStringNode toJavaString_ = this.toJavaString; if (toJavaString_ != null) { if ((CompileRegexNode.stringEquals(s0_.equalsNode_, arg0Value_, s0_.cachedPattern_)) && (CompileRegexNode.stringEquals(s0_.equalsNode2_, arg1Value_, s0_.cachedFlags_))) { break; } } } count0_++; s0_ = s0_.next_; } if (s0_ == null) { { TruffleString cachedPattern__ = (arg0Value_); EqualNode equalsNode__ = this.insert((EqualNode.create())); if ((CompileRegexNode.stringEquals(equalsNode__, arg0Value_, cachedPattern__))) { TruffleString cachedFlags__ = (arg1Value_); EqualNode equalsNode2__ = this.insert((EqualNode.create())); if ((CompileRegexNode.stringEquals(equalsNode2__, arg1Value_, cachedFlags__)) && count0_ < (JSConfig.MaxCompiledRegexCacheLength)) { s0_ = this.insert(new GetCachedData(s0_original)); s0_.cachedPattern_ = cachedPattern__; s0_.cachedFlags_ = cachedFlags__; s0_.cachedCompiledRegex_ = (createAssumedValue()); Objects.requireNonNull(s0_.insert(equalsNode__), "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_.equalsNode_ = equalsNode__; Objects.requireNonNull(s0_.insert(equalsNode2__), "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_.equalsNode2_ = equalsNode2__; ToJavaStringNode toJavaString_; ToJavaStringNode toJavaString__shared = this.toJavaString; if (toJavaString__shared != null) { toJavaString_ = toJavaString__shared; } else { toJavaString_ = s0_.insert((ToJavaStringNode.create())); if (toJavaString_ == 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.toJavaString == null) { this.toJavaString = toJavaString_; } if (!GET_CACHED_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) { continue; } state_0 = state_0 | 0b1 /* add SpecializationActive[CompileRegexNode.getCached(TruffleString, TruffleString, TruffleString, TruffleString, AssumedValue, EqualNode, EqualNode, ToJavaStringNode)] */; this.state_0_ = state_0; } } } } if (s0_ != null) { return getCached(arg0Value_, arg1Value_, s0_.cachedPattern_, s0_.cachedFlags_, s0_.cachedCompiledRegex_, s0_.equalsNode_, s0_.equalsNode2_, this.toJavaString); } break; } } if ((!(JSConfig.TrimCompiledRegexCache))) { ToJavaStringNode toJavaString_1; ToJavaStringNode toJavaString_1_shared = this.toJavaString; if (toJavaString_1_shared != null) { toJavaString_1 = toJavaString_1_shared; } else { toJavaString_1 = this.insert((ToJavaStringNode.create())); if (toJavaString_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.toJavaString == null) { VarHandle.storeStoreFence(); this.toJavaString = toJavaString_1; } state_0 = state_0 | 0b100 /* add SpecializationActive[CompileRegexNode.doCompileNoTrimCache(TruffleString, TruffleString, ToJavaStringNode)] */; this.state_0_ = state_0; return doCompileNoTrimCache(arg0Value_, arg1Value_, toJavaString_1); } ToJavaStringNode toJavaString_2; ToJavaStringNode toJavaString_2_shared = this.toJavaString; if (toJavaString_2_shared != null) { toJavaString_2 = toJavaString_2_shared; } else { toJavaString_2 = this.insert((ToJavaStringNode.create())); if (toJavaString_2 == 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.toJavaString == null) { VarHandle.storeStoreFence(); this.toJavaString = toJavaString_2; } this.getCached_cache = null; state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[CompileRegexNode.getCached(TruffleString, TruffleString, TruffleString, TruffleString, AssumedValue, EqualNode, EqualNode, ToJavaStringNode)] */; state_0 = state_0 | 0b10 /* add SpecializationActive[CompileRegexNode.doCompile(TruffleString, TruffleString, ToJavaStringNode)] */; this.state_0_ = state_0; return doCompile(arg0Value_, arg1Value_, toJavaString_2); } } throw new UnsupportedSpecializationException(this, null, arg0Value, arg1Value); } 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 CompileRegexNode create(JSContext context) { return new CompileRegexNodeGen(context); } @GeneratedBy(CompileRegexNode.class) @DenyReplace private static final class GetCachedData extends Node implements SpecializationDataNode { @Child GetCachedData next_; /** * Source Info:
         *   Specialization: {@link CompileRegexNode#getCached}
         *   Parameter: {@link TruffleString} cachedPattern
*/ @CompilationFinal TruffleString cachedPattern_; /** * Source Info:
         *   Specialization: {@link CompileRegexNode#getCached}
         *   Parameter: {@link TruffleString} cachedFlags
*/ @CompilationFinal TruffleString cachedFlags_; /** * Source Info:
         *   Specialization: {@link CompileRegexNode#getCached}
         *   Parameter: {@link AssumedValue} cachedCompiledRegex
*/ @CompilationFinal AssumedValue cachedCompiledRegex_; /** * Source Info:
         *   Specialization: {@link CompileRegexNode#getCached}
         *   Parameter: {@link EqualNode} equalsNode
*/ @Child EqualNode equalsNode_; /** * Source Info:
         *   Specialization: {@link CompileRegexNode#getCached}
         *   Parameter: {@link EqualNode} equalsNode2
*/ @Child EqualNode equalsNode2_; GetCachedData(GetCachedData next_) { this.next_ = next_; } } }