Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include <stdio.h>
#include <string.h>

#if defined(__wasm__) && defined(OLDABI_COMPAT)
#error WebAssembly does not support the legacy Objective-C ABI.
#endif

/**
* Runtime lock. This is exposed in
*/
Expand Down Expand Up @@ -214,7 +218,7 @@ OBJC_PUBLIC void __objc_load(struct objc_init *init)
{
continue;
}
objc_register_selector(sel);
objc_register_selector_unchecked(sel);
}
for (struct objc_protocol *proto = init->proto_begin ; proto < init->proto_end ;
proto++)
Expand Down
6 changes: 6 additions & 0 deletions selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ extern "C"
*/
SEL objc_register_selector(SEL aSel);

/**
* Registers a selector that the caller knows has not already been registered.
* The version 2 ABI provides each selector exactly once during __objc_load.
*/
SEL objc_register_selector_unchecked(SEL aSel);

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions selector_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ extern "C" PRIVATE SEL objc_register_selector(SEL aSel)
{
return aSel;
}
return objc_register_selector_unchecked(aSel);
}

extern "C" PRIVATE SEL objc_register_selector_unchecked(SEL aSel)
{
UnregisteredSelector unregistered{aSel->name, aSel->types};
// Check that this isn't already registered, before we try
SEL registered = selector_lookup(aSel->name, aSel->types);
Expand Down
Loading