Skip to content

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

Merged
merged 4 commits into from
May 14, 2019
Merged

Hashmap improvements #347

merged 4 commits into from
May 14, 2019

Conversation

aykevl
Copy link
Member

@aykevl aykevl commented May 13, 2019

Implement growing of hashmaps and setting the initial size. Necessary for js.Func support (#226), among others.

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.
@aykevl aykevl force-pushed the hashmap-improvements branch from 220168a to 5ee7c8c Compare May 13, 2019 18:58
var err error
sizeHint, err = c.parseConvert(expr.Reserve.Type(), types.Typ[types.Uintptr], sizeHint, expr.Pos())
if err != nil {
return llvm.Value{}, nil
Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

aykevl added 2 commits May 13, 2019 22:38
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.
@aykevl aykevl force-pushed the hashmap-improvements branch from 5ee7c8c to 8b2ae84 Compare May 13, 2019 20:39
@aykevl
Copy link
Member Author

aykevl commented May 13, 2019

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.

@aykevl aykevl force-pushed the hashmap-improvements branch from 08feb41 to 48a3aca Compare May 13, 2019 20:50
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.
@deadprogram
Copy link
Member

OK, great, we need this. Now merging.

@deadprogram deadprogram merged commit c981f14 into dev May 14, 2019
@deadprogram deadprogram deleted the hashmap-improvements branch May 14, 2019 14:52
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.

2 participants