RFR: 8301244: Replace legacy pragma implementations in HotSpot's compilerWarnings.hpp [v7]
Julian Waters
jwaters at openjdk.org
Mon Jan 30 03:26:16 UTC 2023
On Sun, 29 Jan 2023 06:38:19 GMT, Julian Waters <jwaters at openjdk.org> wrote:
>> HotSpot has a few legacy implementations of pragmas in some of its macros in compilerWarnings.hpp, they should be cleaned up and use a more modern approach. Rename PRAGMA macro in compilerWarnings_gcc.hpp as well since it can be used for more than just compiler warnings
>
> Julian Waters has updated the pull request incrementally with one additional commit since the last revision:
>
> compilerWarnings_gcc.hpp
I've looked through the macros again and I disagree that it would force the Visual C++ compiler to always stringize pragmas, the new `PRAGMA` macro isn't meant to replace the typical #pragma declarations, but rather as a quick and platform independent utility to embed pragmas inside other macros, with otherwise identical behaviour as the direct usage of the #pragma directive. Prior to this gcc had the same declaration but only for expanding the disabled warnings macro in compilerWarnings_gcc.hpp, which, at least to me, seems too limited of a usage scope when it can be useful in more situations than just as a warning support macro. Adding to this, avoidance of the Visual C++ extension isn't a goal, but merely a side effect since it would just be unnecessarily messy and add clutter to differentiate the implementations in macros.hpp when one that fits all platforms can be easily attained.
Additionally, the extra work this requires from Visual C++ is minimal enough that this should not be much of an issue when it comes to build performance (embedded pragmas aren't really used carelessly in HotSpot either, alleviating the issue even more). Expansion of the macro by Visual C++ is actually a bug to my knowledge, which has since been fixed quite some time ago. Other than that, _Pragma is actually pretty much identical to __pragma in Visual C++, so the expected behaviour wouldn't change with this patch. (Also, this helps [JDK-8288293](https://bugs.openjdk.org/browse/JDK-8288293), which aims to allow plugging different compilers, where the compiler for Windows may not necessarily be Visual C++)
I admit that I could have worded the change title much better than I did though :P
-------------
PR: https://git.openjdk.org/jdk/pull/12255
More information about the hotspot-dev
mailing list