Skip to content
Snippets Groups Projects
Commit 617ec971 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

put toJavaClass behind TruffleBoundary

parent cc21724b
Branches
No related tags found
No related merge requests found
...@@ -96,8 +96,7 @@ public abstract class Names extends RBuiltinNode.Arg1 { ...@@ -96,8 +96,7 @@ public abstract class Names extends RBuiltinNode.Arg1 {
String[] staticNames = new String[0]; String[] staticNames = new String[0];
try { try {
if (JavaInterop.isJavaObject(Object.class, obj)) { if (JavaInterop.isJavaObject(Object.class, obj)) {
TruffleObject clazz = JavaInterop.toJavaClass(obj); staticNames = readKeys(keysNode, toJavaClass(obj), getSizeNode, readNode, isBoxedNode, unboxNode);
staticNames = readKeys(keysNode, clazz, getSizeNode, readNode, isBoxedNode, unboxNode);
} }
} catch (UnknownIdentifierException | NoSuchFieldError | UnsupportedMessageException e) { } catch (UnknownIdentifierException | NoSuchFieldError | UnsupportedMessageException e) {
// because it is a class ... ? // because it is a class ... ?
...@@ -114,6 +113,11 @@ public abstract class Names extends RBuiltinNode.Arg1 { ...@@ -114,6 +113,11 @@ public abstract class Names extends RBuiltinNode.Arg1 {
} }
} }
@TruffleBoundary
private static TruffleObject toJavaClass(TruffleObject obj) {
return JavaInterop.toJavaClass(obj);
}
private static String[] readKeys(Node keysNode, TruffleObject obj, Node getSizeNode, Node readNode, Node isBoxedNode, Node unboxNode) private static String[] readKeys(Node keysNode, TruffleObject obj, Node getSizeNode, Node readNode, Node isBoxedNode, Node unboxNode)
throws UnknownIdentifierException, InteropException, UnsupportedMessageException { throws UnknownIdentifierException, InteropException, UnsupportedMessageException {
TruffleObject keys = (TruffleObject) ForeignAccess.send(keysNode, obj); TruffleObject keys = (TruffleObject) ForeignAccess.send(keysNode, obj);
......
...@@ -177,7 +177,7 @@ public abstract class ExtractVectorNode extends RBaseNode { ...@@ -177,7 +177,7 @@ public abstract class ExtractVectorNode extends RBaseNode {
if (KeyInfo.isReadable(info)) { if (KeyInfo.isReadable(info)) {
return ForeignAccess.sendRead(foreignRead, object, pos); return ForeignAccess.sendRead(foreignRead, object, pos);
} else if (pos instanceof String && !KeyInfo.isExisting(info) && JavaInterop.isJavaObject(Object.class, object)) { } else if (pos instanceof String && !KeyInfo.isExisting(info) && JavaInterop.isJavaObject(Object.class, object)) {
TruffleObject clazz = JavaInterop.toJavaClass(object); TruffleObject clazz = toJavaClass(object);
info = ForeignAccess.sendKeyInfo(keyInfoNode, clazz, pos); info = ForeignAccess.sendKeyInfo(keyInfoNode, clazz, pos);
if (KeyInfo.isReadable(info)) { if (KeyInfo.isReadable(info)) {
return ForeignAccess.sendRead(foreignRead, clazz, pos); return ForeignAccess.sendRead(foreignRead, clazz, pos);
...@@ -186,6 +186,11 @@ public abstract class ExtractVectorNode extends RBaseNode { ...@@ -186,6 +186,11 @@ public abstract class ExtractVectorNode extends RBaseNode {
throw caller.error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + pos); throw caller.error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + pos);
} }
@TruffleBoundary
private static TruffleObject toJavaClass(TruffleObject obj) {
return JavaInterop.toJavaClass(obj);
}
@Specialization(guards = {"cached != null", "cached.isSupported(vector, positions)"}) @Specialization(guards = {"cached != null", "cached.isSupported(vector, positions)"})
protected Object doExtractSameDimensions(VirtualFrame frame, RAbstractVector vector, Object[] positions, Object exact, Object dropDimensions, // protected Object doExtractSameDimensions(VirtualFrame frame, RAbstractVector vector, Object[] positions, Object exact, Object dropDimensions, //
@Cached("createRecursiveCache(vector, positions)") RecursiveExtractSubscriptNode cached) { @Cached("createRecursiveCache(vector, positions)") RecursiveExtractSubscriptNode cached) {
......
...@@ -146,7 +146,7 @@ public abstract class ReplaceVectorNode extends RBaseNode { ...@@ -146,7 +146,7 @@ public abstract class ReplaceVectorNode extends RBaseNode {
ForeignAccess.sendWrite(foreignWrite, object, pos, r2Foreign.execute(writtenValue)); ForeignAccess.sendWrite(foreignWrite, object, pos, r2Foreign.execute(writtenValue));
return; return;
} else if (pos instanceof String && !KeyInfo.isExisting(info) && JavaInterop.isJavaObject(Object.class, object)) { } else if (pos instanceof String && !KeyInfo.isExisting(info) && JavaInterop.isJavaObject(Object.class, object)) {
TruffleObject clazz = JavaInterop.toJavaClass(object); TruffleObject clazz = toJavaClass(object);
info = ForeignAccess.sendKeyInfo(keyInfoNode, clazz, pos); info = ForeignAccess.sendKeyInfo(keyInfoNode, clazz, pos);
if (KeyInfo.isWritable(info)) { if (KeyInfo.isWritable(info)) {
ForeignAccess.sendWrite(foreignWrite, clazz, pos, r2Foreign.execute(writtenValue)); ForeignAccess.sendWrite(foreignWrite, clazz, pos, r2Foreign.execute(writtenValue));
...@@ -156,6 +156,11 @@ public abstract class ReplaceVectorNode extends RBaseNode { ...@@ -156,6 +156,11 @@ public abstract class ReplaceVectorNode extends RBaseNode {
throw error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + pos); throw error(RError.Message.GENERIC, "invalid index/identifier during foreign access: " + pos);
} }
@TruffleBoundary
private static TruffleObject toJavaClass(TruffleObject obj) {
return JavaInterop.toJavaClass(obj);
}
@Specialization(limit = "CACHE_LIMIT", guards = {"cached != null", "cached.isSupported(vector, positions)"}) @Specialization(limit = "CACHE_LIMIT", guards = {"cached != null", "cached.isSupported(vector, positions)"})
protected Object doRecursive(VirtualFrame frame, RAbstractListVector vector, Object[] positions, Object value, // protected Object doRecursive(VirtualFrame frame, RAbstractListVector vector, Object[] positions, Object value, //
@Cached("createRecursiveCache(vector, positions)") RecursiveReplaceSubscriptNode cached) { @Cached("createRecursiveCache(vector, positions)") RecursiveReplaceSubscriptNode cached) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment