IDL compiler: Add pre-caching to compiler

This CL adds a pre-caching function to code_generator_v8.py:
if you execute the file itself, it pre-caches templates.
This is needed for a fast Python build.

Bytecode caching provides a *huge* speedup to the IDL compiler, due to
reducing Jinja setup time significantly.

Unfortunately, it's not concurrency-safe: if we run lots of compiler
processes, there's a race condition and later processes try to read a
partially-written cache and die.

This is fixed by pre-caching the templates; when we switch to Python,
I'll do this by adding one step in the build.

This CL just adds the functionality to Python, to make the switch
only require GYP changes.

The contents are quite simple, but require being careful
to normalize paths to be concurrency-safe;
also some minor refactoring for reuse.

BUG=341748
BUG=239771
R=haraken
NOTRY=true

Review URL: https://codereview.chromium.org/173193004

git-svn-id: svn://svn.chromium.org/blink/trunk@167498 bbb929c8-8fbe-4397-9dbb-9b2b20218538