src: only start idle notifier when profiling

The previous commit adds a notifier that tells the V8 profiler when
node.js is idle, i.e. when it's about to start sleeping in the
platform's equivalent of epoll_wait().

This commit adds a heuristic that only starts the notifier when the
V8 profiler is started from the command line.
src: add JS start/stop methods for idle notifier

The previous commit changes the profiler idle notifier so that it only
gets started when a --prof or --prof_lazy argument is specified on the
command line.

This commit adds two internal methods to the process object that allows
one to start and stop the idle notifier programmatically.
src: fix up after botched merge conflict

Mea culpa, I didn't properly resolve a merge conflict in the last two
commits.  The resulting segmentation fault only happened on Linux and
only sometimes.

Fixes #6306.
node: don't share state with in_tick/last_threw

There was no need to share state between C++ and JS for these two
values. So they have been moved to their respective locations. This will
help performance only a tiny bit, but it does help code complexity much
more.
node: add AsyncListener support

The AsyncWrap class has been added as a base class for everything that
will be performing an asynchronous request. This is meant to be a
simpler way to track when requests have gone out, and to allow users
hooks to know when this happens.

Currently only ReqWrap and HandleWrap are covered. Full support will be
added in the future for all the *Wrap classes.

This comes with a new API:

* process.createAsyncListener(listener, callbacks, domain): This will
  create an AsyncListener instance that can be added and removed when
  necessary. The "domain" passed will propagate to each callback unless
  the listener at some point returns a new object.
  Returns the new AsyncListener instance.

* process.addAsyncListener(listener, callbacks, domain): Will create a
  new AsyncListener instance and immediately add it to the listening
  queue.
  Returns the new AsyncListener instance.

* process.removeAsyncListener(instance): Remove an AsycListener instance
  from the current queue and stack.
  Returns undefined.

Explanations for each callback:

* listener(): Callback that's called immediately when a *Wrap, Timer or
  nextTick is queued.

* callbacks.before(context, domain): Run immediately before the async
  callback is about to run. "context" is the "this" of the caller,
  except in the case of nextTick. Where the callback object is passed
  instead. "domain" is the object passed to createAsyncListener() or
  returned from listener().

* callbacks.after(context, domain): Same as before(), except run
  immediately after the callback has run. Except if the callback has
  thrown, in which case this will not be called.

* callbacks.error(domain, error): Called when a callback has thrown.
  Currently the "context" is lost in this case so it's not passed, but
  the "domain" object still is. If the error is properly handled the
  return true to continue program execution. If multiple error handlers
  are queued all will be called, and if any one returns true then the
  error is assumed to have been handled.

In the case of callbacks, they are only allowed to throw two levels
deep. Afterwards the error handler will always return false. This is to
prevent infinite recursive throws.

As you'll see, the domain module still exists. Full support has been
added in it's previous form until a complete solution is patched. The
goal is to have the domain module use AsyncListeners and be as far
removed from core as possible. When that day comes, I'll fully enjoy
torching every last line of integrated code until it's all burnt
stubble.
async-wrap: remove CallAsyncListeners

During initial development there was a need for this method, but since
the need was removed. Though I'm not going to squash this for now just
in case the need arises again in the future.
domain: WIP do some cleanup

Domain#bind() shoved in too much. This helps break things out so I'll be
able to see what's going on.

The re-write of domains won't happen for a while, but this is a start.
It'll be rebased with other similar work.
async-wrap: integrate with WeakObject

Making WeakObject inherit from AsyncWrap allows us to peak into almost
all the MakeCallback calls in Node internals.
cares: add AsyncListener support
timer: allow asyncListener to run for each timer

Inline comment explains why.
crypto: make RandomBytesRequest a class

Since RandomBytesRequest make a call to MakeCallback, I needed it to be
a class so AsyncWrap could handle any async listeners.
REVIEW: fixes for first round of review notes
crypto: convert pbkdf2_req to a class

pbkdf2_req has been renamed to PBKDF2Request and converted to a class.
It now uses AsyncWrap::MakeCallback.

Also includes, using env()->ondone_string() instead of "ondone" and
using malloc instead of new char[].
src: fix MakeCallback implementations

Both node::MakeCallback() and AsyncWrap::MakeCallback should be passing
the process object as the context to {load,unload}AsyncQueue.

Also, the context of the caller should be passed as the first argument
to {load,unload}AsyncQueue. To accomplish this in node::MakeCallback the
"const" was removed.
async_wrap: fix bug that didn't allow after to run

Callbacks assigned to "after" didn't run because they weren't being
accessed properly from the asyncQueue object.
async_wrap: pass callback return value to after

New after callback parameters are as follows:

function after(context, domain, returnValue);
node: fix using magic number

To stay consistent with using variable values as assigned in src/env.h a
small addition has been made for sake of process.nextTick().
src: cleanup scoped variables

SQUASH Didn't like the way I was scoping the variables.
async-wrap: add attachAsyncListener for prototype

We need the ability to attach an asyncListener to an existing handle if
domains are going to be properly emulated. So now applicable methods
that need to attach their asyncListener after they've been created can
do so directly from the handle.

Also fixed that loadAsyncQueue should have been run using the
process_object() for context so error messages doing appear like
Pipe.runAsyncQueue().
async_wrap: added method to few prototypes

Added to PipeWrap, TCPWrap and UDPWrap.

Currently this will just attach the additional method
attachAsyncListener to the prototype. This will allow an async listener
to be added after it's been created.

This method will be added to additional class initializations as are
needed.