com.oracle.truffle.sl.nodes.call.SLDispatchNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-sl Show documentation
Show all versions of truffle-sl Show documentation
Truffle SL is an example language implemented using the Truffle API.
The newest version!
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// CheckStyle: start generated
package com.oracle.truffle.sl.nodes.call;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.internal.SpecializationNode;
import com.oracle.truffle.api.dsl.internal.SpecializedNode;
import com.oracle.truffle.api.dsl.internal.SuppressFBWarnings;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.sl.runtime.SLFunction;
@GeneratedBy(SLDispatchNode.class)
@SuppressFBWarnings("SA_LOCAL_SELF_COMPARISON")
public final class SLDispatchNodeGen extends SLDispatchNode implements SpecializedNode {
@CompilationFinal private boolean excludeDirect_;
@Child private BaseNode_ specialization_;
private SLDispatchNodeGen() {
this.specialization_ = UninitializedNode_.create(this);
}
@Override
public NodeCost getCost() {
return specialization_.getNodeCost();
}
@Override
public Object executeDispatch(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value) {
return specialization_.execute(frameValue, arg0Value, arg1Value);
}
@Override
public SpecializationNode getSpecializationNode() {
return specialization_;
}
@Override
public Node deepCopy() {
return SpecializationNode.updateRoot(super.deepCopy());
}
public static SLDispatchNode create() {
return new SLDispatchNodeGen();
}
@GeneratedBy(SLDispatchNode.class)
private abstract static class BaseNode_ extends SpecializationNode {
protected final SLDispatchNodeGen root;
BaseNode_(SLDispatchNodeGen root, int index) {
super(index);
this.root = root;
}
@Override
protected final Node[] getSuppliedChildren() {
return new Node[] {null, null};
}
@Override
public final Object acceptAndExecute(Frame frameValue, Object arg0Value, Object arg1Value) {
return this.execute((VirtualFrame) frameValue, (SLFunction) arg0Value, (Object[]) arg1Value);
}
public abstract Object execute(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value);
@Override
protected final SpecializationNode createNext(Frame frameValue, Object arg0Value, Object arg1Value) {
if (arg0Value instanceof SLFunction && arg1Value instanceof Object[]) {
SLFunction arg0Value_ = (SLFunction) arg0Value;
if ((arg0Value_.getCallTarget() == null)) {
return UndefinedFunctionNode_.create(root);
}
SLFunction cachedFunction2 = (arg0Value_);
if ((arg0Value_ == cachedFunction2)) {
if (!root.excludeDirect_) {
DirectCallNode callNode2 = (DirectCallNode.create(cachedFunction2.getCallTarget()));
Assumption assumption0_2 = (cachedFunction2.getCallTargetStable());
if (isValid(assumption0_2)) {
SpecializationNode s = DirectNode_.create(root, cachedFunction2, callNode2, assumption0_2);
if (countSame(s) < (SLDispatchNode.INLINE_CACHE_SIZE)) {
return s;
}
}
}
}
IndirectCallNode callNode3 = (IndirectCallNode.create());
root.excludeDirect_ = true;
return IndirectNode_.create(root, callNode3);
}
return null;
}
protected final BaseNode_ getNext() {
return (BaseNode_) this.next;
}
}
@GeneratedBy(SLDispatchNode.class)
private static final class UninitializedNode_ extends BaseNode_ {
UninitializedNode_(SLDispatchNodeGen root) {
super(root, 2147483647);
}
@Override
public Object execute(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value) {
return uninitialized(frameValue, arg0Value, arg1Value);
}
static BaseNode_ create(SLDispatchNodeGen root) {
return new UninitializedNode_(root);
}
}
@GeneratedBy(methodName = "doUndefinedFunction(SLFunction, Object[])", value = SLDispatchNode.class)
private static final class UndefinedFunctionNode_ extends BaseNode_ {
UndefinedFunctionNode_(SLDispatchNodeGen root) {
super(root, 1);
}
@Override
public Object execute(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value) {
if ((arg0Value.getCallTarget() == null)) {
return root.doUndefinedFunction(arg0Value, arg1Value);
}
return getNext().execute(frameValue, arg0Value, arg1Value);
}
static BaseNode_ create(SLDispatchNodeGen root) {
return new UndefinedFunctionNode_(root);
}
}
@GeneratedBy(methodName = "doDirect(VirtualFrame, SLFunction, Object[], SLFunction, DirectCallNode)", value = SLDispatchNode.class)
private static final class DirectNode_ extends BaseNode_ {
private final SLFunction cachedFunction;
@Child private DirectCallNode callNode;
@CompilationFinal private final Assumption assumption0_;
DirectNode_(SLDispatchNodeGen root, SLFunction cachedFunction, DirectCallNode callNode, Assumption assumption0_) {
super(root, 2);
this.cachedFunction = cachedFunction;
this.callNode = callNode;
this.assumption0_ = assumption0_;
}
@Override
public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object arg0Value, Object arg1Value) {
if (newNode.getClass() == IndirectNode_.class) {
removeSame("Contained by doIndirect(VirtualFrame, SLFunction, Object[], IndirectCallNode)");
}
return super.merge(newNode, frameValue, arg0Value, arg1Value);
}
@Override
public boolean isIdentical(SpecializationNode other, Frame frameValue, Object arg0Value, Object arg1Value) {
if (arg0Value instanceof SLFunction && arg1Value instanceof Object[]) {
SLFunction arg0Value_ = (SLFunction) arg0Value;
if ((arg0Value_ == this.cachedFunction)) {
return true;
}
}
return false;
}
@Override
public Object execute(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value) {
if ((arg0Value == this.cachedFunction)) {
try {
check(this.assumption0_);
} catch (InvalidAssumptionException ae) {
return removeThis("Assumption [assumption0] invalidated", frameValue, arg0Value, arg1Value);
}
return SLDispatchNode.doDirect(frameValue, arg0Value, arg1Value, this.cachedFunction, this.callNode);
}
return getNext().execute(frameValue, arg0Value, arg1Value);
}
static BaseNode_ create(SLDispatchNodeGen root, SLFunction cachedFunction, DirectCallNode callNode, Assumption assumption0_) {
return new DirectNode_(root, cachedFunction, callNode, assumption0_);
}
}
@GeneratedBy(methodName = "doIndirect(VirtualFrame, SLFunction, Object[], IndirectCallNode)", value = SLDispatchNode.class)
private static final class IndirectNode_ extends BaseNode_ {
@Child private IndirectCallNode callNode;
IndirectNode_(SLDispatchNodeGen root, IndirectCallNode callNode) {
super(root, 3);
this.callNode = callNode;
}
@Override
public Object execute(VirtualFrame frameValue, SLFunction arg0Value, Object[] arg1Value) {
return SLDispatchNode.doIndirect(frameValue, arg0Value, arg1Value, this.callNode);
}
static BaseNode_ create(SLDispatchNodeGen root, IndirectCallNode callNode) {
return new IndirectNode_(root, callNode);
}
}
}