com.oracle.truffle.sl.nodes.access.SLReadPropertyCacheNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-sl Show documentation
Show all versions of truffle-sl Show documentation
Truffle SL is an example language implemented using the Truffle API.
The newest version!
// CheckStyle: start generated
package com.oracle.truffle.sl.nodes.access;
import com.oracle.truffle.api.Assumption;
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.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Shape;
import java.util.concurrent.locks.Lock;
@GeneratedBy(SLReadPropertyCacheNode.class)
public final class SLReadPropertyCacheNodeGen extends SLReadPropertyCacheNode {
@CompilationFinal private int state_;
@CompilationFinal private int exclude_;
@CompilationFinal private ReadCachedData readCached_cache;
private SLReadPropertyCacheNodeGen() {
}
@ExplodeLoop(kind = LoopExplosionKind.FULL_EXPLODE_UNTIL_RETURN)
@Override
public Object executeRead(DynamicObject arg0Value, Object arg1Value) {
int state = state_;
if (state != 0 /* is-active readCached(DynamicObject, Object, Object, Shape, Location) || readUncached(DynamicObject, Object) || updateShape(DynamicObject, Object) */) {
if ((state & 0b1) != 0 /* is-active readCached(DynamicObject, Object, Object, Shape, Location) */) {
ReadCachedData s1_ = this.readCached_cache;
while (s1_ != null) {
if (!isValid_(s1_.assumption0_)) {
CompilerDirectives.transferToInterpreterAndInvalidate();
removeReadCached_(s1_);
return executeAndSpecialize(arg0Value, arg1Value);
}
if ((SLPropertyCacheNode.namesEqual(s1_.cachedName_, arg1Value)) && (SLPropertyCacheNode.shapeCheck(s1_.shape_, arg0Value))) {
return SLReadPropertyCacheNode.readCached(arg0Value, arg1Value, s1_.cachedName_, s1_.shape_, s1_.location_);
}
s1_ = s1_.next_;
}
}
if ((state & 0b10) != 0 /* is-active readUncached(DynamicObject, Object) */) {
if ((arg0Value.getShape().isValid())) {
return readUncached(arg0Value, arg1Value);
}
}
if ((state & 0b100) != 0 /* is-active updateShape(DynamicObject, Object) */) {
if ((!(arg0Value.getShape().isValid()))) {
return updateShape(arg0Value, arg1Value);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value);
}
private Object executeAndSpecialize(DynamicObject arg0Value, Object arg1Value) {
Lock lock = getLock();
boolean hasLock = true;
lock.lock();
int state = state_;
int exclude = exclude_;
try {
if ((exclude) == 0 /* is-not-excluded readCached(DynamicObject, Object, Object, Shape, Location) */) {
int count1_ = 0;
ReadCachedData s1_ = this.readCached_cache;
if ((state & 0b1) != 0 /* is-active readCached(DynamicObject, Object, Object, Shape, Location) */) {
while (s1_ != null) {
if ((SLPropertyCacheNode.namesEqual(s1_.cachedName_, arg1Value)) && (SLPropertyCacheNode.shapeCheck(s1_.shape_, arg0Value)) && (s1_.assumption0_ == null || isValid_(s1_.assumption0_))) {
break;
}
s1_ = s1_.next_;
count1_++;
}
}
if (s1_ == null) {
{
Object cachedName__ = (arg1Value);
if ((SLPropertyCacheNode.namesEqual(cachedName__, arg1Value))) {
Shape shape__ = (SLPropertyCacheNode.lookupShape(arg0Value));
if ((SLPropertyCacheNode.shapeCheck(shape__, arg0Value))) {
Assumption assumption0 = (shape__.getValidAssumption());
if (isValid_(assumption0)) {
if (count1_ < (SLPropertyCacheNode.CACHE_LIMIT)) {
s1_ = new ReadCachedData(readCached_cache);
s1_.cachedName_ = cachedName__;
s1_.shape_ = shape__;
s1_.location_ = (lookupLocation(shape__, arg1Value));
s1_.assumption0_ = assumption0;
this.readCached_cache = s1_;
this.state_ = state = state | 0b1 /* add-active readCached(DynamicObject, Object, Object, Shape, Location) */;
}
}
}
}
}
}
if (s1_ != null) {
lock.unlock();
hasLock = false;
return SLReadPropertyCacheNode.readCached(arg0Value, arg1Value, s1_.cachedName_, s1_.shape_, s1_.location_);
}
}
if ((arg0Value.getShape().isValid())) {
this.exclude_ = exclude = exclude | 0b1 /* add-excluded readCached(DynamicObject, Object, Object, Shape, Location) */;
this.readCached_cache = null;
state = state & 0xfffffffe /* remove-active readCached(DynamicObject, Object, Object, Shape, Location) */;
this.state_ = state = state | 0b10 /* add-active readUncached(DynamicObject, Object) */;
lock.unlock();
hasLock = false;
return readUncached(arg0Value, arg1Value);
}
if ((!(arg0Value.getShape().isValid()))) {
this.state_ = state = state | 0b100 /* add-active updateShape(DynamicObject, Object) */;
lock.unlock();
hasLock = false;
return updateShape(arg0Value, arg1Value);
}
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new UnsupportedSpecializationException(this, new Node[] {null, null}, 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 */) {
ReadCachedData s1_ = this.readCached_cache;
if ((s1_ == null || s1_.next_ == null)) {
return NodeCost.MONOMORPHIC;
}
}
return NodeCost.POLYMORPHIC;
}
void removeReadCached_(Object s1_) {
Lock lock = getLock();
lock.lock();
try {
ReadCachedData prev = null;
ReadCachedData cur = this.readCached_cache;
while (cur != null) {
if (cur == s1_) {
if (prev == null) {
this.readCached_cache = cur.next_;
} else {
prev.next_ = cur.next_;
}
break;
}
prev = cur;
cur = cur.next_;
}
if (this.readCached_cache == null) {
this.state_ = this.state_ & 0xfffffffe /* remove-active readCached(DynamicObject, Object, Object, Shape, Location) */;
}
} finally {
lock.unlock();
}
}
private static boolean isValid_(Assumption assumption) {
return assumption != null && assumption.isValid();
}
public static SLReadPropertyCacheNode create() {
return new SLReadPropertyCacheNodeGen();
}
@GeneratedBy(SLReadPropertyCacheNode.class)
private static final class ReadCachedData {
@CompilationFinal ReadCachedData next_;
@CompilationFinal Object cachedName_;
@CompilationFinal Shape shape_;
@CompilationFinal Location location_;
@CompilationFinal Assumption assumption0_;
ReadCachedData(ReadCachedData next_) {
this.next_ = next_;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy