common/bin/compare.sh
changeset 36789 46a9456815a3
parent 36506 17612cee3530
child 37405 b406a1747788
child 37032 09347dc49ec8
--- a/common/bin/compare.sh	Tue Apr 05 07:51:34 2016 -0700
+++ b/common/bin/compare.sh	Wed Apr 06 11:16:37 2016 +0200
@@ -75,6 +75,7 @@
     THIS_FILE=$2
 
     SUFFIX="${THIS_FILE##*.}"
+    NAME="${THIS_FILE##*/}"
 
     TMP=1
 
@@ -92,6 +93,7 @@
             $GREP '^[<>]' | \
             $SED -e '/[<>] \* from.*\.idl/d' \
                  -e '/[<>] .*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
+                 -e '/[<>] .*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \
                  -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
                  -e '/\/\/ Generated from input file.*/d' \
                  -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
@@ -100,12 +102,34 @@
     # Ignore date strings in class files.
     # Anonymous lambda classes get randomly assigned counters in their names.
     if test "x$SUFFIX" = "xclass"; then
+        if [ "$NAME" = "module-info.class" ] || [ "$NAME" = "SystemModules.class" ]
+        then
+            # The SystemModules.class and module-info.class have several issues
+            # with random ordering of elements in HashSets.
+            MODULES_CLASS_FILTER="$SED \
+                -e 's/,$//' \
+                -e 's/;$//' \
+                -e 's/^ *[0-9]*://' \
+                -e 's/#[0-9]* */#/' \
+                -e 's/ *\/\// \/\//' \
+                -e 's/aload *[0-9]*/aload X/' \
+                -e 's/ldc_w/ldc  /' \
+                | $SORT \
+                "
+            $JAVAP -c -constants -l -p "${OTHER_FILE}" \
+                | eval "$MODULES_CLASS_FILTER" >  ${OTHER_FILE}.javap &
+            $JAVAP -c -constants -l -p "${THIS_FILE}" \
+                | eval "$MODULES_CLASS_FILTER" > ${THIS_FILE}.javap &
+            wait
+            TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap)
         # To improve performance when large diffs are found, do a rough filtering of classes
         # elibeble for these exceptions
-        if $GREP -R -e '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}' \
-                -e 'lambda\$[a-zA-Z0-9]*\$[0-9]' ${THIS_FILE} > /dev/null; then
-            $JAVAP -c -constants -l -p "${OTHER_FILE}" >  ${OTHER_FILE}.javap
-            $JAVAP -c -constants -l -p "${THIS_FILE}" > ${THIS_FILE}.javap
+        elif $GREP -R -e '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}' \
+                -e 'lambda\$[a-zA-Z0-9]*\$[0-9]' ${THIS_FILE} > /dev/null
+        then
+            $JAVAP -c -constants -l -p "${OTHER_FILE}" >  ${OTHER_FILE}.javap &
+            $JAVAP -c -constants -l -p "${THIS_FILE}" > ${THIS_FILE}.javap &
+            wait
             TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
                 $GREP '^[<>]' | \
                 $SED -e '/[<>].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}.*/d' \
@@ -305,14 +329,19 @@
         if [ -e $OTHER_DIR/$f ]; then
             SUFFIX="${f##*.}"
             if [ "$(basename $f)" = "release" ]; then
-                # Ignore differences in change numbers in release file.
+                # In release file, ignore differences in change numbers and order
+                # of modules in list.
                 OTHER_FILE=$WORK_DIR/$f.other
                 THIS_FILE=$WORK_DIR/$f.this
                 $MKDIR -p $(dirname $OTHER_FILE)
                 $MKDIR -p $(dirname $THIS_FILE)
                 RELEASE_FILTER="$SED \
                     -e 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' \
-                    -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}/<DATE>/g'
+                    -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{6\}/<DATE>/g' \
+                    -e 's/^#.*/#COMMENT/g' \
+                    -e 's/MODULES=/MODULES=\'$'\n/' \
+                    -e 's/,/\'$'\n/g' \
+                    | $SORT
                     "
                 $CAT $OTHER_DIR/$f | eval "$RELEASE_FILTER" > $OTHER_FILE
                 $CAT $THIS_DIR/$f  | eval "$RELEASE_FILTER" > $THIS_FILE
