-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use modern enums in compiler #15775
Use modern enums in compiler #15775
Conversation
I did similar things in #14777 (comment), see Araqs comment for why I reverted those changes in that PR. |
That's now 3 people (i had also attempted a similar thing some time ago) that have tried to replace those
but then it got closed (along with its fusion alternative). |
And that's my threshold so I'm willing to accept this solution now. |
Looks good now, I will look into speeding up reprEnum in future PRs |
const CallingConvToStr*: array[TCallingConvention, string] = ["nimcall", "stdcall", | ||
"cdecl", "safecall", "syscall", "inline", "noinline", "fastcall", "thiscall", | ||
"closure", "noconv"] | ||
ccNimCall = "nimcall" # nimcall, also the default |
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.
unfortunately this still leaves CallingConvToStr: array[TCallingConvention, string] = ["N_NIMCALL",...
in compiler/ccgtypes.nim but without
https://github.com/nim-lang/Nim/pull/14008/files#diff-6b7c28355957ab974fa38584bc810d1aac557bdcc7874e98d8ec005cc2200d72 that's the best one can do; still a good improvement.
(cherry picked from commit 00b495d)
Reduce number of constant strings, but reusing string representation of nim enums that compiler will generate anyway.
I managed to shave off 35 kb from the compiler binary with this trick.
I haven't noticed a slowdown in compiler despite I know about
reprEnum
string allocation overhead.Possibly we need to improve codegen for
reprEnum
before making this change.Also I think we need to get rid of
findStr
proc in wordrecg in favour ofparseEnum
. It is efficient now