-
Notifications
You must be signed in to change notification settings - Fork 0
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
Name mangling #2
base: main
Are you sure you want to change the base?
Conversation
I approve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 Slight Syntactical mistake otherwise ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, i agree with the drawback though, maybe we could have something like a @__NO_MANGLE__
decorator
Maybe without the double underscores, like `@noMangle` or `@no_mangle`
What happened to this
***@***.***` or ***@***.***_mangle`
Remind me not to use email replies anymore
|
lol sorry just a C-ism i'm used to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
|
||
## Basic example | ||
|
||
A method of the class `foo` with the signature `method(data: int) -> string` in the module `bar.baz` would be mangled to `boad2m3barm3bazc3fooi6methodp1t3i32r5string` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not something like boa__bar_baz__foo_method__int__string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was mostly basing it off rust's mangling, which uses RLE (see prior art), but this could work too. It may be a bit messy to unmangle them, however
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leader__module__class_functionName__paramType_paramType_...__returnType
That's more what I meant
|
||
## Drawbacks | ||
|
||
- Generating a mangled name can be slightly costly, and can lead to confusing binaries. A possibility to disable mangling for certain symbols should be considered in the future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that can be fixed by using things like underscores to act as a sort of whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if we choose to go that route, we could use whitespace as whitespace, but it may be a terrible idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I more meant that underscores can be a good replacement for actual spaces where spaces aren't allowed in names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was referring to the fact that symbols in the binary can have any name we want them to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
underscores def make it nicer, i agree with lyxal here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try to find some prior art that uses underscores? All I could find uses RLE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing of note, humans likely wouldn't look at mangled names directly, they'd see it through something like https://github.com/luser/rustfilt
This RFC describes how name mangling will work in Boa.