Skip to content
Snippets Groups Projects
Commit b2a94f39 authored by stepan's avatar stepan
Browse files

REmbedded: do not longjmp when outside of down-call context

parent 7c3d2fc2
No related branches found
No related tags found
No related merge requests found
...@@ -24,16 +24,22 @@ package com.oracle.truffle.r.ffi.impl.nfi; ...@@ -24,16 +24,22 @@ package com.oracle.truffle.r.ffi.impl.nfi;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.ffi.CallRFFI.HandleUpCallExceptionNode; import com.oracle.truffle.r.runtime.ffi.CallRFFI.HandleUpCallExceptionNode;
import com.oracle.truffle.r.runtime.ffi.DownCallNodeFactory.DownCallNode; import com.oracle.truffle.r.runtime.ffi.DownCallNodeFactory.DownCallNode;
import com.oracle.truffle.r.runtime.ffi.NativeFunction; import com.oracle.truffle.r.runtime.ffi.NativeFunction;
public class HandleNFIUpCallExceptionNode extends Node implements HandleUpCallExceptionNode { public class HandleNFIUpCallExceptionNode extends Node implements HandleUpCallExceptionNode {
@Child private DownCallNode setFlagNode = TruffleNFI_DownCallNodeFactory.INSTANCE.createDownCallNode(NativeFunction.set_exception_flag); @Child private DownCallNode setFlagNode = TruffleNFI_DownCallNodeFactory.INSTANCE.createDownCallNode(NativeFunction.set_exception_flag);
private final ConditionProfile isEmbeddedTopLevel = ConditionProfile.createBinaryProfile();
@Override @Override
@TruffleBoundary @TruffleBoundary
public void execute(Throwable originalEx) { public void execute(Throwable originalEx) {
if (isEmbeddedTopLevel.profile(RContext.isEmbedded() && isTopLevel())) {
return;
}
setFlagNode.call(); setFlagNode.call();
RuntimeException ex; RuntimeException ex;
if (originalEx instanceof RuntimeException) { if (originalEx instanceof RuntimeException) {
...@@ -43,4 +49,8 @@ public class HandleNFIUpCallExceptionNode extends Node implements HandleUpCallEx ...@@ -43,4 +49,8 @@ public class HandleNFIUpCallExceptionNode extends Node implements HandleUpCallEx
} }
TruffleNFI_Context.getInstance().setLastUpCallException(ex); TruffleNFI_Context.getInstance().setLastUpCallException(ex);
} }
private static boolean isTopLevel() {
return ((TruffleNFI_Context) RContext.getInstance().getRFFI()).getCallDepth() == 0;
}
} }
...@@ -126,7 +126,7 @@ public abstract class RFFIContext extends RFFI { ...@@ -126,7 +126,7 @@ public abstract class RFFIContext extends RFFI {
cooperativeGc(); cooperativeGc();
} }
public int getCallDepth() { public final int getCallDepth() {
return callDepth; return callDepth;
} }
......
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