Skip to content

Conversation

@DataCorrupted
Copy link
Member

@DataCorrupted DataCorrupted commented Dec 4, 2025

TL;DR

This is a stack of PRs implementing features to expose direct methods ABI.
You can see the RFC, design, and discussion here.

#170616 Flag -fexpose-objc-direct set up
#170617 Code refactoring to ease later reviews
#170618 Thunk generation
#170619 Optimizations, some class objects can be known to be realized

Implementation details

  1. Add a flag. I used expose-direct-method instead of -fobjc-direct-caller-thunks in the proposal for two reasons:
    a. It conveys our intention more clearly, that we are trying to remove the \01 byte before the name of direct method so the developers can expose a symbol if they want
    b. Much of the code is actually handling corner cases of var_arg, which don't have a thunk. Thus the name thunk can be confusing.

  2. Clean up and set up helper functions to implement later
    a. canMessageReceiverBeNull / canClassObjectBeUnrealized these two functions will be helpful later to determine which function (true implementation or nil check thunk) we should dispatch a call to. Formatting.
    b. getSymbolNameForMethod has a new argument includePrefixByte, which allows us to erase the prefixing \01 when the flag is enabled
    c. shouldExposeSymbol is the single source of truth of what we should do. It not only checks for the flag, but also whether the method is qualified and we are in the right runtime. A method that shouldExposeSymbol is either shouldHaveNilCheckThunk or shouldHaveNilCheckInline.

Tests

None, existing ones shouldn't break

1. Add a flag
2. Clean up and set up helper functions to implement later

Signed-off-by: Peter Rong <PeterRong@meta.com>
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@DataCorrupted DataCorrupted changed the title [ExposeObjCDirect] Adding a flag to allow new objc direct ABI [ExposeObjCDirect] Adding a flag to expose symbols with objc_direct Dec 8, 2025
@DataCorrupted DataCorrupted self-assigned this Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants