jemalloc/jemalloc — pull request #172 by guilherme-pg (2014-12-08 22:21:43+00:00)
Title: Split opt.junk into opt.junk_alloc and opt.junk_free.

Currently with mozjemalloc, Gecko will only junk allocated memory on debug builds, but will junk deallocated memory on both optimized and debug builds. It looks like jemalloc3 is incapable of doing that, since `opt.junk` controls both allocation and deallocation at the same time. These patches split `opt.junk` into `opt.junk_alloc` and `opt.junk_free`, thus making it possible to implement the behavior we currently have with mozjemalloc. The associated Gecko bug for this is [bug 1108045](https://bugzil.la/1108045).

A couple of notes on the pull request:
- I kept `opt.junk` to maintain compatibility. Enabling `opt.junk` will imply both `opt.junk_alloc` and `opt.junk_free`;
- I wasn't completely sure how to test these changes, since `opt.junk*` are all read-only options that could potentially share most of the test logic. I ended up creating separate files to test each new option, and had both include junk.c but changing `malloc_conf` accordingly, and skipped irrelevant tests in junk.c when either option wasn't enabled. This way we also get to keep the tests for `opt.junk`. I split these changes into a separate commit for ease of reviewing, let me know if this could be better.