Skip to content

Commit 8ea3746

Browse files
committed
Expose and log the selected native companion backend
1 parent a02484c commit 8ea3746

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public void postInitialize(Python3Core core) {
299299
mod.setAttribute(tsLiteral("storage_to_native"), PNone.NO_VALUE);
300300
mod.setAttribute(tsLiteral("dump_heap"), PNone.NO_VALUE);
301301
mod.setAttribute(tsLiteral("is_native_object"), PNone.NO_VALUE);
302+
mod.setAttribute(tsLiteral("get_native_companion_backend"), PNone.NO_VALUE);
302303
mod.setAttribute(tsLiteral("get_handle_table_id"), PNone.NO_VALUE);
303304
mod.setAttribute(tsLiteral("is_strong_handle_table_ref"), PNone.NO_VALUE);
304305
mod.setAttribute(tsLiteral("has_id_reference"), PNone.NO_VALUE);
@@ -1389,6 +1390,16 @@ boolean isNative(@SuppressWarnings("unused") Object obj) {
13891390

13901391
}
13911392

1393+
@Builtin(name = "get_native_companion_backend", minNumOfPositionalArgs = 0)
1394+
@GenerateNodeFactory
1395+
abstract static class GetNativeCompanionBackend extends PythonBuiltinNode {
1396+
@Specialization
1397+
@TruffleBoundary
1398+
static TruffleString getBackend() {
1399+
return toTruffleStringUncached(CApiContext.getNativeCompanionBackend());
1400+
}
1401+
}
1402+
13921403
@Builtin(name = "get_handle_table_id", minNumOfPositionalArgs = 1)
13931404
@GenerateNodeFactory
13941405
abstract static class GetHandleTableID extends PythonUnaryBuiltinNode {

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,13 @@ public static TruffleLogger getLogger(Class<?> clazz) {
378378
return CApiLoggers.getLogger(clazz);
379379
}
380380

381+
public static String getNativeCompanionBackend() {
382+
return USE_PINNED_NATIVE_COMPANIONS ? "pinned" : "handle-table";
383+
}
384+
381385
public CApiContext(PythonContext context, NativeLibrary library, NativeLibraryLocator locator) {
386+
CompilerAsserts.neverPartOfCompilation();
387+
LOGGER.config("Native companion backend: " + getNativeCompanionBackend());
382388
this.context = context;
383389
this.library = library;
384390
this.libraryName = locator.getCapiLibrary();

0 commit comments

Comments
 (0)