Skip to content
Snippets Groups Projects
Commit 1dc656bc authored by Zbyněk Šlajchrt's avatar Zbyněk Šlajchrt
Browse files

[GR-8137] Truffle boundary added at several places in FastR NFI.

PullRequest: fastr/1401
parents a6254cb4 0edabdf6
No related branches found
No related tags found
No related merge requests found
...@@ -1714,31 +1714,37 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI { ...@@ -1714,31 +1714,37 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI {
public abstract long execute(Object vector); public abstract long execute(Object vector);
@Specialization @Specialization
@TruffleBoundary
protected static long get(RIntVector vector) { protected static long get(RIntVector vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
@Specialization @Specialization
@TruffleBoundary
protected static long get(RLogicalVector vector) { protected static long get(RLogicalVector vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
@Specialization @Specialization
@TruffleBoundary
protected static long get(RRawVector vector) { protected static long get(RRawVector vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
@Specialization @Specialization
@TruffleBoundary
protected static long get(RDoubleVector vector) { protected static long get(RDoubleVector vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
@Specialization @Specialization
@TruffleBoundary
protected static long get(RComplexVector vector) { protected static long get(RComplexVector vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
@Specialization @Specialization
@TruffleBoundary
protected static long get(CharSXPWrapper vector) { protected static long get(CharSXPWrapper vector) {
return vector.allocateNativeContents(); return vector.allocateNativeContents();
} }
......
...@@ -26,6 +26,7 @@ import static com.oracle.truffle.r.runtime.data.NativeDataAccess.readNativeStrin ...@@ -26,6 +26,7 @@ import static com.oracle.truffle.r.runtime.data.NativeDataAccess.readNativeStrin
import java.io.IOException; import java.io.IOException;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.interop.ForeignAccess;
...@@ -45,6 +46,7 @@ public abstract class NewCustomConnectionNode extends FFIUpCallNode.Arg4 { ...@@ -45,6 +46,7 @@ public abstract class NewCustomConnectionNode extends FFIUpCallNode.Arg4 {
} }
@Specialization @Specialization
@TruffleBoundary
Object handleStrings(String description, String mode, String className, RExternalPtr connAddr) { Object handleStrings(String description, String mode, String className, RExternalPtr connAddr) {
try { try {
return new NativeRConnection(description, mode, className, connAddr).asVector(); return new NativeRConnection(description, mode, className, connAddr).asVector();
...@@ -58,6 +60,7 @@ public abstract class NewCustomConnectionNode extends FFIUpCallNode.Arg4 { ...@@ -58,6 +60,7 @@ public abstract class NewCustomConnectionNode extends FFIUpCallNode.Arg4 {
} }
@Specialization @Specialization
@TruffleBoundary
Object handleAddresses(TruffleObject description, TruffleObject mode, TruffleObject className, RExternalPtr connAddr, Object handleAddresses(TruffleObject description, TruffleObject mode, TruffleObject className, RExternalPtr connAddr,
@Cached("createAsPointerNode()") Node descriptionAsPtrNode, @Cached("createAsPointerNode()") Node modeAsPtrNode, @Cached("createAsPointerNode()") Node classNameAsPtrNode) { @Cached("createAsPointerNode()") Node descriptionAsPtrNode, @Cached("createAsPointerNode()") Node modeAsPtrNode, @Cached("createAsPointerNode()") Node classNameAsPtrNode) {
try { try {
......
...@@ -172,8 +172,9 @@ public interface Engine { ...@@ -172,8 +172,9 @@ public interface Engine {
RExpression parse(Source source) throws ParseException; RExpression parse(Source source) throws ParseException;
/** /**
* This is the external interface from {@link org.graalvm.polyglot.Context#eval(Source)}. It is * This is the external interface from
* required to return a {@link CallTarget} which may be cached for future use, and the * {@link org.graalvm.polyglot.Context#eval(org.graalvm.polyglot.Source)}. It is required to
* return a {@link CallTarget} which may be cached for future use, and the
* {@link org.graalvm.polyglot.Context} is responsible for actually invoking the call target. * {@link org.graalvm.polyglot.Context} is responsible for actually invoking the call target.
*/ */
CallTarget parseToCallTarget(Source source, MaterializedFrame executionFrame) throws ParseException; CallTarget parseToCallTarget(Source source, MaterializedFrame executionFrame) throws ParseException;
......
...@@ -24,6 +24,7 @@ package com.oracle.truffle.r.runtime.data; ...@@ -24,6 +24,7 @@ package com.oracle.truffle.r.runtime.data;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RRuntime;
/** /**
...@@ -48,6 +49,7 @@ public final class CharSXPWrapper extends RObject implements RTruffleObject { ...@@ -48,6 +49,7 @@ public final class CharSXPWrapper extends RObject implements RTruffleObject {
this.contents = contents; this.contents = contents;
} }
@TruffleBoundary
public String getContents() { public String getContents() {
if (this == NA) { if (this == NA) {
// The NA string may have been moved to the native space if someone called R_CHAR on it, // The NA string may have been moved to the native space if someone called R_CHAR on it,
...@@ -58,10 +60,12 @@ public final class CharSXPWrapper extends RObject implements RTruffleObject { ...@@ -58,10 +60,12 @@ public final class CharSXPWrapper extends RObject implements RTruffleObject {
return NativeDataAccess.getData(this, contents); return NativeDataAccess.getData(this, contents);
} }
@TruffleBoundary
public byte getByteAt(int index) { public byte getByteAt(int index) {
return NativeDataAccess.getDataAt(this, getBytes(), index); return NativeDataAccess.getDataAt(this, getBytes(), index);
} }
@TruffleBoundary
public int getLength() { public int getLength() {
return NativeDataAccess.getDataLength(this, getBytes()); return NativeDataAccess.getDataLength(this, getBytes());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment