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

com.oracle.truffle.api.interop.java.LookupInnerClassNodeGen Maven / Gradle / Ivy

Go to download

Truffle is a multi-language framework for executing dynamic languages that achieves high performance when combined with Graal.

There is a newer version: 1.0.0-rc7
Show newest version
// CheckStyle: start generated
package com.oracle.truffle.api.interop.java;

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.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
import java.util.concurrent.locks.Lock;

@GeneratedBy(LookupInnerClassNode.class)
final class LookupInnerClassNodeGen extends LookupInnerClassNode {

    @CompilationFinal private int state_;
    @CompilationFinal private int exclude_;
    @CompilationFinal private CachedData cached_cache;

    private LookupInnerClassNodeGen() {
    }

    @ExplodeLoop(kind = LoopExplosionKind.FULL_EXPLODE_UNTIL_RETURN)
    @Override
    public Class execute(Class arg0Value, String arg1Value) {
        int state = state_;
        if (state != 0 /* is-active doCached(Class<>, String, Class<>, String, Class<>) || doUncached(Class<>, String) */) {
            if ((state & 0b1) != 0 /* is-active doCached(Class<>, String, Class<>, String, Class<>) */) {
                CachedData s1_ = this.cached_cache;
                while (s1_ != null) {
                    if ((arg0Value == s1_.cachedClazz_) && (s1_.cachedName_.equals(arg1Value))) {
                        return LookupInnerClassNode.doCached(arg0Value, arg1Value, s1_.cachedClazz_, s1_.cachedName_, s1_.cachedInnerClass_);
                    }
                    s1_ = s1_.next_;
                }
            }
            if ((state & 0b10) != 0 /* is-active doUncached(Class<>, String) */) {
                return LookupInnerClassNode.doUncached(arg0Value, arg1Value);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(arg0Value, arg1Value);
    }

    private Class executeAndSpecialize(Class arg0Value, String arg1Value) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        int state = state_;
        int exclude = exclude_;
        try {
            if ((exclude) == 0 /* is-not-excluded doCached(Class<>, String, Class<>, String, Class<>) */) {
                int count1_ = 0;
                CachedData s1_ = this.cached_cache;
                if ((state & 0b1) != 0 /* is-active doCached(Class<>, String, Class<>, String, Class<>) */) {
                    while (s1_ != null) {
                        if ((arg0Value == s1_.cachedClazz_) && (s1_.cachedName_.equals(arg1Value))) {
                            break;
                        }
                        s1_ = s1_.next_;
                        count1_++;
                    }
                }
                if (s1_ == null) {
                    // assert (arg0Value == s1_.cachedClazz_);
                    // assert (s1_.cachedName_.equals(arg1Value));
                    if (count1_ < (LookupInnerClassNode.LIMIT)) {
                        s1_ = new CachedData(cached_cache);
                        s1_.cachedClazz_ = (arg0Value);
                        s1_.cachedName_ = (arg1Value);
                        s1_.cachedInnerClass_ = (LookupInnerClassNode.doUncached(arg0Value, arg1Value));
                        this.cached_cache = s1_;
                        this.state_ = state = state | 0b1 /* add-active doCached(Class<>, String, Class<>, String, Class<>) */;
                    }
                }
                if (s1_ != null) {
                    lock.unlock();
                    hasLock = false;
                    return LookupInnerClassNode.doCached(arg0Value, arg1Value, s1_.cachedClazz_, s1_.cachedName_, s1_.cachedInnerClass_);
                }
            }
            this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(Class<>, String, Class<>, String, Class<>) */;
            this.cached_cache = null;
            state = state & 0xfffffffe /* remove-active doCached(Class<>, String, Class<>, String, Class<>) */;
            this.state_ = state = state | 0b10 /* add-active doUncached(Class<>, String) */;
            lock.unlock();
            hasLock = false;
            return LookupInnerClassNode.doUncached(arg0Value, arg1Value);
        } finally {
            if (hasLock) {
                lock.unlock();
            }
        }
    }

    @Override
    public NodeCost getCost() {
        int state = state_;
        if (state == 0b0) {
            return NodeCost.UNINITIALIZED;
        } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
            CachedData s1_ = this.cached_cache;
            if ((s1_ == null || s1_.next_ == null)) {
                return NodeCost.MONOMORPHIC;
            }
        }
        return NodeCost.POLYMORPHIC;
    }

    public static LookupInnerClassNode create() {
        return new LookupInnerClassNodeGen();
    }

    @GeneratedBy(LookupInnerClassNode.class)
    private static final class CachedData {

        @CompilationFinal CachedData next_;
        @CompilationFinal Class cachedClazz_;
        @CompilationFinal String cachedName_;
        @CompilationFinal Class cachedInnerClass_;

        CachedData(CachedData next_) {
            this.next_ = next_;
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy