[JDK-8247755](https://bugs.openjdk.org/browse/JDK-8247755) introduced the 
`GrowableArrayCHeap`. This duplicates the current C-Heap allocation capability 
in `GrowableArray`. I now remove that from `GrowableArray` and move all usages 
to `GrowableArrayCHeap`.

This has a few advantages:
- Clear separation between arena (and resource area) allocating array and 
C-heap allocating array.
- We can prevent assigning / copying between arrays of different allocation 
strategies already at compile time, and not only with asserts at runtime.
- We should not have multiple implementations of the same thing (C-Heap backed 
array).
- `GrowableArrayCHeap` is NONCOPYABLE. This is a nice restriction, we now know 
that C-Heap backed arrays do not get copied unknowingly.

**Bonus**
We can now restrict `GrowableArray` element type `E` to be 
`std::is_trivially_destructible<E>::value == true`. The idea is that arena / 
resource allocated arrays get abandoned, often without being even cleared. 
Hence, the elements in the array are never destructed. But if we only use 
elements that are trivially destructible, then it makes no difference if the 
destructors are ever called, or the elements simply abandoned.

For `GrowableArrayCHeap`, we expect that the user eventually calls the 
destructor for the array, which in turn calls the destructors of the remaining 
elements. Hence, it is up to the user to ensure the cleanup. And so we can 
allow non-trivial destructors.

**Testing**
Tier1-3 + stress testing: pending

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

Commit messages:
 - fix comment about trivial elements
 - check for trivial destructors
 - improve comment
 - add an explicit to constructor
 - improve comments
 - remove cheap internals from GrowableArray and fix verification
 - remove constructors for GrowableArray with Cheap backing
 - 8322476

Changes: https://git.openjdk.org/jdk/pull/17160/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17160&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322476
  Stats: 774 lines in 127 files changed: 108 ins; 204 del; 462 mod
  Patch: https://git.openjdk.org/jdk/pull/17160.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17160/head:pull/17160

PR: https://git.openjdk.org/jdk/pull/17160

Reply via email to