diff options
author | Colin Snover | 2016-07-20 10:40:02 -0500 |
---|---|---|
committer | Colin Snover | 2016-08-01 10:37:14 -0500 |
commit | 4a637d65c36d7dad3a4d4ec75c243e12bb3b5449 (patch) | |
tree | 6432032555fae63886c62cbf578321435e48a4e2 /engines/sci/engine/gc.cpp | |
parent | 3645ec0d0d9b88bd0a18e52d83060a8115030a65 (diff) | |
download | scummvm-rg350-4a637d65c36d7dad3a4d4ec75c243e12bb3b5449.tar.gz scummvm-rg350-4a637d65c36d7dad3a4d4ec75c243e12bb3b5449.tar.bz2 scummvm-rg350-4a637d65c36d7dad3a4d4ec75c243e12bb3b5449.zip |
SCI32: Enable optional explicit memory management of hunk entries
Bitmaps in ScrollWindow and Robot code are managed by the kernel
and not by game scripts, although they must be able to be
referenced through a reg_t. To prevent incorrect GC of bitmaps
that are in use but not referenced by any game script, explicit
memory management of hunk entries can be enabled.
Diffstat (limited to 'engines/sci/engine/gc.cpp')
-rw-r--r-- | engines/sci/engine/gc.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index b229490570..e0467e9461 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -143,23 +143,30 @@ AddrSet *findAllActiveReferences(EngineState *s) { const Common::Array<SegmentObj *> &heap = s->_segMan->getSegments(); uint heapSize = heap.size(); - // Init: Explicitly loaded scripts for (uint i = 1; i < heapSize; i++) { - if (heap[i] && heap[i]->getType() == SEG_TYPE_SCRIPT) { - Script *script = (Script *)heap[i]; + if (heap[i]) { + // Init: Explicitly loaded scripts + if (heap[i]->getType() == SEG_TYPE_SCRIPT) { + Script *script = (Script *)heap[i]; - if (script->getLockers()) { // Explicitly loaded? - wm.pushArray(script->listObjectReferences()); + if (script->getLockers()) { // Explicitly loaded? + wm.pushArray(script->listObjectReferences()); + } + } + + // Init: Explicitly opted-out hunks + else if (heap[i]->getType() == SEG_TYPE_HUNK) { + HunkTable *ht = static_cast<HunkTable *>(heap[i]); + + for (uint j = 0; j < ht->_table.size(); j++) { + if (!ht->_table[j].data.gc) { + wm.push(make_reg(i, j)); + } + } } } } -#ifdef ENABLE_SCI32 - // Init: ScrollWindows - if (g_sci->_gfxControls32) - wm.pushArray(g_sci->_gfxControls32->listObjectReferences()); -#endif - debugC(kDebugLevelGC, "[GC] -- Finished explicitly loaded scripts, done with root set"); processWorkList(s->_segMan, wm, heap); |