Skip to content

Commit 173535a

Browse files
committed
Use cached NFI signatures in NFIPosixSupport.
1 parent 9262aa4 commit 173535a

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/runtime/NFIPosixSupport.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import com.oracle.truffle.api.nodes.LanguageInfo;
108108
import com.oracle.truffle.api.nodes.Node;
109109
import com.oracle.truffle.api.source.Source;
110+
import com.oracle.truffle.nfi.api.SignatureLibrary;
110111
import com.oracle.truffle.llvm.api.Toolchain;
111112

112113
import sun.misc.Unsafe;
@@ -372,9 +373,15 @@ private static void loadFunction(NFIPosixSupport posix, Object library, PosixNat
372373
Object unbound;
373374
try {
374375
InteropLibrary interop = InteropLibrary.getUncached();
376+
SignatureLibrary sigs = SignatureLibrary.getUncached();
377+
378+
String sig = String.format("with %s %s", posix.nfiBackend, function.signature);
379+
Source sigSrc = Source.newBuilder("nfi", sig, "posix-nfi-signature").internal(true).build();
380+
Object signature = posix.context.getEnv().parseInternal(sigSrc).call();
381+
375382
unbound = interop.readMember(library, function.name());
376-
posix.cachedFunctions.set(function.ordinal(), interop.invokeMember(unbound, "bind", function.signature));
377-
} catch (UnsupportedMessageException | UnknownIdentifierException | ArityException | UnsupportedTypeException e) {
383+
posix.cachedFunctions.set(function.ordinal(), sigs.bind(signature, unbound));
384+
} catch (UnsupportedMessageException | UnknownIdentifierException e) {
378385
throw CompilerDirectives.shouldNotReachHere(function.name(), e);
379386
}
380387
}

0 commit comments

Comments
 (0)