Remove libgcc_s_seh-1.dll dependency when targeting Win32 with gcc. (mono/mono#14251)
authorJay Krell <jay.krell@cornell.edu>
Sun, 28 Apr 2019 01:57:17 +0000 (18:57 -0700)
committerZoltan Varga <vargaz@gmail.com>
Sun, 28 Apr 2019 01:57:17 +0000 (21:57 -0400)
Don't use popcount intrinsic.
Alternative but not exactly contradictory to https://github.com/mono/mono/pull/14248.

Note that this is a single inlinable instruction on x86,
if you assume at least SSE4 from circa 2007, which I am avoiding here.

Commit migrated from https://github.com/mono/mono/commit/90a91429ae75240b4d0e791a563a9d553be09d56

src/mono/mono/sgen/sgen-marksweep.c
src/mono/mono/utils/monobitset.c

index c90c589..4ff3d2b 100644 (file)
@@ -1544,7 +1544,9 @@ bitcount (mword d)
 {
        int count = 0;
 
-#ifdef __GNUC__
+#if defined (__GNUC__) && !defined (HOST_WIN32)
+// The builtins do work on Win32, but can cause a not worthwhile runtime dependency.
+// See https://github.com/mono/mono/pull/14248.
        if (sizeof (mword) == 8)
                count += __builtin_popcountll (d);
        else
index 944fae8..9d76038 100644 (file)
@@ -201,14 +201,17 @@ mono_bitset_size (const MonoBitSet *set) {
  * \returns number of bits that are set.
  */
 guint32
-mono_bitset_count (const MonoBitSet *set) {
+mono_bitset_count (const MonoBitSet *set)
+{
        guint32 i, count;
        gsize d;
 
        count = 0;
        for (i = 0; i < set->size / BITS_PER_CHUNK; ++i) {
                d = set->data [i];
-#ifdef __GNUC__
+#if defined (__GNUC__) && !defined (HOST_WIN32)
+// The builtins do work on Win32, but can cause a not worthwhile runtime dependency.
+// See https://github.com/mono/mono/pull/14248.
                if (sizeof (gsize) == sizeof (unsigned int))
                        count += __builtin_popcount (d);
                else