Bug 1039965 (attempt 2) - Avoid slop in JS arrays. r=bhackett,terrence.

This patch changes JS array resizing to prefer power-of-two sized slot
requests. Previously it would mostly make slightly-more-than-power-of-two sized
requests that cause lots of slop.

Also, shrinkElements() now only does a reallocation if it would result in going
down a size class. E.g. if you pop all the elements from a 1000-element array,
it would realloc 999, then 998, then 997, all the way down the minimum size.
Now it does 512, then 256, down to the minimum size (which is 8).

I confirmed with DMD that the element allocations now have zero slop. This
reduces peak RSS loading a couple of large PDF files (four times each) with
pdf.js by 10s of MiBs.

--HG--
extra : rebase_source : c10fd4efd8ab80df5bbe14815009edb8eed3f23f