Skip to content

Commit 6eab85e

Browse files
committed
setup IndirectCallContext in downcalls which might return a PException
1 parent af62436 commit 6eab85e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextAbstractBuiltins.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
117117
import com.oracle.graal.python.nodes.subscript.SliceLiteralNode;
118118
import com.oracle.graal.python.nodes.truffle.PythonTypes;
119+
import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext;
119120
import com.oracle.graal.python.runtime.PythonContext;
120121
import com.oracle.graal.python.runtime.exception.PException;
121122
import com.oracle.truffle.api.CompilerDirectives;
@@ -1000,18 +1001,21 @@ static Object doSequence(VirtualFrame frame, Object obj,
10001001
}
10011002

10021003
@Specialization(guards = "isNativeObject(obj)")
1003-
static Object doNative(VirtualFrame frame, Object obj,
1004+
Object doNative(VirtualFrame frame, Object obj,
10041005
@Cached ToSulongNode toSulongNode,
10051006
@Cached PCallCapiFunction callCapiFunction,
10061007
@Cached CheckPrimitiveFunctionResultNode checkFunctionResultNode,
10071008
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
1009+
Object state = IndirectCallContext.enter(frame, this);
10081010
try {
10091011
Object result = callCapiFunction.call(FUN_PY_TRUFFLE_PY_SEQUENCE_SIZE, toSulongNode.execute(obj));
10101012
checkFunctionResultNode.execute(PythonContext.get(callCapiFunction), FUN_PY_TRUFFLE_PY_SEQUENCE_SIZE.getName(), result);
10111013
return result;
10121014
} catch (PException e) {
10131015
transformExceptionToNativeNode.execute(frame, e);
10141016
return -1;
1017+
} finally {
1018+
IndirectCallContext.exit(frame, this, state);
10151019
}
10161020
}
10171021

@@ -1071,19 +1075,22 @@ static int doGenericUnboxed(VirtualFrame frame, Object obj,
10711075
}
10721076

10731077
@Specialization(guards = {"isNativeObject(obj)"})
1074-
static Object size(VirtualFrame frame, Object obj,
1078+
Object size(VirtualFrame frame, Object obj,
10751079
@Cached ToSulongNode toSulongNode,
10761080
@Cached AsPythonObjectNode asPythonObjectNode,
10771081
@Cached PCallCapiFunction callCapiFunction,
10781082
@Cached CheckPrimitiveFunctionResultNode checkFunctionResultNode,
10791083
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
1084+
Object state = IndirectCallContext.enter(frame, this);
10801085
try {
10811086
Object result = callCapiFunction.call(FUN_PY_TRUFFLE_PY_OBJECT_SIZE, toSulongNode.execute(obj));
10821087
checkFunctionResultNode.execute(PythonContext.get(callCapiFunction), FUN_PY_TRUFFLE_PY_OBJECT_SIZE.getName(), result);
10831088
return result;
10841089
} catch (PException e) {
10851090
transformExceptionToNativeNode.execute(frame, e);
10861091
return -1;
1092+
} finally {
1093+
IndirectCallContext.exit(frame, this, state);
10871094
}
10881095
}
10891096
}

0 commit comments

Comments
 (0)