com.oracle.graal.python.util.ByteArrayBuilderFactory Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.graal.python.util;
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAcquireLibrary;
import com.oracle.graal.python.util.ByteArrayBuilder.AppendBytesNode;
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.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.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Objects;
@GeneratedBy(ByteArrayBuilder.class)
@SuppressWarnings("javadoc")
public final class ByteArrayBuilderFactory {
private static final LibraryFactory PYTHON_BUFFER_ACQUIRE_LIBRARY_ = LibraryFactory.resolve(PythonBufferAcquireLibrary.class);
private static final LibraryFactory PYTHON_BUFFER_ACCESS_LIBRARY_ = LibraryFactory.resolve(PythonBufferAccessLibrary.class);
/**
* Debug Info:
* Specialization {@link AppendBytesNode#appendBytes}
* Activation probability: 0.65000
* With/without class size: 19/4 bytes
* Specialization {@link AppendBytesNode#appendBytes}
* Activation probability: 0.35000
* With/without class size: 8/0 bytes
*
*/
@GeneratedBy(AppendBytesNode.class)
@SuppressWarnings("javadoc")
public static final class AppendBytesNodeGen extends AppendBytesNode {
static final ReferenceField APPEND_BYTES0_CACHE_UPDATER = ReferenceField.create(MethodHandles.lookup(), "appendBytes0_cache", AppendBytes0Data.class);
/**
* State Info:
* 0: SpecializationActive {@link AppendBytesNode#appendBytes}
* 1: SpecializationActive {@link AppendBytesNode#appendBytes}
*
*/
@CompilationFinal private int state_0_;
/**
* Source Info:
* Specialization: {@link AppendBytesNode#appendBytes}
* Parameter: {@link PythonBufferAccessLibrary} bufferLib
*/
@Child private PythonBufferAccessLibrary bufferLib;
@UnsafeAccessedField @Child private AppendBytes0Data appendBytes0_cache;
private AppendBytesNodeGen() {
}
@ExplodeLoop
@Override
public void execute(VirtualFrame frameValue, ByteArrayBuilder arg0Value, Object arg1Value) {
int state_0 = this.state_0_;
if (state_0 != 0 /* is SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] || SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */) {
if ((state_0 & 0b1) != 0 /* is SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */) {
AppendBytes0Data s0_ = this.appendBytes0_cache;
while (s0_ != null) {
{
PythonBufferAccessLibrary bufferLib_ = this.bufferLib;
if (bufferLib_ != null) {
if ((s0_.bufferAcquireLib_.accepts(arg1Value))) {
appendBytes(frameValue, arg0Value, arg1Value, s0_.bufferAcquireLib_, bufferLib_);
return;
}
}
}
s0_ = s0_.next_;
}
}
if ((state_0 & 0b10) != 0 /* is SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */) {
{
PythonBufferAccessLibrary bufferLib_ = this.bufferLib;
if (bufferLib_ != null) {
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
{
PythonBufferAcquireLibrary bufferAcquireLib__ = (PYTHON_BUFFER_ACQUIRE_LIBRARY_.getUncached());
appendBytes(frameValue, arg0Value, arg1Value, bufferAcquireLib__, bufferLib_);
return;
}
} finally {
encapsulating_.set(prev_);
}
}
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
executeAndSpecialize(frameValue, arg0Value, arg1Value);
return;
}
private void executeAndSpecialize(VirtualFrame frameValue, ByteArrayBuilder arg0Value, Object arg1Value) {
int state_0 = this.state_0_;
if (((state_0 & 0b10)) == 0 /* is-not SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */) {
while (true) {
int count0_ = 0;
AppendBytes0Data s0_ = APPEND_BYTES0_CACHE_UPDATER.getVolatile(this);
AppendBytes0Data s0_original = s0_;
while (s0_ != null) {
{
PythonBufferAccessLibrary bufferLib_ = this.bufferLib;
if (bufferLib_ != null) {
if ((s0_.bufferAcquireLib_.accepts(arg1Value))) {
break;
}
}
}
count0_++;
s0_ = s0_.next_;
}
if (s0_ == null) {
// assert (s0_.bufferAcquireLib_.accepts(arg1Value));
if (count0_ < (3)) {
s0_ = this.insert(new AppendBytes0Data(s0_original));
PythonBufferAcquireLibrary bufferAcquireLib__ = s0_.insert((PYTHON_BUFFER_ACQUIRE_LIBRARY_.create(arg1Value)));
Objects.requireNonNull(bufferAcquireLib__, "Specialization 'appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)' cache 'bufferAcquireLib' 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'.");
s0_.bufferAcquireLib_ = bufferAcquireLib__;
PythonBufferAccessLibrary bufferLib_;
PythonBufferAccessLibrary bufferLib__shared = this.bufferLib;
if (bufferLib__shared != null) {
bufferLib_ = bufferLib__shared;
} else {
bufferLib_ = s0_.insert((PYTHON_BUFFER_ACCESS_LIBRARY_.createDispatched(3)));
if (bufferLib_ == null) {
throw new IllegalStateException("Specialization 'appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)' contains a shared cache with name 'bufferLib' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.bufferLib == null) {
this.bufferLib = bufferLib_;
}
if (!APPEND_BYTES0_CACHE_UPDATER.compareAndSet(this, s0_original, s0_)) {
continue;
}
state_0 = state_0 | 0b1 /* add SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */;
this.state_0_ = state_0;
}
}
if (s0_ != null) {
appendBytes(frameValue, arg0Value, arg1Value, s0_.bufferAcquireLib_, this.bufferLib);
return;
}
break;
}
}
{
PythonBufferAcquireLibrary bufferAcquireLib__ = null;
{
EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
Node prev_ = encapsulating_.set(this);
try {
bufferAcquireLib__ = (PYTHON_BUFFER_ACQUIRE_LIBRARY_.getUncached());
PythonBufferAccessLibrary bufferLib_;
PythonBufferAccessLibrary bufferLib__shared = this.bufferLib;
if (bufferLib__shared != null) {
bufferLib_ = bufferLib__shared;
} else {
bufferLib_ = this.insert((PYTHON_BUFFER_ACCESS_LIBRARY_.createDispatched(3)));
if (bufferLib_ == null) {
throw new IllegalStateException("Specialization 'appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)' contains a shared cache with name 'bufferLib' that returned a default value for the cached initializer. Default values are not supported for shared cached initializers because the default value is reserved for the uninitialized state.");
}
}
if (this.bufferLib == null) {
VarHandle.storeStoreFence();
this.bufferLib = bufferLib_;
}
this.appendBytes0_cache = null;
state_0 = state_0 & 0xfffffffe /* remove SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */;
state_0 = state_0 | 0b10 /* add SpecializationActive[ByteArrayBuilder.AppendBytesNode.appendBytes(VirtualFrame, ByteArrayBuilder, Object, PythonBufferAcquireLibrary, PythonBufferAccessLibrary)] */;
this.state_0_ = state_0;
appendBytes(frameValue, arg0Value, arg1Value, bufferAcquireLib__, bufferLib_);
return;
} finally {
encapsulating_.set(prev_);
}
}
}
}
@Override
public NodeCost getCost() {
int state_0 = this.state_0_;
if (state_0 == 0) {
return NodeCost.UNINITIALIZED;
} else {
if ((state_0 & (state_0 - 1)) == 0 /* is-single */) {
AppendBytes0Data s0_ = this.appendBytes0_cache;
if ((s0_ == null || s0_.next_ == null)) {
return NodeCost.MONOMORPHIC;
}
}
}
return NodeCost.POLYMORPHIC;
}
@NeverDefault
public static AppendBytesNode create() {
return new AppendBytesNodeGen();
}
@GeneratedBy(AppendBytesNode.class)
@DenyReplace
private static final class AppendBytes0Data extends Node implements SpecializationDataNode {
@Child AppendBytes0Data next_;
/**
* Source Info:
* Specialization: {@link AppendBytesNode#appendBytes}
* Parameter: {@link PythonBufferAcquireLibrary} bufferAcquireLib
*/
@Child PythonBufferAcquireLibrary bufferAcquireLib_;
AppendBytes0Data(AppendBytes0Data next_) {
this.next_ = next_;
}
@Override
public NodeCost getCost() {
return NodeCost.NONE;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy