Improve documentation for debug-only code.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Reduce number of exported symbols (e.g. _static_closure)

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement neededBlocks

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
[START] Implement core infrastructure for resource limits.

This is a basic implementation of the core infrastructure for resource
limits, although it doesn't do anything, as there are no primops for
actually changing your resource container.

TOFIX: GHCi doesn't work.

TOFIX: Compiled-code changes should be optional (either a new way or
configure time option), as they increase code size a bit.

TOFIX: Compaction is not supported.

TOFIX: Some of the RTS function names are not very good.

WONTFIX: 32-bit does not have enough space to support the resource
container pointer in the block descriptor.  So this compilation mode
is not compatible with 32-bit.

Patch notes:

    * Two new registers: RC and OldRC.

    * The key invariants is that the resource container of
      CurrentNursery must be the same as the current resource
      container as recorded in the register RC.

    * Compiled-code changes in two places.  First,
      during thunk entry, we need to do an extra conditional on the RC
      to determine if we need to change containers (doing this fast
      relies on all closures, in particular static closures, having a
      valid block descriptor).  Second, the current RC must be saved and
      restored along with the rest of thread state: thus update frames
      are augmented to record the RC.  We also introduce a new update
      frame for just restoring an RC.  (Exception handling code applies
      these frames).

    * The modified entry code now looks like this:

        W_ rc = Bdescr(node)->rc;
        if (rc != RC) {
            RC = rc; // CurrentNursery/RC invariant violated
            goto gc;
        }

      The slowpath in rts/HeapStackCheck.cmm is responsible for noticing
      that the Current/RC invariant is incorrect, and adjusting
      CurrentNursery so that the invariant is restored, as well as
      pushing a frame stg_restore_container to restore the previous RC.

    * New C-- macros: RC_NURSERY to calculate the resource container of
      the nursery, and RC_CURRENT_NURSERY for the currentNursery

    * GC thread workspaces and nurseries are now reorganized to live in
      the resource container (NB: we change this later in the patchset).
      We do this by appending a variable size array at the end of
      resource containers, which contains a rcthread struct per thread.
      The garbage collector indirects through this, which results in a
      few more dereferences in the evacuate() fast-path.  Work stealing
      is turned off (NB: this is fixed later)

    * New RTS functions alloc*For which allocate into a resource
      container, and allocateFor and cmmMaybeAllocate for respecting
      resource limits when allocating into the current nursery.

    * The most important situation, the heap overflow handler, is
      modified to respect resource limits.

    * New threads inherit the RC of their parent.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement dead container garbage collection [INCOMPLETE]

LEAKS MEMORY! need to stgFree the ResourceContainer struct,
but then we need to invalidate existing RC# pointers.  A little
tricky, so don't bother for now.

Tightens up some invariants, yay!

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement centralized work queue for GC, with a shitty heuristic for finding new work

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement scan stack to find new work in RCs.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Implement support for PINNED objects.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Implement primops and source-language support.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Implement listeners.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement RCRef.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Convert primops to respect resource limits (using cmmMaybeAllocate).

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Convert nursery allocation to respect resource limits.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Convert stack overflow to respect resource limits.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Convert stack freezing to respect resource limits. [INCOMPLETE]

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Optimize nurseries of dead containers by truncating them.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Optimize clearNursery by shortcutting when first empty is found.

This can be backported to vanilla GHC, but the patch looks different.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
[FIXUP] N_CLOSURE_TYPES

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Disable stats department.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Always turn on debug symbols.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>