From 07e4fe9fdcb2a42f1c3d0de08aa9e92d0f98aba8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Aug 2010 09:45:36 +0000 Subject: SCI: Disabled some debug related GC code, which effectively wastes cycles if we're not debugging the GC svn-id: r52465 --- engines/sci/engine/gc.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/gc.cpp b/engines/sci/engine/gc.cpp index 936b83d760..c1939c6566 100644 --- a/engines/sci/engine/gc.cpp +++ b/engines/sci/engine/gc.cpp @@ -28,6 +28,8 @@ namespace Sci { +//#define GC_DEBUG_CODE + struct WorklistManager { Common::Array _worklist; AddrSet _map; @@ -153,10 +155,12 @@ void run_gc(EngineState *s) { // Some debug stuff debugC(2, kDebugLevelGC, "[GC] Running..."); +#ifdef GC_DEBUG_CODE const char *segnames[SEG_TYPE_MAX + 1]; int segcount[SEG_TYPE_MAX + 1]; memset(segnames, 0, sizeof(segnames)); memset(segcount, 0, sizeof(segcount)); +#endif // Compute the set of all segments references currently in use. AddrSet *activeRefs = findAllActiveReferences(s); @@ -166,10 +170,13 @@ void run_gc(EngineState *s) { const Common::Array &heap = segMan->getSegments(); for (uint seg = 1; seg < heap.size(); seg++) { SegmentObj *mobj = heap[seg]; + if (mobj != NULL) { +#ifdef GC_DEBUG_CODE const SegmentType type = mobj->getType(); segnames[type] = SegmentObj::getSegmentTypeName(type); - +#endif + // Get a list of all deallocatable objects in this segment, // then free any which are not referenced from somewhere. const Common::Array tmp = mobj->listAllDeallocatable(seg); @@ -179,7 +186,9 @@ void run_gc(EngineState *s) { // Not found -> we can free it mobj->freeAtAddress(segMan, addr); debugC(2, kDebugLevelGC, "[GC] Deallocating %04x:%04x", PRINT_REG(addr)); +#ifdef GC_DEBUG_CODE segcount[type]++; +#endif } } @@ -188,11 +197,13 @@ void run_gc(EngineState *s) { delete activeRefs; +#ifdef GC_DEBUG_CODE // Output debug summary of garbage collection debugC(2, kDebugLevelGC, "[GC] Summary:"); for (int i = 0; i <= SEG_TYPE_MAX; i++) if (segcount[i]) debugC(2, kDebugLevelGC, "\t%d\t* %s", segcount[i], segnames[i]); +#endif } } // End of namespace Sci -- cgit v1.2.3