Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore a way to adopt Component Model #229

Open
kateinoigakukun opened this issue May 20, 2023 · 3 comments
Open

Explore a way to adopt Component Model #229

kateinoigakukun opened this issue May 20, 2023 · 3 comments

Comments

@kateinoigakukun
Copy link
Member

See https://github.com/WebAssembly/component-model for more details about Component Model

@kateinoigakukun
Copy link
Member Author

kateinoigakukun commented May 21, 2023

To link extension libraries dynamically we need some extra ABI convention on the top of Wasm's import/export and Component Model.
Extra requirements on top of the existing ABI to make the extension libraries work with CRuby convention are:

  1. All extension library instances and the main instance (CRuby program itself) should share memory space because GC needs to traverse objects through C pointers. Note that C stack space should be also shared.
  2. Functions defined in library instances should be called by an indirect call from the main module because an extension library registers its method implementations through rb_define_method and the registered functions are called from CRuby VM. The main module, CRuby VM, does not know what functions are exported from extension libraries at the moment of building it, so calls to extension libraries cannot be direct.
  3. Calls to imported/exported functions should be compatible with Asyncify.

Note that I intentionally ignored dlopen or dlsym because they are essentially unnecessary if the linked modules can be known at the componentizing time.

Thus conventions to be decided here are:

  1. How to place library data segments/table elements into main memory/table space
  2. How to fixup the data and function addresses in library data segments, table elements, code based on where they are placed.

Emscripten's dynamic linking ABI would be useful as a starting point, but it requires external loader to fixup the addresses in code section. IIUC the main reason why it requires external loader is that Wasm cannot self-patch code space. (maybe also for resolving symbols at runtime?)

But I don't have well understanding for "lifting" yet, so maybe I'm missing something key feature in Component Model

Related links:

@kateinoigakukun
Copy link
Member Author

Not for generic extension library, but it looks reasonable approach for importing/exposing functions https://github.com/dicej/componentize-py/

@Speak2Erase
Copy link

Speak2Erase commented Jul 5, 2024

This is something I'd be interested in doing, but I'm not sure where to start? I'm working project that'll be using wasm for plugins and I'd like to support running ruby as that's what most people using the project will be familiar with.
I'd be more than happy to make something like https://github.com/dicej/componentize-py/ and maintain it for the wider ruby community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants