-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feature/strpool #184
Merged
Merged
Feature/strpool #184
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also added missing std::move in Def::setters
These variants don't create new nodes as opposed to isa_lit(def->arity()) and as_lit(def->arity()). This is slightly faster but is important in assertions to not have a discprepancy between Debug and Release build in code like this: assert(A == as_lit(arity()));
Solely relying on the name introduces subtle bugs when some Def's name coincidentally has the same name as an external. This flag distinguishes externals from non-externals with the same name and also makes Def::is_external checks faster.
NeuralCoder3
reviewed
Mar 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR significantly speeds up the whole compiler. Impala test suite runs in 23s instead of 89s on my notebook (Debug build). And this time includes firing up clang and running the actual compiled program. Apparently, we spend much time on
master
packing and unpacking debug infos.Def::meta
is goneWas only used at two spots:
a#x
in the frontend. We are now simply using a map instead.Pi
instead which is much cleaner and simpler anyway.Sym
All strings are tossed into a global hash set - the
SymPool
. This one lives in a new classDriver
where a few global variables live. Well, there are not really global - that's the point of theDriver
class. Also, it decouples some stuff fromWorld
and fights its god class status.Sym
simply wrapsconst std::string*
(so pass it around as value) and does==
/!=
comparisons in O(1). The empty string is internally handled asnullptr
. Thus, you can create aSym
representing an empty string without having access to theSymPool
. The empty string,nullptr
, and"\0"
are all identified asSym()
.Since creating aSym
has a slight runtime penalty (although much faster than the old solution), it's a good idea to create neededSym
bols beforehand. You can see that inlower_for.h
and a few other spots where I already did that but was too lazy to do it in all passes. It's only a slight penalty and hence probably hardly worth the effort. But if you feel like using this trick in your passes, the anonymous sruct and struct initialization - as I did inlower_for.h
- are arguably the solution requiring the least amount of boilerplate.Def::dbg
This changed from
const Def*
tostruct Dbg { Loc loc; Sym sym }
.Instead of passing
const Def* dbg
all over the place, all classes now have setters:Or directly set on creation:
Misc
const Def*
toRef
.