-
-
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
Instantiates generics in the module that uses it #22513
Conversation
tests/ic/genericinst.nim
Outdated
""".} | ||
|
||
type Foo {.importcpp.} = object | ||
echo $Foo() #Notice the generic is instantiate in the this module if not, it wouldnt find Foo |
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.
echo $Foo() #Notice the generic is instantiate in the this module if not, it wouldnt find Foo | |
# Check that the generic implementation of `$` for `Foo` is contained in the | |
# C++ file emitted by the Nim compiler for this module. | |
# If it isn't the C compiler will not be able to find the `Foo` type. | |
echo $Foo() |
What happens if two modules use the same instantiation? ie Also, one thing that significantly increase recompiles is reordering - ie even the smallest change can lead to large recompiles if the call order changes causing the AST traversal to happen in a different order - to fix this, the cgen would have to cache the output of each function and order them deterministically. |
This is specifically for IC so it would be somewhat cached. The reasoning behind it is to not invalidate IC cache in the first place. Which will produce a new C/Cpp and a road file for the module that holds the generic and will trigger all deps as well. When IC is there we can see if it is worth it to do another optimisation on it. :) |
Notice CI is broken due to a package update. |
…ag on pkgs. excludes test
Very interesting work!. 👍 |
Thanks! There are a few edge cases still to cover but getting there |
@@ -19,7 +19,8 @@ import | |||
intsets, transf, vmdef, vm, aliases, cgmeth, lambdalifting, | |||
evaltempl, patterns, parampatterns, sempass2, linter, semmacrosanity, | |||
lowerings, plugins/active, lineinfos, strtabs, int128, | |||
isolation_check, typeallowed, modulegraphs, enumtostr, concepts, astmsgs | |||
isolation_check, typeallowed, modulegraphs, enumtostr, concepts, astmsgs, | |||
extccomp |
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.
Remove again?
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.
Yes, sorry. Totally forgot about it
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, do we still want to move the localPassC
right? If so, is still necessary
Co-authored-by: Andreas Rumpf <[email protected]>
Thanks for your hard work on this PR! Hint: mm: orc; opt: speed; options: -d:release |
Attempts to move the generic instantiation to the module that uses it. This should decrease re-compilation times as the source module where the generic lives doesnt need to be recompiled