Implement memory ranges

Implement the algorithm in the documentation. Adjust the test results
to reflect the new algorithm.

Allow native memory to have an upper bound. Even though this isn't
particularly useful, there is no need to prohibit it.

Improve stack size handling. If a range of stack sizes is specified
and the floor of the range is non-zero, use the floor as the default
stack size. Otherwise, use the JVM default stack size of 1m. Also,
round the number of tasks and ensure it is at least one to behave
better in edge cases.

[#58060090]