@@ -1140,30 +1140,35 @@ final void toNative() {
1140
1140
if (initJNI (this , castLong (nativePointer )) != 0 ) {
1141
1141
throw new RuntimeException ("Could not initialize HPy JNI backend." );
1142
1142
}
1143
- }
1144
- if (useNativeFastPaths ) {
1145
- PythonContext context = getContext ();
1146
- InteropLibrary interop = InteropLibrary .getUncached ();
1147
- SignatureLibrary signatures = SignatureLibrary .getUncached ();
1148
- try {
1149
- Object rlib = evalNFI (context , "load \" " + getJNILibrary () + "\" " , "load " + PythonContext .PYTHON_JNI_LIBRARY_NAME );
1143
+ /*
1144
+ * Currently, the native fast path functions are only available if the JNI backend
1145
+ * is used because they rely on 'initJNI' being called. In future, we might also
1146
+ * want to use the native fast path functions for the NFI backend.
1147
+ */
1148
+ if (useNativeFastPaths ) {
1149
+ PythonContext context = getContext ();
1150
+ InteropLibrary interop = InteropLibrary .getUncached ();
1151
+ SignatureLibrary signatures = SignatureLibrary .getUncached ();
1152
+ try {
1153
+ Object rlib = evalNFI (context , "load \" " + getJNILibrary () + "\" " , "load " + PythonContext .PYTHON_JNI_LIBRARY_NAME );
1150
1154
1151
- Object augmentSignature = evalNFI (context , "(POINTER):VOID" , "hpy-nfi-signature" );
1152
- Object augmentFunction = interop .readMember (rlib , "initDirectFastPaths" );
1153
- signatures .call (augmentSignature , augmentFunction , nativePointer );
1155
+ Object augmentSignature = evalNFI (context , "(POINTER):VOID" , "hpy-nfi-signature" );
1156
+ Object augmentFunction = interop .readMember (rlib , "initDirectFastPaths" );
1157
+ signatures .call (augmentSignature , augmentFunction , nativePointer );
1154
1158
1155
- Object setNativeSpaceSignature = evalNFI (context , "(POINTER, SINT64):VOID" , "hpy-nfi-signature" );
1156
- setNativeSpaceFunction = signatures .bind (setNativeSpaceSignature , interop .readMember (rlib , "setHPyContextNativeSpace" ));
1159
+ Object setNativeSpaceSignature = evalNFI (context , "(POINTER, SINT64):VOID" , "hpy-nfi-signature" );
1160
+ setNativeSpaceFunction = signatures .bind (setNativeSpaceSignature , interop .readMember (rlib , "setHPyContextNativeSpace" ));
1157
1161
1158
- /*
1159
- * Allocate a native array for the native space pointers of HPy objects and
1160
- * initialize it.
1161
- */
1162
- allocateNativeSpacePointersMirror ();
1162
+ /*
1163
+ * Allocate a native array for the native space pointers of HPy objects and
1164
+ * initialize it.
1165
+ */
1166
+ allocateNativeSpacePointersMirror ();
1163
1167
1164
- interop .execute (setNativeSpaceFunction , nativePointer , nativeSpacePointers );
1165
- } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException | UnknownIdentifierException e ) {
1166
- throw CompilerDirectives .shouldNotReachHere ();
1168
+ interop .execute (setNativeSpaceFunction , nativePointer , nativeSpacePointers );
1169
+ } catch (UnsupportedTypeException | ArityException | UnsupportedMessageException | UnknownIdentifierException e ) {
1170
+ throw CompilerDirectives .shouldNotReachHere ();
1171
+ }
1167
1172
}
1168
1173
}
1169
1174
}
@@ -1489,7 +1494,7 @@ public final long ctxGetItemi(long hCollection, long lidx) {
1489
1494
1490
1495
/**
1491
1496
* HPy signature: {@code HPy_SetItem(HPyContext ctx, HPy obj, HPy key, HPy value)}
1492
- *
1497
+ *
1493
1498
* @param hSequence
1494
1499
* @param hKey
1495
1500
* @param hValue
0 commit comments