RFR: 8282469: Allow considered use of C++ thread_local in Hotspot

John R Rose jrose at openjdk.java.net
Mon Mar 7 19:18:10 UTC 2022


On Mon, 7 Mar 2022 06:12:03 GMT, David Holmes <dholmes at openjdk.org> wrote:

> This patch provides a means for using C++ `thread_local` when it is essential - see JBS for more details.
> 
> There are three parts:
> 
> 1. Add the new #define for `thread_local`
> 2. Remove `operator_new.cpp` as use of C++ `thread_local` with a non-trival cleanup actions requires use of global operators new/delete. These are still excluded for hotspot use via a link-time check.
> 3. Remove the prohibition on using `thread_local` from the hotspot style guide
> 
> Due to the way hotspot style guide changes must be done, part 3 is being done under a sub-task in PR https://github.com/openjdk/jdk/pull/7720 and the two PR's will integrate at the same time.
> 
> Testing:
>   - manual testing of the Panama usecase as referenced in the JBS issue
>   - Tiers 1-3
> 
> Thanks,
> David

src/hotspot/share/memory/operator_new.cpp line 37:

> 35: // a memory leak.  Use CHeapObj as the base class of such objects to make it explicit
> 36: // that they're allocated on the C heap.
> 37: // Commented out in product version to avoid conflicts with third-party C++ native code.

There's a little bit of policy information here that is being deleted.  It overlaps with the section `### Memory Allocation` in `hotspot-style.md`, but includes this information which might not be stated elsewhere:

> Typically, uses of the C++ global operator new are inadvertent and therefore often associated with memory leaks.

(This is my rephrasing, perhaps appropriate to the style guide.)

Or is a point like this made in the config file which prevents direct linkage?  (I don't know where that file is.)

-------------

PR: https://git.openjdk.java.net/jdk/pull/7719


More information about the hotspot-dev mailing list