com.oracle.truffle.api.interop.java.LookupMethodNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-api Show documentation
Show all versions of truffle-api Show documentation
Truffle is a multi-language framework for executing dynamic languages
that achieves high performance when combined with Graal.
// 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(LookupMethodNode.class)
final class LookupMethodNodeGen extends LookupMethodNode {
@CompilationFinal private int state_;
@CompilationFinal private int exclude_;
@CompilationFinal private CachedData cached_cache;
private LookupMethodNodeGen() {
}
@ExplodeLoop(kind = LoopExplosionKind.FULL_EXPLODE_UNTIL_RETURN)
@Override
public JavaMethodDesc execute(Class> arg0Value, String arg1Value, boolean arg2Value) {
int state = state_;
if (state != 0 /* is-active doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) || doUncached(Class<>, String, boolean) */) {
if ((state & 0b1) != 0 /* is-active doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */) {
CachedData s1_ = this.cached_cache;
while (s1_ != null) {
if ((arg2Value == s1_.cachedStatic_) && (arg0Value == s1_.cachedClazz_) && (s1_.cachedName_.equals(arg1Value))) {
return LookupMethodNode.doCached(arg0Value, arg1Value, arg2Value, s1_.cachedStatic_, s1_.cachedClazz_, s1_.cachedName_, s1_.cachedMethod_);
}
s1_ = s1_.next_;
}
}
if ((state & 0b10) != 0 /* is-active doUncached(Class<>, String, boolean) */) {
return LookupMethodNode.doUncached(arg0Value, arg1Value, arg2Value);
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
}
private JavaMethodDesc executeAndSpecialize(Class> arg0Value, String arg1Value, boolean arg2Value) {
Lock lock = getLock();
boolean hasLock = true;
lock.lock();
int state = state_;
int exclude = exclude_;
try {
if ((exclude) == 0 /* is-not-excluded doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */) {
int count1_ = 0;
CachedData s1_ = this.cached_cache;
if ((state & 0b1) != 0 /* is-active doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */) {
while (s1_ != null) {
if ((arg2Value == s1_.cachedStatic_) && (arg0Value == s1_.cachedClazz_) && (s1_.cachedName_.equals(arg1Value))) {
break;
}
s1_ = s1_.next_;
count1_++;
}
}
if (s1_ == null) {
// assert (arg2Value == s1_.cachedStatic_);
// assert (arg0Value == s1_.cachedClazz_);
// assert (s1_.cachedName_.equals(arg1Value));
if (count1_ < (LookupMethodNode.LIMIT)) {
s1_ = new CachedData(cached_cache);
s1_.cachedStatic_ = (arg2Value);
s1_.cachedClazz_ = (arg0Value);
s1_.cachedName_ = (arg1Value);
s1_.cachedMethod_ = (LookupMethodNode.doUncached(arg0Value, arg1Value, arg2Value));
this.cached_cache = s1_;
this.state_ = state = state | 0b1 /* add-active doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */;
}
}
if (s1_ != null) {
lock.unlock();
hasLock = false;
return LookupMethodNode.doCached(arg0Value, arg1Value, arg2Value, s1_.cachedStatic_, s1_.cachedClazz_, s1_.cachedName_, s1_.cachedMethod_);
}
}
this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */;
this.cached_cache = null;
state = state & 0xfffffffe /* remove-active doCached(Class<>, String, boolean, boolean, Class<>, String, JavaMethodDesc) */;
this.state_ = state = state | 0b10 /* add-active doUncached(Class<>, String, boolean) */;
lock.unlock();
hasLock = false;
return LookupMethodNode.doUncached(arg0Value, arg1Value, arg2Value);
} 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 LookupMethodNode create() {
return new LookupMethodNodeGen();
}
@GeneratedBy(LookupMethodNode.class)
private static final class CachedData {
@CompilationFinal CachedData next_;
@CompilationFinal boolean cachedStatic_;
@CompilationFinal Class> cachedClazz_;
@CompilationFinal String cachedName_;
@CompilationFinal JavaMethodDesc cachedMethod_;
CachedData(CachedData next_) {
this.next_ = next_;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy