[Chapel Merge] Map: Fix deadlock in parSafe *toArray()

Branch: refs/heads/master
Revision: 75f0621
Author: daviditen
Log Message:

Merge pull request #16350 from cassella/map-lock-deadlock

Map: Fix deadlock in parSafe *toArray()

[PR by @cassella, reviewed/merged by @daviditen]

Introduce proc _size to get the size when the parSafe lock is already
held. Call it from toArray(), keysToArray(), valuesToArray() instead
of size.

Update testToArray.chpl to test a parSafe map as well.

closes #16349

Modified Files:
A test/library/standard/Map/testToArray.compopts
M modules/standard/Map.chpl
M test/library/standard/Map/testToArray.chpl

Compare: https://github.com/chapel-lang/chapel/compare/8db0d57c1325...75f0621217db