Bug 937751, part 1 - Add and set incremental cycle collection phases. r=smaug
Bug 937751, part 2 - Move SliceBudget into js/public. r=billm
Bug 937751, part 3 - Protect against reentrancy with when incrementally CCing. r=smaug

Cycle collection protects against reentrancy by setting a flag to indicate a collection
is in progress. With synchronous CC, it is okay to set this in BeginCollection, and
clear it in CleanupAfterCollection. With ICC, this must be set and cleared in every
slice, so I moved the fixing of it to Collect.  I also changed the name of the variable,
because we can be in the middle of an ICC without the CC being actively running,
and it is only the latter we are worried about here.
Bug 937751, part 4 - Incrementalize nsCycleCollector::Collect. r=smaug

This patch makes it so that Collect takes a time budget that describes
how much longer the collection can be run for. Then we run the current phase.
Once this is done, we check whether we have exceeded our time budget or
if we have finished a collection. If neither of those have happened, we
run the cycle collector some more.

If we're a manually triggered CC, and we were in the middle of an ICC when
the CC started, then once the current CC is complete, we start a new CC
immediately. This is needed to ensure that a manually specified listener
is used, and to ensure that any garbage objects the caller expects to be
collected are in fact collected.

Note that in this patch we are always passing in an unlimited budget to
Collect, so cycle collections will always be run to completion.
Bug 937751, part 5 - Add optional phase logging. r=smaug

For debugging purposes, it can be useful to see what ICC is currently
being run.
Bug 937751, part 6 - Allocate the current MarkRoots node on the heap rather than the stack. r=smaug

To make nsCycleCollector::MarkRoots incremental, we have to store all of its state on
the heap, so we can resume it.  The only remaining state to convert is the NodePool
enumerator.
Bug 937751, part 7 - Incrementalize nsCycleCollector::MarkRoots. r=smaug

Now that all of MarkRoots's state is stored on the heap, it can be run
incrementally. Like with Collect, it takes a budget to determine how
long it can run. Any residual budget will be available to the caller.

One difference is that Collect calls checkOverBudget() which always checks
the time, but MarkRoots uses isOverBudget() to determine if there is
any time remaining. This only checks the current time every
kNumNodesBetweenTimeChecks nodes, to reduce the overhead of checking.