@@ -330,8 +359,9 @@
                     -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
                     -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [0-9]\{4\} [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/<DATE>/'
                     "
-                $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE
-                $CAT $THIS_DIR/$f  | eval "$HTML_FILTER" > $THIS_FILE
+                $CAT $OTHER_DIR/$f | eval "$HTML_FILTER" > $OTHER_FILE &
+                $CAT $THIS_DIR/$f  | eval "$HTML_FILTER" > $THIS_FILE &
+                wait
             else
                 OTHER_FILE=$OTHER_DIR/$f
                 THIS_FILE=$THIS_DIR/$f
@@ -389,7 +419,7 @@
     $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
     $MKDIR -p $THIS_UNZIPDIR
     $MKDIR -p $OTHER_UNZIPDIR
-    if [ "$TYPE" = "jar" || "$TYPE" = "war" || "$TYPE" = "zip" || "$TYPE" = "jmod"]
+    if [ "$TYPE" = "jar" -o "$TYPE" = "war" -o "$TYPE" = "zip" -o "$TYPE" = "jmod" ]
     then
         (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
         (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
@@ -526,7 +556,7 @@
 
     # TODO filter?
     ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" \
-        -o -name "modules" -o -name "*.jmod" | $SORT | $FILTER)
+        -o -name "modules" | $SORT | $FILTER)
 
     if [ -n "$ZIPS" ]; then
         echo Jar files...
@@ -600,8 +630,8 @@
                && [ -f "$OTHER/support/native/java.base/java_objs/java.diz" ]; then
             OTHER_DIZ_FILE="$OTHER/support/native/java.base/java_objs/java.diz"
         elif [ "$NAME" = "jimage.exe" ] \
-               && [ -f "$OTHER/support/native/jdk.dev/jimage_objs/jimage.diz" ]; then
-            OTHER_DIZ_FILE="$OTHER/support/native/jdk.dev/jimage_objs/jimage.diz"
+               && [ -f "$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
+            OTHER_DIZ_FILE="$OTHER/support/native/jdk.jlink/jimage_objs/jimage.diz"
         elif [ "$NAME" = "javacpl.exe" ] \
                && [ -f "$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
             OTHER_DIZ_FILE="$OTHER/support/native/jdk.plugin/javacpl/javacpl.diz"
@@ -632,8 +662,8 @@
                && [ -f "$THIS/support/native/java.base/java_objs/java.diz" ]; then
             THIS_DIZ_FILE="$THIS/support/native/java.base/java_objs/java.diz"
         elif [ "$NAME" = "jimage.exe" ] \
-               && [ -f "$THIS/support/native/jdk.dev/jimage_objs/jimage.diz" ]; then
-            THIS_DIZ_FILE="$THIS/support/native/jdk.dev/jimage_objs/jimage.diz"
+               && [ -f "$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz" ]; then
+            THIS_DIZ_FILE="$THIS/support/native/jdk.jlink/jimage_objs/jimage.diz"
         elif [ "$NAME" = "javacpl.exe" ] \
                && [ -f "$THIS/support/native/jdk.plugin/javacpl/javacpl.diz" ]; then
             THIS_DIZ_FILE="$THIS/support/native/jdk.plugin/javacpl/javacpl.diz"
@@ -732,6 +762,13 @@
         SYM_SORT_CMD="cat"
     fi
 
+    if [ -n "$SYMBOLS_DIFF_FILTER" ] && [ -z "$NEED_SYMBOLS_DIFF_FILTER" ] \
+            || [[ "$NEED_SYMBOLS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then
+        this_SYMBOLS_DIFF_FILTER="$SYMBOLS_DIFF_FILTER"
+    else
+        this_SYMBOLS_DIFF_FILTER="$CAT"
+    fi
+
     # Check symbols
     if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
         # The output from dumpbin on windows differs depending on if the debug symbol
@@ -750,8 +787,16 @@
         $NM -j $ORIG_OTHER_FILE 2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
         $NM -j $ORIG_THIS_FILE  2> /dev/null | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
     else
-        $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
-        $NM -a $ORIG_THIS_FILE  2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
+        $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME \
+            | $AWK '{print $2, $3, $4, $5}' \
+            | eval "$this_SYMBOLS_DIFF_FILTER" \
+            | $SYM_SORT_CMD \
+            > $WORK_FILE_BASE.symbols.other
+        $NM -a $ORIG_THIS_FILE  2> /dev/null | $GREP -v $NAME \
+            | $AWK '{print $2, $3, $4, $5}' \
+            | eval "$this_SYMBOLS_DIFF_FILTER" \
+            | $SYM_SORT_CMD \
+            > $WORK_FILE_BASE.symbols.this
     fi
 
     LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
@@ -828,9 +873,10 @@
             FULLDUMP_DIFF_FILTER="$CAT"
         fi
         $FULLDUMP_CMD $OTHER_FILE | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \
-            > $WORK_FILE_BASE.fulldump.other 2>&1
+            > $WORK_FILE_BASE.fulldump.other 2>&1 &
         $FULLDUMP_CMD $THIS_FILE  | eval "$BUILD_ID_FILTER" | eval "$FULLDUMP_DIFF_FILTER" \
-            > $WORK_FILE_BASE.fulldump.this  2>&1
+            > $WORK_FILE_BASE.fulldump.this  2>&1 &
+        wait
 
         LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this \
             > $WORK_FILE_BASE.fulldump.diff
@@ -854,18 +900,19 @@
             FULLDUMP_MSG="          "
             DIFF_FULLDUMP=
             if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then
-                FULLDUMP_MSG="    !    "
+                FULLDUMP_MSG="    !     "
             fi
         fi
     fi
 
     # Compare disassemble output
     if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
-        # By default we filter out differences that include references to symbols.
-        # To get a raw diff with the complete disassembly, set
-        # DIS_DIFF_FILTER="$CAT"
-        if [ -z "$DIS_DIFF_FILTER" ]; then
-            DIS_DIFF_FILTER="$GREP -v ' # .* <.*>$' | $SED -r -e 's/(\b|x)([0-9a-fA-F]+)(\b|:|>)/X/g'"
+        this_DIS_DIFF_FILTER="$CAT"
+        if [ -n "$DIS_DIFF_FILTER" ]; then
+            if [ -z "$NEED_DIS_DIFF_FILTER" ] \
+                || [[ "$NEED_DIS_DIFF_FILTER" = *"$BIN_FILE"* ]]; then
+                this_DIS_DIFF_FILTER="$DIS_DIFF_FILTER"
+            fi
         fi
         if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
             DIS_GREP_ARG=-a
@@ -873,9 +920,10 @@
             DIS_GREP_ARG=
         fi
         $DIS_CMD $OTHER_FILE | $GREP $DIS_GREP_ARG -v $NAME \
-            | eval "$DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.other 2>&1
+            | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.other 2>&1 &
         $DIS_CMD $THIS_FILE  | $GREP $DIS_GREP_ARG -v $NAME \
-            | eval "$DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this  2>&1
+            | eval "$this_DIS_DIFF_FILTER" > $WORK_FILE_BASE.dis.this  2>&1 &
+        wait
 
         LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
 
@@ -884,11 +932,15 @@
             DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
             if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
                 DIFF_DIS=true
-                if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
+                if [ "$MAX_KNOWN_DIS_DIFF_SIZE" = "" ]; then
+                    MAX_KNOWN_DIS_DIFF_SIZE="0"
+                fi
+                if [[ "$KNOWN_DIS_DIFF" = *"$BIN_FILE"* ]] \
+                    && [ "$DIS_DIFF_SIZE" -lt "$MAX_KNOWN_DIS_DIFF_SIZE" ]; then
+                    DIS_MSG=" $DIS_MSG "
+                else
                     DIS_MSG="*$DIS_MSG*"
                     REGRESSIONS=true
-                else
-                    DIS_MSG=" $DIS_MSG "
                 fi
             else
                 DIS_MSG="($DIS_MSG)"