[Gc] Re: Re[12]: PATCH: Add x32 support to boehm-gc

H.J. Lu hjl.tools at gmail.com
Mon Oct 8 09:08:39 PDT 2012


On Mon, Oct 8, 2012 at 9:05 AM, Ivan Maidanski <ivmai at mail.ru> wrote:
> Hi H.J.,
>
> Mon, 8 Oct 2012 08:54:08 -0700 от "H.J. Lu" <hjl.tools at gmail.com>:
>
> A couple comments:
>
> 1. AO_double_compare_and_swap_full is wrong:
>
> #elif defined(__ILP32__) || !defined(__x86_64__)
> # include "../standard_ao_double_t.h"
>
>   /* X32 has native support for 64-bit integer operations (AO_double_t */
>   /* is a 64-bit integer and we could use 64-bit cmpxchg). */
>   /* This primitive is used by compare_double_and_swap_double_full. */
>   AO_INLINE int
>   AO_double_compare_and_swap_full(volatile AO_double_t *addr,
>                                   AO_double_t old_val, AO_double_t new_val)
>
> This is only for x32. You should check
>
> #elif defined(__ILP32__) && defined(__x86_64__)
>
>
> No, the former is correct. Because this is not only for x32 but also for x86
> (if gcc 4+ and AO_USE_SYNC_CAS_BUILTIN manually defined). I've tested it
> (and inspected -S output) with recent clang and recent gcc-4.4 .. 4.7. See
> this commit message:
> https://github.com/ivmai/libatomic_ops/commit/03de7740c21fe6e4a6bdd7af09d5ff5189d4d70e
>
>

I see.

>
> 2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?
>
>   AO_INLINE unsigned int
>   AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
>   {
>     unsigned int result;
>
>     __asm__ __volatile__ ("lock; xaddl %0, %1"
>                         : "=r" (result), "=m" (*p)
>                         : "0" (incr), "m" (*p)
>                         : "memory");
>     return result;
>   }
>
> works for ia32, x32 and x86-64.
>
> For ia32 and x32, we define AO_T_IS_INT which force
> AO_int_fetch_and_add_full to be defined as AO_fetch_and_add_full in
> ao_t_is_int.h

I see.

> Please run test_atomic and see it output whether AO_int_fetch_and_add_full
> is reported to be missing on X32. I'm sure it's not.
>
> Does "make check" successfully pass all tests on X32?

Yes, I got

make  check-TESTS
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Missing: AO_compare_and_swap_double
Missing: AO_compare_and_swap_double_acquire
Missing: AO_compare_and_swap_double_release
Missing: AO_compare_and_swap_double_read
Missing: AO_compare_and_swap_double_write
Missing: AO_compare_and_swap_double_full
Missing: AO_compare_and_swap_double_release_write
Missing: AO_compare_and_swap_double_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic_pthreads
About 1000000 pushes + 1000000 pops in 1 threads: 23 msecs
About 1000000 pushes + 1000000 pops in 2 threads: 119 msecs
About 1000000 pushes + 1000000 pops in 3 threads: 146 msecs
About 1000000 pushes + 1000000 pops in 4 threads: 179 msecs
PASS: test_stack
Performing 1000 reversals of 1000 element lists in 10 threads
Testing AO_malloc/AO_free
Succeeded
PASS: test_malloc
==================
All 4 tests passed
==================
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'

Thanks.

-- 
H.J.



More information about the Gc mailing list