[Chapel Merge] Use domain's array set only for resizing

Branch: refs/heads/master
Revision: b8e3e76
Author: e-kayrakli
Log Message:

Merge pull request #16523 from e-kayrakli/domain-init-deinit-counter

Use domain’s array set only for resizing

This PR changes how we track the references to a domain.

On master, the number of references to the domain is basically the sum of
the size of its hash table and _arrs_containing_dom. This PR changes the logic
there to always increment/decrement the latter and to avoid using the former for
freeing domains. Hashtable is only used while resizing a domain and when we need
to resize arrays defined using that domain.

This way, the constant domain optimization is more robust: if a domain’s constness
changes over the course of its life (via being moved to a different domain) it doesn’t
impact its deallocation.

[Reviewed by @mppf]

Test:

  • [x] valgrind examples
  • [x] memleaks examples
  • [x] gasnet+asan examples
  • [x] standard
  • [x] gasnet

Modified Files:
M modules/internal/ChapelDistribution.chpl

Compare: https://github.com/chapel-lang/chapel/compare/c8125bc65b28...b8e3e767ced5