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;
}
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;
}
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);
}
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);
}
}
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);
}
}
Aggregations