RFR 8014911 - Use SUPPORTS_NATIVE_CX8 to help C++ compiler elide code

BILL PITTORE bill.pittore at oracle.com
Thu Sep 19 07:12:32 PDT 2013


On 9/18/2013 10:09 PM, Christian Thalinger wrote:
> I'd rather have the #ifdef in the body of the method.  Besides that it looks good.
I was trying to keep the single line function layout the same but I do 
see your point. I changed it to:

-  static bool supports_cx8()  {return _supports_cx8;}
+  static bool supports_cx8()  {
+#ifdef SUPPORTS_NATIVE_CX8
+    return true;
+#else
+    return _supports_cx8;
+#endif
+  }

bill
>
> On Sep 18, 2013, at 9:39 AM, BILL PITTORE <bill.pittore at oracle.com> wrote:
>
>> Would like a review for this simple fix that leverages the macro 'SUPPORTS_NATIVE_CX8' that was added in hotspot revision:
>> changeset:   4611:6b388e7d4905
>> parent:      4547:e01e02a9fcb6
>> user:        bpittore
>> date:        Tue May 07 10:19:33 2013 -0400
>> summary:     8013633: Cleanup platform ifdefs in unsafe.cpp
>>
>> SUPPORTS_NATIVE_CX8 is defined in globalDefinitions_<arch>.hpp based on whether the platform supports 64bit cmpxchg natively. This change uses the define to force the supports_cx8() function to return hard-coded 'true' value. GCC and other compilers will then optimize code that uses supports_cx8() function call by removing the actual reference to _supports_cx8 variable as well as eliminating code for the !supports_cx8() case.
>> Webrev is here: http://cr.openjdk.java.net/~bpittore/8014911/webrev.00/
>>
>> thanks,
>> bill
>>



More information about the hotspot-runtime-dev mailing list