com.oracle.truffle.nfi.backend.panama.FunctionExecuteNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-nfi-panama Show documentation
Show all versions of truffle-nfi-panama Show documentation
Implementation of the Truffle NFI using CLinker from project panama.
The newest version!
// CheckStyle: start generated
package com.oracle.truffle.nfi.backend.panama;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GenerateAOT;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.NeverDefault;
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.frame.VirtualFrame;
import com.oracle.truffle.api.interop.ArityException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import com.oracle.truffle.nfi.backend.panama.PanamaSignature.CachedSignatureInfo;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.concurrent.locks.ReentrantLock;
/**
* Debug Info:
* Specialization {@link FunctionExecuteNode#cachedSignature}
* Activation probability: 0.65000
* With/without class size: 22/8 bytes
* Specialization {@link FunctionExecuteNode#genericExecute}
* Activation probability: 0.35000
* With/without class size: 11/4 bytes
*
*/
@GeneratedBy(FunctionExecuteNode.class)
@SuppressWarnings("javadoc")
final class FunctionExecuteNodeGen extends FunctionExecuteNode implements GenerateAOT.Provider {
static final ReferenceField CACHED_SIGNATURE_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "cachedSignature_cache", CachedSignatureData.class);
private static final Uncached UNCACHED = new Uncached();
/**
* State Info:
* 0: AOTPrepared
* 1: SpecializationActive {@link FunctionExecuteNode#cachedSignature}
* 2: SpecializationActive {@link FunctionExecuteNode#genericExecute}
*
*/
@CompilationFinal private int state_0_;
@UnsafeAccessedField @Child private CachedSignatureData cachedSignature_cache;
/**
* Source Info:
* Specialization: {@link FunctionExecuteNode#genericExecute}
* Parameter: {@link IndirectCallNode} execute
*/
@Child private IndirectCallNode genericExecute_execute_;
private FunctionExecuteNodeGen() {
}
@ExplodeLoop
@Override
public Object execute(long arg0Value, PanamaSignature arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException {
int state_0 = this.state_0_;
if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is AOTPrepared */) {
return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
}
if ((state_0 & 0b110) != 0 /* is SpecializationActive[FunctionExecuteNode.cachedSignature(long, PanamaSignature, Object[], CachedSignatureInfo, DirectCallNode)] || SpecializationActive[FunctionExecuteNode.genericExecute(long, PanamaSignature, Object[], IndirectCallNode)] */) {
if ((state_0 & 0b10) != 0 /* is SpecializationActive[FunctionExecuteNode.cachedSignature(long, PanamaSignature, Object[], CachedSignatureInfo, DirectCallNode)] */) {
CachedSignatureData s0_ = this.cachedSignature_cache;
while (s0_ != null) {
if ((arg1Value.signatureInfo == s0_.cachedInfo_)) {
return cachedSignature(arg0Value, arg1Value, arg2Value, s0_.cachedInfo_, s0_.execute_);
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b100) != 0 /* is SpecializationActive[FunctionExecuteNode.genericExecute(long, PanamaSignature, Object[], IndirectCallNode)] */) {
{
IndirectCallNode execute__ = this.genericExecute_execute_;
if (execute__ != null) {
return FunctionExecuteNode.genericExecute(arg0Value, arg1Value, arg2Value, execute__);
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
}
private Object executeAndSpecialize(long arg0Value, PanamaSignature arg1Value, Object[] arg2Value) {
int state_0 = this.state_0_;
if ((state_0 & 0b1) != 0 /* is AOTPrepared */) {
this.resetAOT_();
state_0 = this.state_0_;
}
if (((state_0 & 0b100)) == 0 /* is-not SpecializationActive[FunctionExecuteNode.genericExecute(long, PanamaSignature, Object[], IndirectCallNode)] */) {
while (true) {
int count0_ = 0;
CachedSignatureData s0_ = CACHED_SIGNATURE_CACHE_UPDATER.getVolatile(this);
CachedSignatureData s0_original = s0_;
while (s0_ != null) {
if ((arg1Value.signatureInfo == s0_.cachedInfo_)) {
break;
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (arg1Value.signatureInfo == s0_.cachedInfo_);
if (count0_ < (3)) {
s0_ = this.insert(new CachedSignatureData(s0_original));
s0_.cachedInfo_ = (arg1Value.signatureInfo);
s0_.execute_ = s0_.insert((FunctionExecuteNode.createCachedSignatureCall(s0_.cachedInfo_)));
if (!CACHED_SIGNATURE_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b10 /* add SpecializationActive[FunctionExecuteNode.cachedSignature(long, PanamaSignature, Object[], CachedSignatureInfo, DirectCallNode)] */;
this.state_0_ = state_0;
}
}
if (s0_ != null) {
return cachedSignature(arg0Value, arg1Value, arg2Value, s0_.cachedInfo_, s0_.execute_);
}
break;
}
}
VarHandle.storeStoreFence();
this.genericExecute_execute_ = this.insert((IndirectCallNode.create()));
this.cachedSignature_cache = null;
state_0 = state_0 & 0xfffffffd /* remove SpecializationActive[FunctionExecuteNode.cachedSignature(long, PanamaSignature, Object[], CachedSignatureInfo, DirectCallNode)] */;
state_0 = state_0 | 0b100 /* add SpecializationActive[FunctionExecuteNode.genericExecute(long, PanamaSignature, Object[], IndirectCallNode)] */;
this.state_0_ = state_0;
return FunctionExecuteNode.genericExecute(arg0Value, arg1Value, arg2Value, this.genericExecute_execute_);
}
@Override
public void prepareForAOT(TruffleLanguage> language, RootNode root) {
assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
if ((state_0_ & 0b1) != 0 /* is AOTPrepared */) {
return;
}
{
VarHandle.storeStoreFence();
this.genericExecute_execute_ = this.insert((IndirectCallNode.create()));
this.cachedSignature_cache = null;
this.state_0_ = state_0_ & 0xfffffffd /* remove SpecializationActive[FunctionExecuteNode.cachedSignature(long, PanamaSignature, Object[], CachedSignatureInfo, DirectCallNode)] */;
this.state_0_ = state_0_ | 0b100 /* add SpecializationActive[FunctionExecuteNode.genericExecute(long, PanamaSignature, Object[], IndirectCallNode)] */;
}
int state_0 = this.state_0_;
state_0 = state_0 | 0b1 /* add AOTPrepared */;
this.state_0_ = state_0;
}
private void resetAOT_() {
int state_0 = this.state_0_;
if (((state_0 & 0b1)) == 0 /* is-not AOTPrepared */) {
return;
}
this.state_0_ = 0;
this.genericExecute_execute_ = null;
}
@NeverDefault
public static FunctionExecuteNode create() {
return new FunctionExecuteNodeGen();
}
@NeverDefault
public static FunctionExecuteNode getUncached() {
return FunctionExecuteNodeGen.UNCACHED;
}
@GeneratedBy(FunctionExecuteNode.class)
@DenyReplace
private static final class CachedSignatureData extends Node implements SpecializationDataNode {
@Child CachedSignatureData next_;
/**
* Source Info:
* Specialization: {@link FunctionExecuteNode#cachedSignature}
* Parameter: {@link CachedSignatureInfo} cachedInfo
*/
@CompilationFinal CachedSignatureInfo cachedInfo_;
/**
* Source Info:
* Specialization: {@link FunctionExecuteNode#cachedSignature}
* Parameter: {@link DirectCallNode} execute
*/
@Child DirectCallNode execute_;
CachedSignatureData(CachedSignatureData next_) {
this.next_ = next_;
}
}
@GeneratedBy(FunctionExecuteNode.class)
@DenyReplace
private static final class Uncached extends FunctionExecuteNode implements UnadoptableNode {
@TruffleBoundary
@Override
public Object execute(long arg0Value, PanamaSignature arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException {
return FunctionExecuteNode.genericExecute(arg0Value, arg1Value, arg2Value, (IndirectCallNode.getUncached()));
}
}
/**
* Debug Info:
* Specialization {@link SignatureExecuteNode#doGeneric}
* Activation probability: 1.00000
* With/without class size: 16/0 bytes
*
*/
@GeneratedBy(SignatureExecuteNode.class)
@SuppressWarnings("javadoc")
static final class SignatureExecuteNodeGen extends SignatureExecuteNode {
private SignatureExecuteNodeGen(PanamaNFILanguage language, CachedSignatureInfo signatureInfo) {
super(language, signatureInfo);
}
@Override
public Object execute(VirtualFrame frameValue) {
return doGeneric(frameValue);
}
@NeverDefault
public static SignatureExecuteNode create(PanamaNFILanguage language, CachedSignatureInfo signatureInfo) {
return new SignatureExecuteNodeGen(language, signatureInfo);
}
}
}