com.oracle.truffle.sl.builtins.SLNewObjectBuiltinFactory Maven / Gradle / Ivy
// CheckStyle: start generated
package com.oracle.truffle.sl.builtins;
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.NodeFactory;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;
@GeneratedBy(SLNewObjectBuiltin.class)
@SuppressWarnings({"unchecked", "rawtypes"})
public final class SLNewObjectBuiltinFactory implements NodeFactory {
private static SLNewObjectBuiltinFactory instance;
private SLNewObjectBuiltinFactory() {
}
@Override
public Class getNodeClass() {
return SLNewObjectBuiltin.class;
}
@Override
public List getExecutionSignature() {
return Arrays.asList();
}
@Override
public List getNodeSignatures() {
return Arrays.asList(Arrays.asList(SLExpressionNode[].class));
}
@Override
public SLNewObjectBuiltin createNode(Object... arguments) {
if (arguments.length == 1 && (arguments[0] == null || arguments[0] instanceof SLExpressionNode[])) {
return create((SLExpressionNode[]) arguments[0]);
} else {
throw new IllegalArgumentException("Invalid create signature.");
}
}
public static NodeFactory getInstance() {
if (instance == null) {
instance = new SLNewObjectBuiltinFactory();
}
return instance;
}
public static SLNewObjectBuiltin create(SLExpressionNode[] arguments) {
return new SLNewObjectBuiltinNodeGen(arguments);
}
@GeneratedBy(SLNewObjectBuiltin.class)
public static final class SLNewObjectBuiltinNodeGen extends SLNewObjectBuiltin {
@CompilationFinal private int state_ = 1;
@SuppressWarnings("unused")
private SLNewObjectBuiltinNodeGen(SLExpressionNode[] arguments) {
}
@Override
protected Object execute(VirtualFrame frameValue) {
int state = state_;
if ((state & 0b10) != 0 /* is-active newObject() */) {
return newObject();
}
CompilerDirectives.transferToInterpreterAndInvalidate();
return executeAndSpecialize();
}
private Object executeAndSpecialize() {
Lock lock = getLock();
boolean hasLock = true;
lock.lock();
try {
int state = state_ & 0xfffffffe/* mask-active uninitialized*/;
this.state_ = state = state | 0b10 /* add-active newObject() */;
lock.unlock();
hasLock = false;
return newObject();
} finally {
if (hasLock) {
lock.unlock();
}
}
}
@Override
public NodeCost getCost() {
int state = state_ & 0xfffffffe/* mask-active uninitialized*/;
if (state == 0b0) {
return NodeCost.UNINITIALIZED;
} else {
return NodeCost.MONOMORPHIC;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy