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

com.oracle.truffle.js.nodes.array.JSGetLengthNodeGen Maven / Gradle / Ivy

// CheckStyle: start generated
package com.oracle.truffle.js.nodes.array;

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.ReferenceField;
import com.oracle.truffle.api.dsl.InlineSupport.UnsafeAccessedField;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.js.nodes.JSGuards;
import com.oracle.truffle.js.nodes.access.PropertyGetNode;
import com.oracle.truffle.js.nodes.array.ArrayLengthNode.ArrayLengthReadNode;
import com.oracle.truffle.js.nodes.interop.ImportValueNode;
import com.oracle.truffle.js.runtime.JSContext;
import com.oracle.truffle.js.runtime.builtins.JSArrayObject;
import com.oracle.truffle.js.runtime.objects.JSDynamicObject;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Objects;

/**
 * Debug Info: 
 *   Specialization {@link JSGetLengthNode#getArrayLengthInt}
 *     Activation probability: 0.32000
 *     With/without class size: 7/0 bytes
 *   Specialization {@link JSGetLengthNode#getArrayLength}
 *     Activation probability: 0.26000
 *     With/without class size: 7/0 bytes
 *   Specialization {@link JSGetLengthNode#getNonArrayLength}
 *     Activation probability: 0.20000
 *     With/without class size: 8/4 bytes
 *   Specialization {@link JSGetLengthNode#getLengthForeign}
 *     Activation probability: 0.14000
 *     With/without class size: 7/8 bytes
 *   Specialization {@link JSGetLengthNode#getLengthForeign}
 *     Activation probability: 0.08000
 *     With/without class size: 5/4 bytes
 * 
*/ @GeneratedBy(JSGetLengthNode.class) @SuppressWarnings({"javadoc", "unused"}) public final class JSGetLengthNodeGen extends JSGetLengthNode { static final ReferenceField GET_LENGTH_FOREIGN0_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "getLengthForeign0_cache", GetLengthForeign0Data.class); private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class); /** * State Info:
     *   0: SpecializationActive {@link JSGetLengthNode#getArrayLengthInt}
     *   1: SpecializationExcluded {@link JSGetLengthNode#getArrayLengthInt}
     *   2: SpecializationActive {@link JSGetLengthNode#getArrayLength}
     *   3: SpecializationActive {@link JSGetLengthNode#getNonArrayLength}
     *   4: SpecializationActive {@link JSGetLengthNode#getLengthForeign}
     *   5: SpecializationActive {@link JSGetLengthNode#getLengthForeign}
     * 
*/ @CompilationFinal private int state_0_; /** * Source Info:
     *   Specialization: {@link JSGetLengthNode#getArrayLengthInt}
     *   Parameter: {@link ArrayLengthReadNode} arrayLengthReadNode
*/ @Child private ArrayLengthReadNode arrayLengthReadNode; /** * Source Info:
     *   Specialization: {@link JSGetLengthNode#getNonArrayLength}
     *   Parameter: {@link PropertyGetNode} getLengthPropertyNode
*/ @Child private PropertyGetNode getNonArrayLength_getLengthPropertyNode_; @UnsafeAccessedField @Child private GetLengthForeign0Data getLengthForeign0_cache; /** * Source Info:
     *   Specialization: {@link JSGetLengthNode#getLengthForeign}
     *   Parameter: {@link ImportValueNode} importValueNode
*/ @Child private ImportValueNode getLengthForeign1_importValueNode_; private JSGetLengthNodeGen(JSContext context) { super(context); } @ExplodeLoop @Override public Object execute(Object arg0Value) { int state_0 = this.state_0_; if ((state_0 & 0b111101) != 0 /* is SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] || SpecializationActive[JSGetLengthNode.getArrayLength(JSArrayObject, ArrayLengthReadNode)] || SpecializationActive[JSGetLengthNode.getNonArrayLength(JSDynamicObject, PropertyGetNode)] || SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] || SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */) { if ((state_0 & 0b101) != 0 /* is SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] || SpecializationActive[JSGetLengthNode.getArrayLength(JSArrayObject, ArrayLengthReadNode)] */ && arg0Value instanceof JSArrayObject) { JSArrayObject arg0Value_ = (JSArrayObject) arg0Value; if ((state_0 & 0b1) != 0 /* is SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] */) { { ArrayLengthReadNode arrayLengthReadNode_ = this.arrayLengthReadNode; if (arrayLengthReadNode_ != null) { try { return getArrayLengthInt(arg0Value_, arrayLengthReadNode_); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); state_0 = this.state_0_; state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] */; state_0 = state_0 | 0b10 /* add SpecializationExcluded */; this.state_0_ = state_0; return ex.getResult(); } } } } if ((state_0 & 0b100) != 0 /* is SpecializationActive[JSGetLengthNode.getArrayLength(JSArrayObject, ArrayLengthReadNode)] */) { { ArrayLengthReadNode arrayLengthReadNode_1 = this.arrayLengthReadNode; if (arrayLengthReadNode_1 != null) { return getArrayLength(arg0Value_, arrayLengthReadNode_1); } } } } if ((state_0 & 0b1000) != 0 /* is SpecializationActive[JSGetLengthNode.getNonArrayLength(JSDynamicObject, PropertyGetNode)] */ && arg0Value instanceof JSDynamicObject) { JSDynamicObject arg0Value_ = (JSDynamicObject) arg0Value; { PropertyGetNode getLengthPropertyNode__ = this.getNonArrayLength_getLengthPropertyNode_; if (getLengthPropertyNode__ != null) { if ((!(JSGuards.isJSArray(arg0Value_)))) { return getNonArrayLength(arg0Value_, getLengthPropertyNode__); } } } } if ((state_0 & 0b110000) != 0 /* is SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] || SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */) { if ((state_0 & 0b10000) != 0 /* is SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */) { GetLengthForeign0Data s3_ = this.getLengthForeign0_cache; while (s3_ != null) { if ((s3_.interop_.accepts(arg0Value)) && (!(JSGuards.isJSDynamicObject(arg0Value)))) { return getLengthForeign(arg0Value, s3_.interop_, s3_.importValueNode_); } s3_ = s3_.next_; } } if ((state_0 & 0b100000) != 0 /* is SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */) { { ImportValueNode importValueNode__ = this.getLengthForeign1_importValueNode_; if (importValueNode__ != null) { if ((!(JSGuards.isJSDynamicObject(arg0Value)))) { return this.getLengthForeign1Boundary(state_0, arg0Value, importValueNode__); } } } } } } CompilerDirectives.transferToInterpreterAndInvalidate(); return executeAndSpecialize(arg0Value); } @SuppressWarnings("static-method") @TruffleBoundary private Object getLengthForeign1Boundary(int state_0, Object arg0Value, ImportValueNode importValueNode__) { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { { InteropLibrary interop__ = (INTEROP_LIBRARY_.getUncached(arg0Value)); return getLengthForeign(arg0Value, interop__, importValueNode__); } } finally { encapsulating_.set(prev_); } } private Object executeAndSpecialize(Object arg0Value) { int state_0 = this.state_0_; if (arg0Value instanceof JSArrayObject) { JSArrayObject arg0Value_ = (JSArrayObject) arg0Value; if (((state_0 & 0b100)) == 0 /* is-not SpecializationActive[JSGetLengthNode.getArrayLength(JSArrayObject, ArrayLengthReadNode)] */ && ((state_0 & 0b10)) == 0 /* is-not SpecializationExcluded */) { ArrayLengthReadNode arrayLengthReadNode_; ArrayLengthReadNode arrayLengthReadNode__shared = this.arrayLengthReadNode; if (arrayLengthReadNode__shared != null) { arrayLengthReadNode_ = arrayLengthReadNode__shared; } else { arrayLengthReadNode_ = this.insert((ArrayLengthReadNode.create())); if (arrayLengthReadNode_ == 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.arrayLengthReadNode == null) { VarHandle.storeStoreFence(); this.arrayLengthReadNode = arrayLengthReadNode_; } state_0 = state_0 | 0b1 /* add SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] */; this.state_0_ = state_0; try { return getArrayLengthInt(arg0Value_, arrayLengthReadNode_); } catch (UnexpectedResultException ex) { CompilerDirectives.transferToInterpreterAndInvalidate(); state_0 = this.state_0_; state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] */; state_0 = state_0 | 0b10 /* add SpecializationExcluded */; this.state_0_ = state_0; return ex.getResult(); } } ArrayLengthReadNode arrayLengthReadNode_1; ArrayLengthReadNode arrayLengthReadNode_1_shared = this.arrayLengthReadNode; if (arrayLengthReadNode_1_shared != null) { arrayLengthReadNode_1 = arrayLengthReadNode_1_shared; } else { arrayLengthReadNode_1 = this.insert((ArrayLengthReadNode.create())); if (arrayLengthReadNode_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.arrayLengthReadNode == null) { VarHandle.storeStoreFence(); this.arrayLengthReadNode = arrayLengthReadNode_1; } state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[JSGetLengthNode.getArrayLengthInt(JSArrayObject, ArrayLengthReadNode)] */; state_0 = state_0 | 0b100 /* add SpecializationActive[JSGetLengthNode.getArrayLength(JSArrayObject, ArrayLengthReadNode)] */; this.state_0_ = state_0; return getArrayLength(arg0Value_, arrayLengthReadNode_1); } if (arg0Value instanceof JSDynamicObject) { JSDynamicObject arg0Value_ = (JSDynamicObject) arg0Value; if ((!(JSGuards.isJSArray(arg0Value_)))) { PropertyGetNode getLengthPropertyNode__ = this.insert((createLengthProperty())); Objects.requireNonNull(getLengthPropertyNode__, "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.getNonArrayLength_getLengthPropertyNode_ = getLengthPropertyNode__; state_0 = state_0 | 0b1000 /* add SpecializationActive[JSGetLengthNode.getNonArrayLength(JSDynamicObject, PropertyGetNode)] */; this.state_0_ = state_0; return getNonArrayLength(arg0Value_, getLengthPropertyNode__); } } if (((state_0 & 0b100000)) == 0 /* is-not SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */) { while (true) { int count3_ = 0; GetLengthForeign0Data s3_ = GET_LENGTH_FOREIGN0_CACHE_UPDATER.getVolatile(this); GetLengthForeign0Data s3_original = s3_; while (s3_ != null) { if ((s3_.interop_.accepts(arg0Value)) && (!(JSGuards.isJSDynamicObject(arg0Value)))) { break; } count3_++; s3_ = s3_.next_; } if (s3_ == null) { if ((!(JSGuards.isJSDynamicObject(arg0Value))) && count3_ < (3)) { // assert (s3_.interop_.accepts(arg0Value)); s3_ = this.insert(new GetLengthForeign0Data(s3_original)); InteropLibrary interop__ = s3_.insert((INTEROP_LIBRARY_.create(arg0Value))); Objects.requireNonNull(interop__, "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."); s3_.interop_ = interop__; ImportValueNode importValueNode__ = s3_.insert((ImportValueNode.create())); Objects.requireNonNull(importValueNode__, "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."); s3_.importValueNode_ = importValueNode__; if (!GET_LENGTH_FOREIGN0_CACHE_UPDATER.compareAndSet(this, s3_original, s3_)) { continue; } state_0 = state_0 | 0b10000 /* add SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */; this.state_0_ = state_0; } } if (s3_ != null) { return getLengthForeign(arg0Value, s3_.interop_, s3_.importValueNode_); } break; } } { InteropLibrary interop__ = null; { EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent(); Node prev_ = encapsulating_.set(this); try { if ((!(JSGuards.isJSDynamicObject(arg0Value)))) { interop__ = (INTEROP_LIBRARY_.getUncached(arg0Value)); ImportValueNode importValueNode__ = this.insert((ImportValueNode.create())); Objects.requireNonNull(importValueNode__, "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.getLengthForeign1_importValueNode_ = importValueNode__; this.getLengthForeign0_cache = null; state_0 = state_0 & 0xffffffef /* remove SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */; state_0 = state_0 | 0b100000 /* add SpecializationActive[JSGetLengthNode.getLengthForeign(Object, InteropLibrary, ImportValueNode)] */; this.state_0_ = state_0; return getLengthForeign(arg0Value, interop__, importValueNode__); } } finally { encapsulating_.set(prev_); } } } throw new UnsupportedSpecializationException(this, null, arg0Value); } @NeverDefault public static JSGetLengthNode create(JSContext context) { return new JSGetLengthNodeGen(context); } @GeneratedBy(JSGetLengthNode.class) @DenyReplace private static final class GetLengthForeign0Data extends Node implements SpecializationDataNode { @Child GetLengthForeign0Data next_; /** * Source Info:
         *   Specialization: {@link JSGetLengthNode#getLengthForeign}
         *   Parameter: {@link InteropLibrary} interop
*/ @Child InteropLibrary interop_; /** * Source Info:
         *   Specialization: {@link JSGetLengthNode#getLengthForeign}
         *   Parameter: {@link ImportValueNode} importValueNode
*/ @Child ImportValueNode importValueNode_; GetLengthForeign0Data(GetLengthForeign0Data next_) { this.next_ = next_; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy