Search in sources :

Example 91 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class ReferenceArrayStoreQuickNode method execute.

@Override
public int execute(VirtualFrame frame) {
    StaticObject value = BytecodeNode.popObject(frame, top - 1);
    int index = BytecodeNode.popInt(frame, top - 2);
    StaticObject array = nullCheck(BytecodeNode.popObject(frame, top - 3));
    objectArrayStore.execute(array, index, value);
    return stackEffectOf_AASTORE;
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Example 92 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class ShortArrayStoreQuickNode method execute.

@Override
public int execute(VirtualFrame frame) {
    short value = (short) BytecodeNode.popInt(frame, top - 1);
    int index = BytecodeNode.popInt(frame, top - 2);
    StaticObject array = nullCheck(BytecodeNode.popObject(frame, top - 3));
    shortArrayStore.execute(array, index, value);
    return stackEffectOf_SASTORE;
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Example 93 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class InvokeInterfaceQuickNode method execute.

@Override
public int execute(VirtualFrame frame) {
    /*
         * Method signature does not change across methods. Can safely use the constant signature
         * from `resolutionSeed` instead of the non-constant signature from the resolved method.
         */
    final Object[] args = BytecodeNode.popArguments(frame, top, true, resolutionSeed.getParsedSignature());
    nullCheck((StaticObject) args[0]);
    Object result = invokeInterface.execute(args);
    if (!returnKind.isPrimitive()) {
        getBytecodeNode().checkNoForeignObjectAssumption((StaticObject) result);
    }
    return (getResultAt() - top) + BytecodeNode.putKind(frame, getResultAt(), result, returnKind);
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Example 94 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class Substitutions method registerStaticSubstitution.

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void registerStaticSubstitution(JavaSubstitution.Factory substitutorFactory) {
    List<Symbol<Type>> parameterTypes = new ArrayList<>();
    for (int i = substitutorFactory.hasReceiver() ? 1 : 0; i < substitutorFactory.parameterTypes().length; i++) {
        String type = substitutorFactory.parameterTypes()[i];
        parameterTypes.add(StaticSymbols.putType(type));
    }
    Symbol<Type> returnType = StaticSymbols.putType(substitutorFactory.returnType());
    Symbol<Signature> signature = StaticSymbols.putSignature(returnType, parameterTypes.toArray(Symbol.EMPTY_ARRAY));
    EspressoRootNodeFactory factory = new EspressoRootNodeFactory() {

        @Override
        public EspressoRootNode createNodeIfValid(Method methodToSubstitute, boolean forceValid) {
            if (!substitutorFactory.isValidFor(methodToSubstitute.getJavaVersion())) {
                return null;
            }
            StaticObject classLoader = methodToSubstitute.getDeclaringKlass().getDefiningClassLoader();
            if (forceValid || ClassRegistry.loaderIsBootOrPlatform(classLoader, methodToSubstitute.getMeta())) {
                return EspressoRootNode.create(null, new IntrinsicSubstitutorNode(substitutorFactory, methodToSubstitute));
            }
            getLogger().warning(new Supplier<String>() {

                @Override
                public String get() {
                    StaticObject givenLoader = methodToSubstitute.getDeclaringKlass().getDefiningClassLoader();
                    return "Static substitution for " + methodToSubstitute + " does not apply.\n" + "\tExpected class loader: Boot (null) or platform class loader\n" + "\tGiven class loader: " + EspressoInterop.toDisplayString(givenLoader, false) + "\n";
                }
            });
            return null;
        }
    };
    String[] classNames = substitutorFactory.substitutionClassNames();
    String[] methodNames = substitutorFactory.getMethodNames();
    for (int i = 0; i < classNames.length; i++) {
        assert classNames[i].startsWith("Target_");
        Symbol<Type> classType = StaticSymbols.putType("L" + classNames[i].substring("Target_".length()).replace('_', '/') + ";");
        Symbol<Name> methodName = StaticSymbols.putName(methodNames[i]);
        registerStaticSubstitution(classType, methodName, signature, factory, true);
    }
}
Also used : Symbol(com.oracle.truffle.espresso.descriptors.Symbol) ArrayList(java.util.ArrayList) Method(com.oracle.truffle.espresso.impl.Method) Name(com.oracle.truffle.espresso.descriptors.Symbol.Name) Type(com.oracle.truffle.espresso.descriptors.Symbol.Type) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) Signature(com.oracle.truffle.espresso.descriptors.Symbol.Signature) IntrinsicSubstitutorNode(com.oracle.truffle.espresso.nodes.IntrinsicSubstitutorNode)

Example 95 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class Target_java_lang_Module method defineModule0.

@Substitution
@TruffleBoundary
public static void defineModule0(@JavaType(internalName = "Ljava/lang/Module;") StaticObject module, boolean isOpen, @SuppressWarnings("unused") @JavaType(String.class) StaticObject version, @SuppressWarnings("unused") @JavaType(String.class) StaticObject location, @JavaType(Object[].class) StaticObject pns, @Inject Meta meta, @Inject SubstitutionProfiler profiler) {
    if (StaticObject.isNull(module)) {
        profiler.profile(0);
        throw meta.throwNullPointerException();
    }
    if (!meta.java_lang_Module.isAssignableFrom(module.getKlass())) {
        profiler.profile(1);
        throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "module is not an instance of java.lang.Module");
    }
    StaticObject guestName = meta.java_lang_Module_name.getObject(module);
    if (StaticObject.isNull(guestName)) {
        profiler.profile(2);
        throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "module name cannot be null");
    }
    String hostName = meta.toHostString(guestName);
    String[] packages = toStringArray(pns, meta);
    if (hostName.equals(JAVA_BASE)) {
        profiler.profile(5);
        meta.getVM().defineJavaBaseModule(module, packages, profiler);
    } else {
        profiler.profile(6);
        meta.getVM().defineModule(module, hostName, isOpen, packages, profiler);
    }
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Aggregations

StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)199 Method (com.oracle.truffle.espresso.impl.Method)57 JavaType (com.oracle.truffle.espresso.substitutions.JavaType)44 Klass (com.oracle.truffle.espresso.impl.Klass)32 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)32 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)30 Meta (com.oracle.truffle.espresso.meta.Meta)29 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)26 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)23 NoSafepoint (com.oracle.truffle.espresso.jni.NoSafepoint)17 ArrayList (java.util.ArrayList)13 EspressoException (com.oracle.truffle.espresso.runtime.EspressoException)9 Symbol (com.oracle.truffle.espresso.descriptors.Symbol)8 FrameInstance (com.oracle.truffle.api.frame.FrameInstance)7 ExportMessage (com.oracle.truffle.api.library.ExportMessage)7 BytecodeNode (com.oracle.truffle.espresso.nodes.BytecodeNode)7 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)6 Name (com.oracle.truffle.espresso.descriptors.Symbol.Name)6 EspressoContext (com.oracle.truffle.espresso.runtime.EspressoContext)6 Type (com.oracle.truffle.espresso.descriptors.Symbol.Type)5