diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2020-05-25 11:59:11 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-11 03:20:35 -0500 |
commit | c34a4b98b1f09ea3096d39a839a86f2d7185c796 (patch) | |
tree | bf3700fd70504a5676220df8702b41810e880846 /rts/LinkerInternals.h | |
parent | 584058ddff71460023712a8d816b83b581e6e78f (diff) | |
download | haskell-c34a4b98b1f09ea3096d39a839a86f2d7185c796.tar.gz |
Fix and enable object unloading in GHCi
Fixes #16525 by tracking dependencies between object file symbols and
marking symbol liveness during garbage collection
See Note [Object unloading] in CheckUnload.c for details.
Diffstat (limited to 'rts/LinkerInternals.h')
-rw-r--r-- | rts/LinkerInternals.h | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h index e8923fb7eb..6b726f7a27 100644 --- a/rts/LinkerInternals.h +++ b/rts/LinkerInternals.h @@ -190,9 +190,6 @@ typedef struct _ObjectCode { /* non-zero if the object file was mmap'd, otherwise malloc'd */ int imageMapped; - /* flag used when deciding whether to unload an object file */ - int referenced; - /* record by how much image has been deliberately misaligned after allocation, so that we can use realloc */ int misalignment; @@ -204,8 +201,37 @@ typedef struct _ObjectCode { int n_segments; Segment *segments; - /* Allow a chain of these things */ - struct _ObjectCode * next; + // + // Garbage collection fields + // + + // Next object in `objects` list + struct _ObjectCode *next; + + // Previous object in `objects` list + struct _ObjectCode *prev; + + // Next object in `loaded_objects` list + struct _ObjectCode *next_loaded_object; + + // Mark bit + uint8_t mark; + + // Set of dependencies (ObjectCode*) of the object file. Traverse + // dependencies using `iterHashTable`. + // + // New entries are added as we resolve symbols in an object file, in + // `lookupDependentSymbol`. When an object file uses multiple symbols from + // another object file we add the dependent multiple times, so we use a + // `HashTable` here rather than a list/array to avoid copies. + // + // Used when unloading object files. See Note [Object unloading] in + // CheckUnload.c. + HashSet *dependencies; + + // + // End of garbage collection fields + // /* SANITY CHECK ONLY: a list of the only memory regions which may safely be prodded during relocation. Any attempt to prod @@ -249,12 +275,8 @@ typedef struct _ObjectCode { (OC)->fileName \ ) -extern ObjectCode *objects; -extern ObjectCode *unloaded_objects; - #if defined(THREADED_RTS) extern Mutex linker_mutex; -extern Mutex linker_unloaded_mutex; #endif /* Type of the initializer */ @@ -305,8 +327,9 @@ int ghciInsertSymbolTable( HsBool weak, ObjectCode *owner); -/* lock-free version of lookupSymbol */ -SymbolAddr* lookupSymbol_ (SymbolName* lbl); +/* Lock-free version of lookupSymbol. When 'dependent' is not NULL, adds it as a + * dependent to the owner of the symbol. */ +SymbolAddr* lookupDependentSymbol (SymbolName* lbl, ObjectCode *dependent); extern StrHashTable *symhash; |