Initial draft of a tracing API.

This is used in conjunction with a collection & analysis server
to analyze memory usage and other aspects of a program running
under emscripten.
Fair enough, I think it's prettier to put the ifdef here so it's clear that we don't trace without it, but better to put the ifdef in just one place.