Closed Bug 906368 Opened 11 years ago Closed 11 years ago

Factor out popcount from RegisterSets::size()

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: sunfish, Unassigned)

References

Details

Attachments

(1 file)

Attached patch popcount.patchSplinter Review
RegisterSets::size() contains a manual popcount implementation. This patch moves it into mfbt/MathAlgorithms.h and uses __builtin_popcount on compilers which support it.
Attachment #791746 - Flags: review?(nicolas.b.pierron)
Comment on attachment 791746 [details] [diff] [review]
popcount.patch

Review of attachment 791746 [details] [diff] [review]:
-----------------------------------------------------------------

Nice.
Thanks for adding a test with it.
Attachment #791746 - Flags: review?(nicolas.b.pierron) → review+
https://hg.mozilla.org/mozilla-central/rev/8d3b2cb5d698
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
The long implementation seems to be incorrect, it needs an extra line:

> uint32_t sum32 = (sum16 & 0x0000ffff) + ((sum16 & 0xffff0000) >> 16);

to correctly figure out the population in all 32 bits.
Depends on: 978397
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: