Skip to content

Disable lazy selector registration check for OLDABI non-compat - #420

Draft
HendrikHuebner wants to merge 1 commit into
gnustep:masterfrom
HendrikHuebner:objc-wasm-4-selector-registration
Draft

Disable lazy selector registration check for OLDABI non-compat#420
HendrikHuebner wants to merge 1 commit into
gnustep:masterfrom
HendrikHuebner:objc-wasm-4-selector-registration

Conversation

@HendrikHuebner

Copy link
Copy Markdown

WebAssembly's linear memory does not guarantee that static/heap alocated selector strings are greater than a certain numeric value. Therefore, we can't reliably assume that sel->index < selector_list->size() means the selector is registered already. The pointer value might be smaller than the size of the selector_list.

This patch uses tsl::robin_map for WebAssembly instead. Perhaps this could be optimized in the future by extending the selector union objc_selector on WASM to have an additional entry to mark it as registered? I think this would also require a compiler change however, so this seems like the easiest option for now.

@davidchisnall

Copy link
Copy Markdown
Member

Do we actually need the is-registered check with the v2 ABI? I think we now guarantee that all selectors are registered in __objc_load. The check is still there because someone might load something with the v1 ABI and do __objc_exec_class to load the classes but expect the selectors to be lazily resolved.

I think WebAssembly can just not expose the v1 entry point and skip the is-resolved checks. We can probably disable them entirely in any build configuration where we're not building v1 ABI support and stick in a #error if you ask for v1 ABI and WAsm in the same build?

@HendrikHuebner

Copy link
Copy Markdown
Author

Alright, I #ifdef'd the check to always return true when the old ABI is not enabled.

I'll create a separate PR to update the build system to support a LIBOBJC_WASM mode, which disables the old ABI.
We'll also have to build libobjc2 as a static archive for WebAssembly.

@HendrikHuebner HendrikHuebner changed the title [WebAssembly] Register selectors using a hash set for WASM Disable lazy selector registration check for OLDABI non-compat Aug 26, 2026
@davidchisnall
davidchisnall force-pushed the objc-wasm-4-selector-registration branch from a779787 to 0ff16de Compare August 26, 2026 10:54
@HendrikHuebner

Copy link
Copy Markdown
Author

@davidchisnall please don't merge this yet - I think selLookup_locked has the same issue. I'll need to look into it first

@davidchisnall
davidchisnall marked this pull request as draft August 26, 2026 14:54
@HendrikHuebner

Copy link
Copy Markdown
Author

@davidchisnall The current #ifdef OLDABI version is wrong. __objc_load will the selector registration entirely because isSelRegistered returns YES all the time. That's why the Windows builds are failing. Should I revert this to the original version which uses the hash set for WASM?

@HendrikHuebner
HendrikHuebner force-pushed the objc-wasm-4-selector-registration branch from 0ff16de to 522fc25 Compare August 27, 2026 09:05
@HendrikHuebner

Copy link
Copy Markdown
Author

@davidchisnall I reverted it to the original patch. Can you restart the CI checks please?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants