Skip to content
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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Name mangling #2

wants to merge 6 commits into from

Conversation

nailuj29
Copy link
Member

@nailuj29 nailuj29 commented Dec 5, 2021

This RFC describes how name mangling will work in Boa.

@Popaulol
Copy link

Popaulol commented Dec 5, 2021

I approve.

Copy link

@Popaulol Popaulol left a 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.

active-rfcs/0000-name-mangling.md Outdated Show resolved Hide resolved
@nailuj29 nailuj29 requested a review from Popaulol December 6, 2021 22:34
Copy link

@Popaulol Popaulol left a 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.

Copy link

@snoglobe snoglobe left a 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

@nailuj29
Copy link
Member Author

nailuj29 commented Dec 9, 2021 via email

@snoglobe
Copy link

snoglobe commented Dec 9, 2021

Maybe without the double underscores, like @. or ***@***.***_mangle

On Thu, Dec 9, 2021, 5:24 PM masonm @.
> wrote: @.**** approved this pull request. looks good to me, i agree with the drawback though, maybe we could have something like a @NO_MANGLE decorator — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub <#2 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5NYZJPABV7MYGGAS34SKLUQEUADANCNFSM5JNHUPMQ .

lol sorry just a C-ism i'm used to

@nailuj29 nailuj29 requested a review from Popaulol December 9, 2021 22:39
@lyxal lyxal self-requested a review December 17, 2021 23:55
Copy link
Member

@lyxal lyxal left a 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`
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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
Copy link
Member

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

Copy link
Member Author

@nailuj29 nailuj29 Dec 18, 2021

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

Copy link
Member

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.

Copy link
Member Author

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

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

Copy link
Member Author

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.

Copy link
Member Author

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

@nailuj29 nailuj29 marked this pull request as draft May 15, 2024 16:29
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.

4 participants