use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class MapEntryInterop method readArrayElement.
@ExportMessage
public static Object readArrayElement(StaticObject receiver, long index, @Cached.Exclusive @Cached InvokeEspressoNode invoke) throws InvalidArrayIndexException {
Meta meta = receiver.getKlass().getMeta();
Method m;
if (index == 0) {
m = doLookup(receiver, meta.java_util_Map_Entry, meta.java_util_Map_Entry_getKey);
} else if (index == 1) {
m = doLookup(receiver, meta.java_util_Map_Entry, meta.java_util_Map_Entry_getValue);
} else {
throw InvalidArrayIndexException.create(index);
}
try {
return invoke.execute(m, receiver, EMPTY_ARRAY);
} catch (ArityException | UnsupportedTypeException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class MapInterop method removeHashEntry.
@ExportMessage
public static void removeHashEntry(StaticObject receiver, Object key, @Cached.Exclusive @Cached InvokeEspressoNode invoke, @Cached.Shared("contains") @Cached InvokeEspressoNode contains) throws UnsupportedMessageException, UnknownKeyException {
if (!isHashEntryReadable(receiver, key, contains)) {
throw UnsupportedMessageException.create();
}
Meta meta = receiver.getKlass().getMeta();
Method remove = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_remove.getITableIndex());
try {
invoke.execute(remove, receiver, new Object[] { key });
} catch (UnsupportedTypeException e) {
throw UnknownKeyException.create(key);
} catch (ArityException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class MapInterop method getHashEntriesIterator.
@SuppressWarnings("static-method")
@ExportMessage
public static Object getHashEntriesIterator(StaticObject receiver, @CachedLibrary(limit = "1") InteropLibrary setLibrary, @Cached.Exclusive @Cached InvokeEspressoNode invoke) throws UnsupportedMessageException {
if (!hasHashEntries(receiver)) {
throw UnsupportedMessageException.create();
}
Meta meta = receiver.getKlass().getMeta();
Method entrySet = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_entrySet.getITableIndex());
Object set = null;
try {
set = invoke.execute(entrySet, receiver, EMPTY_ARRAY);
} catch (ArityException | UnsupportedTypeException e) {
throw EspressoError.shouldNotReachHere(e);
}
assert set != null;
assert setLibrary.hasIterator(set);
return setLibrary.getIterator(set);
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class LinkToVirtualNode method linkTo.
@Override
public Method linkTo(Method target, Object[] args) {
Method resolved = target;
if ((target.getRefKind() == REF_invokeSpecial) || target.isFinalFlagSet() || target.getDeclaringKlass().isFinalFlagSet()) {
return resolved;
}
StaticObject receiver = (StaticObject) args[0];
resolved = receiver.getKlass().vtableLookup(target.getVTableIndex());
return resolved;
}
use of com.oracle.truffle.espresso.impl.Method in project graal by oracle.
the class InvokeEspressoNode method execute.
public final Object execute(Method method, Object receiver, Object[] arguments) throws ArityException, UnsupportedTypeException {
Method.MethodVersion resolutionSeed = method.getMethodVersion();
if (!resolutionSeed.getRedefineAssumption().isValid()) {
// OK, we know it's a removed method then
resolutionSeed = method.getContext().getClassRedefinition().handleRemovedMethod(method, method.isStatic() ? method.getDeclaringKlass() : ((StaticObject) receiver).getKlass()).getMethodVersion();
}
Object result = executeMethod(resolutionSeed, receiver, arguments);
/*
* Unwrap foreign objects (invariant: foreign objects are always wrapped when coming in
* Espresso and unwrapped when going out)
*/
if (result instanceof StaticObject && ((StaticObject) result).isForeignObject()) {
return ((StaticObject) result).rawForeignObject();
}
return result;
}
Aggregations