Change GC triggering to use mallinfo()

Revise the test of whether we should collect based on native allocation
to be based on mallinfo.

Make the GC triggering threshold for native allocations grow somewhat
with the Java heap size to account for the added cost of Java
collection. We currently compromise between that goal and a
desire to avoid drastic changes that might provoke new heap
growth issues. It does now take more native allocations to
trigger a GC earlier in the normal Java GC cycle than later in the
cycle, as it should.

Add the notifyNativeAllocations() interface to replace
registerNativeAllocation() in the common case in which native memory
is completely allocated via malloc(), and thus no longer needs to be
accounted for separately. Arrange for it to be called much more
rarely, since its cost is higher, and we can save time by not going
through JNI on every allocation.

Add 175-alloc-bignums test.


Fix race in IsOutOfMemoryOnAllocation.

Rename max_allowed_footprint_ to avoid suggesting it's a hard limit.
It wasn't and it isn't. Make it atomic, since it's concurrently

Fix a few cases in which unsigned counters could become negative.
I think the only bad consequences of this were weird log messages.

Fix integer sizes/signedness around GrowForUtilization.
Use uint64_t only when we can exceed address space size, and
size_t otherwise. Improve overflow checking.

Make allocator or collector tests check the important kinds first, since
they're not always known at compile time.

Bug: 111447610

Test: Built and booted AOSP. Ran 175-alloc-big-bignums.

Change-Id: I55deac86622019fb85bbd569c3ae8afab2d13d9a
7 files changed