# HG changeset patch # User Yasumasa Suenaga # Date 1395980918 -32400 # Node ID 9c57b65d193b3ccfb7daa573c6e92ef29a559564 # Parent bfde41acb148c7c652bc35ca005071fc516cbbcc Bug 1718: Reduce CPU cycles for child oop traversal. reviewed-by: ykubota diff -r bfde41acb148 -r 9c57b65d193b agent/ChangeLog --- a/agent/ChangeLog Fri Mar 28 13:15:27 2014 +0900 +++ b/agent/ChangeLog Fri Mar 28 13:28:38 2014 +0900 @@ -1,6 +1,7 @@ 2014-03-28 Yasumasa Suenaga * Bug 1716: Reduce getObjectSize() call. + * Bug 1718: Reduce CPU cycles for child oop traversal. 2014-03-17 Yasumasa Suenaga diff -r bfde41acb148 -r 9c57b65d193b agent/src/snapShotContainer.hpp --- a/agent/src/snapShotContainer.hpp Fri Mar 28 13:15:27 2014 +0900 +++ b/agent/src/snapShotContainer.hpp Fri Mar 28 13:28:38 2014 +0900 @@ -332,12 +332,21 @@ TChildClassCounter *prevCounter = NULL; TChildClassCounter *morePrevCounter = NULL; TChildClassCounter *counter = clsCounter->child; + + if(counter == NULL){ + return NULL; + } + /* Search children class list. */ - while (counter != NULL && counter->objData->klassOop != klassOop){ - + while(counter->objData->klassOop != klassOop){ morePrevCounter = prevCounter; prevCounter = counter; counter = counter->next; + + if(counter == NULL){ + return NULL; + } + } /* LFU (Least Frequently Used). */ diff -r bfde41acb148 -r 9c57b65d193b agent/src/snapShotMain.cpp --- a/agent/src/snapShotMain.cpp Fri Mar 28 13:15:27 2014 +0900 +++ b/agent/src/snapShotMain.cpp Fri Mar 28 13:28:38 2014 +0900 @@ -397,23 +397,16 @@ TChildClassCounter *clsCounter = NULL; - /* Lock class counter. */ - spinLockWait(&parentCounter->spinlock); - { - /* Search child class. */ - clsCounter = localSnapshot->findChildClass(parentCounter, klassOop); + /* Search child class. */ + clsCounter = localSnapshot->findChildClass(parentCounter, klassOop); - if(unlikely(clsCounter == NULL)){ - /* Get child class information. */ - TObjectData *clsData = getObjectDataFromKlassOop( - localClsContainer, klassOop); - /* Push new child loaded class. */ - clsCounter = localSnapshot->pushNewChildClass(parentCounter, clsData); - } - + if(unlikely(clsCounter == NULL)){ + /* Get child class information. */ + TObjectData *clsData = getObjectDataFromKlassOop( + localClsContainer, klassOop); + /* Push new child loaded class. */ + clsCounter = localSnapshot->pushNewChildClass(parentCounter, clsData); } - /* Unlock class counter. */ - spinLockRelease(&parentCounter->spinlock); if(unlikely(clsCounter == NULL)){ PRINT_CRIT_MSG("Couldn't get class counter!"); @@ -519,23 +512,16 @@ TOopMapBlock *offsets = NULL; int offsetCount = 0; - /* Lock class counter. */ - spinLockWait(&clsCounter->spinlock); - { - offsets = clsCounter->offsets; - offsetCount = clsCounter->offsetCount; + offsets = clsCounter->offsets; + offsetCount = clsCounter->offsetCount; - /* If offset list is unused yet. */ - if(unlikely(offsets == NULL && offsetCount < 0)){ - /* Generate offset list. */ - generateIterateFieldOffsets(klassOop, oopType, &offsets, &offsetCount); - clsCounter->offsets = offsets; - clsCounter->offsetCount = offsetCount; - } - + /* If offset list is unused yet. */ + if(unlikely(offsets == NULL && offsetCount < 0)){ + /* Generate offset list. */ + generateIterateFieldOffsets(klassOop, oopType, &offsets, &offsetCount); + clsCounter->offsets = offsets; + clsCounter->offsetCount = offsetCount; } - /* Unlock class counter. */ - spinLockRelease(&clsCounter->spinlock); /* Iterate non-static field objects. */ iterateFieldObject(&iterateFieldObjectCallBack, oop, oopType,