From: <bi...@us...> - 2017-07-06 19:33:55
|
Revision: 11269 http://sourceforge.net/p/oorexx/code-0/11269 Author: bigrixx Date: 2017-07-06 19:33:52 +0000 (Thu, 06 Jul 2017) Log Message: ----------- Add some code to assist in debugging GC problems and also document why identity tables use the hash values it does. Modified Paths: -------------- main/trunk/interpreter/classes/ObjectClass.hpp main/trunk/interpreter/classes/support/HashContents.hpp main/trunk/interpreter/memory/RexxMemory.cpp Modified: main/trunk/interpreter/classes/ObjectClass.hpp =================================================================== --- main/trunk/interpreter/classes/ObjectClass.hpp 2017-07-06 18:25:11 UTC (rev 11268) +++ main/trunk/interpreter/classes/ObjectClass.hpp 2017-07-06 19:33:52 UTC (rev 11269) @@ -264,6 +264,7 @@ inline void clearObject() { memset(getObjectDataSpace(), '\0', getObjectDataSize()); } inline void clearObject(size_t l) { memset(getObjectDataSpace(), '\0', l - getObjectHeaderSize()); } inline void setVirtualFunctions(void *t) { *((void **)this) = t; } + inline bool checkVirtualFunctions() { return *((void **)this) != NULL; } inline void setInitHeader(size_t s, size_t markword) { header.initHeader(s, markword); } inline void setInitHeader(size_t markword) { header.initHeader(markword); } Modified: main/trunk/interpreter/classes/support/HashContents.hpp =================================================================== --- main/trunk/interpreter/classes/support/HashContents.hpp 2017-07-06 18:25:11 UTC (rev 11268) +++ main/trunk/interpreter/classes/support/HashContents.hpp 2017-07-06 19:33:52 UTC (rev 11269) @@ -196,6 +196,11 @@ // default index hashing method. bypass the hash() method and directly use the hash value virtual ItemLink hashIndex(RexxInternalObject *index) { + // Note: even though we are using object reference identity to find a match, + // we use the hash value returned from getHashValue() rather than the identityHash + // because identityTables stored in the saved image or compiled programs will have + // a different reference value (and thus a different identifyHash) on restore, meaning + // that lookups against these tables may fail. return (ItemLink)(index->getHashValue() % bucketSize); } Modified: main/trunk/interpreter/memory/RexxMemory.cpp =================================================================== --- main/trunk/interpreter/memory/RexxMemory.cpp 2017-07-06 18:25:11 UTC (rev 11268) +++ main/trunk/interpreter/memory/RexxMemory.cpp 2017-07-06 19:33:52 UTC (rev 11269) @@ -1017,6 +1017,17 @@ { // get the current live mark to use for testing size_t liveMark = markWord | ObjectHeader::OldSpaceBit; + + // The following is useful for debugging some garbage collection problems where + // an object with a NULL VFT is getting pushed on the to stack. This is a somewhat + // critical performance pack, so only enable these lines when debugging problems. +#if 0 + if (!markObject->checkVirtualFunctions()) + { + Interpreter::logicError("Invalid object traced during garbage collection"); + } +#endif + // mark this object as live markObject->setObjectLive(markWord); |