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

com.oracle.truffle.api.interop.java.ReadFieldNodeSubNodeGen 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.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import java.util.concurrent.locks.Lock;

@GeneratedBy(ReadFieldNodeSub.class)
final class ReadFieldNodeSubNodeGen extends ReadFieldNodeSub {

    @CompilationFinal private int state_ = 1;

    private ReadFieldNodeSubNodeGen() {
    }

    @Override
    public Object executeWithTarget(VirtualFrame frameValue, Object arg0Value, Object arg1Value) {
        int state = state_;
        if ((state & 0b110) != 0 /* is-active accessWithTarget(VirtualFrame, JavaObject, Number) || accessWithTarget(JavaObject, String) */ && arg0Value instanceof JavaObject) {
            JavaObject arg0Value_ = (JavaObject) arg0Value;
            if ((state & 0b10) != 0 /* is-active accessWithTarget(VirtualFrame, JavaObject, Number) */ && arg1Value instanceof Number) {
                Number arg1Value_ = (Number) arg1Value;
                return accessWithTarget(frameValue, arg0Value_, arg1Value_);
            }
            if ((state & 0b100) != 0 /* is-active accessWithTarget(JavaObject, String) */ && arg1Value instanceof String) {
                String arg1Value_ = (String) arg1Value;
                return accessWithTarget(arg0Value_, arg1Value_);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(frameValue, arg0Value, arg1Value);
    }

    private Object executeAndSpecialize(VirtualFrame frameValue, Object arg0Value, Object arg1Value) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        try {
            int state = state_ & 0xfffffffe/* mask-active uninitialized*/;
            if (arg0Value instanceof JavaObject) {
                JavaObject arg0Value_ = (JavaObject) arg0Value;
                if (arg1Value instanceof Number) {
                    Number arg1Value_ = (Number) arg1Value;
                    this.state_ = state | 0b10 /* add-active accessWithTarget(VirtualFrame, JavaObject, Number) */;
                    lock.unlock();
                    hasLock = false;
                    return accessWithTarget(frameValue, arg0Value_, arg1Value_);
                }
                if (arg1Value instanceof String) {
                    String arg1Value_ = (String) arg1Value;
                    this.state_ = state | 0b100 /* add-active accessWithTarget(JavaObject, String) */;
                    lock.unlock();
                    hasLock = false;
                    return accessWithTarget(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_ & 0xfffffffe/* mask-active uninitialized*/;
        if (state == 0b0) {
            return NodeCost.UNINITIALIZED;
        } else if (((state & 0b110) & ((state & 0b110) - 1)) == 0 /* is-single-active  */) {
            return NodeCost.MONOMORPHIC;
        }
        return NodeCost.POLYMORPHIC;
    }

    public static ReadFieldNodeSub create() {
        return new ReadFieldNodeSubNodeGen();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy