Skip to content

Commit 3e57267

Browse files
committed
Put CTypesModuleBuiltins$DlOpenNode behind TruffleBounary
1 parent 5d4f088 commit 3e57267

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CtypesModuleBuiltins.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
import com.oracle.graal.python.runtime.PythonOptions;
170170
import com.oracle.graal.python.runtime.exception.PException;
171171
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
172+
import com.oracle.graal.python.runtime.object.PythonObjectSlowPathFactory;
172173
import com.oracle.graal.python.util.PythonUtils;
173174
import com.oracle.truffle.api.CompilerDirectives;
174175
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
@@ -704,14 +705,13 @@ private static TruffleString getErrMsg(Exception e) {
704705
return toTruffleStringUncached(errmsg);
705706
}
706707

708+
@TruffleBoundary
707709
@Specialization
708-
static Object py_dl_open(VirtualFrame frame, PythonModule self, TruffleString name, int m,
710+
static Object py_dl_open(PythonModule self, TruffleString name, int m,
709711
@Bind("this") Node inliningTarget,
710-
@Cached PyObjectHashNode hashNode,
711-
@Cached AuditNode auditNode,
712-
@Cached EqualNode eqNode,
713-
@Cached PythonObjectFactory factory,
714-
@Cached PRaiseNode.Lazy raiseNode) {
712+
@Cached AuditNode auditNode) {
713+
PythonContext context = PythonContext.get(inliningTarget);
714+
PythonObjectSlowPathFactory factory = context.factory();
715715
auditNode.audit(inliningTarget, "ctypes.dlopen", name);
716716
if (name.isEmpty()) {
717717
return factory.createNativeVoidPtr(((CtypesModuleBuiltins) self.getBuiltins()).rtldDefault);
@@ -722,13 +722,12 @@ static Object py_dl_open(VirtualFrame frame, PythonModule self, TruffleString na
722722

723723
int mode = m != Integer.MIN_VALUE ? m : RTLD_LOCAL.getValueIfDefined();
724724
mode |= RTLD_NOW.getValueIfDefined();
725-
PythonContext context = PythonContext.get(inliningTarget);
726725
DLHandler handle;
727726
Exception exception = null;
728727
try {
729728
if (!context.getEnv().isNativeAccessAllowed() && !PythonOptions.NativeModules.getValue(context.getEnv().getOptions())) {
730729
Object handler = loadLLVMLibrary(context, inliningTarget, name);
731-
long adr = hashNode.execute(frame, inliningTarget, handler);
730+
long adr = PyObjectHashNode.executeUncached(handler);
732731
handle = new DLHandler(handler, adr, name.toJavaStringUncached(), true);
733732
registerAddress(context, handle.adr, handle);
734733
return factory.createNativeVoidPtr(handle);
@@ -737,6 +736,7 @@ static Object py_dl_open(VirtualFrame frame, PythonModule self, TruffleString na
737736
/*-
738737
TODO: (mq) cryptography in macos isn't always compatible with ctypes.
739738
*/
739+
EqualNode eqNode = EqualNode.getUncached();
740740
if (!eqNode.execute(name, MACOS_Security_LIB, TS_ENCODING) && !eqNode.execute(name, MACOS_CoreFoundation_LIB, TS_ENCODING)) {
741741
handle = loadNFILibrary(context, ctypes.backendType, name.toJavaStringUncached(), mode);
742742
registerAddress(context, handle.adr, handle);
@@ -746,7 +746,7 @@ static Object py_dl_open(VirtualFrame frame, PythonModule self, TruffleString na
746746
} catch (Exception e) {
747747
exception = e;
748748
}
749-
throw raiseNode.get(inliningTarget).raise(OSError, getErrMsg(exception));
749+
throw PRaiseNode.raiseUncached(inliningTarget, OSError, getErrMsg(exception));
750750
}
751751
}
752752

0 commit comments

Comments
 (0)