From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27393 invoked by alias); 6 Nov 2014 19:05:14 -0000 Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org Received: (qmail 27375 invoked by uid 89); 6 Nov 2014 19:05:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 06 Nov 2014 19:05:13 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA6J5B0S029211 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Nov 2014 14:05:11 -0500 Received: from [10.10.60.106] (vpn-60-106.rdu2.redhat.com [10.10.60.106]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sA6J5Aj3026519; Thu, 6 Nov 2014 14:05:10 -0500 Message-ID: <545BC666.5020007@redhat.com> Date: Thu, 06 Nov 2014 19:05:00 -0000 From: Andrew MacLeod User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Andrew Haley , Richard Biener , Richard Henderson , gcc-patches CC: Jeff Law , java@gcc.gnu.org Subject: Re: [patch] Provide a can_compare_and_swap_p target hook. References: <5458FE9C.2090409@redhat.com> <54590C19.40208@redhat.com> <54591348.1010904@redhat.com> <545913A4.5010400@redhat.com> <54591B3A.8030908@redhat.com> <70044BE8-9F38-4BDB-B73F-6E2FC9AC2629@gmail.com> <54593352.2000700@redhat.com> <545BB682.9000209@redhat.com> <545BBCA5.7060203@redhat.com> In-Reply-To: <545BBCA5.7060203@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2014-11/txt/msg00002.txt.bz2 On 11/06/2014 01:23 PM, Andrew Haley wrote: > On 11/06/2014 05:57 PM, Andrew MacLeod wrote: >> It looks like java is deciding whether or not GCC can inline atomic >> operations or not, and if it can't, doesn't want the atomic >> operations... which presumably means there is no dependency on >> libatomic at runtime. >> >> A call to can_compare_and_swap_p(mode) is analogous to a compile time >> version of folding atomic_always_lock_free(mode) to a constant... >> Frankly that seems like a reasonable question for some front end to >> ask... and elect not to emit atomic calls if so desired. (which is what >> java is doing I think) >> >> whether it still needs to do that is a question for some java person. > I did it because some targets did not have library support for some > builtins, so a compile would fail with a (to a Java programmer) > baffling error message. > > The Java operations certainly should use the generic builtins. > > Thanks Andrew 1) Given that the compiler *always* provides support via libatomic now (even if it is via locks), does that mean that VMSupportsCS8_builtin() should always return true? or should we map to that a call to __atomic_always_lock_free() ? (that always gets folded to a true or false at compile time) my guess is the latter? 2) and in compareAndSwapLong_builtin(), thre is a wonky bit: /* We don't trust flag_use_atomic_builtins for multi-word compareAndSwap. Some machines such as ARM have atomic libfuncs but not the multi-word versions. */ if (can_compare_and_swap_p (mode, (flag_use_atomic_builtins && GET_MODE_SIZE (mode) <= UNITS_PER_WORD))) <..> /* generate 8 byte CAS */ I gather we dont need to do anything special here anymore either? As an observation of inconsistency, compareAndSwapObject_builtin doesn't do that check before calling the 8 byte CAS : machine_mode mode = TYPE_MODE (ptr_type_node); if (can_compare_and_swap_p (mode, flag_use_atomic_builtins)) { tree addr, stmt; enum built_in_function builtin; UNMARSHAL5 (orig_call); builtin = (POINTER_SIZE == 32 ? BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4 : BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8); addr = build_addr_sum (value_type, obj_arg, offset_arg); 3) And finally, is flag_use_atomic_builtins suppose to turn them off completely? Right now it is passed in to the second parameter of can_compare_and_swap_p, which really just says can we compare and swap without calling a libfunc.. so currently if the flag is 0, but there is native support, the call is generated anyway. should that condition really be: if (flag_use_atomic_builtins) { <...> /* generate atomic call */ } Thanks Andrew.