[mono/mono] fd7cec89: [sgen] Use gcc bitcount intrinsics where appropriate.
| Newsgroups | gmane.comp.gnome.mono.patches |
|---|---|
| Message-ID | <000001418509f520-15a6509e-aaee-4329-8cb9-33cd79dc7b35-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/8f604d71f13f...fd7cec894df1
Commit: fd7cec894df1a7fc157c8b47212eab67f241e002
Author: Zoltan Varga <[email protected]> (vargaz)
Date: 2013-10-04 19:54:17 GMT
URL: https://github.com/mono/mono/commit/fd7cec894df1a7fc157c8b47212eab67f241e002
[sgen] Use gcc bitcount intrinsics where appropriate.
Changed paths:
M mono/metadata/sgen-marksweep.c
Modified: mono/metadata/sgen-marksweep.c
===================================================================
@@ -1574,22 +1574,20 @@ struct _MSBlockInfo {
static inline int
bitcount (mword d)
{
-#if SIZEOF_VOID_P == 8
- /* http://www.jjj.de/bitwizardry/bitwizardrypage.html */
- d -= (d>>1) & 0x5555555555555555;
- d = ((d>>2) & 0x3333333333333333) + (d & 0x3333333333333333);
- d = ((d>>4) + d) & 0x0f0f0f0f0f0f0f0f;
- d *= 0x0101010101010101;
- return d >> 56;
+ int count = 0;
+
+#ifdef __GNUC__
+ if (sizeof (mword) == sizeof (unsigned long))
+ count += __builtin_popcountl (d);
+ else
+ count += __builtin_popcount (d);
#else
- /* http://aggregate.org/MAGIC/ */
- d -= ((d >> 1) & 0x55555555);
- d = (((d >> 2) & 0x33333333) + (d & 0x33333333));
- d = (((d >> 4) + d) & 0x0f0f0f0f);
- d += (d >> 8);
- d += (d >> 16);
- return (d & 0x0000003f);
+ while (d) {
+ count ++;
+ d &= (d - 1);
+ }
#endif
+ return count;
}
static void
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches