com.oracle.truffle.nfi.impl.ClosureArgumentNodeFactory Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.truffle.nfi.impl;
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.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.nfi.impl.ClosureArgumentNode.BufferClosureArgumentNode;
import java.nio.ByteBuffer;
import java.util.concurrent.locks.Lock;
@GeneratedBy(ClosureArgumentNode.class)
final class ClosureArgumentNodeFactory {
@GeneratedBy(BufferClosureArgumentNode.class)
static final class BufferClosureArgumentNodeGen extends BufferClosureArgumentNode {
@CompilationFinal private int state_;
private BufferClosureArgumentNodeGen(LibFFIType type) {
super(type);
}
@Override
public Object execute(Object arg0Value) {
int state = state_;
if (state != 0 /* is-active deserialize(ByteBuffer) */ && arg0Value instanceof ByteBuffer) {
ByteBuffer arg0Value_ = (ByteBuffer) arg0Value;
return deserialize(arg0Value_);
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value);
}
private Object executeAndSpecialize(Object arg0Value) {
Lock lock = getLock();
boolean hasLock = true;
lock.lock();
int state = state_;
try {
if (arg0Value instanceof ByteBuffer) {
ByteBuffer arg0Value_ = (ByteBuffer) arg0Value;
this.state_ = state = state | 0b1 /* add-active deserialize(ByteBuffer) */;
lock.unlock();
hasLock = false;
return deserialize(arg0Value_);
}
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new UnsupportedSpecializationException(this, new Node[] {null}, arg0Value);
} finally {
if (hasLock) {
lock.unlock();
}
}
}
@Override
public NodeCost getCost() {
int state = state_;
if (state == 0b0) {
return NodeCost.UNINITIALIZED;
} else {
return NodeCost.MONOMORPHIC;
}
}
public static BufferClosureArgumentNode create(LibFFIType type) {
return new BufferClosureArgumentNodeGen(type);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy