... | ... | @@ -93,12 +93,12 @@ lookupStaticPtr :: StaticName -> Maybe DynStaticPtr |
|
|
where `__static_f` is a fresh name.
|
|
|
|
|
|
- In the type checker, we add `Typeable a` to the set of constraints.
|
|
|
- All such `__static_*` definitions are considered SPT entries. All SPT entries are collected into the SPT for each module, constructed by the code produced by `mkModuleInit`.
|
|
|
- A global SPT constructed using the SPT from each module by the RTS just before `main` is invoked.
|
|
|
- The RTS creates a `StablePtr` to the global SPT (and transitively any of its dependencies), to avoid it being garbage collected.
|
|
|
- The SPT is a hash table mapping `Fingerprint`s to `StaticPtr`s.
|
|
|
- All such `__static_*` definitions are considered SPT entries. Before `main` is invoked, modules are initialized by inserting all their SPT entries into a global SPT which lives in the RTS. This initialization is implemented via [ constructor functions](https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html) in the same way that module initialization is implemented for [ HPC](https://ghc.haskell.org/trac/ghc/wiki/Commentary/Hpc) (Coverage.hpcInitCode).
|
|
|
- A `StablePtr` for each entry is created to avoid it being garbage collected (can we register the SPT as a source of roots with a single call?).
|
|
|
- The SPT is a hash table mapping `Fingerprint`s to the closures of the SPT entries.
|
|
|
|
|
|
**Remark:** do we need `__static_f` at all? It looks like we could get `mkModuleInit` to generate the right code with all the entries, without the extra indirection.
|
|
|
**Remark:** do we need `__static_f` at all? It looks like we could generate the right code with all the entries, without the extra indirection.
|
|
|
**Tentative answer:** at module initialization time, we need pointers to the SPT entries that we can insert into the SPT. Making SPT entries top-level definitions is a convenient mechanism to get such pointers. To avoid producing top-level definitions, we would need an alternative mechanism.
|
|
|
|
|
|
### Appendix: notes about distributed-process
|
|
|
|
... | ... | |