Skip to content

[Don't merge] docs: description of new mangling scheme, version 2 #5433

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

Closed
wants to merge 4 commits into from

Conversation

eeckstein
Copy link
Contributor

This PR is a proposal for a new mangling scheme. It's still draft and probably the grammar contains several bugs. But it should give an idea how it could look like.

These are the main changes:

  1. Change the order of the mangling to a post-fix like structure.

This is the biggest change.
It will help to get more common prefixes in the mangled names to optimize the trie in the mach-o object files.
The length of the mangled names will mostly stay the same but the order of 'operands' inside the mangling is more or less reversed.
This change also required to use different 'operator' characters in some cases.

  1. Word-substitutions

Similar to the S-substitutions, but finer grained. See section 'Identifiers'.
Reduces the size of mangled names in general.

  1. Combined substitutions

A more efficient way to mangle multiple S-substitutions.
Reduces the size of mangled names with lots of substitutions, e.g. specialized functions.

  1. Change the '_T' prefix to '_S'

(on John's request)
Because it's basically a completely new mangling scheme.

These are the main changes:

1) Change the order of the mangling to a post-fix like structure.

This is the biggest change.
It will help to get more common prefixes in the mangled names to optimize the trie in the macho object files.
The length of the mangled names will mostly stay the same but the order of 'operands' inside the mangling is more or less reversed.
This change also required to use different 'operator' characters in some cases.

2) Word-substitutions

Similar to the S-substitutions, but finer grained. See section 'Identifiers'.
Reduces the size of mangled names in general.

3) Combined substitutions

A more efficient way to mangle multiple S-substitutions.
Reduces the size of mangled names with lots of substitutions, e.g. specialized functions.

4) Change the '_T' prefix to '_S'

(on John's request)
Because it's basically a new mangling scheme.
@eeckstein
Copy link
Contributor Author

This new version incorporates feedback from @jckarter
Also I added mangling for partially specialized functions.

@eeckstein
Copy link
Contributor Author

eeckstein commented Oct 24, 2016

@slavapestov

Alternatively we could keep the old mangling format around until we're ready to do an ABI break there.

Yes, that's what I'm going to do.

@eeckstein
Copy link
Contributor Author

@gottesmm

Since you are changing the prefix from _T => _S, we are probably going to have to change strip as well.

good point

@eeckstein
Copy link
Contributor Author

@jckarter I addressed your comments in the second commit

@slavapestov
Copy link
Contributor

Can this PR be closed now?

@eeckstein eeckstein closed this Mar 17, 2017
@eeckstein eeckstein deleted the new-mangling2 branch April 17, 2021 15:01
MaxDesiatov pushed a commit that referenced this pull request Sep 7, 2023
[pull] swiftwasm from main
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