Fix a prof_tctx_t destruction race.
Refactor/fix arenas manipulation.

Abstract arenas access to use arena_get() (or a0get() where appropriate)
rather than directly reading e.g. arenas[ind].  Prior to the addition of
the arenas.extend mallctl, the worst possible outcome of directly
accessing arenas was a stale read, but arenas.extend may allocate and
assign a new array to arenas.

Add a tsd-based arenas_cache, which amortizes arenas reads.  This
introduces some subtle bootstrapping issues, with tsd_boot() now being
split into tsd_boot[01]() to support tsd wrapper allocation
bootstrapping, as well as an arenas_cache_bypass tsd variable which
dynamically terminates allocation of arenas_cache itself.

Promote a0malloc(), a0calloc(), and a0free() to be generally useful for
internal allocation, and use them in several places (more may be
appropriate).

Abstract arena->nthreads management and fix a missing decrement during
thread destruction (recent tsd refactoring left arenas_cleanup()
unused).

Change arena_choose() to propagate OOM, and handle OOM in all callers.
This is important for providing consistent allocation behavior when the
MALLOCX_ARENA() flag is being used.  Prior to this fix, it was possible
for an OOM to result in allocation silently allocating from a different
arena than the one specified.
Use regular arena allocation for huge tree nodes.

This avoids grabbing the base mutex, as a step towards fine-grained
locking for huge allocations. The thread cache also provides a tiny
(~3%) improvement for serial huge allocations.
fine-grained locking for huge allocs via hashing

A tiny hash table is used to spread out the huge allocations across more
than one tree. Each tree is associated with a mutex, rather than having
a global huge allocation lock. The default chunk allocator is serial, so
there is currently very little benefit for the main code paths.

Contrived synthetic benchmark to confirm that it works:

    #include <malloc.h>
    #include <pthread.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sys/sysinfo.h>

    static void *do_work(void *data) {
        void *huge = malloc(8 * 1024 * 1024);
        for (size_t i = 0; i < 1000000; i++) {
            if (malloc_usable_size(huge) != 8 * 1024 * 1024)
                exit(1);
        }
        return data;
    }

    int main(void) {
        int nprocs = get_nprocs();
        pthread_t *threads = malloc(sizeof(pthread_t) * nprocs);
        for (int i = 0; i < nprocs; i++) {
            if (pthread_create(&threads[i], NULL, do_work, NULL))
                return 1;
        }
        for (int i = 0; i < nprocs; i++) {
            if (pthread_join(threads[i], NULL))
                return 1;
        }
    }

On a dual-core Ivy Bridge CPU (4 threads):

Before:

       3283.101936      task-clock (msec)         #    3.556 CPUs utilized
            52,988      context-switches          #    0.016 M/sec

After:

        224.079144      task-clock (msec)         #    3.658 CPUs utilized
                31      context-switches          #    0.138 K/sec

Closes #141