com.oracle.graal.python.builtins.objects.KeysGen Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.graal.python.builtins.objects;
import com.oracle.graal.python.builtins.objects.PythonAbstractObject.Keys;
import com.oracle.graal.python.runtime.GilNode;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
import com.oracle.truffle.api.library.LibraryExport;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.NodeCost;
import java.lang.invoke.VarHandle;
import java.util.Objects;
@GeneratedBy(Keys.class)
@SuppressWarnings("javadoc")
final class KeysGen {
private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
static {
LibraryExport.register(Keys.class, new InteropLibraryExports());
}
private KeysGen() {
}
@GeneratedBy(Keys.class)
private static final class InteropLibraryExports extends LibraryExport {
private InteropLibraryExports() {
super(InteropLibrary.class, Keys.class, false, false, 0);
}
@Override
protected InteropLibrary createUncached(Object receiver) {
assert receiver instanceof Keys;
InteropLibrary uncached = new Uncached();
return uncached;
}
@Override
protected InteropLibrary createCached(Object receiver) {
assert receiver instanceof Keys;
return new Cached();
}
@GeneratedBy(Keys.class)
private static final class Cached extends InteropLibrary {
/**
* State Info:
* 0: SpecializationActive {@link Keys#getArraySize(Keys, GilNode)}
*
*/
@CompilationFinal private int state_0_;
/**
* Source Info:
* Specialization: {@link Keys#getArraySize(Keys, GilNode)}
* Parameter: {@link GilNode} gil
*/
@Child private GilNode gil_;
protected Cached() {
}
@Override
public boolean accepts(Object receiver) {
assert !(receiver instanceof Keys) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof Keys;
}
@Override
public Object readArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
return (((Keys) receiver)).readArrayElement(index);
}
@Override
public boolean hasArrayElements(Object receiver) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
return (((Keys) receiver)).hasArrayElements();
}
/**
* Debug Info:
* Specialization {@link Keys#getArraySize(Keys, GilNode)}
* Activation probability: 1.00000
* With/without class size: 24/4 bytes
*
*/
@Override
public long getArraySize(Object arg0Value_) throws UnsupportedMessageException {
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
Keys arg0Value = ((Keys) arg0Value_);
int state_0 = this.state_0_;
if (state_0 != 0 /* is SpecializationActive[Keys.getArraySize(Keys, GilNode)] */) {
{
GilNode gil__ = this.gil_;
if (gil__ != null) {
return arg0Value.getArraySize(gil__);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize(arg0Value);
}
private long executeAndSpecialize(Keys arg0Value) {
int state_0 = this.state_0_;
GilNode gil__ = this.insert((GilNode.create()));
Objects.requireNonNull(gil__, "Specialization 'getArraySize(Keys, GilNode)' cache 'gil' returned a 'null' default value. The cache initializer must never return a default value for this cache. Use @Cached(neverDefault=false) to allow default values for this cached value or make sure the cache initializer never returns 'null'.");
VarHandle.storeStoreFence();
this.gil_ = gil__;
state_0 = state_0 | 0b1 /* add SpecializationActive[Keys.getArraySize(Keys, GilNode)] */;
this.state_0_ = state_0;
return arg0Value.getArraySize(gil__);
}
@Override
public NodeCost getCost() {
int state_0 = this.state_0_;
if (state_0 == 0) {
return NodeCost.UNINITIALIZED;
} else {
return NodeCost.MONOMORPHIC;
}
}
@Override
public boolean isArrayElementReadable(Object receiver, long index) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
assert assertAdopted();
return (((Keys) receiver)).isArrayElementReadable(index);
}
}
@GeneratedBy(Keys.class)
@DenyReplace
private static final class Uncached extends InteropLibrary {
protected Uncached() {
}
@Override
@TruffleBoundary
public boolean accepts(Object receiver) {
assert !(receiver instanceof Keys) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return receiver instanceof Keys;
}
@Override
public boolean isAdoptable() {
return false;
}
@Override
public NodeCost getCost() {
return NodeCost.MEGAMORPHIC;
}
@TruffleBoundary
@Override
public Object readArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((Keys) receiver) .readArrayElement(index);
}
@TruffleBoundary
@Override
public boolean hasArrayElements(Object receiver) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((Keys) receiver) .hasArrayElements();
}
@TruffleBoundary
@Override
public long getArraySize(Object arg0Value_) {
// declared: true
assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
Keys arg0Value = ((Keys) arg0Value_);
return arg0Value.getArraySize((GilNode.getUncached()));
}
@TruffleBoundary
@Override
public boolean isArrayElementReadable(Object receiver, long index) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((Keys) receiver) .isArrayElementReadable(index);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy