Search in sources :

Example 1 with InvalidObjectException

use of com.ibm.j9ddr.view.dtfj.test.DTFJUnitTest.InvalidObjectException in project openj9 by eclipse.

the class JavaMethodComparator method compareCompiledSections.

// JEXTRACT has a bug where warm/cold compiled sections are not haneld properly.
// DDR handles these sections properly so may return more sections than jextract.
// When number of returned values are the same test that they are all the same.
// If the number siffer, remove all cold sections from DDR output and make sure remainders
// match jextract output.  In this scenerio we must ignore the size of the jextract output since
// it too is incorrect
public static void compareCompiledSections(JavaMethod ddrJavaMethod, JavaMethod jextractJavaMethod, DTFJComparator imageSectionComparator) {
    List<Object> ddrList = new LinkedList<Object>();
    List<Object> jextractList = new LinkedList<Object>();
    try {
        ddrList = DTFJComparator.getList(ImageSection.class, ddrJavaMethod.getCompiledSections(), null);
        jextractList = DTFJComparator.getList(ImageSection.class, jextractJavaMethod.getCompiledSections(), null);
    } catch (InvalidObjectException e) {
        fail("Could not initialize test");
    }
    if (ddrList.size() == jextractList.size()) {
        imageSectionComparator.testComparatorIteratorEquals(ddrJavaMethod, jextractJavaMethod, "getCompiledSections", ImageSection.class, JavaMethodTest.COMPILIED_SECTIONS_SORT_ORDER, imageSectionComparator.getDefaultMask());
    } else {
        // Handle case where DTFJ is correctly detected warm/cold paths and jextract is not.
        // Remove cold paths and then compare.
        List<Object> newDDRList = new LinkedList<Object>();
        for (Object object : ddrList) {
            if (object instanceof ImageSection) {
                ImageSection sectionObject = (ImageSection) object;
                if (!sectionObject.getName().contains("cold")) {
                    newDDRList.add(object);
                }
            }
        }
        assertEquals("JavaMethod.getCompiledSections() returns different size even ignoring cold sections", jextractList.size(), newDDRList.size());
        Object[] ddrArray = newDDRList.toArray();
        Object[] jextractArray = jextractList.toArray();
        Arrays.sort(ddrArray, JavaMethodTest.COMPILIED_SECTIONS_SORT_ORDER);
        Arrays.sort(jextractArray, JavaMethodTest.COMPILIED_SECTIONS_SORT_ORDER);
        for (int j = 0; j < ddrArray.length; j++) {
            imageSectionComparator.testEquals(ddrArray[j], jextractArray[j], ImageSectionComparator.BASE_ADDRESS | ImageSectionComparator.NAME);
        }
    }
}
Also used : ImageSection(com.ibm.dtfj.image.ImageSection) InvalidObjectException(com.ibm.j9ddr.view.dtfj.test.DTFJUnitTest.InvalidObjectException) LinkedList(java.util.LinkedList)

Aggregations

ImageSection (com.ibm.dtfj.image.ImageSection)1 InvalidObjectException (com.ibm.j9ddr.view.dtfj.test.DTFJUnitTest.InvalidObjectException)1 LinkedList (java.util.LinkedList)1