-
Notifications
You must be signed in to change notification settings - Fork 951
Hashmap improvements #347
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
Hashmap improvements #347
Conversation
By moving all allocas used in hashmap operations to the entry block, the stack frame remains at a fixed size known at compile time. This avoids stack overflows when doing map operations in loops and in general improves code quality: the compiled size of testdata/map.go went from 3776 to 3632 in .text size.
220168a
to
5ee7c8c
Compare
compiler/compiler.go
Outdated
var err error | ||
sizeHint, err = c.parseConvert(expr.Reserve.Type(), types.Typ[types.Uintptr], sizeHint, expr.Pos()) | ||
if err != nil { | ||
return llvm.Value{}, nil |
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.
Oh no, that's a bug.
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.
fixed.
It defaults to hint/8 number of buckets. This number may be tuned in the future.
Add support for growing hashmaps beyond their initial size.
5ee7c8c
to
8b2ae84
Compare
Also fixed a leftover from #294 in the last commit (no functional change). Unrelated, but I thought I'd add it here as it is really trivial. |
08feb41
to
48a3aca
Compare
No error is produced, so no error needs to be returned. It was missed in #294. Also, it fixes this smelly code: if err != nil { return <something>, nil } There could never be an error, so the code was already dead.
48a3aca
to
2c2f6b7
Compare
OK, great, we need this. Now merging. |
Implement growing of hashmaps and setting the initial size. Necessary for
js.Func
support (#226), among others.