All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.truffle.api.interop.java.MapRemoveNodeGen Maven / Gradle / Ivy

Go to download

Truffle is a multi-language framework for executing dynamic languages that achieves high performance when combined with Graal.

There is a newer version: 1.0.0-rc7
Show newest version
// CheckStyle: start generated
package com.oracle.truffle.api.interop.java;

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 java.util.concurrent.locks.Lock;

@GeneratedBy(MapRemoveNode.class)
final class MapRemoveNodeGen extends MapRemoveNode {

    @CompilationFinal private int state_;

    private MapRemoveNodeGen() {
    }

    @Override
    protected Object executeWithTarget(JavaObject arg0Value, String arg1Value) {
        int state = state_;
        if (state != 0 /* is-active doMapGeneric(JavaObject, String) || notMap(JavaObject, String) */) {
            if ((state & 0b1) != 0 /* is-active doMapGeneric(JavaObject, String) */) {
                if ((MapRemoveNode.isMap(arg0Value))) {
                    return doMapGeneric(arg0Value, arg1Value);
                }
            }
            if ((state & 0b10) != 0 /* is-active notMap(JavaObject, String) */) {
                if ((!(MapRemoveNode.isMap(arg0Value)))) {
                    return MapRemoveNode.notMap(arg0Value, arg1Value);
                }
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(arg0Value, arg1Value);
    }

    private Object executeAndSpecialize(JavaObject arg0Value, String arg1Value) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        int state = state_;
        try {
            if ((MapRemoveNode.isMap(arg0Value))) {
                this.state_ = state = state | 0b1 /* add-active doMapGeneric(JavaObject, String) */;
                lock.unlock();
                hasLock = false;
                return doMapGeneric(arg0Value, arg1Value);
            }
            if ((!(MapRemoveNode.isMap(arg0Value)))) {
                this.state_ = state = state | 0b10 /* add-active notMap(JavaObject, String) */;
                lock.unlock();
                hasLock = false;
                return MapRemoveNode.notMap(arg0Value, arg1Value);
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value);
        } finally {
            if (hasLock) {
                lock.unlock();
            }
        }
    }

    @Override
    public NodeCost getCost() {
        int state = state_;
        if (state == 0b0) {
            return NodeCost.UNINITIALIZED;
        } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
            return NodeCost.MONOMORPHIC;
        }
        return NodeCost.POLYMORPHIC;
    }

    public static MapRemoveNode create() {
        return new MapRemoveNodeGen();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy