Properly generate info tables for static closures in C--.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Rename _closure to _static_closure, apply naming consistently.

In preparation for indirecting all references to closures,
we rename _closure to _static_closure to ensure any old code
will get an undefined symbol error.  In order to reference
a closure foobar_closure (which is now undefined), you should instead
use STATIC_CLOSURE(foobar).  For convenience, a number of these
old identifiers are macro'd.

Across C-- and C (Windows and otherwise), there were differing
conventions on whether or not foobar_closure or &foobar_closure
was the address of the closure.  Now, all foobar_closure references
are addresses, and no & is necessary.

CHARLIKE/INTLIKE were not changed, simply alpha-renamed.

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

Closure indirections live in the staticclosureinds section
and initially point to their corresponding closure in
the staticclosures.  The intent is that all code goes through
a closure indirection, and at runtime the indirections can
change.

These pieces of code have to go through closure indirections:

    - Code references to a static closure
    - SRTs
    - Heap check (but we want to fix this)
    - References to closures in RTS (see STATIC_CLOSURE) macro
    - Runtime symbol lookup (e.g. GHCi, dynwrapper)
    - The main closure passed to hs_main

Closure indirections should simplify these components (but that
is not implemented yet):

    - Windows DLL handling (which already needed an indirection)

In order to keep the code running, the fields of static closures
are not indirected (although they should be); this will be switched
over in a later commit.

Important invariant: an indirection may only be dereferenced
after the runtime is setup.  In particular, references to
closures in __attribute__(constructor) need to be kept indirections;
this is what the stable pointer deferral is for.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Implement runtime setup code for static closures.

Fields of static closures are now indirected, and we have a simple
runtime initialization code initStaticClosures() which merely rewrites
all of the indirections into untagged pointers and untangles references
between the static closures.  This also copies static closures into
blocks, although this data is unused.

The runtime system finds out about indirections by way of
__attribute__(constructor) methods; thus C-- compilation may now
generate foreign stubs (if it defines closures).

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Indirect SRTs and heap checks.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
CHARLIKE/INTLIKE must use indirections.

While these are "closures", they aren't allocated the usual
way, so we just special case them in closure initialization.

It is very important that these arrays fit in a single block,
since a pointer to a closure across the boundary needs to have
the appropriate BF_STATIC flag set.

Nota bene: C will implicitly dereference the _ind reference,
but C-- will not; thus the extra load in C-- land.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Closure tables must use indirections.

ToDo: This could be improved by short-circuiting the indirections in the
closure table.  However, we have to arrange for the RTS to know about
all of our closure tables, which is a bit annoying to do.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Replace HEAP_ALLOCED with block descriptor check.

Blocks have a new flag BF_STATIC, which indicates if the data
contained therein is static.  This means we can get rid of
all of the complicated nonsense in MBlock.h.

ToDo: There are two functions based on traversing all megablocks
which need to be reimplemented, probably by bringing back part of
the MBlock.h implementation we axed.

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