Skip to content

[GR-75099] Hide C API helpers.#889

Merged
graalvmbot merged 13 commits into
masterfrom
fa/GR-75099/hide_capi_helpers
May 28, 2026
Merged

[GR-75099] Hide C API helpers.#889
graalvmbot merged 13 commits into
masterfrom
fa/GR-75099/hide_capi_helpers

Conversation

@graalvmbot
Copy link
Copy Markdown
Collaborator

This change reduces the GraalPy-specific ABI surface. In particular, we exported all our internal helper/upcall functions and variables.

The new policy for a symbol being exported is:

  1. They are part of the public Python API,
  2. necessary to implement macros (e.g. GraalPyFloat_AS_DOUBLE), or
  3. any of GraalPy_CAPI_HELPERS, GraalPy_CAPI_METADATA, and initialize_graal_capi.

Everything else should be hidden or local.

Major changes summary:

  • Since we were using some of our internal C API functions in GraalPy-specific tests (which build a separate module), I've introduced header graalpy/testcapi.h which defines a struct with the necessary members. The instance of this struct is then exposed via a capsule. This is the Python way to do it.
  • For the C functions we call from Java, I've introduced a function pointer table (C global variable GraalPy_CAPI_HELPERS) that is generated from NativeCAPISymbol. In that case, it doesn't matter if the symbol is exported or hidden.
  • I've introduced CPP macro GraalPy_CAPI_HELPER_SYMBOL to mark such helper functions. The macro is just an alias for Py_LOCAL_SYMBOL.
  • I also took the opportunity and merged the offsets and struct sizes (declared by CFields and CStructs) into table, i.e., GraalPy_CAPI_METADATA.
  • The initialization of the Java-side mirror of those tables is now actually independent from C API initialization. Also, we don't need to call anything, we just read off-heap memory. This should make C API int a bit faster (but probably not measurable). However, currently the two tables are initialized together with the C API since they will only then be used.
  • I've also updated files abi/abi-graalpy250.xml and abi/suppressions-base.ini.
    We do no longer suppress GraalPyPrivate-prefixed symbols.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 27, 2026
@graalvmbot graalvmbot closed this May 28, 2026
@graalvmbot graalvmbot merged commit 4b1db68 into master May 28, 2026
49 of 58 checks passed
@graalvmbot graalvmbot deleted the fa/GR-75099/hide_capi_helpers branch May 28, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants