[ruby-core:126185] [Ruby Feature#22215] Introduce narrow internal interfaces for bundled extensions
Issue #22215 has been reported by nobu (Nobuyoshi Nakada). ---------------------------------------- Feature #22215: Introduce narrow internal interfaces for bundled extensions https://bugs.ruby-lang.org/issues/22215 * Author: nobu (Nobuyoshi Nakada) * Status: Open ---------------------------------------- ## Abstract Introduce narrow internal interfaces for bundled extensions so that they do not need to depend on VM implementation headers such as `vm_core.h` or thread implementation files such as `thread_pthread.h`. These interfaces are declared in `internal/` headers and are not intended to be stable APIs for third-party extensions. ## Background Some bundled extensions currently include private implementation headers to access a small part of CRuby internals. For example, `ext/coverage` needs to enumerate method coverage data. Doing that directly requires knowledge of method entries, IMEMOs, the object space, and VM-private structures. Consequently, the extension depends on `internal/gc.h` and `vm_core.h`. Likewise, `ext/objspace` accesses fields of call-info and call-cache IMEMOs directly. These dependencies expose the extensions to much more of the VM implementation than they actually need. They also cause extensions to depend transitively on thread implementation files through `vm_core.h`. ## Proposal Add narrow internal interfaces for the bundled extensions: * Collect coverage constants and declarations in `internal/coverage.h`. * Perform method-entry traversal in the core and pass normalized method coverage data to `ext/coverage` through `rb_coverage_each_method`. * Add `rb_imemo_callinfo_mid` and `rb_imemo_callcache_get_data` for the information required by `ext/objspace`. * Keep these declarations in `internal/` headers rather than public `ruby/` headers. * Remove the transitive inclusion of `vm_core.h` from `internal/gc.h`. The new interfaces must be exported because the bundled extensions can be built as shared libraries. They are internal implementation interfaces, not supported extension APIs. With these interfaces, extensions under `ext` no longer depend on `vm_core.h` or `thread_pthread.[ch]`. ## Compatibility There is no intended Ruby-level behavior change. The new interfaces are internal to CRuby and are not intended to provide API or ABI compatibility guarantees for third-party extensions. -- https://bugs.ruby-lang.org/
participants (1)
-
nobu (Nobuyoshi Nakada)