[XXX] FIXUP

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

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Add cmmNotWord.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Add BLOCK constants to DeriveConstants.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Add iterateHashTable function.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Teach code generator about Nursery register.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Teach code generator about CurrentAlloc register.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
[HACK] Disable compaction for now.

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

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.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.

TOFIX: Container killing leaks memory.

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 have been split into global and per-resource
      container parts. 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.  Full blocks
      still live in the global queue. Global data is indicated as 'gws'.

    * Because we have a lot of todo blocks, we implement a scan stack,
      where we push containers onto when we write into their todo block.
      This optimization helps a lot.

    * Some GC functions are modified to accept a ResourceContainer as
      an argument.  This is because benchmarking indicated that it is
      far better to avoid retraversing the resource containers list. So
      we try to do as much processing as possible when we walk the list.

    * 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 heap overflow handler and nursery allocation are
      modified to respect resource limits.

    * New threads inherit the RC of their parent.

    * The dead container garbage collection leaks memory. We need to
      stgFree the ResourceContainer struct.

    * When a container is dead, we truncate its nursery to reduce its
      memory usage while the container isn't garbage collected.
      However, we have to keep one block because of assumptions that
      other code makes.

    * clearNursery is optimized in a generic way, see #9067

Signed-off-by: Edward Z. Yang <ezyang@mit.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>
[XXX] Disable listeners

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.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 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>
[XXX] Fix segfault with profiling due to HEAP_ALLOCED

This fix is not right, because it says any STATIC closure automatically
passes the test.  Probably the test itself must be amended to not assume
that the closure is not STATIC.

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